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) { ?> } } function hackdiet_option_page() { global $table_prefix, $wpdb, $user_ID; global $hd_version; $options = hackdiet_get_options($user_ID); // first time they open the page, we need to set default unit if (!$options["unit"]) { $options["unit"] = "lb"; hackdiet_save_options($user_ID, $options); } if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_POST["goal_date"] && !$_POST["goal_weight"]) { // can't plan without a plan $error = "So exactly how much would you like to weigh on " . $_POST["goal_date"] . "?"; } else { // $options["unit"] = $_POST["unit"]; $options["goal_weight"] = $_POST["goal_weight"]; $options["goal_date"] = $_POST["goal_date"]; if ($_POST["maint_mode"]) { $options["maint_mode"] = true; } else { $options["maint_mode"] = ""; } hackdiet_save_options($user_ID, $options); if ($_POST["unit"] != $_POST["old_unit"]) { convert_weights($_POST["old_unit"], $_POST["unit"]); } } } ?>
|
include(dirname(__FILE__).'/ajax_blurb.php');
?>
|
|
include(dirname(__FILE__).'/ajax_togo.php');
?>
|
||||
|
include(dirname(__FILE__).'/ajax_blurb.php');
?>
|
|
$report_url = $_SERVER['PHP_SELF']."?page=hackersdiet.php§ion=reports";
?>
if ( file_exists(ABSPATH . WPINC . '/rss.php') )
require_once(ABSPATH . WPINC . '/rss.php');
else
require_once(ABSPATH . WPINC . '/rss-functions.php');
$rss = fetch_rss('http://www.afex2win.com/stuff/hackersdiet/feed/');
if ( isset($rss->items) && 0 != count($rss->items) ) {
$rss->items = array_slice($rss->items, 0, 3);
echo "
(Your version is = $hd_version ?>) |