die; } echo '<div class="title"> <h2>' . $LANG['stores_add_title'] . '</h2> <div style="float:right; margin: 0 2px 0 0;"> <a href="?route=stores.php&action=list" class="btn">' . $LANG['stores_view'] . '</a> </div>'; if (!empty($LANG['stores_add_subtitle'])) { echo '<span>' . $LANG['stores_add_subtitle'] . '</span>'; } echo '</div>'; if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['csrf']) && check_csrf($_POST['csrf'], 'stores_csrf')) { if (isset($_POST['user']) && isset($_POST['category']) && isset($_POST['name']) && isset($_POST['url']) && isset($_POST['description']) && isset($_POST['tags']) && isset($_FILES['logo']) && isset($_POST['meta_title']) && isset($_POST['meta_desc'])) { if (actions::add_store(array('user' => $_POST['user'], 'category' => $_POST['category'], 'name' => $_POST['name'], 'url' => $_POST['url'], 'description' => $_POST['description'], 'tags' => $_POST['tags'], 'popular' => isset($_POST['popular']) ? 1 : 0, 'publish' => isset($_POST['publish']) ? 1 : 0, 'meta_title' => $_POST['meta_title'], 'meta_desc' => $_POST['meta_desc']))) { echo '<div class="a-success">' . $LANG['msg_added'] . '</div>'; } else { echo '<div class="a-error">' . $LANG['msg_error'] . '</div>'; } } } $csrf = $_SESSION['stores_csrf'] = \site\utils::str_random(10); echo '<div class="form-table"> <form action="#" method="POST" enctype="multipart/form-data" autocomplete="off"> <div class="row"><span>' . $LANG['form_user_id'] . ':</span><div data-search="user"><input type="text" name="user" value="' . (isset($_POST['user']) ? (int) $_POST['user'] : (!empty($_GET['user']) ? (int) $_GET['user'] : $GLOBALS['me']->ID)) . '" required /><a href="#">S</a></div></div> <div class="row"><span>' . $LANG['form_category'] . ':</span> <div><select name="category">';
include 'includes/feed.php'; try { $feed = new feed(\query\main::get_option('feedserver_ID'), \query\main::get_option('feedserver_secret')); $ssuc = $csuc = $serr = $cerr = 0; try { $stores = $feed->stores($store_ids = array('ids' => implode(',', array_keys($_GET['id'])))); if (!empty($stores['Count'])) { $upload_logo = \query\main::get_option('feed_uppics'); $imp_expired = \query\main::get_option('feed_iexpc'); // Let's split everything in pages, because of ggcoupon.com, them allow only 10 results per page. for ($sp = 1; $sp <= ceil($stores['Count'] / 10); $sp++) { if ($sp != 1) { $stores = $feed->stores(array_merge(array('page' => $sp), $store_ids)); } foreach ($stores['List'] as $store) { if (!admin_query::store_imported($store->ID) && ($new_store_id = actions::add_store(array('feedID' => $store->ID, 'user' => $GLOBALS['me']->ID, 'popular' => 0, 'category' => $_GET['category'], 'name' => $store->Name, 'url' => $store->URL, 'description' => $store->Description, 'tags' => $store->Tags, 'import_logo' => $upload_logo, 'logo_url' => $store->Image, 'publish' => 1, 'meta_title' => '', 'meta_desc' => '')))) { $ssuc++; if (isset($_GET['coupons']) && $_GET['coupons'] == 'yes') { try { $coupons = $feed->coupons($coupon_ids = array('store' => $store->ID, 'view' => !$imp_expired ? 'active' : '')); if (!empty($coupons['Count'])) { for ($cp = 1; $cp <= ceil($coupons['Count'] / 10); $cp++) { if ($cp != 1) { $coupons = $feed->coupons(array_merge(array('page' => $cp), $coupon_ids)); } foreach ($coupons['List'] as $coupon) { if (!admin_query::coupon_imported($coupon->ID) && actions::add_item(array('feedID' => $coupon->ID, 'store' => $new_store_id, 'popular' => 0, 'exclusive' => 0, 'category' => $_GET['category'], 'name' => $coupon->Title, 'link' => $coupon->URL, 'code' => $coupon->Code, 'description' => $coupon->Description, 'tags' => $coupon->Tags, 'cashback' => 0, 'start' => $coupon->Start_Date, 'end' => $coupon->End_Date, 'publish' => 1, 'meta_title' => '', 'meta_desc' => ''))) { $csuc++; } else { $cerr++; }