* reqid - This is the request ID to lookup for the group. Must be numeric (int|string). * Example: serialize( * array( * 0 => array('ident' => 0, 'group' => 'none', 'reqid' => 0), * 1723 => array('ident' => 1723, 'group' => 'alt.binaries.moovee', 'reqid' => 194293), * 2384 => array('ident' => 2384, 'group' => 'alt.binaries.teevee', 'reqid' => 293823) * ) * ) */ if (nZEDb_PREINFO_OPEN) { if (!$page->users->isLoggedIn()) { if (!isset($_GET['apikey'])) { apiError('Missing parameter (apikey)', 200); } if (!$page->users->getByRssToken($_GET['apikey'])) { apiError('Incorrect user credentials (api key is wrong)', 100); } } } $preData = array(); $json = false; if (isset($_GET['json']) && $_GET['json'] == 1) { $json = true; } if (isset($_GET['type'])) { $limit = 1; if (isset($_GET['limit']) && is_numeric($_GET['limit'])) { $limit = $_GET['limit']; if ($limit > 100) { $limit = 100; }
// Application Secure Key define('CLIENT_SECRET', '9Z6zdpd5d924cuc5Ow2o'); // Scopes define('SCOPE', 'wall,offline,nohttps'); // VK Api Version define('API_VERSION', '5.40'); // That's all, do not modify below. $thisPage = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']; if (!$_GET['code'] && !$_GET['error']) { header("Location: https://oauth.vk.com/authorize?client_id=" . CLIENT_ID . "&scope=" . SCOPE . "&redirect_uri=" . $thisPage . "&response_type=code&v=" . API_VERSION); } elseif ($_GET['error']) { apiError($_GET['error'], $_GET['error_description']); } else { $content = file_get_contents("https://oauth.vk.com/access_token?client_id=" . CLIENT_ID . "&client_secret=" . CLIENT_SECRET . "&code=" . $_GET['code'] . "&redirect_uri=" . $thisPage); if (!$content) { exit("Error."); } $response = json_decode($content); if ($response->error) { apiError($response->error, $response->error_description); exit; } $secret = $response->secret ? "Secret: {$response->secret}<br />\n" : ""; $https_required = $response->https_required ? "HTTPS Required: {$response->https_required}<br />\n" : ""; $email = $response->email ? "Email: {$response->email}<br />\n" : ""; echo "Intermediate value: " . $_GET['code'] . "<br /><br />\n\nAccess Token: " . $response->access_token . "<br />\n" . $secret . $https_required . $email . "Expires in: " . $response->expires_in . "<br />\nUser id: " . $response->user_id; } function apiError($type, $description) { echo "Error: " . $type . "\n<br />Desription: " . $description; }
private function upsellProcess() { // is this request still valid? set to one hour. there is a cron that salvages orphaned upsell orders after 1 hour if ($this->intervalCheck) { $this->checkInterval($this->order->updated); } // load previous order upsells, if any $orderUpsells = AFActiveDataProvider::models('OrderUpsell'); $orderUpsells->loadId($this->order->order_id); // is this a switch main product upsell? $replace = false; $upsell = new Upsell(); if (!$upsell->fillFromDbPk($this->post['uid'])) { apiError('order upsell invalid'); } if ($upsell->product_replace && $this->post['act_up'] == 'yes') { $replace = true; // overwrite main order_product record and reset upsell path $this->post['product_id'] = $upsell->product_id; $this->newOrder = false; // $this->upsell_id is built via the function below $this->buildProducts(); $this->order->amount_product = $this->amount_product; if ($upsell->shipping_id) { $shipping = new Shipping(); if ($shipping->fillFromDbPk($upsell->shipping_id)) { $this->order->shipping_id = $shipping->shipping_id; $this->order->amount_shipping = $shipping->amount_initial; } unset($shipping); } if (!$this->order->save()) { fb('order not saved'); continue; } // overwrite step so we can delete all previous steps below $this->post['step'] = 0; } // is this a replace product, or has this step already been recorded? if so, wipe out steps in DB if ($replace || (int) $this->post['step'] <= $orderUpsells->getUpsellStep()) { $orderUpsells->deleteSteps($this->post['step']); } if (!$replace) { $orderUpsells->add($this->order->order_id, $this->post['uid'], $this->post['act_up'], $this->post['step']); if (!$orderUpsells->save()) { apiError('order upsell invalid'); } // is there another upsell based on the asnwer given? $this->upsell_id = $orderUpsells->nextUpsell(); } if (!$this->upsell_id) { // We're all done with upsells, insert upsell products into order products // retrieve existing order_products $orderProducts = new OrderProducts('OrderProduct'); $orderProducts->loadByOrderId($this->order->order_id); foreach ($orderUpsells->orderUpsells as $oa) { if ($oa->answer == 'yes') { $orderProducts->add($oa->product_id, $oa->shipping_id, $this->order->order_id); } // remove from DB $oa->delete(); } if (!$orderProducts->save()) { continue; } // update amounts $this->order->amount_product = $orderProducts->getTotal(); if (!$this->order->save()) { fb('order not saved'); continue; } // process Payment $this->webPayment(); } else { // send user to next upsell page $this->upsellDirect((int) $this->post['step'] + 1); } }