"; $end = ""; $lines = substr($lines, strpos($lines, $start)); $lines = substr($lines, 0, strpos($lines, $end)); $trans["href='wine.asp"] = " target='_new' href='http://www.cellartracker.com/wine.asp"; $trans["href='list.asp"] = " target='_new' href='http://www.cellartracker.com/list.asp"; $trans['/images/'] = "http://www.cellartracker.com/images/"; $trans['images/camera.gif'] = "http://www.cellartracker.com/images/camera.gif"; $trans['lbl_disp.asp'] = "http://www.cellartracker.com/lbl_disp.asp"; $trans[''] = "
"; $trans[''] = "\r\n"; $trans[''] = "\r\n"; $trans[''] = "\r\n"; $trans[""] = ''; $trans[''] = ''; unset($trans['"'], $trans[">"], $trans["<"], $trans["&"]); $text = strtr($lines,$trans); $wArray['date'] = $date; $wArray['timestamp'] = time(); update_option('winex_content', $text); update_option('winex_options', $wArray); } else { $text = 'WineX needs your CellarTracker user_id before it can download your cellar listing'; } return $text; } /** * Checks against date to see if a new cache file is required, otherwise returns * the contents of the current one. * * @param string $content page content, incoming * @return string $content page content */ function winex_showWineList($content){ global $id; $wArray = get_option('winex_options'); if ($id == $wArray['page_id']){ if ($wArray['date'] != date('Ymd')){ $content = $this->winex_fetchWineList($wArray); } else { $content = get_option('winex_content'); } } return $content; } /** * Installs the plugin by creating the page and options * * @param NULL * @return NULL */ function winex_install(){ if (!get_option('winex_options')){ $page = array(); $page['post_type'] = 'page'; $page['post_title'] = 'Wine Cellar'; $page['post_name'] = 'winecellar'; $page['post_status'] = 'publish'; $page['comment_status'] = 'closed'; $page['post_content'] = 'This page is used to display your CellarTracker wine cellar via WineX.

'; $page_id = wp_insert_post($page); $wArray['page_id'] = $page_id; $wArray['user_id'] = ''; $wArray['date'] = ''; $wArray['timestamp'] = ''; update_option('winex_options', $wArray); update_option('winex_content', array()); } } /** * Uninstalls the plugin by deleting the options and page * * @param NULL * @return NULL */ function winex_uninstall(){ $wArray = get_option('winex_options'); global $wpdb; $sql = "delete from `" . $wpdb->prefix . "posts` where `ID` = '" . $wArray['page_id'] . "' limit 1"; $wpdb->query($sql); delete_option('winex_options'); delete_option('winex_content'); } /** * The hook for the admin menu * * @param NULL * @return NULL */ function winex_admin_menu(){ add_management_page('WineX', 'WineX', 1, __FILE__, array($this, 'winex_admin_page')); } /** * The administration page for updating options * * @param NULL * @return NULL */ function winex_admin_page(){ clearstatcache(); $wArray = get_option('winex_options'); if ($_POST['action'] == "update"){ $user_id = trim(rtrim($_POST['user_id'])); if (!is_numeric($user_id)){ $message = "Invalid Member ID"; } if (!$message){ if ($user_id != $wArray['user_id']){ $wArray['user_id'] = $user_id; $wArray['date'] = 0; } if ($_POST['winex_date'] == 0){ $wArray['date'] = 0; } update_option('winex_options', $wArray); $message = 'Options Updated'; } } if ($wArray["date"] == 0){ $lastUpdate = "No Results Cached"; } else { $lastUpdate = date("M-d-Y H:i", $wArray["timestamp"]); } $text .= "

WineX

"; $text .= "WineX enables you to import your CellarTracker"; $text .= " into your WP installation.

WineX downloads your cellar"; $text .= " once a day and saves it. This keeps it running fast for both your users and your server."; //$text .= " If you would like WineX to reset the cache contents, use the check box below."; $text .= "
"; $text .= ""; if ($message){ $text .= "
$message"; } $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= "
"; $text .= "
"; $text .= "  (Last Updated: " . $lastUpdate . ")"; $text .= "
"; $text .= "

"; $text .= "

"; print($text); } } ?>