public function check_decline_price_giftsAction()
 {
     $decline = new p_decline_price_gifts();
     $decline_price_gifts = $decline->select($count, array('filter' => array('find_decline_prices' => true, 'status' => 0)));
     if (!empty($decline_price_gifts)) {
         $i = 1;
         foreach ($decline_price_gifts as $decline) {
             $gift = new gift($decline->gift_id);
             $id[] = $decline->id;
             $email = new email_template('decline_price_gift');
             $email->assign('GIFT_NAME', $gift->get('display_name'))->assign('OLD_PRICE', $decline->old_price)->assign('PRICE', $decline->price)->assign('LINK', "http://{$_SERVER['HTTP_HOST']}/" . $gift->get('local_url') . '/?utm_source=email&utm_medium=user&utm_campaign=decline_price_gifts')->assign('USER_NAME', $decline->user_name)->send($decline->email, $decline->user_name)->send('*****@*****.**');
             $list .= $i . '.&nbsp;<a href="http://' . $_SERVER["HTTP_HOST"] . '/' . $gift->get('local_url') . '/"><b>' . $gift->get('display_name') . "</b></a> {$decline->user_name} &lt;{$decline->email}&gt;<br>Старая цена: {$decline->old_price}&nbsp;руб.<br>Новая цена: <b>{$decline->price}</b>&nbsp;руб.<br><br>";
             $i++;
         }
         $decline->set_status(1, $id);
         $em = new email_template('decline_price_gift_us');
         $em->assign('COUNT', count($id))->assign('LIST', !empty($list) ? $list : '')->send('*****@*****.**');
     }
     die('OK');
 }
 public function callbackAction()
 {
     // Убедимся что кеш выключен
     Zend_Registry::get('target')->enable_cache(0);
     // Проверим: а правильно ли пришли данные?
     $gift = new gift(@$_POST["gift_id"]);
     if (!$gift->get('id') || !isset($_POST["phone"])) {
         die(json_encode(array('msg' => 'Извините, заказ звонка не удался')));
     }
     $_POST["email"] = $_POST["email"] == 'Email' ? '' : $_POST["email"];
     //Преобразовываем номер телефона к единому виду.В номере телефона оставляем только цифры.
     $_POST["phone"] = preg_replace("/\\D/", "", $_POST["phone"]);
     // Расчитаем стоимость заказа обратного звонка
     $_POST['price_call'] = floor($_POST['gift_price'] * Zend_Registry::get('config')->callback->percent / 25) / 4;
     //Проверяем что бы цена звонка была не меньше заданой в конфиге минимальной стоимости звонка
     $_POST['price_call'] = $_POST['price_call'] >= Zend_Registry::get('config')->callback->min_price_call ? $_POST['price_call'] : Zend_Registry::get('config')->callback->min_price_call;
     $_POST['price_call'] = $_POST['price_call'] <= Zend_Registry::get('config')->callback->max_price_call ? $_POST['price_call'] : Zend_Registry::get('config')->callback->max_price_call;
     $_POST['ip'] = $_SERVER["REMOTE_ADDR"];
     $_POST['user_agent'] = $_SERVER["HTTP_USER_AGENT"];
     // Первым делом отправляем письмо юзеру - чтобы не волновался, по идее будем еще ему слать СМС
     $shops = new shop((int) $_POST['shop_id']);
     if (!empty($_POST["email"])) {
         $work_time = $shops->get('work_time');
         $et = new email_template('callback_user');
         $et->assign('USER_NAME', $_POST["name"])->assign('GIFT_NAME', $gift->get('display_name'))->assign('SHOP_NAME', $shops->get('display_name'))->assign('URL_GIFT', "http://{$_SERVER['SERVER_NAME']}/" . $gift->get('local_url') . '/?utm_source=email&utm_medium=user&utm_campaign=callback_user')->assign('WORK_TIME', !empty($work_time) ? 'Время работы магазина: <strong>' . $work_time . '</strong>' : '')->send($_POST["email"], $_POST["name"])->send('*****@*****.**');
     }
     //Записываем заказ звонка в таблицу p_stat_out в любом случае
     $stat = new stat();
     $stat_id = $stat->insert(array('gift_id' => (int) $_POST["gift_id"], 'category_id' => (int) @$_POST["category_id"], 'gift_name' => $gift->get('display_name'), 'cpc' => (double) $_POST['price_call'], 'price' => (int) $_POST['gift_price'], 'partner_id' => (int) $shops->get('partner_id'), 'ip' => $_POST["ip"], 'user_agent' => $_POST["user_agent"], 'from_url' => $gift->get('local_url'), 'to_url' => $_POST["url"], 'click_type' => 2));
     $callback = new p_callback();
     //Проверяем наличие одинаковых записей за временный интервал
     $exist_reserves = $callback->select($count, array('filter' => array('gift_id' => (int) $_POST["gift_id"], 'name' => $_POST["name"], 'phone' => $_POST["phone"], 'email' => $_POST["email"], 'interval' => Zend_Registry::get('config')->callback->interval_order)));
     if (empty($exist_reserves)) {
         //Записываем заказ звонка в таблицу p_callback
         $callback->insert(array('name' => $_POST["name"], 'phone' => $_POST["phone"], 'email' => $_POST["email"], 'stat_id' => (int) $stat_id, 'gift_id' => (int) $_POST["gift_id"], 'gift_name' => $gift->get('display_name'), 'gift_price' => (int) $_POST['gift_price'], 'shop_id' => (int) $_POST['shop_id'], 'partner_id' => (int) $shops->get('partner_id'), 'to_url' => $_POST["url"], 'price_call' => (double) $_POST['price_call'], 'ip' => $_POST["ip"], 'user_agent' => $_POST["user_agent"], 'comment' => !empty($_POST['comment']) ? $_POST['comment'] : ''));
         //Отправляем письмо партнеру
         $et = new email_template('callback');
         $et->assign('GIFT_NAME', $gift->get('display_name'))->assign('BUYER_NAME', $_POST["name"])->assign('PHONE', $_POST["phone"])->assign('EMAIL', $_POST["email"])->assign('SHOP_NAME', $shops->get('display_name'))->assign('URL_GIFT', $_POST["url"])->assign('STAT_URL', "http://{$_SERVER['SERVER_NAME']}/stat/callback/?utm_source=email&utm_medium=partner&utm_campaign=callback")->assign('COMMENT', !empty($_POST['comment']) ? $_POST['comment'] : '')->send(Zend_Registry::get('config')->server->enviroment == 'live' ? $shops->get('callback_email') : Zend_Registry::get('config')->log->error_email)->send('*****@*****.**');
     }
     die(json_encode(array('msg' => 'Заказ звонка принят, спасибо')));
 }
示例#3
0
/*!
 * ifsoft.co.uk engine v1.0
 *
 * http://ifsoft.com.ua, http://ifsoft.co.uk
 * qascript@ifsoft.co.uk
 *
 * Copyright 2012-2016 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk)
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/init.inc.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/config/api.inc.php";
if (!empty($_POST)) {
    $clientId = isset($_POST['clientId']) ? $_POST['clientId'] : 0;
    $accountId = isset($_POST['accountId']) ? $_POST['accountId'] : 0;
    $accessToken = isset($_POST['accessToken']) ? $_POST['accessToken'] : '';
    $profileId = isset($_POST['profileId']) ? $_POST['profileId'] : 0;
    $itemId = isset($_POST['itemId']) ? $_POST['itemId'] : 0;
    $clientId = helper::clearInt($clientId);
    $accountId = helper::clearInt($accountId);
    $profileId = helper::clearInt($profileId);
    $itemId = helper::clearInt($itemId);
    $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
    $auth = new auth($dbo);
    if (!$auth->authorize($accountId, $accessToken)) {
        api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
    }
    $gifts = new gift($dbo);
    $gifts->setRequestFrom($accountId);
    $result = $gifts->get($profileId, $itemId);
    echo json_encode($result);
    exit;
}