/var/www/doncode.com.ua/www/models
NameSizeModeActions
class.admin_model.php377020644editdlrm
class.api_model.php328640644editdlrm
class.archive_model.php29750644editdlrm
class.arm_model.php93930644editdlrm
class.dcccatalog_model.php98710644editdlrm
class.dcclist_model.php108290644editdlrm
class.dccsupport_model.php4710644editdlrm
class.dccupdate_model.php4700644editdlrm
class.dmp_platforms_model.php79590644editdlrm
class.docs_model.php11280644editdlrm
class.doncode_users_model.php67120644editdlrm
class.driver_model.php3690644editdlrm
class.exchange_model.php82660644editdlrm
class.files_model.php1940644editdlrm
class.index_model.php11290644editdlrm
class.login_model.php250140644editdlrm
class.mobile_users_model.php100090644editdlrm
class.news_model.php77210644editdlrm
class.orders_model.php97820644editdlrm
class.settings_model.php117990644editdlrm
class.support_model.php287830644editdlrm
class.users_model.php91540644editdlrm
class.user_model.php448730644editdlrm
Edit: /var/www/doncode.com.ua/www/models/class.user_model.php (44873B)
0){ // Загрузка данных о текущем заказе $ord = new order(); $order = $ord->select_one("do.id='".session::get('order_id')."'"); if ($ord->getCount() > 0) { if($order['status']=='complite'){ session::set("order_id",0); $json['redirect'] = true; $json['page'] = 'user/complite_order'; }elseif($order['status']=='cancel'){ session::set("order_id",0); $json['redirect'] = true; $json['page'] = 'user/canceled_order'; }else{ $json['timer'] = CHECK_STATUS_ORDER_TIME; $json['page'] = 'user/canceled_order'; $json['msg'] = $order['status_name']; } }else{ session::set("order_id",0); $json['msg'] = 'Заказ не найден'; } }else{ $json['msg'] = 'Заказ не выполняется'; } // USER AREA if($this->hasPrivilege('menu_user')){ // Есть ли новые водители на активацию? $sth = $this->database->prepare("SELECT online FROM `".DB_PREFIX."users` WHERE `id`='".session::get('id_user')."';"); $sth->execute(); $count = $sth->rowCount(); if ($count > 0) { $data = $sth->fetch(PDO::FETCH_ASSOC); $json['online_badge'] = $data['online']; session::set("online",$data['online']); } } // END OF USER AREA // EXCHANGE AREA if($this->hasPrivilege('menu_exchange')){ // Есть ли новые водители на активацию? $sth = $this->database->prepare("SELECT count(*) as cnt FROM `".DB_PREFIX."orders` WHERE `status`='new' AND `city_id`='".session::get('city_id')."';"); $sth->execute(); $count = $sth->rowCount(); if ($count > 0) { $data = $sth->fetch(PDO::FETCH_ASSOC); $json['exchange_badge'] = $data['cnt']; } } // END OF EXCHANGE AREA // ADMIN AREA if($this->hasPrivilege('menu_admin')){ $all_cnt = 0; $orders_cnt = 0; $clients_cnt = 0; $drivers_cnt = 0; $exchange_cnt = 0; // Есть ли новые заказы? $sth = $this->database->prepare("SELECT count(*) as cnt FROM `".DB_PREFIX."orders` WHERE `status`='new';"); $sth->execute(); $count = $sth->rowCount(); if ($count > 0) { $data = $sth->fetch(PDO::FETCH_ASSOC); $all_cnt += $data['cnt']; $orders_cnt = $data['cnt']; } // Есть ли новые клиенты на активацию? $sth = $this->database->prepare("SELECT count(*) as cnt FROM `".DB_PREFIX."users` WHERE `email_confirmed`='0' AND `deleted`='0';"); $sth->execute(); $count = $sth->rowCount(); if ($count > 0) { $data = $sth->fetch(PDO::FETCH_ASSOC); $all_cnt += $data['cnt']; $clients_cnt = $data['cnt']; } // Есть ли новые водители на активацию? $sth = $this->database->prepare("SELECT count(*) as cnt FROM `".DB_PREFIX."drivers` WHERE `active`='0' AND `deleted`='0';"); $sth->execute(); $count = $sth->rowCount(); if ($count > 0) { $data = $sth->fetch(PDO::FETCH_ASSOC); $all_cnt += $data['cnt']; $drivers_cnt = $data['cnt']; } // Есть ли новые диспетчерские на активацию? $sth = $this->database->prepare("SELECT count(*) as cnt FROM `".DB_PREFIX."exchange` WHERE `active`='0' AND `deleted`='0';"); $sth->execute(); $count = $sth->rowCount(); if ($count > 0) { $data = $sth->fetch(PDO::FETCH_ASSOC); $all_cnt += $data['cnt']; $exchange_cnt = $data['cnt']; } $json['admin_badge'] = $all_cnt; $json['admin_badge_orders'] = $orders_cnt; $json['admin_badge_clients'] = $clients_cnt; $json['admin_badge_drivers'] = $drivers_cnt; $json['admin_badge_exchange'] = $exchange_cnt; } // END OF ADMIN AREA echo $this->json_encode__($json); } // <-- public function test_payment(){ if(!isset($_POST['payment'])) { return false; } $pay_arr = explode('&',$_POST['payment']); foreach($pay_arr as $k => $v){ $temp = explode('=',$v); $payment[$temp[0]] = $temp[1]; } $rowcount = $this->database->update(DB_PREFIX.'payments_pb',array( 'complitedate' => date("Y-m-d H:i:s"), 'amt' => $payment['amt'], 'state' => $payment['state'], 'ref' => $payment['ref'], 'bankdate' => $payment['date'] ),"id={$payment['order']} AND state='create'"); if($rowcount>0){ $rc = $this->database->update(DB_PREFIX.'users',array( 'balance' => (session::get('balance')+$payment['amt']) ),"id=".session::get('id_user')); session::set('balance',session::get('balance')+$payment['amt']); return true; } return false; } public function new_payment(){ $order_id = $this->database->insert(DB_PREFIX.'payments_pb',array( 'user_id' => session::get('id_user'), 'state' => 'create' )); return $order_id; } // НАСТРОЙКИ public function save_photo($fn){ if(isset($_POST['data'])){ $path = PATH_USER_IMAGES.session::get('id_user'); if(!is_dir($path)){ mkdir($path); } if(bootstrap::base64_to_jpeg($_POST['data'],$path.'/'.$fn.'.jpg')){ echo '{"status":"success","url":"'.$path.'/'.$fn.'.jpg"}'; exit; } } $save = false; if($save){ //$json = session::set('json',$json); ajax::success(true); }else{ echo '{"error":"Ошибка сохранения"}'; exit; } } public function save_main(){ $fio = $_POST['fio']; $country_id = intval($_POST['country_id']); $region_id = intval($_POST['region_id']); $city_id = intval($_POST['city_id']); $country = $_POST['country']; $region = $_POST['region']; $city = $_POST['city']; $email = $_POST['email']; $pass = $_POST['pass']; $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; $user_id = session::get('id_user'); $old_email = session::get('email'); $email_confirmed = session::get('email_confirmed'); if (strlen($fio)<3){ echo '{"fail":"Введите своё имя"}'; exit; } if (!$country_id>0){ echo '{"fail":"Укажите страну."}'; exit; } if (!$region_id>0){ echo '{"fail":"Укажите регион."}'; exit; } if (!$city_id>0){ echo '{"fail":"Укажите город."}'; exit; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)){ echo '{"fail":"E-mail указан не верно."}'; exit; }else{ // смена email if($old_email!=$email){ $email_confirmed = 0; session::set('email', $email); session::set('email_confirmed', $email_confirmed); $this->send_email_activate(); } } // Смена пароля if (strlen($pass)>3){ $sth = $this->database->prepare("SELECT * FROM `".DB_PREFIX."users` WHERE `id`=:uid AND `password`=:password AND `block`='0';"); $sth->execute(array(':uid' => $user_id, ':password' =>hash::create('sha256',$pass,HASH_STATIC))); $count = $sth->rowCount(); if ($count > 0) { if (strlen($pass1)<4){ echo '{"fail":"Пароль не может состоять меньше 4 символов."}'; exit; } if ($pass1!=$pass2){ echo '{"fail":"Пароли не совпадают."}'; exit; } $rowcount = $this->database->update(DB_PREFIX.'users',array( 'password' =>hash::create('sha256',$pass1,HASH_STATIC) ),"id={$user_id}"); if($rowcount>0){ $message = '

Здравствуйте, '.$fio.'!


Вы получили это письмо, так как изменили пароль учетной записи на сайте doncode.com.ua

Ваш логин: '.session::get('login').'

Для входа в систему нажмите здесь '; $this->mail->send($email, "Изменение пароля учетной записи", $message); } }else{ echo '{"fail":"Ошибка пароля."}'; exit; } } if($fio!=session::get('fio')||$country_id!=session::get('country_id')||$region_id!=session::get('region_id')||$city_id!=session::get('city_id')||$old_email!=$email){ $rowcount = $this->database->update(DB_PREFIX.'users',array( 'FIO' =>$fio, 'email' =>$email, 'email_confirmed'=>$email_confirmed, 'country_id' =>$country_id, 'region_id' =>$region_id, 'city_id' =>$city_id ),"id={$user_id}"); if($rowcount>0){ $json = session::set('country_id',$country_id); $json = session::set('region_id',$region_id); $json = session::set('city_id',$city_id); $json = session::set('country',$country); $json = session::set('region',$region); $json = session::set('city',$city); ajax::success(true); }else{ echo '{"fail":"Ошибка сохранения настроек!"}'; exit; } }else{ ajax::success(true); } } public function send_email_activate($return_ajax=0){ $user_id = session::get('id_user'); $fio = session::get('fio'); $login = session::get('login'); $email = session::get('email'); $activate_key = hash::create('sha256',$login.$email.$user_id,HASH_STATIC); $insertkeyid = $this->database->insert(DB_PREFIX.'activate_email',array( 'key' =>$activate_key, 'user_id' =>$user_id )); $message = '

Здравствуйте, '.$fio.'!


Вы получили это письмо, так как изменили адрес электронной почты на сайте doncode.com.ua

Внимание! Для активации нового адреса '.$email.' нажмите здесь '; $this->mail->send($email, "Изменение адреса электронной почты", $message); if($return_ajax)ajax::success(true); } public function save_event(){ $callon =isset($_POST['callon'])?1:0; $smson =isset($_POST['smson'])?1:0; $showphone =isset($_POST['showphone'])?1:0; $emailon =isset($_POST['emailon'])?1:0; $emailnews =isset($_POST['emailnews'])?1:0; $json = session::get('json'); $json['events']['callon'] = $callon; $json['events']['smson'] = $smson; $json['events']['showphone'] = $showphone; $json['events']['emailon'] = $emailon; $json['events']['emailnews'] = $emailnews; $user_id = session::get('id_user'); $rowcount = $this->database->update(DB_PREFIX.'users',array( 'json' =>json_encode($json) ),"id={$user_id}"); if($rowcount>0){ $json = session::set('json',$json); ajax::success(true); }else{ echo '{"fail":"Ошибка сохранения настроек!"}'; exit; } } public function save_driver(){ $phone_call = preg_replace("/[^0-9]/","",$_POST['phone_call']); $phone_work = preg_replace("/[^0-9]/","",$_POST['phone_work']); $car_mark = intval($_POST['car_mark']); $car_model = intval($_POST['car_model']); $car_color = intval($_POST['car_color']); $car_date = intval($_POST['car_date']); $car_nr = $_POST['car_nr']; $dl_nr = $_POST['dl_nr']; $dl_date = $_POST['dl_date']; $dl_cat = $_POST['dl_cat']; $bdate = $_POST['bdate']; $pas_fio = $_POST['pas_fio']; $pas_nr = $_POST['pas_nr']; $pas_who = $_POST['pas_who']; $pas_date = $_POST['pas_date']; $pas_home = $_POST['pas_home']; $pas_inn = $_POST['pas_inn']; if ($car_mark==0){ echo '{"fail":"Выберите марку автомобиля","failid":"car","focus":"car_mark"}'; exit; } if ($car_model==0){ echo '{"fail":"Выберите модель автомобиля","failid":"car","focus":"car_model"}'; exit; } if ($car_color==0){ echo '{"fail":"Выберите цвет автомобиля","failid":"car","focus":"car_color"}'; exit; } if (strlen($car_nr)<3){ echo '{"fail":"Введите номер автомобиля","failid":"car","focus":"car_nr"}'; exit; } if (strlen($car_date)<4){ echo '{"fail":"Введите год выпуска автомобиля","failid":"car","focus":"car_date"}'; exit; } if (strlen($dl_nr)<3){ echo '{"fail":"Введите номер водительского удостоверения","failid":"dl","focus":"dl_nr"}'; exit; } if (strlen($dl_date)<3){ echo '{"fail":"Введите дату выдачи водительского удостоверения","failid":"dl","focus":"dl_date"}'; exit; } if (strlen($dl_cat)<1){ echo '{"fail":"Введите категории водительского удостоверения","failid":"dl","focus":"dl_cat"}'; exit; } if (strlen($bdate)<3){ echo '{"fail":"Введите Вашу дату рождения","failid":"dl","focus":"bdate"}'; exit; } if (strlen($pas_fio)<3){ echo '{"fail":"Введите ФИО","failid":"pas1","focus":"pas_fio"}'; exit; } if (strlen($pas_nr)<3){ echo '{"fail":"Введите серию и номер паспорта","failid":"pas1","focus":"pas_nr"}'; exit; } if (strlen($pas_who)<3){ echo '{"fail":"Введите кем выдан паспорт","failid":"pas2","focus":"pas_who"}'; exit; } if (strlen($pas_date)<3){ echo '{"fail":"Выберите когда выдан паспорт","failid":"pas2","focus":"pas_date"}'; exit; } if (strlen($pas_home)<3){ echo '{"fail":"Введите Вашу прописку","failid":"pas3","focus":"pas_home"}'; exit; } if (strlen($pas_inn)<3){ echo '{"fail":"Введите идентификационный номер налогоплатильщика ИНН","failid":"pas3","focus":"pas_inn"}'; exit; } if (strlen($phone_call)<10){ echo '{"fail":"Телефон не может состоять меньше 10 символов","failid":"phones","focus":"phone_call"}'; exit; } if (strlen($phone_work)<10){ echo '{"fail":"Телефон не может состоять меньше 10 символов","failid":"phones","focus":"phone_work"}'; exit; } $count = $this->database->update(DB_PREFIX.'drivers',array( 'active' =>'0', 'mark_id' =>$car_mark, 'model_id' =>$car_model, 'color_id' =>$car_color, 'car_nr' =>$car_nr, 'car_date' =>$car_date, 'dl_nr' =>$dl_nr, 'dl_date' =>$dl_date, 'dl_cat' =>$dl_cat, 'bdate' =>$bdate, 'pas_fio' =>$pas_fio, 'pas_nr' =>$pas_nr, 'pas_who' =>$pas_who, 'pas_date' =>$pas_date, 'pas_home' =>$pas_home, 'pas_inn' =>$pas_inn, 'phone_call' =>$phone_call, 'phone_work' =>$phone_work ),"id=".session::get('driver_id')); if($count>0){ session::set('driver_active',0); $message = '

Здравствуйте, '.session::get('fio').'


Вы изменили данные в анкете водителя на Бирже Такси doncode.com.ua

Внимание! Для подтверждения введенных Вами данных и доступа к работе, загрузите фотографии документов в Вашем профиле, которые соответствуют новым данным!

После проверки данных Ваша анкета будет активирована! Также с Вами может связаться менеджер компании в рабочее время '.WORK_TIME.' '; $this->mail->send_uid(session::get('id_user'), "Изменены анкетные данные водителя", $message); // отправка админу $message = '

Имя водителя: '.session::get('fio').'


Позывной: '.session::get('driver_id').' '; $this->mail->send_uid(1, "Изменены анкетные данные водителя ".session::get('driver_id'), $message); ajax::success(true); }else{ echo '{"fail":"Ошибка создания аккаунта водителя."}'; exit; } } public function getUserByPhone($phone){ $phone = trim($phone); if (substr($phone,1,1)=='+'){ $phone = substr($phone,1); } if(strlen($phone)<11){ return null; } try{ $sth = $this->database->prepare("SELECT u.* FROM `".DB_PREFIX."users` u WHERE u.login='".$phone."' LIMIT 1"); $sth->execute(); $data = $sth->fetchAll(PDO::FETCH_ASSOC); }catch(PDOException $e){ //echo $e->getMessage();exit; return $e->getMessage(); } //var_export($data);exit; return $data[0]; } public function getDriver($driver_id=0){ if ($driver_id==0){ return; } try{ $sth = $this->database->prepare("SELECT du.id as user_id, d.id as driver_id, du.balance, d.*, cm.mark, cmo.model, cc.name as color, co.country_name_ru as country,r.region_name_ru as region,c.city_name_ru as city, co.currency FROM `".DB_PREFIX."drivers` d INNER JOIN ".DB_PREFIX."users du ON d.`id` = du.`driver_id` LEFT JOIN ".DB_PREFIX."car_mark cm ON cm.`id` = d.`mark_id` LEFT JOIN ".DB_PREFIX."car_model cmo ON cmo.`id` = d.`model_id` LEFT JOIN ".DB_PREFIX."car_colors cc ON cc.`id` = d.`color_id` INNER JOIN city_ c ON c.`id_city` = du.`city_id` INNER JOIN region_ r ON r.`id_region` = c.`id_region` INNER JOIN country_ co ON co.`id_country` = c.`id_country` WHERE d.id='".$driver_id."' LIMIT 1"); $sth->execute(); $data = $sth->fetchAll(PDO::FETCH_ASSOC); }catch(PDOException $e){ //echo $e->getMessage();exit; return $e->getMessage(); } //var_export($data);exit; return $data[0]; } public function getExchange($exchange_id=0){ if ($exchange_id==0){ return; } try{ $sth = $this->database->prepare("SELECT d.id as driver_id, d.*, dc.host,dc.port,dc.mob_port,dc.ver,dc.last_update,dc.last_backup,dc.key, co.country_name_ru as country,r.region_name_ru as region,c.city_name_ru as city, co.currency FROM `".DB_PREFIX."exchange` d LEFT JOIN `".DB_PREFIX."dcc` dc ON dc.`id` = d.`dcc_id` INNER JOIN city_ c ON c.`id_city` = d.`city_id` INNER JOIN region_ r ON r.`id_region` = c.`id_region` INNER JOIN country_ co ON co.`id_country` = c.`id_country` WHERE d.id='{$exchange_id}' LIMIT 1"); $sth->execute(); $data = $sth->fetchAll(PDO::FETCH_ASSOC); //print_r($data[0]); return $data[0]; }catch(PDOException $e){ //echo $e->getMessage();exit; return $e->getMessage(); } //var_export($data);exit; return false; } public function changeExchange($ex_id=0){ $exchange_id = isset($_POST['ex_id'])?intval($_POST['ex_id']):$ex_id; if ($exchange_id==0){ return; } try{ $count = $this->database->update(DB_PREFIX.'users',array( 'exchange_id' =>$exchange_id ),"id=".session::get('id_user')); session::set('exchange_id',$exchange_id); $exchanges = $this->getUserExchanges(); session::set('dcc_id',$exchanges[$exchange_id]['dcc_id']); session::set('exchange_active',$exchanges[$exchange_id]['active']); session::set('taxi_name',$exchanges[$exchange_id]['taxi_name']); session::set('taxi_host',$exchanges[$exchange_id]['host']); session::set('taxi_port',$exchanges[$exchange_id]['port']); session::set('taxi_key',$exchanges[$exchange_id]['key']); ajax::success(true); exit; }catch(PDOException $e){ //echo $e->getMessage();exit; return $e->getMessage(); } //var_export($data);exit; echo '{"fail":"Ошибка изменения диспетчерской."}'; exit; } public function signup_exchange(){ if(!ajax::check_ajax_request()) { header('Location:'.$this->_redirect ); exit; } $taxi = $_POST['taxi']; $director = $_POST['director']; $director_phone = preg_replace("/[^0-9]/","",$_POST['director_phone']); $policy =isset($_POST['policyexchange'])?1:0; if (strlen($taxi)<2){ echo '{"fail":"Введите название диспетчерской","failid":"taxi","focus":"taxi"}'; exit; } if (strlen($director)<2){ echo '{"fail":"Введите ФИО директора","failid":"director","focus":"director"}'; exit; } if (strlen($director_phone)<10){ echo '{"fail":"Телефон не может состоять меньше 10 символов","failid":"director","focus":"director_phone"}'; exit; } if ($policy==0){ echo '{"fail":"Примите условия использования сервиса","failid":"policyexchange","focus":"policyexchange"}'; exit; } // reCapcha $myCurl = curl_init(); $request['secret'] = SECRET_RECAPCHA; $request['response'] = $_POST['g-recaptcha-response']; curl_setopt_array($myCurl, array( CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify', CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($request) )); $response = curl_exec($myCurl); curl_close($myCurl); $capcha = json_decode($response,true); if(!is_array($capcha)||$capcha['success']==false){ echo '{"fail":"Подтвердите что Вы не робот"}'; exit; } $insertid = $this->database->insert(DB_PREFIX.'exchange',array( 'city_id' =>session::get('city_id'), 'taxi_name' =>$taxi, 'director' =>$director, 'director_phone' =>$director_phone )); if($insertid>0){ $this->database->insert(DB_PREFIX.'exchange_relations',array( 'exchange_id' =>$insertid, 'user_id' =>session::get('id_user') )); $this->database->update(DB_PREFIX.'users',array( 'exchange_id' => $insertid ),"id=".session::get('id_user')); $this->database->update('user_role',array( 'role_id' => 4 ),"user_id=".session::get('id_user').' AND (role_id=2 OR role_id=3)'); session::set('taxi_name',$taxi); session::set('exchange_id',$insertid); session::set('exchange_active',0); $message = '

Здравствуйте, '.session::get('fio').'


Вы отправили заявку на регистрацию диспетчерской '.$taxi.' на Бирже Такси doncode.com.ua

Внимание! Для активации службы с Вами свяжется менеджер в рабочее время '.WORK_TIME.'

Будем рады сотрудничать с Вами! '; $this->mail->send_uid(session::get('id_user'), "Заявка на регистрацию диспетчерской", $message); // отправка админу $message = '

Новая диспетчерская: '.$taxi.'


Директор: '.$director.'
Телефон: '.$director_phone.'
'; $this->mail->send_uid(1, "Новая диспетчерская ".$taxi, $message); ajax::success(true); }else{ echo '{"fail":"Ошибка создания диспетчерской."}'; exit; } } // <--- НАСТРОЙКИ // Создание заказа (еще не подтвержден!!!) public function addorder($from_api=false){ $object = isset($_POST['object'])?$_POST['object']:0; $adres = isset($_POST['adres'])?$_POST['adres']:''; $house = isset($_POST['house'])?$_POST['house']:''; $porch = isset($_POST['porch'])?$_POST['porch']:''; $comment = isset($_POST['comment'])?$_POST['comment']:''; $thecity =isset($_POST['thecity'])?1:0; $saveadres =isset($_POST['saveadres'])?1:0; $adresX = isset($_POST['adresX'])?$_POST['adresX']:''; $houseX = isset($_POST['houseX'])?$_POST['houseX']:''; $objectX = isset($_POST['objectX'])?$_POST['objectX']:''; if(is_array($adresX)){ foreach($adresX as $k => $v){ $ad['adres'] = $adresX[$k]; $ad['house'] = $houseX[$k]; $ad['object'] = $objectX[$k]; $adresXarr[] = $ad; } } $options = isset($_POST['options'])?$_POST['options']:array(); $ontime = isset($_POST['ontime'])?$_POST['ontime']:0; $ontimedate = isset($_POST['ontimedate'])?$_POST['ontimedate']:''; $ontimetime = isset($_POST['ontimetime'])?$_POST['ontimetime']:''; $phone = isset($_POST['phone'])?preg_replace("/[^0-9]/","",$_POST['phone']):''; $fio = isset($_POST['fio'])?$_POST['fio']:''; $addcost = isset($_POST['addcost'])?$_POST['addcost']:0; $la = isset($_POST['la'])?$_POST['la']:0; $lo = isset($_POST['lo'])?$_POST['lo']:0; $distance = isset($_POST['distance'])?$_POST['distance']:0; $cost = isset($_POST['cost'])?$_POST['cost']:0; if (strlen($phone)<10){ echo '{"error":"100","error_msg":"Phone length < 10","fail":"Телефон не может быть меньше 10 символов","failid":"phone","focus":"phone"}'; exit; } if (strlen($adres)<2){ echo '{"error":"101","error_msg":"Adres length < 2","fail":"Адрес не может состоять меньше 2 символов","failid":"adres","focus":"adres"}'; exit; } if ($object==0&&strlen($house)<1){ echo '{"error":"102","error_msg":"House number empty","fail":"Введите номер дома","failid":"adres","focus":"house"}'; exit; } if ($thecity==0){ foreach($adresXarr as $k2 => $v2){ if (strlen($v2['adres'])<2){ echo '{"error":"103","error_msg":"Adres 2 length < 2","fail":"Куда едем? Введите адрес","failid":"adres'.$k2.'","focus":"adres'.$k2.'"}'; exit; } if ($v2['object']==0&&strlen($v2['house'])<1){ echo '{"error":"104","error_msg":"House 2 number empty","fail":"Куда едем? Введите номер дома","failid":"adres'.$k2.'","focus":"house'.$k2.'"}'; exit; } } } if(true){ session::set("order_phone",$phone); session::set("order_adres",$adres); session::set("order_house",$house); session::set("order_porch",$porch); session::set("order_comment",$comment); session::set("order_thecity",$thecity); session::set("order_adresX",$adresXarr); session::set("order_fio",$fio); session::set("order_ontime",$ontime); session::set("order_ontimedate",$ontimedate); session::set("order_ontimetime",$ontimetime); session::set("order_addcost",$addcost); session::set("order_la",$la); session::set("order_lo",$lo); session::set("order_distance",$distance); session::set("order_cost",$cost); session::set("order_options",$options); session::set("order_object",$object); session::set("order_saveadres",$saveadres); if($from_api)return; ajax::success(true); }else{ echo '{"fail":"Ошибка создания заказа."}'; exit; } } // Создание заказа (подтвержден!!!) public function create_order($from_api=false){ $order['user_id'] = session::get('id_user'); $order['city_id'] = session::get('city_id'); $order['status'] = 'new'; $order['ontime'] = session::get('order_ontime'); $order['ontimedate'] = session::get('order_ontimedate'); $order['ontimetime'] = session::get('order_ontimetime'); $order_id = $this->database->insert(DB_PREFIX.'orders',$order); if($order_id>0){ $json['adres'] = session::get('order_adres'); $json['house'] = session::get('order_house'); $json['porch'] = session::get('order_porch'); $json['object'] = session::get('order_object'); $json['comment'] = session::get('order_comment'); $json['thecity'] = session::get('order_thecity'); $json['adresX'] = session::get('order_adresX'); $json['phone'] = session::get('order_phone'); $json['fio'] = session::get('order_fio'); $json['addcost'] = session::get('order_addcost'); $json['la'] = session::get('order_la'); $json['lo'] = session::get('order_lo'); $json['distance'] = session::get('order_distance'); $json['cost'] = session::get('order_cost'); $json['options'] = session::get('order_options'); $adres_id = $this->database->insert(DB_PREFIX.'orders_adres',array( 'order_id' => $order_id, 'json' => $this->json_encode__($json) )); if($adres_id>0){ $order_createdate = date("Y-m-d H:i:s"); session::set('order_id',$order_id); session::set('last_order_id',$order_id); session::set('order_createdate',$order_createdate); $result = array_merge($order, $json); $result['cmd'] = 'new_order'; $result['order_id'] = $order_id; $result['order_createdate'] = $order_createdate; command::send($this->json_encode__($result)); if($from_api)return $order_id; ajax::success(true); }else{ echo '{"error":"105","error_msg":"Create error","fail":"Ошибка создания адреса."}'; exit; } if(session::get('order_saveadres')==1){ $this->database->insert(DB_PREFIX.'users_adres',array( 'user_id' =>session::get('id_user'), 'city_id' =>session::get('city_id'), 'adres' =>session::get('order_adres'), 'house' =>session::get('order_house'), 'porch' =>session::get('order_porch'), 'comment' =>session::get('order_comment'), 'object' =>session::get('order_object'), 'name' =>session::get('order_adres') )); } }else{ echo '{"fail":"Ошибка создания заказа."}'; exit; } } // Отмена заказа public function cancel_order(){ $ord = new order(); if($ord->cancel(session::get('order_id'),300)){ session::set('order_id',0); ajax::success(true); }else{ echo '{"fail":"Ошибка отмены заказа."}'; exit; } } // Мои адреса public function getAdresListCities(){ try{ $sth = $this->database->prepare("SELECT ua.city_id,co.country_name_ru as country,r.region_name_ru as region,c.city_name_ru as city FROM `".DB_PREFIX."users_adres` ua INNER JOIN city_ c ON c.`id_city` = ua.`city_id` INNER JOIN region_ r ON r.`id_region` = c.`id_region` INNER JOIN country_ co ON co.`id_country` = c.`id_country` WHERE ua.user_id=".session::get('id_user')." GROUP BY ua.`city_id`"); $sth->execute(); $data = $sth->fetchAll(PDO::FETCH_ASSOC); }catch(PDOException $e){ return $e->getMessage(); } //var_export($data);exit; return $data; } public function getAdresListCount($city_id=0){ $where = ''; if ($city_id>0){ $where = " AND ua.city_id='".$city_id."'"; } try{ $sth = $this->database->prepare("SELECT count(*) as count FROM `".DB_PREFIX."users_adres` ua WHERE ua.user_id=".session::get('id_user').$where.""); echo $sth->execute(); $data = $sth->fetchAll(PDO::FETCH_ASSOC); }catch(PDOException $e){ //echo $e->getMessage();exit; return $e->getMessage(); } //var_export($data);exit; return $data[0]['count']; } public function getAdresList($city_id=0,$page=0){ $where = ''; if ($city_id>0){ $where = " AND ua.city_id='".$city_id."'"; } if ($page!=0){ $page_number=abs(($page-1)*LIMIT); }else{ $page_number=0; } try{ $sth = $this->database->prepare("SELECT ua.*,co.country_name_ru as country,r.region_name_ru as region,c.city_name_ru as city FROM `".DB_PREFIX."users_adres` ua INNER JOIN city_ c ON c.`id_city` = ua.`city_id` INNER JOIN region_ r ON r.`id_region` = c.`id_region` INNER JOIN country_ co ON co.`id_country` = c.`id_country` WHERE ua.user_id=".session::get('id_user').$where." ORDER BY ua.id DESC LIMIT ".$page_number." , ".LIMIT.""); $sth->execute(); $data = $sth->fetchAll(PDO::FETCH_ASSOC); }catch(PDOException $e){ //echo $e->getMessage();exit; return $e->getMessage(); } return $data; } // ---------------------------------------------------- public function getEventsLogCount($type='all'){ $where = ''; if ($type!='all'){ $where = " AND ue.type='".$type."'"; } try{ $sth = $this->database->prepare("SELECT count(*) as count FROM `".DB_PREFIX."users_events_log` ue WHERE user_id=".session::get('id_user')." ".$where.""); echo $sth->execute(); $data = $sth->fetchAll(PDO::FETCH_ASSOC); }catch(PDOException $e){ //echo $e->getMessage();exit; return $e->getMessage(); } //var_export($data);exit; return $data[0]['count']; } public function getEventsLog($type='all',$page=0){ $where = ''; if ($type!='all'){ $where = " AND ue.type='".$type."'"; } if ($page!=0){ $page_number=abs(($page-1)*LIMIT); }else{ $page_number=0; } try{ $sth = $this->database->prepare("SELECT ue.* FROM `".DB_PREFIX."users_events_log` ue WHERE user_id=".session::get('id_user')." ".$where." ORDER BY ue.datetime DESC LIMIT ".$page_number." , ".LIMIT.""); $sth->execute(); $data = $sth->fetchAll(PDO::FETCH_ASSOC); foreach($data as $k => $v){ $data[$k]['datetime'] = bootstrap::HumanDatePrecise($v['datetime']); } }catch(PDOException $e){ //echo $e->getMessage();exit; return $e->getMessage(); } //var_export($data);exit; return $data; } // ----------------------------------------------------- public function getCars (){ if(ajax::check_ajax_request()) { if(session::get('gid')>0){ $sth=$this->database->prepare("SELECT gps FROM `dcc` WHERE `gid`='".session::get('gid')."' AND `deleted`=0"); $sth->execute(); $r = $sth->fetch(); $ar = explode('|',$r['gps']); if(is_array($ar)){ //var_export($ar);exit; $i=0; foreach($ar as $k => $v){ $l = explode(',',$v); for($y=0;$y<10;$y++){ if(isset($l[$y])){$j[$i][$y]=$l[$y];} } $i++; } //$this->view->gps = $j;//json_encode($j,true); header('Content-type: application/json'); $arr['gps'] = $j; $arr['la'] = session::get('la'); $arr['lo'] = session::get('lo'); echo json_encode($arr,JSON_NUMERIC_CHECK); } } } } public function setLocation (){ if(ajax::check_ajax_request()) { $arr['la'] = $_POST['la']; $arr['lo'] = $_POST['lo']; session::set('la',$arr['la']); session::set('lo',$arr['lo']); if(session::get('gid')<1){ $found = false; $sth= $this->database->query("SELECT gid,parks,la,lo,zoom,city_id,gps,host,port FROM dcc WHERE deleted='0'"); $sth->execute(); $r= $sth->fetchAll(); //var_export($r); foreach($r as $k => $v){ if($found){continue;} $p = explode('~',$v['parks']); $i=0; foreach($p as $k1 => $v1){ if($found){continue;} $l = explode('|',$v1); if(isset($l[2])){ $coords = json_decode($l[2],true); //var_export($coords[0]); if($this->into_poly($arr['la'], $arr['lo'], $coords[0])){ $found = true; session::set('gid',$v['gid']); session::set('city_id',$v['city_id']); session::set('host',$v['host'].':'.$v['port']); session::set('gps',json_decode(base64_decode($v['gps']),true)); $arr['map_la'] = $v['la']; $arr['map_lo'] = $v['lo']; //echo 'FOUND
'; continue; } } $i++; } } if(!$found){ session::set('gid',8); session::set('city_id',3184); $sth= $this->database->query("SELECT host,port,gps FROM dcc WHERE deleted='0' AND gid='8'"); $sth->execute(); $r= $sth->fetchAll(); var_export($r);exit; session::set('host',$r[0]['host'].':'.$r[0]['port']); session::set('gps',json_decode(base64_decode($r[0]['gps']),true)); //echo 'SET DEFAULT
'; } }else{ $gid = session::get('gid'); $sth= $this->database->query("SELECT host,port,gps FROM dcc WHERE deleted='0' AND gid='".$gid."' "); $sth->execute(); $r= $sth->fetchAll(); //var_export($r);exit; session::set('host',$r[0]['host'].':'.$r[0]['port']); session::set('gps',json_decode(base64_decode($r[0]['gps']),true)); } $arr['gid'] = session::get('gid'); $arr['city_id'] = session::get('city_id'); if(!isset($arr['map_la'])){ $arr['map_la'] = $arr['la']; $arr['map_lo'] = $arr['lo']; } if(session::get('gps')!=''){ $arr['gps'] = session::get('gps'); if(is_array($arr['gps'])){ foreach($arr['gps'] as $k => $v){ $arr['gps'][$k]['ch'] = substr($v['login'],0,1); $arr['gps'][$k]['poz'] = substr($v['login'],1); if($v['la']==''){ unset($arr['gps'][$k]); } } } } $arr['host'] = session::get('host'); header('Content-type: application/json'); echo json_encode($arr); //var_export($_SESSION); } } public function into_poly($sx, $sy, $coords, $x=0, $y=1){ $pj=0; $pk=0; $wrkx=0; $yu = 0; $yl = 0; $n = count($coords); for ($pj=0; $pj<$n; $pj++) { $yu = $coords[$pj][$y]>$coords[($pj+1)%$n][$y]?$coords[$pj][$y]:$coords[($pj+1)%$n][$y]; $yl = $coords[$pj][$y]<$coords[($pj+1)%$n][$y]?$coords[$pj][$y]:$coords[($pj+1)%$n][$y]; if ($coords[($pj+1)%$n][$y] - $coords[$pj][$y]) $wrkx = $coords[$pj][$x] + ($coords[($pj+1)%$n][$x] - $coords[$pj][$x])*($sy - $coords[$pj][$y])/($coords[($pj+1)%$n][$y] - $coords[$pj][$y]); else $wrkx = $coords[$pj][$x]; if ($yu >= $sy) if ($yl < $sy) { if ($sx > $wrkx) $pk++; if (abs($sx - $wrkx) < 0.00001) return 1; } if ((abs($sy - $yl) < 0.00001) && (abs($yu - $yl) < 0.00001) && (abs(abs($wrkx - $coords[$pj][$x]) + abs($wrkx - $coords[($pj+1)%$n][$x]) - abs($coords[$pj][$x] - $coords[($pj+1)%$n][$x])) < 0.0001)) return 1; } if ($pk%2) return 1; else return 0; } public function getDCC ($gid,$ajax=false){ $sth=$this->database->prepare("SELECT d.`gid` as id, c.`city_name_ru`, co.`country_name_ru`,d.`taxi_name`,d.internet,d.la,d.lo,d.zoom,d.gps,d.auto_type,d.tariff,d.valuta,d.mobile_online,d.host,d.port,d.mob_port FROM `dcc` d INNER JOIN `city_` c ON c.`id_city`=d.`city_id` INNER JOIN `country_` co ON c.`id_country`=co.`id_country` WHERE `gid`='{$gid}' AND d.`deleted`=0"); $sth->execute(); if ($ajax){ echo json_encode($sth->fetch()); }else{ return $sth->fetchAll(); } //header('Content-type: application/json'); //echo json_encode($arr,JSON_NUMERIC_CHECK); } //------------------------------------------------------ public function getRegions ($ajax=false){ // Города добавленные в каталог $sth=$this->database->prepare("SELECT d.`internet` ,c.`id_city`, c.`city_name_ru`, r.`region_name_ru`, co.`country_name_ru` FROM `city_` c INNER JOIN `region_` r ON c.`id_region`=r.`id_region` INNER JOIN `country_` co ON c.`id_country`=co.`id_country` LEFT JOIN `dcc` d ON c.`id_city`=d.`city_id` WHERE c.`catalog`=1 GROUP BY c.`id_city`"); $sth->execute(); if ($ajax){ echo json_encode($sth->fetch()); }else{ return $sth->fetchAll(); } } public function getOptions ($ajax=false){ // Города добавленные в каталог $sth=$this->database->prepare("SELECT * FROM `options` WHERE `deleted`='0'"); $sth->execute(); if ($ajax){ echo json_encode($sth->fetch()); }else{ return $sth->fetchAll(); } } }