The Hacker's Diet. This plugin replaces the Excel files supplied for his original system. Version: 0.9.8b Author: Keith 'afex' Thornhill Author URI: http://www.afex2win.com/ */ $hd_version = "0.9.8b"; $hackdiet_user_level = 1; // feel free to change this value (1-10) if you want to restrict lower users from using the plugin // find URI to plugin dir so ajax calls have correct path preg_match("/.*(\/wp-content\/plugins\/.*)\/hackersdiet.php$/", __FILE__, $hd_matches); define("PLUGIN_FOLDER_URL", get_bloginfo('wpurl') . $hd_matches[1]); $hd_parsed_url = parse_url(PLUGIN_FOLDER_URL); define("PLUGIN_PATH", $hd_parsed_url['path'] . "/"); require_once(dirname(__FILE__).'/hackersdiet_lib.php'); function hackdiet_install() { global $table_prefix, $wpdb; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); $table_name = $table_prefix . "hackdiet_weightlog"; if ($wpdb->get_var("show tables like '$table_name'") != $table_name) { $sql = "CREATE TABLE ".$table_name." (wp_id BIGINT( 20 ) UNSIGNED NOT NULL, date DATE NOT NULL, weight DOUBLE UNSIGNED NOT NULL DEFAULT '0', trend DOUBLE UNSIGNED NOT NULL DEFAULT '0', rung SMALLINT UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY ( wp_id, date ))"; dbDelta($sql); } $table_name = $table_prefix . "hackdiet_settings"; if ($wpdb->get_var("show tables like '$table_name'") != $table_name) { $sql = "CREATE TABLE ".$table_name." (wp_id BIGINT UNSIGNED NOT NULL, name VARCHAR( 50 ) NOT NULL, value TEXT NOT NULL, PRIMARY KEY ( wp_id , name ) )"; dbDelta($sql); } } function hackdiet_add_dashboard_page() { global $hackdiet_user_level; if (function_exists('add_submenu_page')) { add_submenu_page('index.php', 'hackersdiet', 'Hacker\'s Diet', $hackdiet_user_level, basename(__FILE__), 'hackdiet_option_page'); } } function hackdiet_js() { global $plugin_page; if (basename(__FILE__) == $plugin_page) { ?>

The Hacker's Diet

get_row($query); $_GET['start_date'] = $row->max; $_GET['end_date']= $row->min; } ?> "> "> ">
From: To:


&maint_mode=">
"", "trend" => "", "rung" => ""); $date_index = strtotime("yesterday", $date_index); } $query = "select date, weight, trend from ".$table_prefix."hackdiet_weightlog where wp_id = $user_ID and date > '".date("Y-m-d", strtotime("2 weeks ago"))."' order by date desc"; $dbweights = $wpdb->get_results($query); if ($dbweights) { foreach ($dbweights as $weight) { $weight_array[$weight->date]["weight"] = $weight->weight; $weight_array[$weight->date]["trend"] = $weight->trend; } } foreach ($weight_array as $date => $weight) { $dif = round($weight["weight"] - $weight["trend"], 1); ?>
Date Weight (s)
" id="weight_">$dif":"click here to add a weight")?>
&maint_mode=">

items) && 0 != count($rss->items) ) { $rss->items = array_slice($rss->items, 0, 3); echo "
    "; foreach ($rss->items as $item ) { ?>
  • '>
  • "; } ?>

    (Your version is )
Settings
Goal Weight: "> Maintenance mode? > Just hit your goal?
Select Maintenance mode."; } ?>
Goal Date: " class="format-y-m-d divider-dash range-low-">

Hacker's Diet widget not yet designed. ''); if ( $_POST['hackdiet-submit'] ) { $options['title'] = strip_tags(stripslashes($_POST['hackdiet-title'])); update_option('widget_hackdiet', $options); } $title = htmlspecialchars($options['title'], ENT_QUOTES); echo '

'; echo ''; } register_sidebar_widget(array('The Hacker\'s Diet', 'widgets'), 'widget_hackdiet'); register_widget_control(array('The Hacker\'s Diet', 'widgets'), 'widget_hackdiet_control', 300, 100); } // hooks add_action('admin_menu', 'hackdiet_add_dashboard_page'); add_action('admin_head', 'hackdiet_js'); add_action('widgets_init', 'hackdiet_widget_init'); register_activation_hook(__FILE__, 'hackdiet_install'); ?>