function pagination() { $string = $_SERVER['REQUEST_URI']; $pattern = '/(&page=[0-9]+)/i'; $replacement = ''; $target = preg_replace('/([&?]+page=[0-9]+)/i', '', $_SERVER['REQUEST_URI']); $this->load->library('pagination'); $page = new pagination(); $page->target($target); $page->limit($this->paged->page_size); @$page->currentPage($this->paged->current_page); $page->Items($this->paged->total_rows); return $page->show(); }
public function pagination() { $string = $_SERVER["REQUEST_URI"]; $pattern = "/(&page=[0-9]+)/i"; $replacement = ""; $target = preg_replace("/([&?]+page=[0-9]+)/i", "", $_SERVER["REQUEST_URI"]); $this->load->library("pagination"); $page = new pagination(); $page->target($target); @$page->limit($this->paged->page_size); @$page->currentPage($this->paged->current_page); @$page->Items($this->paged->total_rows); return $page->show(); }
function paginate($model, $options = array()) { $m = new Model(); $limit = preg_match("/LIMIT (\\d+) OFFSET (\\d+)/", $model->last_query, $matches); $limit = $matches[1]; $offset = $matches[2]; $page = $offset / $limit + 1; $query = preg_replace("/^SELECT (.*) FROM/", "SELECT COUNT(*) AS count FROM", $model->last_query); $query = preg_replace("/LIMIT (.*)\$/", "", $query); $m->find_by_sql($query); $pagination = new pagination(); $pagination->page = $page; $pagination->target = $options['target']; $pagination->items($m->fields['count']); $pagination->limit($limit); return $pagination->show(); }
function Iscritti() { require 'pagination.class.php'; global $_POST; global $wpdb; $table_email = $wpdb->prefix . "nl_email"; //cancellazione provamoce if ($_POST['delete'] && $_POST['id_email']) { $delete = $wpdb->query("delete from {$table_email} where id_email = '{$_POST['id_email']}'"); echo '<div id="message" class="updated fade"><p><strong>' . __("Email deleted succesfully!", "sendit") . '</strong></p></div>'; //print_r($_POST); } //modifica provamoce if ($_POST['update']) { //$code = md5(uniqid(rand(), true)); $update = $wpdb->query("update {$table_email} set email = '{$_POST['email']}', magic_string='{$_POST['code']}', accepted = '{$_POST['status']}' where id_email = '{$_POST['id_email']}'"); echo '<div id="message" class="updated fade"><p><strong>' . sprintf(__('email %s edited succesfully', 'sendit'), $_POST[email]) . '</p></div>'; //print_r($_POST); } //aggiunta indirizzo o indirizzi email dalla textarea if ($_POST['emails_add'] != "") { //ver 1.1 multiaddress support $email_add = explode("\n", $_POST['emails_add']); foreach ($email_add as $key => $value) { //echo $value."<br />"; //validation fix 1.5.6 (also there!) {2,4} if (!ereg("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})\$", trim($value))) { echo '<div id="message" class="error"><p><strong>indirizzo email ' . $value . ' non valido!</strong></p></div>'; } else { $user_count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_email} where email ='{$value}' and id_lista = '{$_GET['lista']}' order by email;"); if ($user_count > 0) { echo "<div class=\"error\"><p><strong>" . sprintf(__('email %s already present', 'sendit'), $value) . "</strong></p></div>"; } else { //genero stringa univoca x conferme e cancellazioni sicure $code = md5(uniqid(rand(), true)); $wpdb->query("INSERT INTO {$table_email} (email,id_lista, magic_string, accepted) VALUES ('{$value}', '{$_POST['id_lista']}', '{$code}', 'y')"); echo '<div class="updated fade"><p><strong>' . sprintf(__('email %s added succesfully!', 'sendit'), $value) . '</strong></p></div>'; } } } //fine ciclo for } $email_items = $wpdb->get_var("SELECT count(*) FROM {$table_email} where id_lista= '{$_GET['lista']}'"); // number of total rows in the database if ($email_items > 0) { $p = new pagination(); $p->items($email_items); $p->limit(20); // Limit entries per page $p->target("admin.php?page=lista-iscritti&lista=" . $_GET['lista']); $p->currentPage($_GET[$p->paging]); // Gets and validates the current page $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { //echo "No Record Found"; } $emails = $wpdb->get_results("SELECT id_email, id_lista, email, subscriber_info, magic_string, accepted FROM {$table_email} where id_lista= '{$_GET['lista']}' order by email {$limit}"); //email confermat $emails_confirmed = $wpdb->get_results("SELECT id_email, id_lista, email, subscriber_info, magic_string, accepted FROM {$table_email} where id_lista= '{$_GET['lista']}' and accepted='y'"); echo "<div class=\"wrap\"><h2>" . __('Subscribers', 'sendit') . "</h2>"; //estraggo le liste $table_liste = $wpdb->prefix . "nl_liste"; $liste = $wpdb->get_results("SELECT id_lista, nomelista FROM {$table_liste} "); // print_r($_POST); echo "<div class=\"table\">\n\t\t\t<table class=\"widefat fixed\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>" . __('id', 'sendit') . "</th>\n\t\t\t\t\t\t<th class=" . $css_list . ">" . __('mailing list', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('actions', 'sendit') . "</th>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</thead><tbody>"; foreach ($liste as $lista) { if ($_GET['lista'] == $lista->id_lista) { $selected = " class=\"updated fade\""; } else { $selected = ""; } echo "<tr >\n \t\t<td>" . $lista->id_lista . "</td>\n \t\t<td " . $selected . "><a class=\"\" href=\"admin.php?page=lista-iscritti&lista=" . $lista->id_lista . "\">" . $lista->nomelista . "</a></td>\n \t\t<td></td><tr>"; } echo "</tbody></table>\n </div><br clear=\"all\\ />"; /*miglioro facendo comparire la form x aggiungere solo se selezionata una lista*/ if ($_GET['lista']) { echo "<h3>" . __('Manual Subscribe mailing list ', 'sendit') . " " . $_POST['lista'] . "</h3>\n\n <label for=\"email_add\">" . __('email address (one or more: default separator= line break)', 'sendit') . "<br />\n <div id=\"dashboard-widgets\" class=\"metabox-holder\">\n <div class='postbox-container' style='width:49%;'>\n\t\t\t\t<div id=\"normal-sortables\" class=\"meta-box-sortables\">\n\t\t\t\t<div id=\"dashboard_right_now\" class=\"postbox \" >\n\t\t\t\t\t<div class=\"handlediv\" title=\"Fare clic per cambiare.\"><br /></div>\n\t\t\t\t<h3 class='hndle'><span>" . __('Subscription', 'sendit') . "</span></h3>\n\t\t\t\t<div class=\"inside\">\n\t\t\t\t <p>" . __('Copy here one or more email address', 'sendit') . "</p>\n\n\t\t\t\t\t <form id=\"add\" name=\"add\" method=\"post\" action=\"admin.php?page=lista-iscritti&lista=" . $_GET[lista] . "\">\n\n \n <textarea id=\"emails_add\" type=\"text\" value=\"\" name=\"emails_add\" rows=\"10\" cols=\"50\"/></textarea></label>\n <input type=\"hidden\" name=\"id_lista\" value=\"" . $_GET[lista] . "\" /> \n\n <input class=\"button\" type=\"submit\" value=\"" . __('Add', 'sendit') . "\"/>\n </p>\n </form>\n </div>\n </div>\n </div>\n </div>\n </div>\n <br clear=\"all\" />"; //posiziono la paginazione echo "<h3>" . __('Subscribers', 'sendit') . " n." . $email_items . " (" . __('Subscriptions confirmed', 'sendit') . ": " . count($emails_confirmed) . ")</h3>"; if ($p) { echo $p->show(); } echo "\n <br clear=\"all\" />\n\t\t\t<table class=\"widefat post fixed\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>"; if (get_option('sendit_gravatar') == 'yes') { echo "<th style=\"width:30px !important;\"></th>"; } echo "<th>" . __('email', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('status', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('Additional info', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('actions', 'sendit') . "</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n \t\n "; foreach ($emails as $email) { //coloro le input per distinguere tra chi ha confermato e chi no if ($email->accepted == "y") { $style = "style=\"background:#E4FFCF; border:1px solid #B6FF7F;\""; } elseif ($email->accepted == "n") { $style = "style=\"background:#fffbcc; border:1px solid #e6db55;\""; } else { $style = "style=\"background:#fd919b; border:1px solid #EF4A5C;\""; } //fare funzione per ricaare i valori ovunque $subscriber_info = json_decode($email->subscriber_info); $subscriber_options = explode("&", $subscriber_info->options); $options = ''; foreach ($subscriber_options as $option) { $option = explode("=", $option); //stampo solo i campi unserializzati senza email_add e lista if ($option[0] != 'email_add' and $option[0] != 'lista') { $options .= $option[0]; $options .= ':'; $options .= urldecode($option[1]); $options .= '<br />'; } } echo "<tr>\t\n \t\t<form action=\"#email_" . $email->id_email . "\" method=\"post\">"; if (get_option('sendit_gravatar') == 'yes') { echo "<td class=\"grav\" style=\"width:30px !important;\">" . get_avatar($email->email, '24') . "</td>"; } echo "<td id=\"email_" . $email->id_email . "\">\n \n <!--input type=\"checkbox\" name=\"email_handler[]\" value=\"" . $email->id_email . "\">-->\n <input type=\"hidden\" name=\"id_email\" value=\"" . $email->id_email . "\">\n <input type=\"hidden\" name=\"lista\" value=\"" . $_POST['lista'] . "\">\n <input type='hidden' name='code' value='" . $email->magic_string . "' />\n <input type='text' name='email' value='" . $email->email . "' />\n </td>\n <td " . $style . " >\n <select name=\"status\">\n \n <option value=\"y\""; if ($email->accepted == "y") { echo " selected=\"selected\""; } echo ">" . __('Confirmed', 'sendit') . "</option>\n <option value=\"n\""; if ($email->accepted == "n") { echo " selected=\"selected\""; } echo ">" . __('Not confirmed', 'sendit') . "</option>\n <option value=\"d\""; if ($email->accepted == "d") { echo " selected=\"selected\""; } echo ">" . __('Cancelled', 'sendit') . "</option>\n \n </select>\n </td>\n <td>" . $options . "</td>\n\n <td>\n\t <input type=\"submit\" class=\"button\" name=\"update\" value=\"" . __('Update', 'sendit') . "\">\n\t <input type=\"submit\" class=\"button\" name=\"delete\" value=\"" . __('Delete', 'sendit') . "\">\n\t\t\t\t\t\t</td>\n </form>\n </tr> "; } echo "\t\t<tfoot>\n\t\t\t\t\t<tr>"; if (get_option('sendit_gravatar') == 'yes') { echo "<th style=\"width:30px !important;\"></th>"; } echo "<th>" . __('email', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('status', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('Additional info', 'sendit') . "</th>\n\t\t\t\t\t\t<th>" . __('actions', 'sendit') . "</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</tfoot>\n</table><br clear=\"all\" />"; //ripeto la paginazione if ($p) { echo $p->show(); } } echo "</div>"; }
function WassUp() { global $wpdb, $wp_version, $version, $wpurl, $wassup_options, $whash; // Start getting time of execution to debug SQL query $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; // This could be commented out //#debug... //error_reporting(E_ALL | E_STRICT); //debug, E_STRICT=php5 only //ini_set('display_errors','On'); //debug //$wpdb->show_errors(); //debug $table_name = $wpdb->prefix . "wassup"; $table_tmp_name = $wpdb->prefix . "wassup_tmp"; $wassup_options->loadSettings(); //needed in case "update_option is run elsewhere in wassup (widget) // RUN THE SAVE/RESET OPTIONS $admin_message=""; if (isset($_POST['submit-options']) || isset($_POST['submit-options2']) || isset($_POST['submit-options3'])) { if ($_POST['wassup_remind_flag'] == 1 AND $_POST['wassup_remind_mb'] == "") { $wassup_options->wassup_remind_flag = $_POST['wassup_remind_flag']; $wassup_options->wassup_remind_mb = 10; } else { $wassup_options->wassup_remind_flag = $_POST['wassup_remind_flag']; $wassup_options->wassup_remind_mb = $_POST['wassup_remind_mb']; } $wassup_options->wassup_active = $_POST['wassup_active']; $wassup_options->wassup_chart_type = $_POST['wassup_chart_type']; $wassup_options->wassup_loggedin = $_POST['wassup_loggedin']; $wassup_options->wassup_spider = $_POST['wassup_spider']; $wassup_options->wassup_attack = $_POST['wassup_attack']; $wassup_options->wassup_hack = $_POST['wassup_hack']; $wassup_options->wassup_spamcheck = $_POST['wassup_spamcheck']; $wassup_options->wassup_spam = $_POST['wassup_spam']; $wassup_options->wassup_refspam = $_POST['wassup_refspam']; $wassup_options->wassup_exclude = $_POST['wassup_exclude']; $wassup_options->wassup_exclude_url = $_POST['wassup_exclude_url']; $wassup_options->delete_auto = $_POST['delete_auto']; $wassup_options->delete_auto_size = $_POST['delete_auto_size']; $wassup_options->wassup_screen_res = $_POST['wassup_screen_res']; $wassup_options->wassup_refresh = $_POST['wassup_refresh']; $wassup_options->wassup_userlevel = $_POST['wassup_userlevel']; $wassup_options->wassup_dashboard_chart = $_POST['wassup_dashboard_chart']; $wassup_options->wassup_geoip_map = $_POST['wassup_geoip_map']; $wassup_options->wassup_googlemaps_key = $_POST['wassup_googlemaps_key']; $wassup_options->wassup_time_format = $_POST['wassup_time_format']; $wassup_options->wassup_default_type = $_POST['wassup_default_type']; $wassup_options->wassup_default_limit = $_POST['wassup_default_limit']; $top_ten = array("topsearch" => $_POST['topsearch'], "topreferrer" => $_POST['topreferrer'], "toprequest" => $_POST['toprequest'], "topbrowser" => $_POST['topbrowser'], "topos" => $_POST['topos'], "toplocale" => $_POST['toplocale'], "topvisitor" => $_POST['topvisitor'], "topfeed" => "0", "topcrawler" => "0", "topreferrer_exclude" => $_POST['topreferrer_exclude']); $wassup_options->wassup_top10 = serialize($top_ten); /* if ( $_POST['wassup_savepath'] != $wassup_options->wassup_savepath ) { if (empty($_POST['wassup_savepath']) || rtrim($_POST['wassup_savepath'],"/") == getSessionpath()) { $wassup_options->wassup_savepath = NULL; } else { $wassup_options->setSavepath($_POST['wassup_savepath']); } } */ if ($wassup_options->saveSettings()) { $admin_message = __("Wassup options updated successfully","wassup")."." ; } } elseif (isset($_POST['submit-options4'])) { //uninstall checkbox $wassup_options->wassup_uninstall = $_POST['wassup_uninstall']; if ($wassup_options->saveSettings()) { $admin_message = __("Wassup uninstall option updated successfully","wassup")."." ; } } elseif (isset($_POST['submit-spam'])) { $wassup_options->wassup_spamcheck = $_POST['wassup_spamcheck']; $wassup_options->wassup_spam = $_POST['wassup_spam']; $wassup_options->wassup_refspam = $_POST['wassup_refspam']; if ($wassup_options->saveSettings()) { $admin_message = __("Wassup spam options updated successfully","wassup")."." ; } } elseif (isset($_POST['reset-to-default'])) { $wassup_options->loadDefaults(); if ($wassup_options->saveSettings()) { $admin_message = __("Wassup options updated successfully","wassup")."." ; } } //#sets current tab style for Wassup admin submenu? if ($_GET['page'] == "wassup-spy") { $class_spy="class='current'"; } elseif ($_GET['page'] == "wassup-options") { $class_opt="class='current'"; } elseif ($_GET['page'] == "wassup-online") { $class_ol="class='current'"; } else { $class_sub="class='current'"; } //for stringShortener calculated values and max-width...-Helene D. 11/27/07, 12/6/07 if (!empty($wassup_options->wassup_screen_res)) { $screen_res_size = (int) $wassup_options->wassup_screen_res; } else { $screen_res_size = 670; } $max_char_len = ($screen_res_size)/10; $screen_res_size = $screen_res_size+20; //for wrap margins... //for generating page link urls.... //$wpurl = get_bloginfo('wpurl'); //global $siteurl = get_bloginfo('siteurl'); //#display an admin message or an alert. This must be above "wrap" //# div. -Helene D. 2/26/08. if (!empty($admin_message)) { $wassup_options->showMessage($admin_message); } elseif (!empty($wassup_options->wassup_alert_message)) { $wassup_options->showMessage(); //#show alert message only once, so remove it here... $wassup_options->wassup_alert_message = ""; $wassup_options->saveSettings(); } //#debug - display MySQL errors/warnings //$mysqlerror = $wpdb->print_error(); //debug //if (!empty($mysqlerror)) { $wassup_options->showMessage($mysqlerror); } //debug //moved max-width to single "wrap" div and removed it from // the individual spans and divs in style.php... ?> <div class="wrap" style="max-width:<?php echo $screen_res_size; ?>px;" > <?php // HERE IS THE VISITORS ONLINE VIEW if ($_GET['page'] == "wassup-online") { ?> <h2><?php _e("Current Visitors Online", "wassup"); ?></h2> <p class="legend"><?php echo __("Legend", "wassup").': <span class="box-log"> </span> '.__("Logged-in Users", "wassup").' <span class="box-aut"> </span> '.__("Comments Authors", "wassup").' <span class="box-spider"> </span> '.__("Spiders/bots", "wassup"); ?></p><br /> <p class="legend"><a href="#" class="toggle-all"><?php _e("Expand All","wassup"); ?></a></p> <?php $to_date = wassup_get_time(); $from_date = strtotime('-3 minutes', $to_date); $currenttot = $wpdb->get_var("SELECT COUNT(DISTINCT wassup_id) as currenttot FROM $table_tmp_name WHERE `timestamp` BETWEEN $from_date AND $to_date"); $currenttot = $currenttot+0; //set to integer print "<p class='legend'>".__("Visitors online", "wassup").": <strong>".$currenttot."</strong></p><br />"; if ($currenttot > 0) { $qryC = $wpdb->get_results("SELECT id, wassup_id, max(timestamp) as max_timestamp, ip, hostname, searchengine, urlrequested, agent, referrer, spider, username, comment_author FROM $table_tmp_name WHERE `timestamp` BETWEEN $from_date AND $to_date GROUP BY ip ORDER BY max_timestamp DESC"); foreach ($qryC as $cv) { if ($wassup_options->wassup_time_format == 24) { $timed = gmdate("H:i:s", $cv->max_timestamp); } else { $timed = gmdate("h:i:s a", $cv->max_timestamp); } $ip_proxy = strpos($cv->ip,","); //if proxy, get 2nd ip... if ($ip_proxy !== false) { $ip = substr($cv->ip,(int)$ip_proxy+1); } else { $ip = $cv->ip; } if ($cv->referrer != '') { if (!eregi($wpurl, $cv->referrer) OR $cv->searchengine != "") { if (!eregi($wpurl, $cv->referrer) AND $cv->searchengine == "") { $referrer = '<a href="'.$cv->referrer.'" target=_"BLANK"><span style="font-weight: bold;">'.stringShortener($cv->referrer, round($max_char_len*.8,0)).'</span></a>'; } else { $referrer = '<a href="'.$cv->referrer.'" target=_"BLANK">'.stringShortener($cv->referrer, round($max_char_len*.9,0)).'</a>'; } } else { $referrer = __("From your blog", "wassup"); } } else { $referrer = __("Direct hit", "wassup"); } $numurl = $wpdb->get_var("SELECT COUNT(DISTINCT id) as numurl FROM $table_tmp_name WHERE wassup_id='".$cv->wassup_id."'"); ?> <div class="sum"> <span class="sum-box"><?php if ($numurl >= 2) { ?><a href="#" class="showhide" id="<?php echo $cv->id ?>"><?php print $ip; ?></a><?php } else { ?><?php print $ip; ?><?php } ?></span> <div class="sum-det"><span class="det1"> <?php //# html_entity_decode() links that were already //# "htmlentities-encoded" in database to prevent wacky links //# like "/imagegallery/?album=3&amp;amp;gallery=13" print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($cv->urlrequested))).'" target="_BLANK">'; print stringShortener(urlencode(html_entity_decode($cv->urlrequested)), round($max_char_len*.9,0)); ?></a></span><br /> <span class="det2"><strong><?php print $timed; ?> - </strong><?php print $referrer ?></span></div> </div> <?php // User is logged in or is a comment's author if ($cv->username != "" OR $cv->comment_author != "") { if ($cv->username != "") { $Ousername = '******'.__("LOGGED IN USER", "wassup").': <strong>'.$cv->username.'</strong></span></li>'; $Ocomment_author = '<li class="users"><span class="indent-li-agent">'.__("COMMENT AUTHOR", "wassup").': <strong>'.$cv->comment_author.'</strong></span></li>'; $unclass = "userslogged"; } elseif ($cv->comment_author != "") { $Ocomment_author = '<li class="users"><span class="indent-li-agent">'.__("COMMENT AUTHOR", "wassup").': <strong>'.$cv->comment_author.'</strong></span></li>'; $unclass = "users"; } ?> <ul class="<?php print $unclass; ?>"> <?php print $Ousername; ?> <?php print $Ocomment_author; ?> </ul> <?php } ?> <div style="display: none;" class="togglenavi navi<?php echo $cv->id ?>"> <ul class="url"> <?php $qryCD = $wpdb->get_results("SELECT `timestamp`, urlrequested FROM $table_tmp_name WHERE wassup_id='".$cv->wassup_id."' ORDER BY `timestamp` ASC"); $i=0; foreach ($qryCD as $cd) { $time2 = gmdate("H:i:s", $cd->timestamp); $num = ($i&1); $char_len = round($max_char_len*.9,0); if ($num == 0) $classodd = "urlodd"; else $classodd = "url"; if ($i >= 1) { ?> <li class="<?php print $classodd; ?> navi<?php echo $cv->id ?>"><span class="indent-li"><?php print $time2; ?> - <?php print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($cd->urlrequested))).'" target="_BLANK">'; print stringShortener(urlencode(html_entity_decode($cd->urlrequested)), $char_len).'</a></span></li>'."\n"; } $i++; } //end foreach qryCD print '</ul>'; print '</div>'; print '<p class="sum-footer"></p>'; } //end foreach qryC } //end if currenttot ?> <br /><p class="legend"><a href="#" class="toggle-all"><?php _e("Expand All", "wassup"); ?></a></p> <?php // HERE IS THE SPY MODE VIEW } elseif ($_GET['page'] == "wassup-spy") { ?> <h2><?php _e("SPY Visitors", "wassup"); ?></h2> <p class="legend"><?php echo __("Legend", "wassup").': <span class="box-log"> </span> '.__("Logged-in Users", "wassup").' <span class="box-aut"> </span> '.__("Comments Authors", "wassup").' <span class="box-spider"> </span> '.__("Spiders/bots", "wassup"); ?></p><br /> <div> <a href="#?" onclick="return pauseSpy();"><span id="spy-pause"><?php _e("Pause", "wassup"); ?></span></a> <a href="#?" onclick="return playSpy();"><span id="spy-play"><?php _e("Play", "wassup"); ?></span></a> - <span style="font-size: 11px;"><?php _e('Spy items by','wassup'); ?>: <select name="navi" style="font-size: 11px;" onChange="window.location.href=this.options[this.selectedIndex].value;"> <?php //## selectable filter by type of record (wassup_default_spy_type) if (isset($_GET['spytype'])) { $spytype = htmlentities(attribute_escape($_GET['spytype'])); } elseif ($wassup_options->wassup_default_spy_type != '') { $spytype = $wassup_options->wassup_default_spy_type; } $selected=$spytype; $optionargs="?page=wassup-spy&spytype="; $wassup_options->showFormOptions("wassup_default_spy_type","$selected","$optionargs"); ?> </select> </span> <br /> <br /></div> <?php // GEO IP Map if ($wassup_options->wassup_geoip_map == 1 AND $wassup_options->wassup_googlemaps_key != "") { ?> <script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo $wassup_options->wassup_googlemaps_key; ?>" type="text/javascript"></script> <div id="map" style="width: <?php echo ($screen_res_size*95/100); ?>px; height: 220px;border:2px solid #999;"></div> <script type="text/javascript"> //<![CDATA[ if (GBrowserIsCompatible()) { // Display the map, with some controls and set the initial location var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); //map.enableScrollWheelZoom(); map.setCenter(new GLatLng(0,0),3); } // display a warning if the browser was not compatible else { alert("Sorry, the Google Maps API is not compatible with this browser"); } //]]> </script> <p> </p> <? } //end if geoip_map ?> <div id="spyContainer"> <?php //display the last few hits here. The rest will be added by spy.js $to_date = (wassup_get_time()-2); $from_date = ($to_date - 12*(60*60)); //display last 10 visits in 12 hours... spyview($from_date,$to_date,10,$spytype); ?> </div><br /> <?php // HERE IS THE OPTIONS VIEW } elseif($_GET['page'] == "wassup-options") { //#moved content to external include file, "settings.php" //# to make "wassup" code easier to read and modify //# -Helene D. 1/15/08. include(dirname(__FILE__).'/lib/settings.php'); ?> <?php // HERE IS THE MAIN/DETAILS VIEW } else { ?> <h2><?php _e("Latest hits", "wassup"); ?></h2> <?php if ($wassup_options->wassup_active != 1) { ?> <p style="color:red; font-weight:bold;"><?php _e("WassUp recording is disabled", "wassup"); ?></p> <?php } $res = (int) $wassup_options->wassup_screen_res; if (empty($res)) $res=620; elseif ($res < 800) $res=620; elseif ($res < 1024) $res=740; elseif ($res < 1200) $res=1000; else $res=1000; //## GET parameters that change options settings if (isset($_GET['wchart']) || isset($_GET['wmark'])) { if (isset($_GET['wchart'])) { if ($_GET['wchart'] == 0) { $wassup_options->wassup_chart = 0; } else { $wassup_options->wassup_chart = 1; } } if (isset($_GET['wmark'])) { if ($_GET['wmark'] == 0) { $wassup_options->wmark = "0"; $wassup_options->wip = ""; } else { $wassup_options->wmark = "1"; $wassup_options->wip = attribute_escape($_GET['wip']); } } $wassup_options->saveSettings(); } //## GET params that filter detail display // //## Filter detail list by date range... $to_date = wassup_get_time(); if (isset($_GET['last']) && $_GET['last'] != "") { $last = htmlentities(attribute_escape($_GET['last'])); } else { $last = 1; } $from_date = strtotime('-'.$last.' day', $to_date); //## Filter detail lists by visitor type... if (isset($_GET['type'])) { $type = htmlentities(attribute_escape($_GET['type'])); } elseif ($wassup_options->wassup_default_type != '') { $type = $wassup_options->wassup_default_type; } $whereis=""; if ($type == 'spider') { $whereis = " AND spider!=''"; } elseif ($type == 'nospider') { $whereis = " AND spider=''"; } elseif ($type == 'spam') { $whereis = " AND spam>0"; } elseif ($type == 'nospam') { $whereis = " AND spam=0"; } elseif ($type == 'nospamspider') { $whereis = " AND spam=0 AND spider=''"; } elseif ($type == 'searchengine') { $whereis = " AND searchengine!='' AND search!=''"; } elseif ($type == 'referrer') { $whereis = " AND referrer!='' AND referrer NOT LIKE '%$wpurl%' AND searchengine='' AND search=''"; } elseif ($type == 'comauthor') { $whereis = " AND comment_author!=''"; } elseif ($type == 'loggedin') { $whereis = " AND username!=''"; } //## Filter detail lists by a specific page and number //# of items per page... $items = 10; //default if (isset($_GET['limit']) && is_numeric($_GET['limit'])) { //$items = htmlentities(attribute_escape($_GET['limit'])); $items = $_GET['limit']; } elseif ($wassup_options->wassup_default_limit != '') { $items = $wassup_options->wassup_default_limit; } if ((int)$items < 1 ) { $items = 10; } //# current page selections if (isset($_GET['pages']) && is_numeric($_GET['pages'])) { $pages = (int)$_GET['pages']; } else { $pages = 1; } if ( $pages > 1 ) { $limit = " LIMIT ".(($pages-1)*$items).",$items"; } else { $limit = " LIMIT $items"; } //## Filter detail lists by a searched item if (!empty($_GET['search'])) { $search = attribute_escape($_GET['search']); } else { $search = ""; } // DELETE EVERY RECORD MARKED BY IP //# Delete limited to selected date range only. -Helene D. 3/4/08. if (!empty($_GET['deleteMARKED']) && $wassup_options->wmark == "1" ) { $rec_deleted = $wpdb->get_var("SELECT COUNT(ip) as deleted FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND `timestamp` BETWEEN $from_date AND $to_date"); if (method_exists($wpdb,'prepare')) { $wpdb->query($wpdb->prepare("DELETE FROM $table_name WHERE ip='%s' AND `timestamp` BETWEEN %s AND %s", urlencode(attribute_escape($_GET['dip'])), $from_date, $to_date)); } else { $wpdb->query("DELETE FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND `timestamp` BETWEEN $from_date AND $to_date"); } echo '<p><strong>'.$rec_deleted.' '.__('records deleted','wassup').'</strong></p>'; //reset wmark/deleteMarked after delete and // clean up $_SERVER['QUERY_STRING'] as it is // used in filter selections below... $remove_query= array("&dip=".$_GET['dip'],"&deleteMARKED=".$_GET['deleteMARKED'],"&wmark=1","&wip=".$_GET['wip']); $new_query = str_replace($remove_query,"",$_SERVER['QUERY_STRING']); $_SERVER['QUERY_STRING']=$new_query; $wassup_options->wmark = "0"; $wassup_options->wip = null; $wassup_options->saveSettings(); } // Instantiate class to count items $Tot = New MainItems; $Tot->tableName = $table_name; $Tot->from_date = $from_date; $Tot->to_date = $to_date; $Tot->whereis = $whereis; $Tot->Limit = $limit; $Tot->WpUrl = $wpurl; $itemstot = $Tot->calc_tot("count", $search, null, "DISTINCT"); $pagestot = $Tot->calc_tot("count", $search, null, null); $spamtot = $Tot->calc_tot("count", $search, "AND spam>0"); // Check if some records was marked if ($wassup_options->wmark == "1") { $markedtot = $Tot->calc_tot("count", $search, "AND ip LIKE '%".$wassup_options->wip."%'", "DISTINCT"); } // Check if some records was searched if (!empty($search)) { $searchtot = $Tot->calc_tot("count", $search, null, "DISTINCT"); } ?> <form><table width="100%"> <tr> <td> <p class="legend"> <?php if ($wassup_options->wassup_chart == "1") { ?> <a href="<?php echo '?page='.WASSUPFOLDER.'&wchart=0&last='.$last.'&limit='.$items.'&type='.$_GET['type'].'&search='.$search.'&pages='.$pages; ?>" style="text-decoration:none;"> <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/chart_delete.png" style="padding:0px 6px 0 0;" alt="'.__('hide chart','wassup').'" title="'.__('Hide the chart and site usage','wassup'); ?>" /></a> <?php } else { ?> <a href="<?php echo '?page='.WASSUPFOLDER.'&wchart=1&last='.$last.'&limit='.$items.'&type='.$_GET['type'].'&search='.$search.'&pages='.$pages; ?>" style="text-decoration:none;"> <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/chart_add.png" style="padding:0px 6px 0 0;" alt="'.__('show chart','wassup').'" title="'.__('Show the chart and site usage','wassup'); ?>" /></a> <?php } //## Show selectable detail filters... if (isset($_GET['limit'])) { $new_limit = eregi_replace("\&limit=".$_GET['limit']."", "", $_SERVER['QUERY_STRING']); } else { $new_limit = $_SERVER['QUERY_STRING']; } if (isset($_GET['last'])) { $new_last = eregi_replace("\&last=".$_GET['last']."", "", $_SERVER['QUERY_STRING']); } else { $new_last = $_SERVER['QUERY_STRING']; } _e('Summary for the last','wassup'); ?> <select style="font-size: 11px;" name="last" onChange="window.location.href=this.options[this.selectedIndex].value;"> <?php //## selectable filter by date range echo " <option value='?$new_last&last=1'".($_GET['last'] == 1 ? " SELECTED" : "").">".__('24 hours','wassup')."</option> <option value='?$new_last&last=7'".($_GET['last'] == 7 ? " SELECTED" : "").">".__('7 days','wassup')."</option> <option value='?$new_last&last=30'".($_GET['last'] == 30 ? " SELECTED" : "").">".__('1 month','wassup')."</option> <option value='?$new_last&last=365'".($_GET['last'] == 365 ? " SELECTED" : "").">".__('1 year','wassup')."</option>"; ?> </select></p> </td> <td align="right"><p style="font-size: 11px;"><?php _e('Items per page','wassup'); ?>: <select name="navi" style="font-size: 11px;" onChange="window.location.href=this.options[this.selectedIndex].value;"> <?php //## selectable filter by number of items on page (default_limit) $selected=$items; $optionargs="?$new_limit&limit="; $wassup_options->showFormOptions("wassup_default_limit","$selected","$optionargs"); ?> </select> - <?php _e('Show items by','wassup'); ?>: <select style="font-size: 11px;" name="type" onChange="window.location.href=this.options[this.selectedIndex].value;"> <?php //## selectable filter by type of record (wassup_default_type) $selected=$type; $optionargs="?page=".WASSUPFOLDER."&type="; $wassup_options->showFormOptions("wassup_default_type","$selected","$optionargs"); ?> </select> </p> </td> </tr> </table> </form> <?php // Print Site Usage if ($wassup_options->wassup_chart == 1) { ?> <div class='main-tabs'> <div id='usage'> <ul> <li><span style="border-bottom:2px solid #0077CC;"><?php echo $itemstot; ?></span> <small><?php _e('Visits','wassup'); ?></small></li> <li><span style="border-bottom:2px dashed #FF6D06;"><?php echo $pagestot; ?></span> <small><?php _e('Pageviews','wassup'); ?></small></li> <li><span><?php echo @number_format(($pagestot/$itemstot), 2); ?></span> <small><?php _e('Pages/Visits','wassup'); ?></small></li> <?php // Print spam usage only if enabled if ($wassup_options->wassup_spamcheck == 1) { ?> <li><span><a href="#TB_inline?height=180&width=300&inlineId=hiddenspam" class="thickbox"><?php echo $spamtot; ?></a></span> <span>(<?php echo @number_format(($spamtot*100/$pagestot), 2); ?>%)</span> <small><?php _e('Spams','wassup'); ?></small></li> <?php } ?> </ul> <?php // Print the Google chart! if ($pagestot > 20) { echo $Tot->TheChart($last, $res, "125", $search, $wassup_options->wassup_chart_type, "bg,s,ffffff").""; } else { echo '<div id="placeholder" align="center"><p style="padding-top:50px;">'.__('Too few records to print chart','wassup').'...</p></div>'; } ?> </div> </div> <?php } //end if wassup_chart == 1 if (!isset($_GET['limit']) OR $_GET['limit'] == 10 OR $_GET['limit'] == 20) { $expcol = ' <table width="100%"><tr> <td align="left" class="legend"><a href="#" class="toggle-all">'.__('Expand All','wassup').'</a></td> <td align="right" class="legend"><a href="#" class="toggle-allcrono">'.__('Collapse Chronology','wassup').'</a></td> </tr></table><br />'; } // MAIN QUERY $main = $Tot->calc_tot("main", $search); if ($itemstot > 0) { $p=new pagination(); $p->items($itemstot); $p->limit($items); $p->currentPage($pages); $p->target("admin.php?page=".WASSUPFOLDER."&limit=$items&type=$type&last=$last&search=$search"); $p->calculate(); $p->adjacents(5); } // hidden spam options ?> <div id="hiddenspam" style="display:none;"> <h2><?php _e('Spam Options','wassup'); ?></h2> <form action="" method="post"> <p><input type="checkbox" name="wassup_spamcheck" value="1" <?php if($wassup_options->wassup_spamcheck == 1 ) print "CHECKED"; ?> /> <strong><?php _e('Enable/Disable Spam Check on Records','wassup'); ?></strong></p> <p style="padding-left:30px;"><input type="checkbox" name="wassup_spam" value="1" <?php if($wassup_options->wassup_spam == 1) print "CHECKED"; ?> /> <?php _e('Record Akismet comment spam attempts','wassup'); ?></p> <p style="padding-left:30px;"><input type="checkbox" name="wassup_refspam" value="1" <?php if($wassup_options->wassup_refspam == 1) print "CHECKED"; ?> /> <?php _e('Record referrer spam attempts','wassup'); ?></p> <p style="padding-left:0;"><input type="submit" name="submit-spam" value="<?php _e('Save Settings','wassup'); ?>" /></p> </form> </div> <table width="100%"> <tr> <td align="left" class="legend"> <?php // Marked items - Refresh if ($wassup_options->wmark == 1) echo '<a href="?'.$_SERVER['QUERY_STRING'].'&search='.$wassup_options->wip.'" title="'.__('Filter by marked IP','wassup').'"><strong>'.$markedtot.'</strong> '.__('show marked items','wassup').'</a> - '; if (!empty($search)) print "<strong>$searchtot</strong> ".__('Searched for','wassup').": <strong>$search</strong> - "; echo __('Auto refresh in','wassup').' <span id="CountDownPanel"></span> '.__('seconds','wassup'); ?> </td> <td align="right" class="legend"><a href="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/lib/action.php?action=topten&whash='.$whash.'&from_date='.$from_date.'&to_date='.$to_date.'&width='.$res.'&height=400'; ?>" class="thickbox" title="Wassup <?php _e('Top Ten','wassup'); ?>"><?php _e('Show Top Ten','wassup'); ?></a> - <a href="#" class='show-search'><?php _e('Search','wassup'); ?></a></td> </tr> </table> <div class="search-ip" style="display: none;"> <table border=0 width="100%"> <tr valign="top"> <td align="right"> <form action="" method="get"> <input type="hidden" name="page" value="<?php echo WASSUPFOLDER; ?>" /> <input type="text" size="25" name="search" value="<?php if ($search != "") print $search; ?>" /><input type="submit" name="submit-search" value="search" /> </form> </td> </tr> </table> </div> <?php //# Detailed List of Wassup Records... print $expcol; //# Show Page numbers/Links... if ($itemstot >= 10) { print "\n".'<div id="pag" align="center">'.$p->show().'</div><br />'."\n"; } if ($itemstot > 0) { foreach ($main as $rk) { $timestampF = $rk->max_timestamp; $dateF = gmdate("d M Y", $timestampF); if ($wassup_options->wassup_time_format == 24) { $datetimeF = gmdate('Y-m-d H:i:s', $timestampF); $timeF = gmdate("H:i:s", $timestampF); } else { $datetimeF = gmdate('Y-m-d h:i:s a', $timestampF); $timeF = gmdate("h:i:s a", $timestampF); } //$ip = @explode(",", $rk->ip); $ip_proxy = strpos($rk->ip,","); //if proxy, get 2nd ip... if ($ip_proxy !== false) { $ip = substr($rk->ip,(int)$ip_proxy+1); } else { $ip = $rk->ip; } // Visitor Record - raw data (hidden) $raw_div="raw-".substr($rk->wassup_id,0,25).rand(0,99); echo "\n"; ?> <div id="<?php echo $raw_div; ?>" style="display:none; padding-top:7px;" > <h2><?php _e("Raw data","wassup"); ?>:</h2> <style type="text/css">.raw { color: #542; padding-left:5px; }</style> <ul style="list-style-type:none;padding:20px 0 0 30px;"> <li><?php echo __("Visit type","wassup").': <span class="raw">'; if ($rk->username != "") { echo __("Logged-in user","wassup").' - '.$rk->username; } elseif ($rk->spam == "1" || $rk->spam == "2" ) { _e("Spammer","wassup"); } elseif ($rk->comment_author != "") { echo __("Comment author","wassup").' - '.$rk->comment_author; } elseif ($rk->feed != "") { echo __("Feed","wassup").' - '.$rk->feed; } elseif ($rk->spider != "") { echo __("Spider","wassup").' - '.$rk->spider; } else { _e("Regular visitor","wassup"); } echo '</span>'; ?></li> <li><?php echo __("IP","wassup").': <span class="raw">'.$rk->ip.'</span>'; ?></li> <li><?php echo __("Hostname","wassup").': <span class="raw">'.$rk->hostname.'</span>'; ?></li> <li><?php echo __("Url Requested","wassup").': <span class="raw">'.htmlspecialchars(html_entity_decode(clean_url($rk->urlrequested))).'</span>'; ?></li> <li><?php echo __("User Agent","wassup").': <span class="raw">'.$rk->agent.'</span>'; ?></li> <li><?php echo __("Referrer","wassup").': <span class="raw">'.urldecode($rk->referrer).'</span>'; ?></li> <?php if ($rk->search != "") { ?> <li><?php echo __("Search Engine","wassup").': <span class="raw">'.$rk->searchengine.'</span> '; echo __("Search","wassup").': <span class="raw">'.$rk->search.'</span>'; ?></li> <?php } if ($rk->os != "") { ?> <li><?php echo __("OS","wassup").': <span class="raw">'.$rk->os.'</span>'; ?></li> <?php } if ($rk->browser != "") { ?> <li><?php echo __("Browser","wassup").': <span class="raw">'.$rk->browser.'</span>'; ?></li> <?php } if ($rk->language != "") { ?> <li><?php echo __("Locale/Language","wassup").': <span class="raw">'.$rk->language.'</span>'; ?></li> <?php } ?> <li><?php echo 'Wassup ID'.': <span class="raw">'.$rk->wassup_id.'</span>'; ?></li> <li><?php echo __("End timestamp","wassup").': <span class="raw">'.$datetimeF.' ( '.$rk->max_timestamp.' )</span>'; ?></li> </ul> </div> <!-- raw-wassup_id --> <?php //Visitor Record - detail listing if ($rk->referrer != '') { if (!eregi($wpurl, $rk->referrer) OR $rk->searchengine != "") { if (!eregi($wpurl, $rk->referrer) AND $rk->searchengine == "") { $referrer = '<a href="'.$rk->referrer.'" target="_BLANK"><span style="font-weight: bold;">'.stringShortener($rk->referrer, round($max_char_len*.8,0)).'</span></a>'; } else { $referrer = '<a href="'.$rk->referrer.'" target="_BLANK">'.stringShortener($rk->referrer, round($max_char_len*.9,0)).'</a>'; } } else { $referrer = __('From your blog','wassup'); } } else { $referrer = __('Direct hit','wassup'); } $numurl = $wpdb->get_var("SELECT COUNT(DISTINCT id) as numurl FROM $table_name WHERE wassup_id='".$rk->wassup_id."'"); if ($rk->hostname != "") $hostname = $rk->hostname; else $hostname = "unknown"; ?> <div class="delID<?php echo $rk->wassup_id ?>"> <div class="<?php if ($wassup_options->wmark == 1 AND $wassup_options->wip == $ip) echo "sum-nav-mark"; else echo "sum-nav"; ?>"> <p class="delbut"> <?php // Mark/Unmark IP if ($wassup_options->wmark == 1 AND $wassup_options->wip == $ip) { ?> <a href="?<?php echo $_SERVER['QUERY_STRING']; ?>&deleteMARKED=1&dip=<?php print $ip; ?>" style="text-decoration:none;"> <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/cross.png" alt="'.__('delete','wassup').'" title="'.__('Delete ALL marked records with this IP','wassup'); ?>" /></a> <a href="?page=<?php echo WASSUPFOLDER; ?>&wmark=0" style="text-decoration:none;"> <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/error_delete.png" alt="'.__('unmark','wassup').'" title="'.__('UnMark IP','wassup'); ?>" /></a> <?php } else { ?> <a href="#" class="deleteID" id="<?php echo $rk->wassup_id ?>" style="text-decoration:none;"> <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/cross.png" alt="'.__('delete','wassup').'" title="'.__('Delete this record','wassup'); ?>" /></a> <a href="?<?php echo $_SERVER['QUERY_STRING']; ?>&wmark=1&wip=<?php print $ip; ?>" style="text-decoration:none;"> <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/error_add.png" alt="'.__('mark','wassup').'" title="'.__('Mark IP','wassup'); ?>" /></a> <?php } ?> <a href="#TB_inline?height=400&width=<?php echo $res.'&inlineId='.$raw_div; ?>" class="thickbox"> <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/database_table.png" alt="'.__('show raw table','wassup').'" title="'.__('Show the items as raw table','wassup'); ?>" /></a> </p> <span class="sum-box"><?php if ($numurl >= 2) { ?><a href="#" class="showhide" id="<?php echo $rk->id ?>"><?php print $ip; ?></a><?php } else { ?><?php print $ip; ?><?php } ?></span> <span class="sum-date"><?php print $datetimeF; ?></span> <div class="sum-det"><span class="det1"> <?php print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode(clean_url($rk->urlrequested)))).'" target="_BLANK">'; print stringShortener(urlencode(html_entity_decode(clean_url($rk->urlrequested))), round($max_char_len*.8,0)); ?></a> </span><br /> <span class="det2"><strong><?php _e('Referrer','wassup'); ?>: </strong><?php print $referrer; ?><br /><strong><?php _e('Hostname','wassup'); ?>:</strong> <a href="#" class="toggleagent" id="<?php echo $rk->id ?>"><?php print $hostname; ?></a></span></div> </div> <div style="margin-left: auto; margin-right: auto;"> <div style="display: none;" class="togglenavi naviagent<?php echo $rk->id ?>"> <ul class="useragent"> <li class="useragent"><span class="indent-li-agent"><?php _e('User Agent','wassup'); ?>: <strong><?php print $rk->agent; ?></strong></span></li> </ul> </div> <?php // Referer is search engine if ($rk->searchengine != "") { if (eregi("images", $rk->searchengine)) { $bg = 'style="background: #e5e3ec;"'; $page = (number_format(($rk->searchpage / 19), 0) * 18); $Apagenum = explode(".", number_format(($rk->searchpage / 19), 1)); $pagenum = ($Apagenum[0] + 1); $url = parse_url($rk->referrer); $ref = $url['scheme']."://".$url['host']."/images?q=".eregi_replace(" ", "+", $rk->search)."&start=".$page; } else { $bg = 'style="background: #e4ecf4;"'; $pagenum = $rk->searchpage; $ref = $rk->referrer; } ?> <ul class="searcheng" <?php print $bg; ?>> <li class="searcheng"><span class="indent-li-agent"><?php _e('SEARCH ENGINE','wassup'); ?>: <strong><?php print $rk->searchengine." (".__("page","wassup").": $pagenum)"; ?></strong></span></li> <li class="searcheng"><?php _e("KEYWORDS","wassup"); ?>: <strong><a href="<?php print $ref; ?>" target="_BLANK"><?php print stringShortener($rk->search, round($max_char_len*.52,0)); ?></a></strong></li> </ul> <?php } ?> <?php // User is logged in or is a comment's author if ($rk->username != "" OR $rk->comment_author != "") { if ($rk->username != "") { $Ocomment_author = '<li class="users"><span class="indent-li-agent">'.__("LOGGED IN USER","wassup").': <strong>'.$rk->username.'</strong></span></li> <li class="users"><span class="indent-li-agent">'.__("COMMENT AUTHOR","wassup").': <strong>'.$rk->comment_author.'</strong></span></li>'; $unclass = "userslogged"; } elseif ($rk->comment_author != "") { $Ocomment_author = '<li class="users"><span class="indent-li-agent">'.__("COMMENT AUTHOR","wassup").': <strong>'.utf8_decode($rk->comment_author).'</strong></span></li>'; $unclass = "users"; } ?> <ul class="<?php print $unclass; ?>"> <?php print $Ocomment_author; ?> </ul> <?php } ?> <?php // Referer is a Spider or Bot if ($rk->spider != "") { if ($rk->feed != "") { ?> <ul style="background:#fdeec8;" class="spider"> <li class="feed"><span class="indent-li-agent"><?php _e('FEEDREADER','wassup'); ?>: <strong><?php print $rk->spider; ?></strong></span></li> <?php if (is_numeric($rk->feed)) { ?> <li class="feed"><span class="indent-li-agent"><?php _e('SUBSCRIBER(S)','wassup'); ?>: <strong><?php print (int)$rk->feed; ?></strong></span></li> <?php } ?> </ul> <?php } else { ?> <ul class="spider"> <li class="spider"><span class="indent-li-agent"><?php _e('SPIDER','wassup'); ?>: <strong><?php print $rk->spider; ?></strong></span></li> </ul> <?php } } ?> <?php // Referer is a SPAM if ($rk->spam > 0 && $rk->spam < 3) { ?> <ul class="spam"> <li class="spam"><span class="indent-li-agent"> <?php _e("Probably SPAM!","wassup"); if ($rk->spam==2) { echo '('.__("Referer Spam","wassup").')'; } else { echo '(Akismet '.__("Spam","wassup").')'; } ?> </span></li> </ul> <?php } elseif ($rk->spam == 3) { ?> <ul class="spam"> <li class="spam"><span class="indent-li-agent"> <?php _e("Probably hack attempt!","wassup"); ?> </li></ul> <?php } ?> <?php // User os/browser/language if ($rk->spider == "" AND ($rk->os != "" OR $rk->browser != "")) { ?> <ul class="agent"> <li class="agent"><span class="indent-li-agent"> <?php if ($rk->language != "") { ?> <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/flags/'.strtolower($rk->language).'.png'.'" alt="'.strtolower($rk->language).'" title="'.__("Language","wassup").': '.strtolower($rk->language); ?>" /> <?php } _e("OS","wassup"); ?>: <strong><?php print $rk->os; ?></strong></span></li> <li class="agent"><?php _e("BROWSER","wassup"); ?>: <strong><?php print $rk->browser; ?></strong></li> <?php if ($rk->screen_res != "") { ?> <li class="agent"><?php _e("RESOLUTION","wassup"); ?>: <strong><?php print $rk->screen_res; ?></strong></li> <?php } ?> </ul> <?php } ?> <div style="display: visible;" class="togglecrono navi<?php echo $rk->id ?>"> <ul class="url"> <?php $qryCD = $wpdb->get_results("SELECT `timestamp`, urlrequested FROM $table_name WHERE wassup_id='".$rk->wassup_id."' ORDER BY `timestamp` ASC"); $i=0; foreach ($qryCD as $cd) { //$timestamp2 = $cd->timestamp; //redundant $time2 = gmdate("H:i:s", $cd->timestamp); $char_len = round($max_char_len*.92,0); $num = ($i&1); if ($num == 0) $classodd = "urlodd"; else $classodd = "url"; if ($i >= 1) { print '<li class="'.$classodd.' navi'.$rk->id.'"><span class="indent-li-nav">'.$time2.' ->'; print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($cd->urlrequested))).'" target="_BLANK">'; print stringShortener(urlencode(html_entity_decode($cd->urlrequested)), $char_len).'</a></span></li>'."\n"; } $i++; } //end foreach qryCD print "</ul>"; ?> </div> <p class="sum-footer"></p> </div> </div> <?php } //end foreach qry } //end if itemstot > 0 print '<br />'; if ($itemstot >= 10) $p->show(); print '<br />'; if (!isset($_GET['limit']) OR $_GET['limit'] == 10 OR $_GET['limit'] == 20) { print $expcol; } if($con) mysql_close($con); } //end MAIN/DETAILS VIEW // End calculating execution time of script $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); ?> <p><small>WassUp ver: <?php echo $version.' - '.__("Check the official","wassup").' <a href="http://www.wpwp.org" target="_BLANK">WassUp</a> '.__("page for updates, bug reports and your hints to improve it","wassup").' - <a href="http://trac.wpwp.org/wiki/Documentation" title="Wassup '.__("User Guide documentation","wassup").'">Wassup '.__("User Guide documentation","wassup").'</a>'; ?> - Exec time: <?php echo $totaltime ?></small></p> </div> <!-- end wrap --> <?php } //end function Wassup
function get($sql = FALSE, $noSplitPage = FALSE) { $sql = $sql ? $sql : 'select ' . $this->select . ' from ' . $this->table . ' ' . $this->join . ' ' . $this->where . ' ' . $this->sort . ' ' . $this->order; //$sql = iconv('UTF-8','TIS-620',$sql); if ($noSplitPage == FALSE) { $this->load->library('pagination'); $page = new pagination(); $page->target($this->target); $page->limit($this->limit); @$page->currentPage($this->current_page); $rs = $this->db->PageExecute($sql, $page->limit, $page->page); $page->Items($rs->_maxRecordCount); $this->pagination = $page->show(); } else { $rs = $this->db->Execute($sql); } $this->free_result(); $data = $rs->GetArray(); ///array_walk($data,'dbConvert'); return $data; }
/** * Create WP ULike bbPress Logs page with separate pagination * * @author Alimir * @since 2.2 * @return String */ function wp_ulike_bbpress_likes_logs() { global $wpdb; $alternate = true; $items = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "ulike_forums"); if ($items > 0) { $p = new pagination(); $p->items($items); $p->limit(wp_ulike_logs_return_per_page()); // Limit entries per page $p->target("admin.php?page=wp-ulike-bbpress-logs"); $p->calculate(); // Calculates what to show $p->parameterName('page_number'); $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['page_number'])) { $p->page = 1; } else { $p->page = $_GET['page_number']; } //Query for limit page_number $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; $get_ulike_logs = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ulike_forums ORDER BY id DESC " . $limit . ""); ?> <div class="wrap"> <h2><?php _e('WP ULike Logs', 'alimir'); ?> </h2> <h3><?php _e('Topics Likes Logs', 'alimir'); ?> </h3> <div class="tablenav"> <div class='tablenav-pages'> <span class="displaying-num"><?php echo $items . ' ' . __('Logs', 'alimir'); ?> </span> <?php echo $p->show(); // Echo out the list of paging. ?> </div> </div> <table class="widefat"> <thead> <tr> <th width="2%"><?php _e('ID', 'alimir'); ?> </th> <th width="10%"><?php _e('Username', 'alimir'); ?> </th> <th><?php _e('Status', 'alimir'); ?> </th> <th width="6%"><?php _e('Topic ID', 'alimir'); ?> </th> <th><?php _e('Topic Title', 'alimir'); ?> </th> <th width="20%"><?php _e('Date / Time', 'alimir'); ?> </th> <th><?php _e('IP', 'alimir'); ?> </th> <th><?php _e('Actions', 'alimir'); ?> </th> </tr> </thead> <tbody class="wp_ulike_logs"> <?php foreach ($get_ulike_logs as $get_ulike_log) { ?> <tr <?php if ($alternate == true) { echo 'class="alternate"'; } ?> > <td> <?php echo $get_ulike_log->id; ?> </td> <td> <?php $user_info = get_userdata($get_ulike_log->user_id); if ($user_info) { echo get_avatar($user_info->user_email, 16, '', 'avatar') . '<em> @' . $user_info->user_login . '</em>'; } else { echo '<em> #' . __('Guest User', 'alimir') . '</em>'; } ?> </td> <td> <?php $get_the_status = $get_ulike_log->status; if ($get_the_status == 'like') { echo '<img src="' . plugin_dir_url(__FILE__) . '/classes/img/like.png" alt="like" width="24"/>'; } else { echo '<img src="' . plugin_dir_url(__FILE__) . '/classes/img/unlike.png" alt="unlike" width="24"/>'; } ?> </td> <td> <?php echo $get_ulike_log->topic_id; ?> </td> <td> <?php echo '<a href="' . get_permalink($get_ulike_log->topic_id) . '" title="' . get_the_title($get_ulike_log->topic_id) . '">' . get_the_title($get_ulike_log->topic_id) . '</a>'; ?> </td> <td> <?php echo wp_ulike_date_i18n($get_ulike_log->date_time); ?> </td> <td> <?php echo $get_ulike_log->ip; ?> </td> <td> <button class="wp_ulike_delete button" type="button" data-id="<?php echo $get_ulike_log->id; ?> " data-table="ulike_forums"><i class="dashicons dashicons-trash"></i></button> </td> <?php $alternate = !$alternate; } ?> </tr> </tbody> </table> <div class="tablenav"> <div class='tablenav-pages'> <span class="displaying-num"><?php echo $items . ' ' . __('Logs', 'alimir'); ?> </span> <?php echo $p->show(); // Echo out the list of paging. ?> </div> </div> </div> <?php } else { echo "<div class='error'><p>" . __('<strong>ERROR:</strong> No Record Found. (This problem is created because you don\'t have any data on this table)', 'alimir') . "</p></div>"; } }
/** * Abandon Cart Settings Page */ function woocommerce_ac_page() { if (is_user_logged_in()) { global $wpdb; // Check the user capabilities if (!current_user_can('manage_woocommerce')) { wp_die(__('You do not have sufficient permissions to access this page.', 'woocommerce-ac')); } ?> <div class="wrap"> <div class="icon32" style="background-image: url('<?php echo plugins_url(); ?> /woocommerce-abandon-cart-pro/images/abandoned_cart_small.png') !important;"> <br /> </div> <h2><?php _e('WooCommerce - Abandon Cart', 'woocommerce-ac'); ?> </h2> <?php if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = ""; } if (isset($_GET['mode'])) { $mode = $_GET['mode']; } else { $mode = ""; } $this->display_tabs(); if ($action == 'emailsettings') { // Save the field values if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'save') { $ac_settings = new stdClass(); if (isset($_POST['enable_cart_notifications'])) { $ac_settings->enable_cart_notification = $_POST['enable_cart_notifications']; } $ac_settings->cart_time = $_POST['cart_abandonment_time']; $ac_settings->delete_order_days = $_POST['delete_abandoned_orders_days']; if (isset($_POST['email_admin_on_conversion'])) { $ac_settings->email_admin = $_POST['email_admin_on_conversion']; } if (isset($_POST['track_coupons'])) { $ac_settings->track_coupons = $_POST['track_coupons']; } //$ac_settings->conver_email = $_POST['conversion_emails_sendto']; //$ac_settings->conver_link = $_POST['stop_on_conversion_link']; //$ac_settings->conver_order = $_POST['stop_on_conversion_order']; $woo_ac_settings[] = $ac_settings; $woocommerce_ac_settings = json_encode($woo_ac_settings); update_option('woocommerce_ac_settings', $woocommerce_ac_settings); //exit; } ?> <?php if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'save') { ?> <div id="message" class="updated fade"><p><strong><?php _e('Your settings have been saved.', 'woocommerce-ac'); ?> </strong></p></div> <?php } ?> <?php //$enable_email_sett = array(); $enable_email_sett = json_decode(get_option('woocommerce_ac_settings')); ?> <p><?php _e('Change settings for sending email notifications to Customers, to Admin, Tracking Coupons etc.', 'woocommerce-ac'); ?> </p> <div id="content"> <form method="post" action="" id="ac_settings"> <input type="hidden" name="ac_settings_frm" value="save"> <div id="poststuff"> <div class="postbox"> <h3 class="hndle"><?php _e('Settings', 'woocommerce-ac'); ?> </h3> <div> <table class="form-table"> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Enable abandoned cart notifications', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $noti = ""; if (isset($enable_email_sett[0]->enable_cart_notification) && $enable_email_sett[0]->enable_cart_notification == 'on') { $noti = "checked"; } print '<input type="checkbox" name="enable_cart_notifications" id="enable_cart_notifications" ' . $noti . '>'; ?> <img class="help_tip" width="16" height="16" data-tip="<?php _e('Yes, enable the abandoned cart notifications', 'woocommerce-ac'); ?> " src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!-- <span class="description"><?php _e('Yes, enable the abandoned cart notifications', 'woocommerce-ac'); ?> </span> --> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Cart abandoned cut-off time', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $cart_time = ""; if (isset($enable_email_sett[0]->cart_time) && ($enable_email_sett[0]->cart_time != '' || $enable_email_sett[0]->cart_time != 'null')) { $cart_time = $enable_email_sett[0]->cart_time; } print '<input type="text" name="cart_abandonment_time" id="cart_abandonment_time" size="5" value="' . $cart_time . '"> minutes '; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Consider cart abandoned after X minutes of item being added to cart & order not placed', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!-- <span class="description"><?php _e('Consider cart abandoned after X minutes of item being added to cart & order not placed', 'woocommerce-ac'); ?> </span> --> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Automatically Delete Abandoned Orders after', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $delete_order_days = ""; if (isset($enable_email_sett[0]->delete_order_days) && ($enable_email_sett[0]->delete_order_days != '' || $enable_email_sett[0]->delete_order_days != 'null')) { $delete_order_days = $enable_email_sett[0]->delete_order_days; } print '<input type="text" name="delete_abandoned_orders_days" id="delete_abandoned_orders_days" size="5" value="' . $delete_order_days . '"> days '; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Automatically delete abandoned cart orders after X days', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!-- <span class="description"><?php _e('Automatically delete abandoned cart orders after X days', 'woocommerce-ac'); ?> </span> --> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Email admin on order recovery', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $email_admin = ""; if (isset($enable_email_sett[0]->email_admin) && $enable_email_sett[0]->email_admin == 'on') { $email_admin = "checked"; } print '<input type="checkbox" name="email_admin_on_conversion" ' . $email_admin . '> '; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Sends email to Admin if an Abandoned Cart Order is recoverd', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!--<span id="email_on_conversion">--> <?php /* $conversation_email = ""; if ( $enable_email_sett[0]->conver_email != '' || $enable_email_sett[0]->conver_email != 'null') { $conversation_email = $enable_email_sett[0]->conver_email; } print'<input type="text" name="conversion_emails_sendto" id="conversion_emails_sendto" size="30" value="'.$conversation_email.'"></span> <br />'; */ ?> <!-- <span class="description"><?php //_e( 'Email me when an abandoned cart is saved & results in an order', 'woocommerce-ac' ); ?> </span> --> </td> </tr> <!-- <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Stop sending emails', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $stop_conversation_email = ""; if ($enable_email_sett[0]->conver_link == 'on') { $stop_conversation_email = "checked"; } print '<input type="checkbox" name="stop_on_conversion_link" id="stop_on_conversion_link"' . $stop_conversation_email . '> '; ?> <img class="help_tip" data-tip='<?php _e('Sends email to Admin if an Abandoned Cart Order is recoverd', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <span><?php _e('Stop sending when the shopper clicks the \\"Complete Order\\" link in the email', 'woocommerce-ac'); ?> </span> <br /> <?php $stop_conversation_onorder = ""; if ($enable_email_sett[0]->conver_order == 'on') { $stop_conversation_onorder = "checked"; } print '<input type="checkbox" name="stop_on_conversion_order" id="stop_on_conversion_order" ' . $stop_conversation_onorder . '> '; ?> <span><?php _e('Stop sending when the shopper completes their order', 'woocommerce-ac'); ?> </span> <span class="description"><?php //echo _e( 'Email me when an abandoned cart is saved & results in an order', 'woocommerce-ac' ); ?> </span> </td> </tr> --> <!--<tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Email Frequency:', 'woocommerce-ac'); ?> </b></label> </th> <td> <select name="woocommerce_ac_email_frequency"> <?php foreach ($intervals_arr as $seconds => $value) { printf("<option %s value='%s'>%s</option>\n", selected($seconds, get_option('woocommerce_ac_email_frequency'), false), esc_attr($seconds), $value); } ?> </select> <br /> <span class="description"><?php echo __('Set email frequency (since cart was abandoned).', 'woocommerce-ac'); ?> </span> </td> </tr>--> <tr> <th> <label for="woocommerce_ac_track_coupons"><b><?php _e('Track Coupons', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $coupon_track = ""; if (isset($enable_email_sett[0]->track_coupons) && $enable_email_sett[0]->track_coupons == 'on') { $coupon_track = "checked"; } print '<input type="checkbox" name="track_coupons" id="track_coupons" ' . $coupon_track . '>'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Tracks all coupons that were applied to abandoned carts', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <!-- <span class="description"><?php _e('Tracks all coupons that were applied to abandoned carts', 'woocommerce-ac'); ?> </span> --> </td> </tr> </table> </div> </div> </div> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes', 'woocommerce-ac'); ?> " /> </p> </form> </div> <?php } elseif ($action == 'listcart' || $action == '') { ?> <p> <?php _e('The list below shows all Abandoned Carts which have remained in cart for a time higher than the "Cart abandoned cut-off time" setting.', 'woocommerce-ac'); ?> </p> <?php //echo plugins_url(); include_once "pagination.class.php"; /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */ $wpdb->get_results("SELECT wpac . * , wpu.user_login, wpu.user_email \n\t\t\t\t\t FROM `" . $wpdb->prefix . "ac_abandoned_cart_history` AS wpac \n\t\t\t\t\t LEFT JOIN " . $wpdb->prefix . "users AS wpu ON wpac.user_id = wpu.id\n\t\t\t\t\t WHERE recovered_cart='0' AND unsubscribe_link='0' "); $count = $wpdb->num_rows; if ($count > 0) { $p = new pagination(); $p->items($count); $p->limit(10); // Limit entries per page $p->target("admin.php?page=woocommerce_ac_page&action=listcart"); if (isset($p->paging)) { if (isset($_GET[$p->paging])) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page } $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page $p->showCounter(true); if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { $limit = ""; } ?> <div class="tablenav"> <div class='tablenav-pages'> <?php if ($count > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php $order = ""; if (isset($_GET['order'])) { $order = $_GET['order']; } if ($order == "") { $order = "desc"; $order_next = "asc"; } elseif ($order == "asc") { $order_next = "desc"; } elseif ($order == "desc") { $order_next = "asc"; } $order_by = ""; if (isset($_GET['orderby'])) { $order_by = $_GET['orderby']; } if ($order_by == "") { $order_by = "abandoned_cart_time"; } /* Now we use the LIMIT clause to grab a range of rows */ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email \n\t\t\t\t\t FROM `" . $wpdb->prefix . "ac_abandoned_cart_history` AS wpac \n\t\t\t\t\t LEFT JOIN " . $wpdb->prefix . "users AS wpu ON wpac.user_id = wpu.id\n\t\t\t\t\t WHERE recovered_cart='0' AND unsubscribe_link='0' \n\t\t\t\t\t ORDER BY `{$order_by}` {$order} \n\t\t\t\t\t {$limit}"; //echo $query; $results = $wpdb->get_results($query); /* echo "<pre>"; print_r($results); echo "</pre>"; */ //exit; /* From here you can do whatever you want with the data from the $result link. */ $ac_cutoff_time = json_decode(get_option('woocommerce_ac_settings')); if (isset($ac_cutoff_time[0]->track_coupons)) { $display_tracked_coupons = $ac_cutoff_time[0]->track_coupons; } else { $display_tracked_coupons = ""; } ?> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data'> <tr> <th> <?php _e('Customer', 'woocommerce-ac'); ?> </th> <th> <?php _e('Order Total', 'woocommerce-ac'); ?> </th> <th> <?php _e('Quantity', 'woocommerce-ac'); ?> </th> <th scope="col" id="date_ac" class="manage-column column-date_ac sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=listcart&orderby=abandoned_cart_time&order=<?php echo $order_next; ?> "> <span> <?php _e('Date', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <?php if ($display_tracked_coupons == 'on') { ?> <th> <?php _e('Coupon Code Used', 'woocommerce-ac'); ?> </th> <th> <?php _e('Coupon Status', 'woocommerce-ac'); ?> </th> <?php } ?> <th scope="col" id="status_ac" class="manage-column column-status_ac sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=listcart&orderby=cart_ignored&order=<?php echo $order_next; ?> "> <span> <?php _e('Status', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th> <?php _e('Actions', 'woocommerce-ac'); ?> </th> </tr> <?php foreach ($results as $key => $value) { if ($value->user_type == "GUEST") { $query_guest = "SELECT * from `" . $wpdb->prefix . "ac_guest_abandoned_cart_history`\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $value->user_id . "'"; $results_guest = $wpdb->get_results($query_guest); /* echo "<pre>"; print_r($results_guest); echo "</pre>";*/ } $abandoned_order_id = $value->id; $user_id = $value->user_id; $user_login = $value->user_login; if ($value->user_type == "GUEST") { if (isset($results_guest[0]->email_id)) { $user_email = $results_guest[0]->email_id; } if (isset($results_guest[0]->billing_first_name)) { $user_first_name = $results_guest[0]->billing_first_name; } else { $user_first_name = ""; } if (isset($results_guest[0]->billing_last_name)) { $user_last_name = $results_guest[0]->billing_last_name; } else { $user_last_name = ""; } // echo $user_first_name . " " . $user_last_name; } else { $user_email = $value->user_email; $user_first_name_temp = get_user_meta($value->user_id, 'first_name'); if (isset($user_first_name_temp[0])) { $user_first_name = $user_first_name_temp[0]; } else { $user_first_name = ""; } $user_last_name_temp = get_user_meta($value->user_id, 'last_name'); if (isset($user_last_name_temp[0])) { $user_last_name = $user_last_name_temp[0]; } else { $user_last_name = ""; } // echo $user_first_name . " " . $user_last_name; } $cart_info = json_decode($value->abandoned_cart_info); $order_date = ""; $cart_update_time = $value->abandoned_cart_time; if ($cart_update_time != "" && $cart_update_time != 0) { $order_date = date('d M, Y h:i A', $cart_update_time); } $ac_cutoff_time = json_decode(get_option('woocommerce_ac_settings')); $cut_off_time = $ac_cutoff_time[0]->cart_time * 60; $current_time = current_time('timestamp'); $compare_time = $current_time - $cart_update_time; if (isset($ac_cutoff_time[0]->track_coupons)) { $display_tracked_coupons = $ac_cutoff_time[0]->track_coupons; } /*echo $display_tracked_coupons."</br>"; echo $cut_off_time." <pre>"; print_r($ac_cutoff_time); echo "</pre>"; exit;*/ $cart_details = $cart_info->cart; $line_total = 0; if (count($cart_details) > 0) { foreach ($cart_details as $k => $v) { $line_total = $line_total + $v->line_total; } } $quantity_total = 0; if (count($cart_details) > 0) { foreach ($cart_details as $k => $v) { $quantity_total = $quantity_total + $v->quantity; } } if ($quantity_total == 1) { $item_disp = "item"; } else { $item_disp = "items"; } $coupon_details = get_user_meta($value->user_id, '_woocommerce_ac_coupon', true); if ($value->cart_ignored == 0 && $value->recovered_cart == 0) { $ac_status = "Abandoned"; } elseif ($value->cart_ignored == 1 && $value->recovered_cart == 0) { $ac_status = "Abandoned but new </br>cart created after this"; } else { $ac_status = ""; } ?> <?php if ($compare_time > $cut_off_time && $ac_status != "") { if ($quantity_total > 0) { ?> <tr id="row_<?php echo $abandoned_order_id; ?> "> <td><strong><a href="admin.php?page=woocommerce_ac_page&action=orderdetails&id=<?php echo $value->id; ?> "><?php echo "Abandoned Order #" . $abandoned_order_id; ?> </a></strong><?php echo "</br>Name: " . $user_first_name . " " . $user_last_name . "<br><a href='mailto:{$user_email}'>" . $user_email . "</a>"; ?> </td> <td><?php echo get_woocommerce_currency_symbol() . " " . $line_total; ?> </td> <td><a href="admin.php?page=woocommerce_ac_page&action=orderdetails&id=<?php echo $value->id; ?> "><?php echo $quantity_total . " " . $item_disp; ?> </a></td> <td><?php echo $order_date; ?> </td> <?php if ($display_tracked_coupons == 'on') { ?> <td><?php if ($coupon_details != '') { foreach ($coupon_details as $key => $value) { echo $coupon_details[$key]['coupon_code'] . "</br>"; } } ?> </td> <td><?php if ($coupon_details != '') { foreach ($coupon_details as $key => $value) { echo $coupon_details[$key]['coupon_message'] . "</br>"; } } ?> </td> <?php } ?> <td><?php echo $ac_status; ?> <td id="<?php echo $abandoned_order_id; ?> "> <?php echo "<a href='#' id='{$abandoned_order_id}-{$user_id}' class='remove_cart'> <img src='" . plugins_url() . "/woocommerce-abandon-cart-pro/images/delete.png' alt='Remove Cart Data' title='Remove Cart Data'></a>"; ?> <br><?php //echo "<a href='#' id='$abandoned_order_id-$user_id' class='contact_customer'> Contact Customer </a>"; ?> </td> </tr> <?php } } } echo "</table>"; } elseif ($action == 'emailtemplates' && ($mode != 'edittemplate' && $mode != 'addnewtemplate' && $mode != 'copytemplate')) { ?> <p> <?php _e('Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-ac'); ?> </p> <?php // Save the field values if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'save') { if (isset($_POST['coupon_ids'][0])) { $coupon_code_id = $_POST['coupon_ids'][0]; } else { $coupon_code_id = ""; } $active_post = empty($_POST['is_active']) ? '0' : '1'; if ($active_post == 1) { $check_query = "SELECT * FROM `" . $wpdb->prefix . "ac_email_templates` \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE is_active='1' AND frequency='" . $_POST['email_frequency'] . "' AND day_or_hour='" . $_POST['day_or_hour'] . "' "; $check_results = $wpdb->get_results($check_query); if (count($check_results) == 0) { $query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates` \n\t\t\t\t\t\t\t\t\t\t(from_email, subject, body, is_active, frequency, day_or_hour, coupon_code, template_name, from_name, reply_email)\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $_POST['woocommerce_ac_email_from'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_subject'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_body'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $active_post . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['email_frequency'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['day_or_hour'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $coupon_code_id . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_template_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_from_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_reply'] . "' )"; //echo $query; $wpdb->query($query); } else { $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tis_active='0'\n\t\t\t\t\t\t\t\t\t\tWHERE frequency='" . $_POST['email_frequency'] . "' AND day_or_hour='" . $_POST['day_or_hour'] . "' "; //echo $query_update; $wpdb->query($query_update); $query_insert_new = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates` \n\t\t\t\t\t\t\t\t\t\t(from_email, subject, body, is_active, frequency, day_or_hour, coupon_code, template_name, from_name, reply_email)\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $_POST['woocommerce_ac_email_from'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_subject'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_body'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $active_post . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['email_frequency'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['day_or_hour'] . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $coupon_code_id . "', \n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_template_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_from_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['woocommerce_ac_email_reply'] . "' )"; //echo $query; $wpdb->query($query_insert_new); } } else { $query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t(from_email, subject, body, is_active, frequency, day_or_hour, coupon_code, template_name, from_name, reply_email)\n\t\t\t\t\t\t\t\t\tVALUES ('" . $_POST[woocommerce_ac_email_from] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_email_subject] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_email_body] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $active_post . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[email_frequency] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[day_or_hour] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $coupon_code_id . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_template_name] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_from_name] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST[woocommerce_ac_email_reply] . "' )"; //echo $query; $wpdb->query($query); } } if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'update') { /* echo "<pre>"; print_r($_POST); echo "</pre>"; */ if (isset($_POST['coupon_ids'])) { $coupon_code_id = $_POST['coupon_ids'][0]; if ($coupon_code_id == "" && $_POST['existing_coupon_id'] != "") { $coupon_code_id = $_POST['existing_coupon_id']; } } else { if (isset($_POST['coupon_ids'][0])) { $coupon_code_id = $_POST['coupon_ids'][0]; } else { $coupon_code_id = ""; } } $active = empty($_POST['is_active']) ? '0' : '1'; if ($active == 1) { $check_query = "SELECT * FROM `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\tWHERE is_active='1' AND frequency='" . $_POST['email_frequency'] . "' AND day_or_hour='" . $_POST['day_or_hour'] . "' "; $check_results = $wpdb->get_results($check_query); if (count($check_results) == 0) { $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tfrom_email='" . $_POST['woocommerce_ac_email_from'] . "',\n\t\t\t\t\t\t\t\t\t\tsubject='" . $_POST['woocommerce_ac_email_subject'] . "',\n\t\t\t\t\t\t\t\t\t\tbody='" . $_POST['woocommerce_ac_email_body'] . "',\n\t\t\t\t\t\t\t\t\t\tis_active='" . $active . "', frequency='" . $_POST['email_frequency'] . "',\n\t\t\t\t\t\t\t\t\t\tday_or_hour='" . $_POST['day_or_hour'] . "',\n\t\t\t\t\t\t\t\t\t\tcoupon_code='" . $coupon_code_id . "',\n\t\t\t\t\t\t\t\t\t\ttemplate_name='" . $_POST['woocommerce_ac_template_name'] . "',\n\t\t\t\t\t\t\t\t\t\tfrom_name='" . $_POST['woocommerce_ac_from_name'] . "',\n\t\t\t\t\t\t\t\t\t\treply_email='" . $_POST['woocommerce_ac_email_reply'] . "'\n\t\t\t\t\t\t\t\t\t\tWHERE id='" . $_POST['id'] . "' "; //echo $query_update; $wpdb->query($query_update); } else { $query_update_new = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tis_active='0'\n\t\t\t\t\t\t\t\t\t\tWHERE frequency='" . $_POST['email_frequency'] . "' AND day_or_hour='" . $_POST['day_or_hour'] . "' "; //echo $query_update; $wpdb->query($query_update_new); $query_update_latest = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tfrom_email='" . $_POST['woocommerce_ac_email_from'] . "',\n\t\t\t\t\t\t\t\t\t\tsubject='" . $_POST['woocommerce_ac_email_subject'] . "',\n\t\t\t\t\t\t\t\t\t\tbody='" . $_POST['woocommerce_ac_email_body'] . "',\n\t\t\t\t\t\t\t\t\t\tis_active='" . $active . "', frequency='" . $_POST['email_frequency'] . "',\n\t\t\t\t\t\t\t\t\t\tday_or_hour='" . $_POST['day_or_hour'] . "',\n\t\t\t\t\t\t\t\t\t\tcoupon_code='" . $coupon_code_id . "',\n\t\t\t\t\t\t\t\t\t\ttemplate_name='" . $_POST['woocommerce_ac_template_name'] . "',\n\t\t\t\t\t\t\t\t\t\tfrom_name='" . $_POST['woocommerce_ac_from_name'] . "',\n\t\t\t\t\t\t\t\t\t\treply_email='" . $_POST['woocommerce_ac_email_reply'] . "'\n\t\t\t\t\t\t\t\t\t\tWHERE id='" . $_POST['id'] . "' "; //echo $query_update; $wpdb->query($query_update_latest); } } else { $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates`\n\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\tfrom_email='" . $_POST[woocommerce_ac_email_from] . "',\n\t\t\t\t\t\t\t\t\tsubject='" . $_POST[woocommerce_ac_email_subject] . "',\n\t\t\t\t\t\t\t\t\tbody='" . $_POST[woocommerce_ac_email_body] . "',\n\t\t\t\t\t\t\t\t\tis_active='" . $active . "', frequency='" . $_POST[email_frequency] . "',\n\t\t\t\t\t\t\t\t\tday_or_hour='" . $_POST[day_or_hour] . "',\n\t\t\t\t\t\t\t\t\tcoupon_code='" . $coupon_code_id . "',\n\t\t\t\t\t\t\t\t\ttemplate_name='" . $_POST[woocommerce_ac_template_name] . "',\n\t\t\t\t\t\t\t\t\tfrom_name='" . $_POST[woocommerce_ac_from_name] . "',\n\t\t\t\t\t\t\t\t\treply_email='" . $_POST[woocommerce_ac_email_reply] . "'\n\t\t\t\t\t\t\t\t\tWHERE id='" . $_POST[id] . "' "; //echo $query_update; $wpdb->query($query_update); } } if ($action == 'emailtemplates' && $mode == 'removetemplate') { $id_remove = $_GET['id']; $query_remove = "DELETE FROM `" . $wpdb->prefix . "ac_email_templates` WHERE id='" . $id_remove . "' "; //echo $query_remove; $wpdb->query($query_remove); } if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'save') { ?> <div id="message" class="updated fade"><p><strong><?php _e('The Email Template has been successfully added.', 'woocommerce-ac'); ?> </strong></p></div> <?php } if (isset($_POST['ac_settings_frm']) && $_POST['ac_settings_frm'] == 'update') { ?> <div id="message" class="updated fade"><p><strong><?php _e('The Email Template has been successfully updated.', 'woocommerce-ac'); ?> </strong></p></div> <?php } ?> <div class="tablenav"> <p style="float:left;"> <input type="button" value="+ Add New Template" id="add_new_template" onclick="location.href='admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=addnewtemplate';" style="font-weight: bold; color: green; font-size: 18px; cursor: pointer;"> <!--<a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=addnewtemplate">Add New Template</a>--> </p> <?php include_once "pagination.class.php"; /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */ $wpdb->get_results("SELECT wpet . * \n\t\t\t\t\t\t\t\t\t\tFROM `" . $wpdb->prefix . "ac_email_templates` AS wpet \n\t\t\t\t\t\t\t\t\t\t"); $count = $wpdb->num_rows; if ($count > 0) { $p = new pagination(); $p->items($count); $p->limit(10); // Limit entries per page $p->target("admin.php?page=woocommerce_ac_page&action=emailtemplates"); if (isset($p->paging)) { if (isset($_GET[$p->paging])) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page } $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page $p->showCounter(true); if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { $limit = ""; } ?> <div class='tablenav-pages'> <?php if ($count > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php $order = ""; if (isset($_GET['order'])) { $order = $_GET['order']; } if ($order == "") { $order = "desc"; $order_next = "asc"; } elseif ($order == "asc") { $order_next = "desc"; } elseif ($order == "desc") { $order_next = "asc"; } $order_by_2 = ""; $order_by = ""; if (isset($_GET['orderby'])) { $order_by = $_GET['orderby']; } if ($order_by == "" || $order_by == "frequencyday_or_hour") { $order_by = "day_or_hour"; $order_by_2 = ",frequency {$order_next}"; } $query = "SELECT wpet . * \n\t\t\t\t\t\t FROM `" . $wpdb->prefix . "ac_email_templates` AS wpet \n\t\t\t\t\t\t ORDER BY {$order_by} {$order}\n\t\t\t\t\t\t {$order_by_2} \n\t\t\t\t\t\t {$limit}"; $results = $wpdb->get_results($query); /* From here you can do whatever you want with the data from the $result link. */ ?> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='email_templates'> <tr> <th> <?php _e('Sr', 'woocommerce-ac'); ?> </th> <th scope="col" id="temp_name" class="manage-column column-temp_name sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&orderby=template_name&order=<?php echo $order_next; ?> "> <span> <?php _e('Template Name', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th scope="col" id="sent" class="manage-column column-sent sorted <?php echo $order_next; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&orderby=frequencyday_or_hour&order=<?php echo $order_next; ?> "> <span> <?php _e('Sent', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th> <?php _e('Active ?', 'woocommerce-ac'); ?> </th> <th> <?php _e('Emails Sent', 'woocommerce-ac'); ?> </th> <th> <?php _e('Actions', 'woocommerce-ac'); ?> </th> </tr> <?php if (isset($_GET['pageno'])) { $add_var = ($_GET['pageno'] - 1) * $limit; } else { $add_var = ""; } $i = 1 + $add_var; foreach ($results as $key => $value) { $id = $value->id; $query_no_emails = "SELECT * FROM " . $wpdb->prefix . "ac_sent_history\n\t\t\t\t\t\t\t\t\t \t \t\t\tWHERE template_id='" . $id . "' "; $number_emails = $wpdb->get_results($query_no_emails); $from = $value->from_email; $subject = $value->subject; $body = $value->body; $is_active = $value->is_active; if ($is_active == '1') { $active = "Yes"; } else { $active = "No"; } $frequency = $value->frequency; $day_or_hour = $value->day_or_hour; ?> <tr id="row_<?php echo $id; ?> "> <td><?php echo $i; ?> </td> <td><?php echo $value->template_name; ?> </td> <td><?php echo $frequency . " " . $day_or_hour . " After Abandonment"; ?> </td> <td><?php echo $active; ?> </td> <td><?php echo count($number_emails); ?> </td> <td> <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=copytemplate&id=<?php echo $id; ?> "> <img src="<?php echo plugins_url(); ?> /woocommerce-abandon-cart-pro/images/copy.png" alt="Copy as a new template" title="Copy as a new template" width="20" height="20"> </a> <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=edittemplate&id=<?php echo $id; ?> "> <img src="<?php echo plugins_url(); ?> /woocommerce-abandon-cart-pro/images/edit.png" alt="Edit Template" title="Edit Template" width="20" height="20"> </a> <a href="#" onclick="delete_email_template( <?php echo $id; ?> )" > <img src="<?php echo plugins_url(); ?> /woocommerce-abandon-cart-pro/images/delete.png" alt="Delete Template" title="Delete Template" width="20" height="20"> </a> </td> </tr> <?php $i++; } echo "</table>"; //echo "</p>"; } elseif ($action == 'stats' || $action == '') { ?> <p> <script language='javascript'> jQuery(document).ready(function() { jQuery('#duration_select').change(function() { var group_name = jQuery('#duration_select').val(); var today = new Date(); var start_date = ""; var end_date = ""; if ( group_name == "yesterday") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1); } else if ( group_name == "today") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_seven") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_fifteen") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 15); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_thirty") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 30); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_ninety") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 90); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_year_days") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 365); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; var start_date_value = start_date.getDate() + " " + monthNames[start_date.getMonth()] + " " + start_date.getFullYear(); var end_date_value = end_date.getDate() + " " + monthNames[end_date.getMonth()] + " " + end_date.getFullYear(); jQuery('#start_date').val(start_date_value); jQuery('#end_date').val(end_date_value); //location.href= 'admin.php?page=woocommerce_ac_page&action=stats&durationselect='+group_name; }); }); </script> <?php if (isset($_POST['duration_select'])) { $duration_range = $_POST['duration_select']; } else { $duration_range = ""; } if ($duration_range == "") { if (isset($_GET['duration_select'])) { $duration_range = $_GET['duration_select']; } } if ($duration_range == "") { $duration_range = "last_seven"; } else { $duration_range = ""; } //global $this->duration_range_select,$this->start_end_dates; ?> <p> The Report below shows how many Abandoned Carts we were able to recover for you by sending automatic emails to encourage shoppers.</p> <div id="recovered_stats_date" class="postbox" style="display:block"> <div class="inside"> <form method="post" action="admin.php?page=woocommerce_ac_page&action=stats" id="ac_stats"> <select id="duration_select" name="duration_select" > <?php foreach ($this->duration_range_select as $key => $value) { $sel = ""; if ($key == $duration_range) { $sel = " selected "; } echo "<option value='{$key}' {$sel}> {$value} </option>"; } $date_sett = $this->start_end_dates[$duration_range]; ?> </select> <script type="text/javascript"> jQuery(document).ready(function() { var formats = ["d.m.y", "d M yy","MM d, yy"]; jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] ); jQuery("#start_date").datepicker({dateFormat: formats[1]}); }); jQuery(document).ready(function() { var formats = ["d.m.y", "d M yy","MM d, yy"]; jQuery("#end_date").datepicker({dateFormat: formats[1]}); }); </script> <?php if (isset($_POST['start_date'])) { $start_date_range = $_POST['start_date']; } else { $start_date_range = ""; } if ($start_date_range == "") { $start_date_range = $date_sett['start_date']; } if (isset($_POST['end_date'])) { $end_date_range = $_POST['end_date']; } else { $end_date_range = ""; } if ($end_date_range == "") { $end_date_range = $date_sett['end_date']; } ?> <label class="start_label" for="start_day"> <?php _e('Start Date:', 'woocommerce-ac'); ?> </label> <input type="text" id="start_date" name="start_date" readonly="readonly" value="<?php echo $start_date_range; ?> "/> <label class="end_label" for="end_day"> <?php _e('End Date:', 'woocommerce-ac'); ?> </label> <input type="text" id="end_date" name="end_date" readonly="readonly" value="<?php echo $end_date_range; ?> "/> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Go', 'woocommerce-ac'); ?> " /> </form> </div> </div> <?php global $wpdb; $start_date = strtotime($start_date_range . " 00:01:01"); $end_date = strtotime($end_date_range . " 23:59:59"); include_once "pagination.class.php"; /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */ $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history\n\t\t\t\t\t\t\t\t WHERE abandoned_cart_time >= " . $start_date . "\n\t\t\t\t\t\t\t\t AND abandoned_cart_time <= " . $end_date . "\n\t\t\t\t\t\t\t\t AND recovered_cart > '0' \n\t\t\t\t\t\t\t\t "); $count = $wpdb->num_rows; if ($count > 0) { $p = new pagination(); $p->items($count); $p->limit(10); // Limit entries per page $p->target("admin.php?page=woocommerce_ac_page&action=stats&duration_select={$duration_range}"); if (isset($p->paging)) { if (isset($_GET[$p->paging])) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page } $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page $p->showCounter(true); if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { $limit = ""; } ?> <div class="tablenav"> <div class='tablenav-pages'> <?php if ($count > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php $order = ""; if (isset($_GET['order'])) { $order = $_GET['order']; } if ($order == "") { $order = "desc"; $order_next = "asc"; } elseif ($order == "asc") { $order_next = "desc"; } elseif ($order == "desc") { $order_next = "asc"; } $order_by = ""; if (isset($_GET['orderby'])) { $order_by = $_GET['orderby']; } if ($order_by == "") { $order_by = "recovered_cart"; } $query_ac = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history \n\t\t\t\t\t\t\t\t\t WHERE abandoned_cart_time >= " . $start_date . "\n\t\t\t\t\t\t\t\t\t AND abandoned_cart_time <= " . $end_date . "\n\t\t\t\t\t\t\t\t\t AND recovered_cart > 0 \n\t\t\t\t\t\t\t\t\t ORDER BY {$order_by} {$order} {$limit}"; /* echo "<br>".date("d M Y H:i:s", $start_date); echo "<br>".date("d M Y H:i:s", $end_date); echo $query_ac; */ $ac_results = $wpdb->get_results($query_ac); $query_ac_carts = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history\n\t\t\t\t\t\t\t\t\t\t WHERE abandoned_cart_time >= " . $start_date . "\n\t\t\t\t\t\t\t\t\t \t AND abandoned_cart_time <= " . $end_date; $ac_carts_results = $wpdb->get_results($query_ac_carts); $recovered_item = $recovered_total = $count_carts = $total_value = $order_total = 0; foreach ($ac_carts_results as $key => $value) { $count_carts += 1; $cart_detail = json_decode($value->abandoned_cart_info); $product_details = $cart_detail->cart; $line_total = 0; foreach ($product_details as $k => $v) { $line_total = $line_total + $v->line_total; } $total_value += $line_total; } $table_data = ""; foreach ($ac_results as $key => $value) { if ($value->recovered_cart != 0) { $recovered_id = $value->recovered_cart; $rec_order = get_post_meta($recovered_id); /* echo "<pre>"; //print_r($rec_order); print_r(unserialize($rec_order['_order_items'][0])); echo "</pre>"; */ $woo_order = new WC_Order($recovered_id); $recovered_date = strtotime($woo_order->order_date); $recovered_date_new = date('d M, Y h:i A', $recovered_date); $recovered_item += 1; /* $order_items = unserialize($rec_order['_order_items'][0]); foreach ( $order_items as $order_key => $order_value) { $order_total += $order_items[$order_key]['line_total']; } */ $recovered_total += $rec_order['_order_total'][0]; $abandoned_date = date('d M, Y h:i A', $value->abandoned_cart_time); $abandoned_order_id = $value->id; $is_email_sent_for_this_order = $this->check_email_sent_for_order($abandoned_order_id) ? 'Yes' : 'No'; $table_data .= "<tr>\n\t\t\t\t\t\t\t\t\t\t\t <td>Name: " . $rec_order['_billing_first_name'][0] . " " . $rec_order['_billing_last_name'][0] . "</br><a href='mailto:'" . $rec_order['_billing_email'][0] . "'>" . $rec_order['_billing_email'][0] . "</td>\n\t\t\t\t\t\t\t\t\t\t\t <td>" . $abandoned_date . "</td>\n\t\t\t\t\t\t\t\t\t\t\t <td>{$is_email_sent_for_this_order}</td>\n\t\t\t\t\t\t\t\t\t\t\t <td>" . $recovered_date_new . "</td>\n\t\t\t\t\t\t\t\t\t\t\t <td>" . get_woocommerce_currency_symbol() . " " . $rec_order['_order_total'][0] . "</td>\n\t\t\t\t\t\t\t\t\t\t\t <td> <a href=\"post.php?post=" . $recovered_id . "&action=edit\">View Details</td>"; } } ?> <div id="recovered_stats" class="postbox" style="display:block"> <div class="inside" > <p style="font-size: 15px"> During the selected range <strong><?php echo $count_carts; ?> </strong> carts totaling <strong><?php echo get_woocommerce_currency_symbol() . " " . $total_value; ?> </strong> were abandoned. We were able to recover <strong><?php echo $recovered_item; ?> </strong> of them, which led to an extra <strong><?php echo get_woocommerce_currency_symbol() . " " . $recovered_total; ?> </strong> in sales</p> </div> </div> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data'> <tr> <th> <?php _e('Customer', 'woocommerce-ac'); ?> </th> <th scope="col" id="created_date" class="manage-column column-created_date sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=stats&orderby=abandoned_cart_time&order=<?php echo $order_next; ?> &durationselect=<?php echo $duration_range; ?> "> <span> <?php _e('Created On', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th> <?php _e('Email Sent', 'woocommerce-ac'); ?> </th> <th scope="col" id="rec_order" class="manage-column column-rec_order sorted <?php echo $order; ?> " style=""> <a href="admin.php?page=woocommerce_ac_page&action=stats&orderby=recovered_cart&order=<?php echo $order_next; ?> &durationselect=<?php echo $duration_range; ?> "> <span> <?php _e('Recovered Date', 'woocommerce-ac'); ?> </span> <span class="sorting-indicator"></span> </a> </th> <th> <?php _e('Order Total', 'woocommerce-ac'); ?> </th> <th></th> </tr> <?php echo $table_data; print '</table>'; } elseif ($action == 'emailstats') { ?> <p> <script language='javascript'> jQuery(document).ready(function() { jQuery('#duration_select_email').change(function() { var group_name = jQuery('#duration_select_email').val(); var today = new Date(); var start_date = ""; var end_date = ""; if ( group_name == "yesterday") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1); } else if ( group_name == "today") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_seven") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_fifteen") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 15); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_thirty") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 30); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_ninety") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 90); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } else if ( group_name == "last_year_days") { start_date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 365); end_date = new Date(today.getFullYear(), today.getMonth(), today.getDate()); } var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; var start_date_value = start_date.getDate() + " " + monthNames[start_date.getMonth()] + " " + start_date.getFullYear(); var end_date_value = end_date.getDate() + " " + monthNames[end_date.getMonth()] + " " + end_date.getFullYear(); jQuery('#start_date_email').val(start_date_value); jQuery('#end_date_email').val(end_date_value); //location.href= 'admin.php?page=woocommerce_ac_page&action=emailstats&durationselect='+group_name; }); }); </script> <?php if (isset($_POST['duration_select_email'])) { $duration_range = $_POST['duration_select_email']; } else { $duration_range = ""; } if ($duration_range == "") { if (isset($_GET['duration_select_email'])) { $duration_range = $_GET['duration_select_email']; } } if ($duration_range == "") { $duration_range = "last_seven"; } //global $this->duration_range_select,$this->start_end_dates; ?> <p> <?php _e('The Report below shows emails sent, emails opened and other related stats for the selected date range', 'woocommerce-ac'); ?> </p> <div id="email_stats" class="postbox" style="display:block"> <div class="inside"> <form method="post" action="admin.php?page=woocommerce_ac_page&action=emailstats" id="ac_email_stats"> <select id="duration_select_email" name="duration_select_email" > <?php foreach ($this->duration_range_select as $key => $value) { $sel = ""; if ($key == $duration_range) { $sel = " selected "; } echo "<option value='{$key}' {$sel}> {$value} </option>"; } $date_sett = $this->start_end_dates[$duration_range]; ?> </select> <script type="text/javascript"> jQuery(document).ready(function() { var formats = ["d.m.y", "d M yy","MM d, yy"]; jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] ); jQuery("#start_date_email").datepicker({ dateFormat: formats[1]}); }); jQuery(document).ready(function() { var formats = ["d.m.y", "d M yy","MM d, yy"]; jQuery("#end_date_email").datepicker({ dateFormat: formats[1]}); }); </script> <?php if (isset($_POST['start_date_email'])) { $start_date_range = $_POST['start_date_email']; } else { $start_date_range = ""; } if ($start_date_range == "") { $start_date_range = $date_sett['start_date']; } if (isset($_POST['end_date_email'])) { $end_date_range = $_POST['end_date_email']; } else { $end_date_range = ""; } if ($end_date_range == "") { $end_date_range = $date_sett['end_date']; } ?> <label class="start_label" for="start_day"> <?php _e('Start Date:', 'woocommerce-ac'); ?> </label> <input type="text" id="start_date_email" name="start_date_email" readonly="readonly" value="<?php echo $start_date_range; ?> "/> <label class="end_label" for="end_day"> <?php _e('End Date:', 'woocommerce-ac'); ?> </label> <input type="text" id="end_date_email" name="end_date_email" readonly="readonly" value="<?php echo $end_date_range; ?> "/> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Go', 'woocommerce-ac'); ?> " /> </form> </div> </div> <?php global $wpdb, $woocommerce; $start_date = strtotime($start_date_range . " 00:01:01"); $start_date_db = date('Y-m-d H:i:s', $start_date); $end_date = strtotime($end_date_range . " 23:59:59"); $end_date_db = date('Y-m-d H:i:s', $end_date); include_once "pagination.class.php"; /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */ $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ac_sent_history\n\t\t\t\t\t\t\t\t\t \t WHERE sent_time >= '" . $start_date_db . "'\n\t\t\t\t\t\t\t\t\t \t AND sent_time <= '" . $end_date_db . "'\n\t\t\t\t\t\t\t\t"); $count = $wpdb->num_rows; if ($count > 0) { $p = new pagination(); $p->items($count); $p->limit(10); // Limit entries per page $p->target("admin.php?page=woocommerce_ac_page&action=emailstats&duration_select_email={$duration_range}"); if (isset($p->paging)) { if (isset($_GET[$p->paging])) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page } $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page $p->showCounter(true); if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { $limit = ""; } ?> <div class="tablenav"> <div class='tablenav-pages'> <?php if ($count > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php /* Now we use the LIMIT clause to grab a range of rows */ $query_ac_sent = "SELECT * FROM " . $wpdb->prefix . "ac_sent_history\n\t\t\t\t\t\t\t\t\t \t WHERE sent_time >= '" . $start_date_db . "'\n\t\t\t\t\t\t\t\t\t \t AND sent_time <= '" . $end_date_db . "'\n\t\t\t\t\t\t\t\t\t\t ORDER BY `id` DESC\n\t\t\t\t\t\t\t\t\t\t {$limit}"; //echo $query; $ac_results_sent = $wpdb->get_results($query_ac_sent); $query_ac_clicked = "SELECT DISTINCT email_sent_id FROM " . $wpdb->prefix . "ac_link_clicked_email\n\t\t\t\t\t\t\t\t\t\t\t WHERE time_clicked >= '" . $start_date_db . "'\n\t\t\t\t\t\t\t\t\t\t\t AND time_clicked <= '" . $end_date_db . "'\n\t\t\t\t\t\t\t\t\t\t\t ORDER BY id DESC "; $ac_results_clicked = $wpdb->get_results($query_ac_clicked, ARRAY_A); $query_ac_opened = "SELECT DISTINCT email_sent_id FROM " . $wpdb->prefix . "ac_opened_emails\n\t\t\t\t\t\t\t\t\t\t \tWHERE time_opened >= '" . $start_date_db . "'\n\t\t\t\t\t\t\t\t\t\t \tAND time_opened <= '" . $end_date_db . "'\n\t\t\t\t\t\t\t\t\t\t\tORDER BY id DESC "; $ac_results_opened = $wpdb->get_results($query_ac_opened, ARRAY_A); ?> <div id="email_sent_stats" class="postbox" style="display:block"> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data_sent' style="font-size : 15px"> <tr> <td> <p style="font-size : 15px"> <?php _e('Emails Sent :', 'woocommerce-ac'); ?> <?php echo $count; ?> </p> </td> <td> <p style="font-size : 15px"> <?php _e('Emails Opened :', 'woocommerce-ac'); ?> <?php echo count($ac_results_opened); ?> </p> </td> <td> <p style="font-size : 15px"> <?php _e('Links Clicked :', 'woocommerce-ac'); ?> <?php echo count($ac_results_clicked); ?> </p> </td> </tr> </table> </div> <div id="email_sent_stats_table" class="postbox" style="display:block"> <table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data_sent'> <tr> <th> <?php _e('Sent Time', 'woocommerce-ac'); ?> </th> <th> <?php _e('Email Address', 'woocommerce-ac'); ?> </th> <th> <?php _e('Date/Time Opened', 'woocommerce-ac'); ?> </th> <th> <?php _e('Link Clicked', 'woocommerce-ac'); ?> </th> <th> <?php _e('Email Template', 'woocommerce-ac'); ?> </th> <th> <?php _e('View Order', 'woocommerce-ac'); ?> </th> </tr> <?php foreach ($ac_results_sent as $key => $value) { $sent_tmstmp = strtotime($value->sent_time); $sent_date = date('d M Y h:i A', $sent_tmstmp); $query_template_name = "SELECT template_name FROM " . $wpdb->prefix . "ac_email_templates\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id='" . $value->template_id . "' "; $ac_results_template_name = $wpdb->get_results($query_template_name); $link_clicked = ""; if (isset($ac_results_template_name[0]->template_name)) { $ac_email_template_name = $ac_results_template_name[0]->template_name; } else { $ac_email_template_name = ""; } foreach ($ac_results_clicked as $clicked_key => $clicked_value) { if ($clicked_value['email_sent_id'] == $value->id) { $query_links = "SELECT * FROM " . $wpdb->prefix . "ac_link_clicked_email\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE email_sent_id='" . $value->id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `id` DESC\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1"; $results_links = $wpdb->get_results($query_links); /* echo "<pre>"; print_r($results_links); echo "</pre>"; */ $checkout_page_id = get_option('woocommerce_checkout_page_id'); $checkout_page = get_post($checkout_page_id); $checkout_page_link = $checkout_page->guid; //echo "checkout ".$checkout_page_link."</br>"; $cart_page_id = get_option('woocommerce_cart_page_id'); $cart_page = get_post($cart_page_id); $cart_page_link = $cart_page->guid; if ($results_links[0]->link_clicked == $checkout_page_link) { $link_clicked = "Checkout Page"; } elseif ($results_links[0]->link_clicked == $cart_page_link) { $link_clicked = "Cart Page"; } } } $email_opened = ""; foreach ($ac_results_opened as $opened_key => $opened_value) { if ($opened_value['email_sent_id'] == $value->id) { $query_opens = "SELECT * FROM " . $wpdb->prefix . "ac_opened_emails\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE email_sent_id='" . $value->id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `id` DESC\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1"; $results_opens = $wpdb->get_results($query_opens); /* echo "<pre>"; print_r($results_opens); echo "</pre>"; */ $opened_tmstmp = strtotime($results_opens[0]->time_opened); $email_opened = date('d M Y h:i A', $opened_tmstmp); } } $view_order_query = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history\n\t\t\t\t\t\t\t\t\t\t\t\t WHERE id='" . $value->abandoned_order_id . "'"; $view_order_results = $wpdb->get_results($view_order_query); if ($view_order_results[0]->recovered_cart == 0) { $view_link = "admin.php?page=woocommerce_ac_page&action=orderdetails&id=" . $value->abandoned_order_id; $view_name = "Abandoned Order"; } else { $view_link = "post.php?post=" . $view_order_results[0]->recovered_cart . "&action=edit"; $view_name = "Recovered Order"; } ?> <tr> <td> <p> <?php echo $sent_date; ?> </p> </td> <td> <p> <?php echo $value->sent_email_id; ?> </p> </td> <td> <p> <?php echo $email_opened; ?> </p> </td> <td> <p> <?php echo $link_clicked; ?> </p> </td> <td> <p> <?php echo $ac_email_template_name; ?> </p> </td> <td> <p> <a href="<?php echo $view_link; ?> "> <?php echo $view_name; ?> </a> </p> </td> </tr> <?php } print '</table> </div>'; } elseif ($action == 'orderdetails') { $ac_order_id = $_GET['id']; ?> <p> </p> <div id="ac_order_details" class="postbox" style="display:block"> <h3> <p> <?php _e("Abandoned Order #{$ac_order_id} Details", "woocommerce-ac"); ?> </p> </h3> <div class="inside"> <table cellpadding="0" cellspacing="0" class="wp-list-table widefat fixed posts"> <tr> <th> <?php _e('Item', 'woocommerce-ac'); ?> </th> <th> <?php _e('Id', 'woocommerce-ac'); ?> </th> <th> <?php _e('Name', 'woocommerce-ac'); ?> </th> <th> <?php _e('Quantity', 'woocommerce-ac'); ?> </th> <th> <?php _e('Line Subtotal', 'woocommerce-ac'); ?> </th> <th> <?php _e('Line Total', 'woocommerce-ac'); ?> </th> </tr> <?php $query = "SELECT * \n\t\t\t\t\t \t\t\t\tFROM `" . $wpdb->prefix . "ac_abandoned_cart_history` \n\t\t\t\t\t \t\t\t\tWHERE id = '" . $_GET['id'] . "' "; //echo $query; $results = $wpdb->get_results($query); /* echo "<pre>"; print_r($results); echo "</pre>"; */ //exit; if ($results[0]->user_type == "GUEST") { $query_guest = "SELECT * FROM `" . $wpdb->prefix . "ac_guest_abandoned_cart_history`\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $results[0]->user_id . "'"; $results_guest = $wpdb->get_results($query_guest); $user_email = $results_guest[0]->email_id; $user_first_name = $results_guest[0]->billing_first_name; $user_last_name = $results_guest[0]->billing_last_name; $user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_postcode = $user_billing_state = $user_billing_country = $user_billing_phone = ""; $user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_postcode = $user_shipping_state = $user_shipping_country = ""; } else { $user_id = $results[0]->user_id; if (isset($results[0]->user_login)) { $user_login = $results[0]->user_login; } $user_email = get_user_meta($results[0]->user_id, 'billing_email', true); $user_first_name_temp = get_user_meta($results[0]->user_id, 'first_name'); if (isset($user_first_name_temp[0])) { $user_first_name = $user_first_name_temp[0]; } else { $user_first_name = ""; } $user_last_name_temp = get_user_meta($results[0]->user_id, 'last_name'); if (isset($user_last_name_temp[0])) { $user_last_name = $user_last_name_temp[0]; } else { $user_last_name = ""; } $user_billing_first_name = get_user_meta($results[0]->user_id, 'billing_first_name'); $user_billing_last_name = get_user_meta($results[0]->user_id, 'billing_last_name'); $user_billing_company_temp = get_user_meta($results[0]->user_id, 'billing_company'); if (isset($user_billing_company_temp[0])) { $user_billing_company = $user_billing_company_temp[0]; } else { $user_billing_company = ""; } $user_billing_address_1_temp = get_user_meta($results[0]->user_id, 'billing_address_1'); if (isset($user_billing_address_1_temp[0])) { $user_billing_address_1 = $user_billing_address_1_temp[0]; } else { $user_billing_address_1 = ""; } $user_billing_address_2_temp = get_user_meta($results[0]->user_id, 'billing_address_2'); if (isset($user_billing_address_2_temp[0])) { $user_billing_address_2 = $user_billing_address_2_temp[0]; } else { $user_billing_address_2 = ""; } $user_billing_city_temp = get_user_meta($results[0]->user_id, 'billing_city'); if (isset($user_billing_city_temp[0])) { $user_billing_city = $user_billing_city_temp[0]; } else { $user_billing_city = ""; } $user_billing_postcode_temp = get_user_meta($results[0]->user_id, 'billing_postcode'); if (isset($user_billing_postcode_temp[0])) { $user_billing_postcode = $user_billing_postcode_temp[0]; } else { $user_billing_postcode = ""; } $user_billing_state_temp = get_user_meta($results[0]->user_id, 'billing_state'); if (isset($user_billing_state_temp[0])) { $user_billing_state = $user_billing_state_temp[0]; } else { $user_billing_state = ""; } $user_billing_country_temp = get_user_meta($results[0]->user_id, 'billing_country'); if (isset($user_billing_country_temp[0])) { $user_billing_country = $user_billing_country_temp[0]; } else { $user_billing_country = ""; } $user_billing_phone_temp = get_user_meta($results[0]->user_id, 'billing_phone'); if (isset($user_billing_phone_temp[0])) { $user_billing_phone = $user_billing_phone_temp[0]; } else { $user_billing_phone = ""; } $user_shipping_first_name = get_user_meta($results[0]->user_id, 'shipping_first_name'); $user_shipping_last_name = get_user_meta($results[0]->user_id, 'shipping_last_name'); $user_shipping_company_temp = get_user_meta($results[0]->user_id, 'shipping_company'); if (isset($user_shipping_company_temp[0])) { $user_shipping_company = $user_shipping_company_temp[0]; } else { $user_shipping_company = ""; } $user_shipping_address_1_temp = get_user_meta($results[0]->user_id, 'shipping_address_1'); if (isset($user_shipping_address_1_temp[0])) { $user_shipping_address_1 = $user_shipping_address_1_temp[0]; } else { $user_shipping_address_1 = ""; } $user_shipping_address_2_temp = get_user_meta($results[0]->user_id, 'shipping_address_2'); if (isset($user_shipping_address_2_temp[0])) { $user_shipping_address_2 = $user_shipping_address_2_temp[0]; } else { $user_shipping_address_2 = ""; } $user_shipping_city_temp = get_user_meta($results[0]->user_id, 'shipping_city'); if (isset($user_shipping_city_temp[0])) { $user_shipping_city = $user_shipping_city_temp[0]; } else { $user_shipping_city = ""; } $user_shipping_postcode_temp = get_user_meta($results[0]->user_id, 'shipping_postcode'); if (isset($user_shipping_postcode_temp[0])) { $user_shipping_postcode = $user_shipping_postcode_temp[0]; } else { $user_shipping_postcode = ""; } $user_shipping_state_temp = get_user_meta($results[0]->user_id, 'shipping_state'); if (isset($user_shipping_state_temp[0])) { $user_shipping_state = $user_shipping_state_temp[0]; } else { $user_shipping_state = ""; } $user_shipping_country_temp = get_user_meta($results[0]->user_id, 'shipping_country'); if (isset($user_shipping_country_temp[0])) { $user_shipping_country = $user_shipping_country_temp[0]; } else { $user_shipping_country = ""; } } //echo $user_id."</br>"; $cart_info = json_decode($results[0]->abandoned_cart_info); $cart_details = $cart_info->cart; foreach ($cart_details as $k => $v) { $quantity_total = $v->quantity; $product_id = $v->product_id; //echo $product_id."</br>"; $prod_name = get_post($product_id); $product_name = $prod_name->post_title; // $prod_details = new WC_PRODUCT ( $product_id); $item_total = $v->line_total / $quantity_total; $product = get_product($product_id); $prod_image = $product->get_image(); ?> <tr> <td> <?php echo $prod_image; ?> </td> <td> <?php echo $product->id; ?> </td> <td> <?php echo $product_name; ?> </td> <td> <?php echo $quantity_total; ?> </td> <td> <?php echo get_woocommerce_currency_symbol() . " " . $item_total; ?> </td> <td> <?php echo get_woocommerce_currency_symbol() . " " . $v->line_total; ?> </td> </tr> <?php } ?> </table> </div> </div> <div id="ac_order_customer_details" class="postbox" style="display:block"> <h3> <p> <?php _e('Customer Details', 'woocommerce-ac'); ?> </p> </h3> <div class="inside" style="height: 300px;" > <div id="order_data" class="panel"> <div style="width:500px;float:left"> <h3> <p> <?php _e('Billing Details', 'woocommerce-ac'); ?> </p> </h3> <p> <strong> <?php _e('Name:', 'woocommerce-ac'); ?> </strong> <?php echo $user_first_name . " " . $user_last_name; ?> </p> <p> <strong> <?php _e('Address:', 'woocommerce-ac'); ?> </strong> <?php echo $user_billing_company . "</br>" . $user_billing_address_1 . "</br>" . $user_billing_address_2 . "</br>" . $user_billing_city . "</br>" . $user_billing_postcode . "</br>" . $user_billing_state . "</br>" . $user_billing_country . "</br>"; ?> </p> <p> <strong> <?php _e('Email:', 'woocommerce-ac'); ?> </strong> <a href='mailto:$user_email'><?php echo $user_email; ?> </a> </p> <p> <strong> <?php _e('Phone:', 'woocommerce-ac'); ?> </strong> <?php echo $user_billing_phone; ?> </p> </div> <div style="width:500px;float:right"> <h3> <p> <?php _e('Shipping Details', 'woocommerce-ac'); ?> </p> </h3> <!-- <p> <strong>Name:</strong> <?php echo $user_first_name[0] . " " . $user_last_name[0]; ?> </p> --> <p> <strong> <?php _e('Address:', 'woocommerce-ac'); ?> </strong> <?php if ($user_shipping_company == '' && $user_shipping_address_1 == '' && $user_shipping_address_2 == '' && $user_shipping_city == '' && $user_shipping_postcode == '' && $user_shipping_state == '' && $user_shipping_country == '') { echo "Shipping Address same as Billing Address"; } else { ?> <?php echo $user_shipping_company . "</br>" . $user_shipping_address_1 . "</br>" . $user_shipping_address_2 . "</br>" . $user_shipping_city . "</br>" . $user_shipping_postcode . "</br>" . $user_shipping_state . "</br>" . $user_shipping_country . "</br>"; ?> </p> <?php } ?> <!-- <p> <strong>Email:</strong> <a href='mailto:$user_email'><?php echo $user_email; ?> </a> </p> <p> <strong>Phone:</strong> <?php echo $user_shipping_phone[0]; ?> </p>--> </div> </div> </div> </div> <?php } if (isset($_GET['action'])) { $action = $_GET['action']; } if (isset($_GET['mode'])) { $mode = $_GET['mode']; } if ($action == 'emailtemplates' && ($mode == 'addnewtemplate' || $mode == 'edittemplate' || $mode == 'copytemplate')) { if ($mode == 'edittemplate') { $edit_id = $_GET['id']; $query = "SELECT wpet . * FROM `" . $wpdb->prefix . "ac_email_templates` AS wpet WHERE id='" . $edit_id . "'"; //echo $query; $results = $wpdb->get_results($query); } if ($mode == 'copytemplate') { $copy_id = $_GET['id']; $query_copy = "SELECT wpet . * FROM `" . $wpdb->prefix . "ac_email_templates` AS wpet WHERE id='" . $copy_id . "'"; //echo $query; $results_copy = $wpdb->get_results($query_copy); } $active_post = empty($_POST['is_active']) ? '0' : '1'; /*if ( (isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save') || (isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update') ) { ?> <div id="message" class="updated fade"><p><strong><?php _e( 'Your settings have been saved.', 'woocommerce-ac' ); ?></strong></p></div> <?php } */ ?> <div id="content"> <form method="post" action="admin.php?page=woocommerce_ac_page&action=emailtemplates" id="ac_settings"> <input type="hidden" name="mode" value="<?php echo $mode; ?> " /> <input type="hidden" name="id" value="<?php echo $_GET['id']; ?> " /> <?php $button_mode = "save"; $display_message = "Add Email Template"; if ($mode == 'edittemplate') { $button_mode = "update"; $display_message = "Edit Email Template"; } print '<input type="hidden" name="ac_settings_frm" value="' . $button_mode . '">'; ?> <div id="poststuff"> <div class="postbox"> <h3 class="hndle"><?php _e($display_message, 'woocommerce-ac'); ?> </h3> <div> <table class="form-table" id="addedit_template"> <tr> <th> <label for="woocommerce_ac_template_name"><b><?php _e('Template Name:', 'woocommerce-ac '); ?> </b></label> </th> <td> <?php $template_name = ""; if ($mode == 'edittemplate') { $template_name = $results[0]->template_name; } if ($mode == 'copytemplate') { $template_name = "Copy of " . $results_copy[0]->template_name; } print '<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="' . $template_name . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter a template name for reference', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> </tr> <tr> <th> <label for="woocommerce_ac_from_name"><b><?php _e('Send From This Name:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $from_name = "Admin"; if ($mode == 'edittemplate') { $from_name = $results[0]->from_name; } if ($mode == 'copytemplate') { $from_name = $results_copy[0]->from_name; } print '<input type="text" name="woocommerce_ac_from_name" id="woocommerce_ac_from_name" class="regular-text" value="' . $from_name . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the name that should appear in the email sent', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <?php //echo stripslashes(get_option( 'woocommerce_ac_email_body' )); ?> </textarea> </tr> <tr> <th> <label for="woocommerce_ac_email_from"><b><?php _e('Send From This Email Address:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $from_edit = get_option('admin_email'); if ($mode == 'edittemplate') { $from_edit = $results[0]->from_email; } if ($mode == 'copytemplate') { $from_edit = $results_copy[0]->from_email; } print '<input type="text" name="woocommerce_ac_email_from" id="woocommerce_ac_email_from" class="regular-text" value="' . $from_edit . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Which email address should be shown in the "From Email" field for this email?', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <?php //echo stripslashes(get_option( 'woocommerce_ac_email_body' )); ?> </textarea> </tr> <tr> <th> <label for="woocommerce_ac_email_reply"><b><?php _e('Send Reply Emails to:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $reply_edit = get_option('admin_email'); if ($mode == 'edittemplate') { $reply_edit = $results[0]->reply_email; } if ($mode == 'copytemplate') { $reply_edit = $results_copy[0]->reply_email; } print '<input type="text" name="woocommerce_ac_email_reply" id="woocommerce_ac_email_reply" class="regular-text" value="' . $reply_edit . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <?php //echo stripslashes(get_option( 'woocommerce_ac_email_body' )); ?> </textarea> </tr> <tr> <th> <label for="woocommerce_ac_email_subject"><b><?php _e('Subject:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $subject_edit = ""; if ($mode == 'edittemplate') { $subject_edit = $results[0]->subject; } if ($mode == 'copytemplate') { $subject_edit = $results_copy[0]->subject; } print '<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="' . $subject_edit . '">'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the subject that should appear in the email sent', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> <?php //echo stripslashes(get_option( 'woocommerce_ac_email_body' )); ?> </textarea> </tr> <tr> <th> <label for="woocommerce_ac_email_body"><b><?php _e('Email Body:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $initial_data = ""; //stripslashes(get_option( 'woocommerce_ac_email_body' )); if ($mode == 'edittemplate') { $initial_data = $results[0]->body; } if ($mode == 'copytemplate') { $initial_data = $results_copy[0]->body; } /* $settings = array( 'quicktags' => array('buttons' => 'em,strong,link',), 'text_area_name'=>'woocommerce_ac_email_body',//name you want for the textarea 'quicktags' => true, 'class' => 'tinymce', 'tinymce' => true ); //echo "<textarea id='editortest'> </textarea>"; $id = 'woocommerce_ac_email_body';//has to be lower case wp_editor(stripslashes($initial_data),$id,$settings); */ echo "<textarea id='woocommerce_ac_email_body' name='woocommerce_ac_email_body' rows='15'' cols='80'>" . $initial_data . "</textarea>"; ?> <!--<textarea name="woocommerce_ac_email_body" cols="45" rows="3" class="regular-text"><?php echo stripslashes(get_option('woocommerce_ac_email_body')); ?> </textarea><br />--> <span class="description"><?php echo __('Message to be sent in the reminder email.', 'woocommerce-ac'); ?> </span> </td> </tr> <tr> <th> <label for="is_active"><b><?php _e('Active:', 'woocommerce-ac'); ?> </b></label> </th> <td> <?php $is_active_edit = ""; if ($mode == 'edittemplate') { $active_edit = $results[0]->is_active; if ($active_edit == '1') { $is_active_edit = "checked"; } else { $is_active_edit = ""; } } if ($mode == 'copytemplate') { $active_edit = $results_copy[0]->is_active; if ($active_edit == '1') { $is_active_edit = "checked"; } else { $is_active_edit = ""; } } print '<input type="checkbox" name="is_active" id="is_active" ' . $is_active_edit . '> </input>'; ?> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Yes, This email should be sent to shoppers with abandoned carts', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /></p> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_frequency"><b><?php _e('Send this email:', 'woocommerce-ac'); ?> </b></label> </th> <td> <select name="email_frequency" id="email_frequency"> <?php $frequency_edit = ""; if ($mode == 'edittemplate') { $frequency_edit = $results[0]->frequency; } if ($mode == 'copytemplate') { $frequency_edit = $results_copy[0]->frequency; } for ($i = 1; $i < 60; $i++) { printf("<option %s value='%s'>%s</option>\n", selected($i, $frequency_edit, false), esc_attr($i), $i); } ?> </select> <select name="day_or_hour" id="day_or_hour"> <?php $days_or_hours_edit = ""; if ($mode == 'edittemplate') { $days_or_hours_edit = $results[0]->day_or_hour; } if ($mode == 'copytemplate') { $days_or_hours_edit = $results_copy[0]->day_or_hour; } $days_or_hours = array('Minutes' => 'Minute(s)', 'Days' => 'Day(s)', 'Hours' => 'Hour(s)'); foreach ($days_or_hours as $k => $v) { printf("<option %s value='%s'>%s</option>\n", selected($k, $days_or_hours_edit, false), esc_attr($k), $v); } ?> <!--<select name="day_or_hour" id="day_or_hour"> <option value="Days" <?php echo $day_serl; ?> > Days </option> <option value="Hours" <?php echo $hours_serl; ?> > Hours </option>--> </select> <span class="description"><?php echo __('after cart is abandoned.', 'woocommerce-ac'); ?> </span> </td> </tr> <?php $entered_coupon = ""; if ($mode == 'edittemplate') { $entered_coupon = $results[0]->coupon_code; } if ($mode == 'copytemplate') { $entered_coupon = $results_copy[0]->coupon_code; } ?> <input type="hidden" name="existing_coupon_id" value="<?php echo $entered_coupon; ?> " /> <tr> <th> <label for="woocommerce_ac_coupon_auto_complete"><b><?php _e('Enter a coupon code to add into email:', 'woocommerce-ac'); ?> </b></label> </th> <td> <!-- code started for woocommerce auto-complete coupons field --> <div id="coupon_options" class="panel woocommerce_options_panel"> <div class="options_group"> <p class="form-field" style="padding-left:0px;"> <select id="coupon_ids" name="coupon_ids[]" class="ajax_chosen_select_coupons" multiple="multiple" data-placeholder="<?php _e('Search for a coupon…', 'woocommerce'); ?> "> <?php if ($mode == 'edittemplate') { $coupon_code_id = $results[0]->coupon_code; } if ($mode == 'copytemplate') { $coupon_code_id = $results_copy[0]->coupon_code; } if ($coupon_code_id > 0) { $title = get_the_title($coupon_code_id); $sku = get_post_meta($coupon_code_id, '_sku', true); if (isset($sku) && $sku) { $sku = ' (SKU: ' . $sku . ')'; } echo '<option value="' . $product_id . '" selected="selected">' . $title . $sku . '</option>'; } ?> </select> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Search & select one coupon code that customers should use to get a discount.', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /> </p> </div></div> <!-- code ended for woocommerce auto-complete coupons field --> <!--<input type="text" id="enter_coupon" name="enter_coupon" class="regular-text" value="<?php echo $entered_coupon; ?> "/>--> </td> </tr> <tr> <th> <label for="woocommerce_ac_email_preview"><b><?php _e('Send a test email to:', 'woocommerce-ac'); ?> </b></label> </th> <td> <input type="text" id="send_test_email" name="send_test_email" class="regular-text" > <input type="button" value="Send a test email" id="preview_email" onclick="javascript:void(0);"> <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the email id to which the test email needs to be sent.', 'woocommerce'); ?> ' src="<?php echo plugins_url(); ?> /woocommerce/assets/images/help.png" /> <div id="preview_email_sent_msg" style="display:none;"></div> </p> </td> </tr> </table> </div> </div> </div> <p class="submit"> <?php $button_value = "Save Changes"; if ($mode == 'edittemplate') { $button_value = "Update Changes"; } ?> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e($button_value, 'woocommerce-ac'); ?> " /> </p> </form> </div> <?php } } }
function sc_render_manager_page() { require_once plugin_dir_path(__FILE__) . 'includes/Services/Soundcloud.php'; require_once plugin_dir_path(__FILE__) . 'includes/class/pagination.class.php'; $options = get_option('sc_options'); $client = new Services_Soundcloud($options['client_id'], $options['client_secret'], $options['callback_url']); // Error message if app settings are not filled in. if ($options['client_id'] == "Your client ID goes here" || $options['client_secret'] == "Your client secret goes here" || $options['callback_url'] == "Your callback url goes here") { echo '<div class="error fade"><p>Warning: One or more of the required fields have not been set. Please insure that your cliend ID, client secret, and callback url are defined <a href="' . admin_url('options-general.php?page=soundcloud/soundcloud.php') . '">HERE</a>.</br>Soundcloud functionality will not be available until these fields are set.</p></div></br>'; } // SoundCloud login/logout if (isset($_GET['code']) || get_option('soundcloud_access_token')) { echo '<a href="' . admin_url('admin.php?page=soundcloud-disconnect') . '" class="soundcloud-icon"><img src="' . plugins_url() . '/soundcloud/includes/images/btn-disconnect-l.png" alt="Disconnect"/></a>'; try { $client = new Services_Soundcloud($options['client_id'], $options['client_secret'], $options['callback_url']); if (isset($_GET['code'])) { $accessToken = $client->accessToken($_GET['code']); update_option('soundcloud_access_token', $accessToken['access_token']); update_option('soundcloud_refresh_token', $accessToken['refresh_token']); update_option('soundcloud_token_expiration', time() + $accessToken['expires_in']); } else { if (get_option('soundcloud_access_token')) { // refresh token code deprecated due to non-expiring tokens /*if (time() > get_option('soundcloud_token_expiration')) { $client->setAccessToken(get_option('soundcloud_access_token')); // refresh access token $accessToken = $client->accessTokenRefresh(get_option('soundcloud_refresh_token')); //$client->setAccessToken($accessToken['access_token']); update_option('soundcloud_access_token', $accessToken['access_token']); update_option('soundcloud_refresh_token', $accessToken['refresh_token']); update_option('soundcloud_token_expiration', time() + $accessToken['expires_in']); } else {*/ $client->setAccessToken(get_option('soundcloud_access_token')); //} } } } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } } else { echo '<a href="' . $client->getAuthorizeUrl(array('scope' => 'non-expiring')) . '" class="soundcloud-icon"><img src="' . plugins_url() . '/soundcloud/includes/images/btn-connect-sc-l.png" alt="Connect with Soundcloud"/></a>'; } // tab switching if (isset($_GET['tab'])) { sc_admin_tabs($_GET['tab']); $tab = $_GET['tab']; } else { sc_admin_tabs('user'); $tab = 'user'; } if (get_option('soundcloud_access_token')) { try { $me = json_decode($client->get('me'), true); } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } echo '<h3>Logged in as: ' . $me['username'] . '</h3>'; } else { echo '<h3>Not logged in.</h3>'; } switch ($tab) { case 'user': try { $me = json_decode($client->get('me'), true); ?> <form action="" method="post"> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="username">Username:</label></th> <td><input type="text" name="username" value="<?php echo $me['username']; ?> " size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="permalink">Permalink:</label></th> <td><input type="text" name="permalink" value="<?php echo $me['permalink']; ?> " size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="description">Description:</label></th> <td><input type="text" name="description" value="<?php echo $me['description']; ?> " size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="website">Website:</label></th> <td><input type="text" name="website" value="<?php echo $me['website']; ?> " size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="website_title">Website Name:</label></th> <td><input type="text" name="website_title" value="<?php echo $me['website_title']; ?> " size="30" class="regular-text code"></td> </tr> </table> <p class="submit"><input type="submit" value="Update Account" class="button-primary"></p> </form> <?php if (isset($_POST['username']) || isset($_POST['permalink']) || isset($_POST['description']) || isset($_POST['website']) || isset($_POST['website_title'])) { $response = json_decode($client->put('me', array('user[username]' => $_POST['username'], 'user[permalink]' => $_POST['permalink'], 'user[description]' => $_POST['description'], 'user[website]' => strlen($_POST['website']) ? $_POST['website'] : null, 'user[website_title]' => strlen($_POST['website_title']) ? $_POST['website_title'] : null))); } } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } break; case 'upload': ?> <form action="" enctype="multipart/form-data" method="post" id ="add_track"> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="track_title">Track title:</label></th> <td><input type="text" name="track_title" size="30" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="track_file">Please specify a track:</label></th> <td><input type="file" name="track_file" id="track_file" size="40" accept="audio/*" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="track_art">Please specify track artwork:</label></th> <td><input type="file" name="track_art" id="track_art" size="40" accept="image/*" class="regular-text code"></td> </tr> <tr valign="top"> <th scope="row"><label for="tag">Track tags:</label></th> <td><input type="text" name="tag" id="tag" size="30"><input type="button" id="add_tag" name="add_tag" class="button" value="Add Tag" /> <br><ul id="tags"></ul></td> </tr> <tr valign="top"> <th scope="row"><label for="sharing">Track privacy:</label></th> <td><select name="sharing"> <option value="public">Public</option> <option value="private">Private</option> </select></td> </tr> </table> <p class="submit"><input type="submit" value="Upload" class="button-primary"></p> </form> <?php try { $tmp_file = '/tmp/' . stripslashes($_FILES['track_file']['name']); $tmp_art_file = '/tmp/' . stripslashes($_FILES['track_art']['name']); if (move_uploaded_file($_FILES['track_file']['tmp_name'], $tmp_file) && move_uploaded_file($_FILES['track_art']['tmp_name'], $tmp_art_file)) { // upload audio file $track = json_decode($client->post('tracks', array('track[title]' => $_POST['track_title'], 'track[asset_data]' => '@' . $tmp_file, 'track[artwork_data]' => '@' . $tmp_art_file, 'track[tags]' => strlen($_POST['tags']) ? $_POST['tags'] : null, 'track[sharing]' => $_POST['sharing']))); unlink(realpath($tmp_file)); unlink(realpath($tmp_art_file)); } } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } break; case 'tracks': try { echo '</br>'; $page_size = 5; // Pagination code $p = new pagination(); $p->items($me['track_count']); $p->limit($page_size); // Limit entries per page $p->target("admin.php?page=soundcloud-manager&tab=tracks"); $p->currentPage($_GET[$p->paging]); // Gets and validates the current page $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } if ($p->page == 1) { // get first page of tracks $tracks = json_decode($client->get('users/' . $me['id'] . '/tracks', array('order' => 'created_at', 'limit' => $page_size))); } else { // get additional pages of tracks $tracks = json_decode($client->get('users/' . $me['id'] . '/tracks', array('order' => 'created_at', 'limit' => $page_size, 'offset' => $page_size * $page))); } ?> <div class="tablenav"> <div class='tablenav-pages'> <?php echo $p->show(); ?> </div> </div> <?php foreach ($tracks as $track) { $client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1)); $embed_info = json_decode($client->get('oembed', array('url' => $track->permalink_url))); // render the html for the player widget echo $embed_info->html . '</br></br>'; } } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { var_dump($e->getMessage()); exit; } break; } }
function show_easy_gallery($atts, $content = null) { $order = 'desc'; $pagesql = ''; $limit = ''; $count = 8; $page = true; $page_st = true; $theme = 'fancybox'; $view = 'album'; $album = ''; global $wpdb; //echo "select * from easy_photos order by $order limit $limit offset $offset"; if (isset($atts['order'])) { $order = $atts['order']; } if (isset($atts['theme'])) { $theme = trim($atts['theme']); if ($theme != 'fancybox' && $theme != 'swipebox') { $theme = 'fancybox'; } } if (isset($atts['view'])) { $view = trim($atts['view']); if ($view != 'album' && $view != 'image') { $view = 'album'; } } if (isset($atts['album'])) { $album = trim($atts['album']); } if (isset($atts['limit'])) { $count = trim($atts['limit']); if ($count < 1) { $count = 2; } } $order = strtolower($order); if ($order != 'asc' && $order != 'desc') { $order = 'desc'; } if (isset($atts['pagination'])) { $page_st = trim($atts['pagination']); if ($page_st != 'true' && $page_st != 'false') { $page_st = 'true'; } } if ($page_st == 'true') { $page = true; $sql = " SELECT DISTINCT(a.album_id) FROM easy_album a,easy_photos b WHERE a.album_id=b.album_id AND a.disabled=0 AND b.disabled=0"; if ($album != '') { $sql = $sql . " and a.album_id = {$album}"; } if ($view == 'image') { $sql = "select * from easy_photos where album_id not in(select album_id from easy_album b where b.disabled=1) and disabled=0"; if ($album != '') { $sql = $sql . " and album_id = {$album}"; } } $rows = $wpdb->get_results($sql); $items = count($rows); if ($items > 0) { $p = new pagination(); $p->items($items); $p->limit($count); // Limit entries per page if ($album != '') { $p->target(get_permalink() . '?album=' . $album); } else { $p->target(get_permalink()); } //$p->urlFriendly(); if (isset($p->paging)) { $p->currentPage($_GET[$p->paging]); } // Gets and validates the current page $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->nextLabel(''); //removing next text $p->prevLabel(''); //removing previous text $p->nextIcon('►'); //Changing the next icon $p->prevIcon('◄'); //Changing the previous icon $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { echo "No Images"; } } else { $page = false; } ?> <div class="easy-gallery-base"> <div class="easy-gallery-content"> <?php $sql = ""; $tmp_sql = " SELECT DISTINCT(a.album_id) FROM easy_album a,easy_photos b WHERE a.album_id=b.album_id AND a.disabled=0 AND b.disabled=0 "; if ($album != '') { $tmp_sql = $tmp_sql . " and a.album_id = {$album}"; } $tmp_sql = $tmp_sql . " order by album_id {$order} {$limit}"; $rows_tmp = $wpdb->get_results($tmp_sql); $data = array(); foreach ($rows_tmp as $obj_temp) { array_push($data, $obj_temp->album_id); } $album_list = implode(',', $data); if ($view == 'image') { $sql = "select * from easy_photos where album_id not in(select album_id from easy_album b where b.disabled=1) and disabled=0 "; if ($album != '') { $sql = $sql . " and album_id = {$album}"; } $sql = $sql . " order by id {$order} {$limit}"; } else { $sql = "select a.*,b.album_cover,b.name from easy_photos a,easy_album b where a.album_id = b.album_id and b.disabled=0 and a.disabled=0 and b.album_id in({$album_list}) order by b.album_id {$order}"; } $rows = $wpdb->get_results($sql); $aid = ""; $i = 1; $img_count = count($rows); if ($view == 'album') { foreach ($rows as $obj) { if ($obj->album_id != $aid && $aid != "") { echo '</div>'; $i = 1; } if ($i == 1) { ?> <div class="album_thumb has-album-name"> <?php } if ($i == 1) { ?> <a href="<?php echo $obj->image_path; ?> " class="<?php echo $theme; ?> " rel="<?php echo $obj->album_id; ?> " title="<?php echo $obj->description; ?> "> <img title="<?php echo $obj->name; ?> " src="<?php echo $obj->album_cover; ?> " /> </a> <div class="album-name"><?php if (strlen($obj->name) > 30) { echo substr($obj->name, 0, 30) . '..'; } else { echo $obj->name; } ?> </div> <?php } else { ?> <a href="<?php echo $obj->image_path; ?> " class="<?php echo $theme; ?> " rel="<?php echo $obj->album_id; ?> " title="<?php echo $obj->description; ?> "> </a> <?php } $i++; if ($img_count == 1) { $i = 1; ?> </div> <?php } //else if($obj->album_id!=$aid && $aid!="" and ) //{ //echo $obj->album_id; // $i=1; ?> <?php //} $aid = $obj->album_id; ?> <?php } if ($img_count > 0) { echo '</div>'; } } else { if ($view == 'image') { foreach ($rows as $obj) { ?> <div class="album_thumb"> <p><a class="fancybox" data-fancybox-group="thumb" href="<?php echo $obj->image_path; ?> "> <img src="<?php echo $obj->thumb_path; ?> " /></a> </p> </div> <?php } } } ?> <br style="clear:both;" /> </div> <div> <?php if ($page && $items > 0) { echo $p->show(); } // Echo out the list of paging. ?> </div> </div> <?php }
function sql_page($sql, $limit = 20) { $db = get_instance()->db; $rs = preg_replace("/select(.*)from/is", "select count(users.id) total from", $sql); $q = $db->query($rs)->row_array(); $this->sql_page_total = $q['total']; // $this->sql_page_total = $db->query($sql)->num_rows(); $this->load->library('pagination'); $page = new pagination(); $page->target(preg_replace('/([&?]+page=[0-9]+)/i', '', $_SERVER['REQUEST_URI'])); $page->limit($limit); @$page->currentPage($_GET['page']); $page->Items($this->sql_page_total); $this->sql_pagination = $page->show(); $c_page = $page->page == 1 ? 0 : ($page->page - 1) * $page->limit; return $db->query($sql . ' limit ' . $c_page . ',' . $page->limit)->result(); }
$index++; } } } } ?> <!--Pagination Start--> <?php if (!empty($buildings)) { ?> <div class="row"> <div class="col-xs-12 text-center"> <nav> <?php $pag->show(); ?> </nav> </div> </div> <?php } ?> <!--Pagination End--> </div> <div class="tab-pane fade active in" id="mapview"> <br/> <?php
function detail_page($detail) { $page = 0; if (@$_GET["page"]) { $page = $_GET["page"] - 1; } $foo = @split("<!-- pagebreak -->", $detail); $target = preg_replace("/([&?]+page=[0-9]+)/i", "", $_SERVER["REQUEST_URI"]); $pagination = new pagination(); $pagination->target($target); $pagination->limit(1); @$pagination->currentPage($_GET["page"]); $pagination->Items(count($foo)); return @$foo[$page] . $pagination->show(); }
function list_voucher_display_settings() { global $wpdb; $sql = 'SELECT COUNT(*) FROM wp_voucher_post'; $items = $wpdb->get_var($sql); // $items = mysql_num_rows(mysql_query("SELECT * FROM wp_voucher_post")); // number of total rows in the database if ($items > 0) { $p = new pagination(); $p->items($items); $p->limit(500); // Limit entries per page $p->target("admin.php?page=list_voucher_settings"); $p->currentPage($_GET[$p->paging]); // Gets and validates the current page $p->calculate(); // Calculates what to show $p->parameterName('paging'); $p->adjacents(1); //No. of page away from the current page if (!isset($_GET['paging'])) { $p->page = 1; } else { $p->page = $_GET['paging']; } //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { echo "No Record Found"; } echo '<div class="wrap"> <h2>List of Records</h2> <div class="tablenav"> <div class="tablenav-pages">'; echo $p->show(); echo '</div> </div> <table class="widefat"> <thead> <tr> <th><strong>ID</strong></th> <th><strong>Người nhận</strong></th> <th><strong>Email</strong></th> <th><strong>Điện thoại</strong></th> <th><strong>Tên voucher</strong></th> <th><strong>Số lượng</strong></th> </tr> </thead> <tbody>'; $sql = "SELECT * FROM wp_voucher_post, wp_posts where wp_voucher_post.post_id = wp_posts.id ORDER BY wp_voucher_post.id DESC {$limit}"; $result = $wpdb->get_results($sql) or die('Error, query failed'); foreach ($result as $value) { echo '<tr> <td>' . $value->post_id . '</td> <td>' . $value->fullname . '</td> <td>' . $value->email . '</td> <td>' . $value->phone . '</td> <td>' . $value->post_title . '</td> <td>' . $value->total . '</td> </tr>'; } echo '</tbody> </table> </div>'; }
<h2><?php _e('Gerenciar vendas'); ?> </h2> <form action="admin-post.php" id="modulo-vendas-realizadas" method="post"><?php wp_nonce_field('modulo_venda_transacao'); ?> <input type="hidden" name="action" value="modulo_venda_transacao"> <p>Itens encontrados: <?php echo $items; ?> </p> <div class="tablenav"> <div class="tablenav-pages"> <?php echo $p->show(); // Echo out the list of paging. ?> </div> <fieldset class="alignleft" id="modulo-pagamento-acoes"> <legend>Ações e filtros</legend> <input type="submit" value="Apagar" name="modulo_venda_transacao" class="button-secondary delete" /> <select name="modulo-venda-status" id="status" class= "postform"> <option value="todos">Todos</option> <option value="pendente">Pendente</option> <option value="aguardando_pagamento">Aguardando Pagamento</option> <option value="enviando">Enviando</option> <option value="finalizado">Finalizado</option> </select> <input type="submit" id="post-query-status" value="Modificar Status" name="modulo_venda_transacao"
/* fetching country name for the specific ip address */ $country = $ip2country->get_country_name($ip); echo "<tr>"; echo "<td>{$id}</td>"; echo "<td>{$ip}</td>"; echo "<td><a href=\"{$website}/" . ADMIN_DIRECTORY . "/manageuser/{$uid}#/logs\">{$name}</a></td>"; echo "<td>{$country}</td>"; echo "<td><abbr class=\"micro\" title=\"{$date}\"></abbr></td>"; echo "</tr>"; } echo "</tbody>"; echo "</table>"; /* displaying pagination below the table. */ if ($number > $max_show) { $p->show(); } } else { echo "<div class=\"alert\"><strong>" . _("No Access Records.") . "</strong><br/>" . _("There are no access records in the database.") . "</div>"; echo "<div class=\"alert alert-info\"><strong>" . _("Suggestion") . "</strong><br/>" . _("Make sure you have enabled the option to log user access information in the settings panel.") . "</div>"; } } else { echo "<div class=\"alert alert-error\"><strong>" . _("Unauthorized Access.") . "</strong><br/>" . _("You are not authorized to access this page.") . "</div>"; } } else { echo "<meta http-equiv=\"refresh\" content=\"0;url={$website}/" . USER_DIRECTORY . "/login\" />"; } include "../" . USER_DIRECTORY . "/footer.php";
function managetestimonial() { $x = 0; $data = get_option('testimonials_manager'); if ($_GET['action'] == 'delete') { $id = $_GET['testimonial_id']; $data = get_option('testimonials_manager'); unset($data['data'][$id]); $data['data'] = array_values($data['data']); update_option('testimonials_manager', $data); echo "Testimonial Deleted<br/>"; } $testimonialboxcount = count($data['data']); $p = new pagination(); $p->items($testimonialboxcount); $p->limit(25); if (empty($_GET['pg'])) { $page = 1; } else { $page = $_GET['pg']; } $p->currentPage($page); $p->target('admin.php?page=testimonials_manage'); ?> <div class="tablenav"> <div class='tablenav-pages'> <?php echo $p->show(); // Echo out the list of paging. ?> </div> <div class = "alignleft actions" > <select name = "act" > <option value = "-1" selected = "selected" > Bulk Actions</option > <option value = "trash" > Delete</option > </select > <input type = "submit" name = "doaction" id = "doaction" value = "Apply" class = "button-secondary apply" / > </div><br class = "clear" / > </div > <?php // print_r($data); if ($testimonialboxcount > 25) { $testimonialboxcount = 25; // now to make the array smaller $newarray = array_slice($data['data'], ($page - 1) * 25, 25); $data['data'] = $newarray; $testimonialboxcount = count($newarray); } ?> <table class="widefat" cellspacing="0"> <thead> <tr> <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" class="checkall"/></th> <th scope="col" width="250px">Name</th> <th scope="col">Testimonial</th> </tr> </thead> <tfoot> <tr> <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" class="checkall" /></th> <th scope="col">Name</th> <th scope="col">Testimonial</th> </tr> </tfoot> <tbody> <?php if ($testimonialboxcount == 0) { ?> <tr style="background:#eeeeee;"> <td colspan="3" align="center"><strong>No testimonial yet, add one below.</strong></td> </tr> <?php } else { while ($x < $testimonialboxcount) { $num = $x; $num = $num + 1 + ($page - 1) * 25; $url = $data['data'][$x]['url']; if (substr($url, 0, 7) != 'http://') { $url = 'http://' . $url; } if ($data['data'][$x]['avatar']) { if ($data['data'][$x]['avatar'] == "gravatar") { $av = get_avatar($data['data'][$x]['email'], 48); } else { $av = '<img src="' . $data['data'][$x]['own_avatar'] . '" class="avatar" alt="avatar" width="48" height="48" />'; } } ?> <tr> <td align="center" valign="top"><input type='checkbox' name='delete_comments[]' class="tobedeleted" value='<?php echo $num - 1; ?> ' /></td> <td class="author column-author"> <strong><?php echo $av; ?> <?php echo $data['data'][$x]['name']; ?> </strong><br> <?php echo $data['data'][$x]['company']; ?> <br/> <a href="<?php echo $url; ?> "><?php echo $data['data'][$x]['url']; ?> </a> </td> <td align="" valign="top"><?php echo $data['data'][$x]['text']; ?> <div class="row-actions"><span class='edit'><a href="<?php echo $_SERVER['PHP_SELF']; ?> ?page=testimonials_add&action=edit&testimonial_id=<?php echo $num - 1; ?> " title="Edit this post">Edit</a> | </span><!-- <span class='inline hide-if-no-js'><a href="#" class="editinline" title="Edit this post inline">Quick Edit</a> | </span> --><span class='trash'><a class='submitdelete' title='Move this post to the Trash' href='<?php echo $_SERVER['PHP_SELF']; ?> ?page=testimonials_manage&action=delete&testimonial_id=<?php echo $num - 1; ?> '>Delete</a> </span></div> </td> </tr> <?php $x++; } } ?> </tbody> </table> <div class="tablenav"> <div class='tablenav-pages'> <?php echo $p->show(); // Echo out the list of paging. ?> </div> <div class = "alignleft actions" > <select name = "act" > <option value = "-1" selected = "selected" > Bulk Actions</option > <option value = "trash" > Delete</option > </select ><input type = "submit" name = "doaction" id = "doaction" value = "Apply" class = "button-secondary apply" / > </div><br class = "clear" / > </div> <br /> <br /> <a href="<?php echo $_SERVER['PHP_SELF']; ?> ?page=testimonials_add" class="button-primary">Add New Testimonial</a> <br /> <br /> <?php }