public static function have_plugins($category = array(), $special = array()) { global $db; $categories = \site\utils::validate_user_data($category); $where = array(); /* WHERE / ORDER BY */ if (!empty($categories['search'])) { $search = implode('.*', explode(' ', trim($categories['search']))); $where[] = 'CONCAT(name, description) REGEXP "' . \site\utils::dbp($search) . '"'; } if (isset($categories['show'])) { $show = array_map('trim', explode(',', strtolower($categories['show']))); foreach ($show as $v) { switch ($v) { case 'languages': $where[] = 'scope = "language"'; break; case 'payment_gateways': $where[] = 'scope = "pay_gateway"'; break; case 'feed_servers': $where[] = 'scope = "feed_server"'; break; case 'applications': $where[] = 'scope = ""'; break; } } } /* */ $stmt = $db->stmt_init(); $stmt->prepare("SELECT COUNT(*) FROM " . DB_TABLE_PREFIX . "plugins" . (empty($where) ? '' : ' WHERE ' . implode(' AND ', $where))); $stmt->execute(); $stmt->bind_result($count); $stmt->fetch(); $stmt->close(); if (isset($special['only_count'])) { return $count; } $pags = array(); $pags['results'] = $count; $pags['per_page'] = !empty($categories['per_page']) ? (int) $categories['per_page'] : \query\main::get_option('items_per_page'); $pags['pages'] = ceil($pags['results'] / $pags['per_page']); $page = !empty($_GET['page']) ? (int) $_GET['page'] : 1; if ($page < 1) { $page = 1; } if ($page > $pags['pages']) { $page = $_GET['page'] = $pags['pages']; } $pags['page'] = $page; if ($pags['pages'] > $pags['page']) { $pags['next_page'] = \site\utils::update_uri('', array('page' => $pags['page'] + 1)); } if ($pags['pages'] > 1 && $pags['page'] > 1) { $pags['prev_page'] = \site\utils::update_uri('', array('page' => $pags['page'] - 1)); } return $pags; }
function get_remove($array, $url = '') { return \site\utils::update_uri($url, $array, 'remove'); }
' . (empty($item->coupons) ? $LANG['no_coupons_store'] : '<a href="?route=coupons.php&store=' . $item->ID . '">' . sprintf($LANG['nr_coupons_store'], $item->coupons) . '</a>') . '</div> </div> <div style="clear:both;"></div> <div class="options">'; if ($ab_edt) { echo '<a href="?route=stores.php&action=edit&id=' . $item->ID . '">' . $LANG['edit'] . '</a>'; echo '<a href="' . \site\utils::update_uri('', array('type' => !$item->visible ? 'publish' : 'unpublish', 'id' => $item->ID, 'token' => $csrf)) . '">' . (!$item->visible ? $LANG['publish'] : $LANG['unpublish']) . '</a>'; } if ($ab_add) { echo '<a href="?route=coupons.php&action=add&store=' . $item->ID . '&category=' . $item->catID . '">' . $LANG['coupons_add_button'] . '</a>'; } if ($ab_del) { echo '<a href="' . \site\utils::update_uri('', array('action' => 'delete', 'id' => $item->ID, 'token' => $csrf)) . '" data-delete-msg="' . $LANG['delete_store'] . '">' . $LANG['delete'] . '</a>'; } if ($feed_view && $item->feedID !== 0) { echo '<a href="?route=feed.php&action=coupons&store=' . $item->feedID . '">' . $LANG['feed_coupons_link'] . '</a>'; } echo '</div> </li>'; } echo '</ul> <input type="hidden" name="csrf" value="' . $csrf . '" /> </form>'; if (isset($p['prev_page']) || isset($p['next_page'])) { echo '<div class="pagination">'; if (isset($p['prev_page'])) {
public static function have_invoices($category = array(), $special = array()) { global $db; $categories = \site\utils::validate_user_data($category); $where = array(); /* WHERE / ORDER BY */ if (!empty($categories['search'])) { $search = implode('.*', explode(' ', trim($categories['search']))); $where[] = 'CONCAT(gateway, transaction_id, details) REGEXP "' . \site\utils::dbp($search) . '"'; } if (isset($categories['show'])) { switch ($categories['show']) { case 'paid': $where[] = 'paid > 0'; break; case 'unpaid': $where[] = 'paid = 0'; break; case 'delivered': $where[] = 'delivered > 0'; break; case 'undelivered': $where[] = 'delivered = 0'; break; case 'undeliveredpayments': $where[] = 'paid > 0 AND delivered = 0'; } } if (!empty($categories['date'])) { $date = array_map('trim', explode(',', $categories['date'])); $where[] = 'date >= FROM_UNIXTIME(' . \site\utils::dbp($date[0]) . ')'; if (isset($date[1])) { $where[] = 'date <= FROM_UNIXTIME(' . \site\utils::dbp($date[1]) . ')'; } } /* */ $stmt = $db->stmt_init(); $stmt->prepare("SELECT COUNT(*), SUM(price) FROM " . DB_TABLE_PREFIX . "p_transactions" . (empty($where) ? '' : ' WHERE ' . implode(' AND ', $where))); $stmt->execute(); $stmt->bind_result($count, $sum_inv); $stmt->fetch(); $stmt->close(); if (isset($special['only_count'])) { return $count; } if (isset($special['statistics'])) { return array('count' => $count, 'sum' => $sum_inv); } $pags = array(); $pags['results'] = $count; $pags['per_page'] = !empty($categories['per_page']) ? (int) $categories['per_page'] : \query\main::get_option('items_per_page'); $pags['pages'] = ceil($pags['results'] / $pags['per_page']); $page = !empty($_GET['page']) ? (int) $_GET['page'] : 1; if ($page < 1) { $page = 1; } if ($page > $pags['pages']) { $page = $_GET['page'] = $pags['pages']; } $pags['page'] = $page; if ($pags['pages'] > $pags['page']) { $pags['next_page'] = \site\utils::update_uri('', array('page' => $pags['page'] + 1)); } if ($pags['pages'] > 1 && $pags['page'] > 1) { $pags['prev_page'] = \site\utils::update_uri('', array('page' => $pags['page'] - 1)); } return $pags; }
public static function have_rewards_reqs($category = array(), $special = array()) { global $db; $categories = \site\utils::validate_user_data($category); $where = array(); /* WHERE / ORDER BY */ if (!empty($categories['user'])) { $where[] = 'user = "******"'; } if (!empty($categories['reward'])) { $where[] = 'reward = "' . (int) $categories['reward'] . '"'; } if (!empty($categories['search'])) { $search = implode('.*', explode(' ', trim($categories['search']))); $where[] = 'fields REGEXP "' . \site\utils::dbp($search) . '"'; } if (isset($categories['show'])) { $show = strtolower($categories['show']); switch ($show) { case 'valid': $where[] = 'claimed = 1'; break; case 'notvalid': $where[] = 'claimed = 0'; break; } } /* */ $stmt = $db->stmt_init(); $stmt->prepare("SELECT COUNT(*) FROM " . DB_TABLE_PREFIX . "rewards_reqs" . (empty($where) ? '' : ' WHERE ' . implode(' AND ', $where))); $stmt->execute(); $stmt->bind_result($count); $stmt->fetch(); $stmt->close(); if (isset($special['only_count'])) { return $count; } $pags = array(); $pags['results'] = $count; $pags['per_page'] = !empty($categories['per_page']) ? (int) $categories['per_page'] : \query\main::get_option('items_per_page'); $pags['pages'] = ceil($pags['results'] / $pags['per_page']); $page = !empty($_GET['page']) ? (int) $_GET['page'] : 1; if ($page < 1) { $page = 1; } if ($page > $pags['pages']) { $page = $_GET['page'] = $pags['pages']; } $pags['page'] = $page; if ($pags['pages'] > $pags['page']) { $pags['next_page'] = \site\utils::update_uri('', array('page' => $pags['page'] + 1)); } if ($pags['pages'] > 1 && $pags['page'] > 1) { $pags['prev_page'] = \site\utils::update_uri('', array('page' => $pags['page'] - 1)); } return $pags; }
<img src="' . (empty($item->image) ? '../' . DEFAULT_IMAGES_LOC . '/plugin_ico.png' : '../' . $item->image) . '" alt="" style="width: 70px;" /> <div class="info-div"><h2>' . ($item->visible !== 1 ? '<span class="msg-error">' . $LANG['notpublished'] . '</span> ' : '') . $item->name . ' <span class="fright date">' . date('Y.m.d, ' . (\query\main::get_option('hour_format') == 12 ? 'g:i A' : 'G:i'), strtotime($item->date)) . '</span></h2> v ' . sprintf('%0.2f', $item->version) . ' </div> </div> <div style="clear:both;"></div> <div class="options">'; if (empty($item->scope)) { echo '<a href="?plugin=' . $item->main_file . '">' . $LANG['open'] . '</a>'; } echo '<a href="?route=plugins.php&action=edit&id=' . $item->ID . '">' . $LANG['edit'] . '</a>'; echo '<a href="' . \site\utils::update_uri('', array('type' => !$item->visible ? 'publish' : 'unpublish', 'id' => $item->ID, 'token' => $csrf)) . '">' . (!$item->visible ? $LANG['publish'] : $LANG['unpublish']) . '</a>'; if (!empty($item->options_file)) { echo '<a href="?plugin=' . $item->options_file . '">' . $LANG['options'] . '</a>'; } echo '<a href="?route=plugins.php&action=uninstall&id=' . $item->ID . '">' . $LANG['plugins_uninstall'] . '</a>'; if (!empty($item->description)) { echo '<a href="javascript:void(0)" onclick="$(this).show_next( { after_action: \'\', element: \'div\' } ); return false;">' . $LANG['description'] . '</a>'; echo '<div style="display: none; margin: 10px 0; font-size: 12px;">' . nltobr($item->description) . '</div>'; } echo '</div> </li>'; } echo '</ul> <input type="hidden" name="csrf" value="' . $csrf . '" />
echo '</div> </li>'; } echo '</ul> </form>'; if (($pages = ceil($stores['Count'] / 10)) > 1) { $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? (int) $_GET['page'] : 1; $page = $page > $pages ? $pages : $page; echo '<div class="pagination">'; if ($page > 1) { echo '<a href="' . \site\utils::update_uri('', array('page' => $page - 1)) . '" class="btn">' . $LANG['prev_page'] . '</a>'; } if ($page < $pages) { echo '<a href="' . \site\utils::update_uri('', array('page' => $page + 1)) . '" class="btn">' . $LANG['next_page'] . '</a>'; } if ($pages > 1) { echo '<div class="pag_goto">' . sprintf($LANG['pageofpages'], $page, $pages) . ' <form action="#" method="GET">'; foreach ($_GET as $gk => $gv) { if ($gk !== 'page') { echo '<input type="hidden" name="' . htmlspecialchars($gk) . '" value="' . htmlspecialchars($gv) . '" />'; } } echo '<input type="number" name="page" min="1" max="' . $pages . '" size="5" value="' . $page . '" /> <button class="btn">' . $LANG['go'] . '</button> </form> </div>'; } echo '</div>';
echo '<input type="hidden" name="coupon[' . $item['id'] . ']" value="' . $cdata . '" />'; } echo '</div> </li>'; } echo '</ul> <input type="hidden" name="token" value="' . $csrf . '" /> </form>'; echo '<div class="pagination">'; if ($page >= 1) { echo '<a href="' . \site\utils::update_uri('', array('page' => $page - 1)) . '" class="btn">← Prev</a>'; } if (count($links) >= $per_page) { echo '<a href="' . \site\utils::update_uri('', array('page' => $page + 1)) . '" class="btn">Next →</a>'; } echo '</div>'; } else { echo '<div class="a-alert">No links.</div>'; } break; /** PREVIEW COUPON */ /** PREVIEW COUPON */ case 'coupon_preview': echo '<div class="title"> <h2>Preview & Import</h2> <span>Here you can edit the details of this coupon before the import</span> </div>';
public static function add_user($opt = array()) { global $db, $LANG; if (!ab_to(array('users' => 'add'))) { return false; } $opt = \site\utils::array_map_recursive('trim', $opt); if (empty($opt['name']) || empty($opt['email']) || empty($opt['password'])) { return false; } $stmt = $db->stmt_init(); $stmt->prepare("INSERT INTO " . DB_TABLE_PREFIX . "users (name, email, password, avatar, points, credits, privileges, erole, subscriber, valid, date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())"); $avatar = \site\images::upload(@$_FILES['logo'], 'avatar_', array('path' => DIR . '/', 'max_size' => 1024, 'max_width' => 500, 'max_height' => 600, 'current' => '')); $password = md5($opt['password']); $stmt->bind_param("ssssiiisii", $opt['name'], $opt['email'], $password, $avatar, $opt['points'], $opt['credits'], $opt['privileges'], @serialize($opt['erole']), $opt['subscriber'], $opt['confirm']); if ($stmt->execute()) { if (!$opt['confirm']) { $stmt->prepare("SELECT id FROM " . DB_TABLE_PREFIX . "users WHERE email = ?"); $stmt->bind_param("s", $opt['email']); $stmt->execute(); $stmt->bind_result($id); $stmt->fetch(); $stmt->close(); $cofirm_session = md5(\site\utils::str_random(15)); if (\user\mail_sessions::insert('confirmation', array('user' => $id, 'session' => $cofirm_session))) { \site\mail::send($opt['email'], $LANG['email_acc_title'] . ' - ' . \query\main::get_option('sitename'), array('template' => 'account_confirmation', 'path' => '../'), array('hello_name' => sprintf($LANG['email_text_hello'], $opt['name']), 'confirmation_main_text' => $LANG['email_acc_maintext'], 'confirmation_button' => $LANG['email_acc_button'], 'link' => \site\utils::update_uri($GLOBALS['siteURL'] . 'verify.php', array('user' => $id, 'token' => $cofirm_session)))); } } return true; } $stmt->close(); return false; }
public static function unsubscribe($post) { global $db, $LANG; $post = array_map('trim', $post); if (!isset($post['email']) || !filter_var($post['email'], FILTER_VALIDATE_EMAIL)) { throw new \Exception($LANG['newsletter_usevalide']); } else { $stmt = $db->stmt_init(); $stmt->prepare("SELECT COUNT(*) FROM " . DB_TABLE_PREFIX . "newsletter WHERE email = ?"); $stmt->bind_param("s", $post['email']); $stmt->bind_result($count); $stmt->execute(); $stmt->fetch(); $stmt->close(); if ($count == 0) { throw new \Exception($LANG['uunsubscr_notsubscr']); } if (\query\main::get_option('unsubscr_confirm_req')) { $session = md5(\site\utils::str_random(15)); if (\user\mail_sessions::insert('unsubscription', array('email' => $post['email'], 'session' => $session)) && \site\mail::send($post['email'], $LANG['email_unsub_title'] . ' - ' . \query\main::get_option('sitename'), array('template' => 'confirm_unsubscription'), array('confirmation_main_text' => $LANG['email_unsub_maintext'], 'confirmation_button' => $LANG['email_unsub_button'], 'link' => \site\utils::update_uri($GLOBALS['siteURL'] . 'verify.php', array('action' => 'unsubscribe2', 'email' => $post['email'], 'token' => $session))))) { return 1; } else { throw new \Exception($LANG['msg_error']); } } else { // auto-unsubscribe $stmt = $db->stmt_init(); $stmt->prepare("DELETE FROM " . DB_TABLE_PREFIX . "newsletter WHERE email = ?"); $stmt->bind_param("s", $post['email']); $execute = $stmt->execute(); $stmt->close(); if ($execute) { return 2; } else { throw new \Exception($LANG['msg_error']); } } } }