/** * Метод для добавление контактов в список рассылки * @param $name * @param $fam * @param $otch * @param $phone * @param $mail * @param $date * @param string $gorod * @param string $obl * @return $this */ public function add_new(&$name = "", &$fam = "", &$otch = "", &$phone, &$mail = "", &$gorod = "", &$obl = "") { $ret = $fam . " " . $name . " " . $otch; phoneReplace($phone); //Если контакт с таким номером уже есть, то он не будет добавлен if ($this->db->count_rows("SELECT id FROM users WHERE phone='{$phone}'")->get_res()) { $this->result = $ret; return $this; } //$conf_reg = ((int)$this->get_conf_reg() == 0) ? 1 : 0; $query = "INSERT INTO users (fam, name, otch, phone, mail, date, obl, gorod)\n\t\t\t\t\t\t\t VALUES ('{$fam}', '{$name}', '{$otch}', '{$phone}', '{$mail}', '" . date("Y-m-d") . "', "; switch ($this->get_prava()) { case 4: //добавление в рамках города $query .= "{$this->obl}, {$this->gorod})"; break; case 3: //В рамках области if ($gorod == "") { $query .= $this->obl . ", " . $this->gorod . ")"; } else { //Следующий код добавит город в текущую область, если его нет в базе if (!$this->db->count_rows("SELECT id FROM goroda WHERE obl='{$this->obl}' AND gorod='{$gorod}'")->get_res()) { $this->db->query("INSERT INTO goroda (gorod, obl) VALUES ('{$gorod}', '{$this->obl}')"); $gorod_id = $this->db->get_last_id(); } else { $gorod_id = $this->db->super_query("SELECT id FROM goroda WHERE gorod='{$gorod}'")->get_res(); } $query .= $this->obl . ", " . $gorod_id . ")"; } break; case 2: //добавление по всей стране if ($obl == "") { $query .= $this->obl . ", "; } else { //Добавит область, если её нет if (!$this->db->count_rows("SELECT id FROM obl WHERE obl='{$obl}'")->get_res()) { $this->db->query("INSERT INTO obl (obl) VALUES ('{$obl}')"); $obl_id = $this->db->get_last_id(); } else { $obl_id = $this->db->super_query("SELECT id FROM obl WHERE obl='{$obl}'")->get_res(); } $query .= $obl_id . ", "; } if ($gorod == "") { $query .= $this->gorod . ")"; } else { //Следующий код добавит город в текущую область, если его нет в базе if (!$this->db->count_rows("SELECT id FROM goroda WHERE obl='{$this->obl}' AND gorod='{$gorod}'")->get_res()) { $this->db->query("INSERT INTO goroda (gorod, obl) VALUES ('{$gorod}', '{$this->obl}')"); $gorod_id = $this->db->get_last_id(); } else { $gorod_id = $this->db->super_query("SELECT id FROM goroda WHERE gorod='{$gorod}'")->get_res(); } $query .= $gorod_id . ")"; } break; } $this->db->query($query) or $ret = false; /*Этот код отвечает за проверку номеров. Удалять жалко if ($ret){ $_SESSION['count']++; $_SESSION['added'] .= "<p>".$ret."</p>"; if (!$conf_reg) { $month = array ( '01' => "января", '02' => "февраля", '03' => "марта", '04' => "апреля", '05' => "мая", '06' => "июня", '07' => "июля", '08' => "августа", '09' => "сентября", '10' => "октября", '11' => "ноября", '12' => "декабря" ); $date_arr = explode("-", $date); $date_arr[2] = (string)$date_arr[2]; $date = $date_arr[2]." ".$month[$date_arr[1]]." ".$date_arr[0]." года"; unset($month); $msg = $this->get_conf_msg(); $msg = str_replace("[дата]", $date, $msg); $xd = $this->send_sms($msg, $phone)->get_result('code'); if ($xd == 0){ $query = "UPDATE users SET date_send_ver='".date("Y-m-d")."' WHERE phone='$phone'"; $this->db->query($query); } } } */ $this->result = $ret; $this->db->write_log(3, $this->db->get_last_id()); return $this; }
clear_rep($item); } } } else { $view = 'auth'; } } else { $view = 'auth'; } switch ($view) { case 'search': $title = TITLE . " - Поиск"; switch ($get) { case 'phone': $phone = $_POST['phone']; phoneReplace($phone); $query = "SELECT fam, name, otch, date FROM users WHERE phone='{$phone}'"; $db->super_query($query, false)->echo_result("json"); exit; break; } break; case 'auth': $title = TITLE . " - Авторизация"; $auth = false; if ($_GET['do'] == 'auth') { $us = new user($_POST['login'], $_POST['pass']); /* if ($auth) { echo "true"; exit(); }