0){ $text = "WineX needs you to set your CellarTracker \"Privacy Settings\" to \"Low\"."; } else { $trans = get_html_translation_table(HTML_ENTITIES); $start = ""; $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[''] = ''; $trans["
"] = "
"; unset($trans['"'], $trans[">"], $trans["<"], $trans["&"]); $lines = strtr($lines,$trans); $headers = substr($lines, strpos($lines, "")); $headers = substr($headers, 0, strpos($headers, "")); //print($headers); $headerArray = explode("', '', $x); $x = str_replace('', '', $x); $headerCols[] = $x; } } $body = substr($lines, strpos($lines, "") - 23); $body = substr($body, 0, strpos($body, "in stock")); $rowArray = explode("', '', $x); $x = str_replace('', '', $x); $cell[] = $x; } } $rows[] = $cell; } else if (count($cells) == 3){ $footer = substr($cells[2], 14); } } if (!$wArray['cols']){ $cols = array("0", "1", "2", "3", "4", "5"); } else { if (in_array('type', array_keys($wArray['cols']))){ $cols[] = "0"; } if (in_array('size', array_keys($wArray['cols']))){ $cols[] = "1"; } if (in_array('qty', array_keys($wArray['cols']))){ $cols[] = "2"; } if (in_array('details', array_keys($wArray['cols']))){ $cols[] = "3"; } if (in_array('window', array_keys($wArray['cols']))){ $cols[] = "4"; } if (in_array('rating', array_keys($wArray['cols']))){ $cols[] = "5"; } } $number = count($cols); $text = '
'; $text .= "
"; $text .= ""; foreach(array_keys($headerCols) as $h){ if (in_array($h, $cols)){ $text .= ""; } } $text .= ""; //print_r($rows); foreach($rows as $r){ $text .= ""; foreach(array_keys($r) as $c){ if (in_array($c, $cols)){ $text .= ""; } } $text .= ""; } $text .= ""; $text .= "
" . $headerCols[$h] . "
" . $r[$c] . "
$footer
"; $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'] = ''; $wArray['cols'] = array(); 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; } $cols = array(); if ($_POST['type'] == 1){ $cols['type'] = 1; } if ($_POST['size'] == 1){ $cols['size'] = 1; } if ($_POST['qty'] == 1){ $cols['qty'] = 1; } if ($_POST['details'] == 1){ $cols['details'] = 1; } if ($_POST['window'] == 1){ $cols['window'] = 1; } if ($_POST['rating'] == 1){ $cols['rating'] = 1; } $wArray['cols'] = $cols; 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 .= ""; $text .= "
"; $text .= "
"; $text .= "  (Last Updated: " . $lastUpdate . ")"; $text .= "
"; if ($wArray['cols']['type'] == 1){ $c = "checked"; } else { $c = ''; } $text .= " Wine Type
"; if ($wArray['cols']['size'] == 1){ $c = "checked"; } else { $c = ''; } $text .= " Size
"; if ($wArray['cols']['qty'] == 1){ $c = "checked"; } else { $c = ''; } $text .= " Quantity
"; if ($wArray['cols']['details'] == 1){ $c = "checked"; } else { $c = ''; } $text .= " Details
"; if ($wArray['cols']['window'] == 1){ $c = "checked"; } else { $c = ''; } $text .= " Drinking Window
"; if ($wArray['cols']['rating'] == 1){ $c = "checked"; } else { $c = ''; } $text .= " Rating
"; $text .= "
"; $text .= "

"; $text .= "

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