public function update_image_students() { $this->use->use_model('data_base'); $this->use->use_lib('table/tpl_students'); $this->use->use_lib('system/image/class_upload_image'); $tpl = new tpl_students(); $image = new class_upload_image('image_students_update', 'include/img/student'); if ($image->get_type() == 'image/png' || $image->get_type() == 'image/jpeg') { if ($image->get_error()) { $image_path = $image->move_file(); if ($image_path == false) { echo json_encode(array('valid' => false)); } else { $db = new data_base($tpl->table(), array($tpl->image() => $image_path), array($tpl->id() => $_POST['id_image_update'])); if ($db->change()) { echo json_encode(array('valid' => true, 'image' => $image_path)); } else { echo json_encode(array('valid' => false)); } } } else { echo json_encode(array('valid' => false)); } } else { echo json_encode(array('valid' => false)); } }
public function find_users_login() { if (isset($_POST['username']) && isset($_POST['password'])) { if (!empty($_POST['username']) && !empty($_POST['password'])) { $this->use->use_model('data_base'); $this->use->use_lib('table/tpl_users'); $tpl = new tpl_users(); $db = new data_base($tpl->table(), array($tpl->id()), array($tpl->username() => $_POST['username'], $tpl->password() => md5($_POST['password']))); $data = $db->get_where(); if (!empty($data)) { $this->use->use_lib('site/sessions'); $session = new sessions(); if ($session->new_login_admin()) { $session->info_user($data); return json_encode(array('valid' => true, 'massage' => '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>welcome Back </strong></div>')); } else { return json_encode(array('valid' => false, 'massage' => '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>Error login</strong></div>')); } } else { return json_encode(array('valid' => false, 'massage' => '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>Incorrect password or username </strong></div>')); } } else { return json_encode(array('valid' => false, 'massage' => '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>The field is required and can\'t be empty</strong></div>')); } } else { return json_encode(array('valid' => false, 'massage' => '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>The field is required and can\'t be empty</strong></div>')); } }
public function find_slider() { $this->use->use_model('data_base'); $this->use->use_lib('table/tpl_slider'); $tpl = new tpl_slider(); $db = new data_base($tpl->table(), array($tpl->id(), $tpl->text(), $tpl->image()), array($tpl->status() => 1)); return $db->get_where(); }
public function update_specialty() { $this->use->use_model('data_base'); $this->use->use_lib('table/tpl_specialty'); $tpl = new tpl_specialty(); $db = new data_base($tpl->table(), array($tpl->id_college() => $_POST['name_college_update'], $tpl->name() => $_POST['name_update']), array($tpl->id() => $_POST['id'])); echo json_encode(array('valid' => $db->change(), 'massage' => '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>Update success </strong></div>')); }
public function find_companies() { $db = new data_base(tpl_companies::companies(), array(tpl_companies::id(), tpl_companies::active(), tpl_companies::name()), array(tpl_companies::active() => 1)); $data = $db->get_where(); $w = ''; foreach ($data as $row) { $w = $w . '<option value="' . $row[tpl_companies::id()] . '">' . $row[tpl_companies::name()] . '</option>'; } return $w; }
public function find($id) { $db = new data_base(tpl_college::college(), array("*"), array(tpl_college::id() => $id)); $results = $db->get_where(); if (!empty($results)) { return $results; } else { return false; } }
public function update_user() { $this->use->use_model('data_base'); $this->use->use_lib('table/tpl_users'); $tpl = new tpl_users(); $data = array($tpl->username() => $_POST['username_update']); if (!empty($_POST['password_update'])) { $data[$tpl->password()] = md5($_POST['password_update']); } $db = new data_base($tpl->table(), $data, array($tpl->id() => $_POST['id'])); echo json_encode(array('valid' => $db->change(), 'massage' => '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>Update success </strong></div>')); }
public function update_status() { $id = $_POST[tpl_onus::onus() . '_' . tpl_onus::id()]; $status = $_POST[tpl_onus::onus() . '_' . tpl_onus::active()]; $db = new data_base(tpl_onus::onus(), array(tpl_onus::active() => $status), array(tpl_onus::id() => $id)); $results = $db->change(); $status_data = $status == 1 ? 'active' : 'dative'; if ($results) { echo json_encode(array('valid' => 1, 'title' => 'Successfully !!', 'massage' => 'I\'ve been Update ' . $status_data)); } else { echo json_encode(array('valid' => 0, 'title' => 'Oops !!', 'massage' => 'Was not Update ' . $status_data . ', please try again')); } }
public function find_users_login() { $db = new data_base(tpl_user_site::user_site(), array(tpl_user_site::id()), array(tpl_user_site::username() => $this->data[tpl_user_site::user_site() . '_' . tpl_user_site::username()], tpl_user_site::password() => $this->hash_password($this->data[tpl_user_site::user_site() . '_' . tpl_user_site::password()]), tpl_user_site::status() => 1)); $results = $db->get_where(); $results = array_shift($results); if (!empty($results[tpl_user_site::id()])) { $this->session->new_login_admin(); $this->session->set_id_user($results[tpl_user_site::id()]); return json_encode(array('valid' => true)); } else { return json_encode(array('valid' => false, 'title' => 'Oops !!', 'massage' => 'The password you\'ve entered is incorrect')); } }
/** * Конструктор класса * устанавливает массив с id устройств * задает токен для доступа к аккуанту * устанавливает устройства по умолчанию */ function __construct() { $this->devices = array(); $query = "SELECT device FROM devices WHERE is_active='1'"; $db = new data_base(); $devices = $db->super_query($query)->get_res(); foreach ($devices as $device) { $this->devices[] = $device[device]; } $query = "SELECT device FROM devices WHERE is_default='1'"; $default = $db->super_query($query, false)->get_res(); $this->set_token()->default_dev = $default[device]; }
public function ajax_find_students() { $db = new data_base(tpl_models::models(), array(tpl_models::id(), tpl_models::id_companies(), data_base::select_multiple_table(tpl_students::students(), tpl_students::students() . '.' . tpl_students::id(), tpl_models::models() . '.' . tpl_models::id_student(), tpl_students::first_name(), tpl_students::students() . '_' . tpl_students::first_name()), data_base::select_multiple_table(tpl_students::students(), tpl_students::students() . '.' . tpl_students::id(), tpl_models::models() . '.' . tpl_models::id_student(), tpl_students::last_name(), tpl_students::students() . '_' . tpl_students::last_name()), data_base::select_multiple_table(tpl_supervisor::supervisor(), tpl_supervisor::supervisor() . '.' . tpl_supervisor::id(), data_base::select_multiple_table(tpl_students::students(), tpl_students::students() . '.' . tpl_students::id(), tpl_models::models() . '.' . tpl_models::id_student(), tpl_students::id_supervisor()), tpl_supervisor::name(), tpl_supervisor::supervisor() . '_' . tpl_supervisor::name()), data_base::select_multiple_table(tpl_university::university(), tpl_university::university() . '.' . tpl_university::id(), data_base::select_multiple_table(tpl_students::students(), tpl_students::students() . '.' . tpl_students::id(), tpl_models::models() . '.' . tpl_models::id_student(), tpl_students::id_supervisor()), tpl_university::name(), tpl_university::university() . '_' . tpl_university::name()), data_base::select_multiple_table(tpl_college::college(), tpl_college::college() . '.' . tpl_college::id(), data_base::select_multiple_table(tpl_students::students(), tpl_students::students() . '.' . tpl_students::id(), tpl_models::models() . '.' . tpl_models::id_student(), tpl_students::id_supervisor()), tpl_college::name(), tpl_college::college() . '_' . tpl_college::name()), data_base::select_multiple_table(tpl_specialty::specialty(), tpl_specialty::specialty() . '.' . tpl_specialty::id(), data_base::select_multiple_table(tpl_students::students(), tpl_students::students() . '.' . tpl_students::id(), tpl_models::models() . '.' . tpl_models::id_student(), tpl_students::id_supervisor()), tpl_specialty::name(), tpl_specialty::specialty() . '_' . tpl_specialty::name()), data_base::select_multiple_table(tpl_department::department(), tpl_department::department() . '.' . tpl_department::id(), data_base::select_multiple_table(tpl_students::students(), tpl_students::students() . '.' . tpl_students::id(), tpl_models::models() . '.' . tpl_models::id_student(), tpl_students::id_supervisor()), tpl_department::name(), tpl_department::department() . '_' . tpl_department::name()), data_base::select_multiple_table(tpl_section::section(), tpl_section::section() . '.' . tpl_section::id(), data_base::select_multiple_table(tpl_students::students(), tpl_students::students() . '.' . tpl_students::id(), tpl_models::models() . '.' . tpl_models::id_student(), tpl_students::id_supervisor()), tpl_section::name(), tpl_section::section() . '_' . tpl_section::name())), array(tpl_models::id_companies() => $_GET['id'])); echo json_encode($db->get_where()); }
public function find_supervisor() { if (isset($_POST[tpl_students::id() . '_' . tpl_students::students()])) { $id = $_POST[tpl_students::id() . '_' . tpl_students::students()]; if (!empty($id)) { $db = new data_base(tpl_students::students(), array(tpl_students::id(), tpl_students::id_supervisor(), data_base::select_multiple_table(tpl_supervisor::supervisor(), tpl_supervisor::supervisor() . '.' . tpl_supervisor::id(), tpl_students::students() . '.' . tpl_students::id_supervisor(), tpl_supervisor::name(), tpl_supervisor::supervisor() . '_' . tpl_supervisor::name())), array(tpl_students::status() => 1, tpl_students::id() => $id)); $data = $db->get_where(); $w = '<option></option>'; foreach ($data as $row) { $w = $w . '<option value="' . $row[tpl_students::id_supervisor()] . '">' . $row[tpl_supervisor::supervisor() . '_' . tpl_supervisor::name()] . '</option>'; } echo $w; } else { echo 'error empty'; die; } } else { echo 'error isset'; exit; } }
public function count_all() { $this->use->use_model('data_base'); $this->use->use_lib('table/tpl_election'); $tpl = new tpl_election(); $db = new data_base($tpl->table(), array($tpl->id())); return count($db->get()); }
} else { if (is_string($this->result)) { echo $this->result; } else { if (is_int($this->result)) { echo $this->result; } else { echo $otvet; } } } } } include "mysql.php"; include "sms.php"; $db = new data_base(); $query = "SELECT token, devices FROM admin"; $result = $db->super_query($query)->get_res(); foreach ($result as $device) { $devices[] = explode(",", $device['devices']); } if (!isset($_COOKIE['PHPSESSID'])) { foreach ($result as $token) { $sms = new sms($devices, $token['token']); $in = $sms->get_in_sms(); if ($in['code'] == 0) { foreach ($in['data'] as $value) { $phone = str_replace("+7", "8", $value['phone']); $date_time = explode(" ", $value['date']); $query = "UPDATE `users` SET phone_ver='1', date_ver='" . $date_time[0] . "' WHERE phone='{$phone}' AND phone_ver='0'"; $db->query($query);
function get($id) { $query = "SELECT sended_sms.delivered, sended_sms.is_error, sended_sms.msg, sended_sms.id_rassilki, sended_sms.msg, sended_sms.id, sended_sms.phone as phone1,\n users.name, users.otch, users.phone, users.id, users.fam,\n sended_mass.tema\n FROM sended_sms\n Left Join users ON users.phone = sended_sms.phone\n LEFT JOIN sended_mass ON sended_mass.id = sended_sms.id_rassilki\n WHERE sended_sms.id_rassilki = {$id}"; $db = new data_base(); return $db->super_query($query)->get_res(); }
public function __construct() { parent::__construct(); }
public function info_onus_designate($id = null) { $db = new data_base(tpl_onus_designate::onus_designate(), array(tpl_onus_designate::id(), tpl_onus_designate::id_degree(), tpl_onus_designate::id_models(), tpl_onus_designate::id_student(), tpl_onus_designate::id_onus(), data_base::select_multiple_table(tpl_onus::onus(), tpl_onus::onus() . '.' . tpl_onus::id(), tpl_onus_designate::onus_designate() . '.' . tpl_onus_designate::id_onus(), tpl_onus::name(), tpl_onus::onus() . '_' . tpl_onus::name()), data_base::select_multiple_table(tpl_onus::onus(), tpl_onus::onus() . '.' . tpl_onus::id(), tpl_onus_designate::onus_designate() . '.' . tpl_onus_designate::id_onus(), tpl_onus::description(), tpl_onus::onus() . '_' . tpl_onus::description()), data_base::select_multiple_table(tpl_degree::degree(), tpl_degree::degree() . '.' . tpl_degree::id(), tpl_onus_designate::onus_designate() . '.' . tpl_onus_designate::id_degree(), tpl_degree::name(), tpl_degree::degree() . '_' . tpl_degree::name())), array(tpl_onus_designate::id_student() => $id)); return $db->get_where(); }
public function ajax_find_students() { $db = new data_base(tpl_students::students(), array(tpl_students::id(), tpl_students::first_name(), tpl_students::last_name(), tpl_students::id_college(), tpl_students::id_specialty(), data_base::select_multiple_table(tpl_specialty::specialty(), tpl_specialty::specialty() . '.' . tpl_specialty::id(), tpl_students::students() . '.' . tpl_students::id_specialty(), tpl_specialty::name(), tpl_specialty::specialty() . '_' . tpl_specialty::name()), data_base::select_multiple_table(tpl_college::college(), tpl_college::college() . '.' . tpl_college::id(), tpl_students::students() . '.' . tpl_students::id_college(), tpl_college::name(), tpl_college::college() . '_' . tpl_college::name())), array(tpl_students::id_college() => $_GET['id'])); echo json_encode($db->get_where()); }
public function select() { $db = new data_base(tpl_university::university(), array(tpl_university::id(), tpl_university::name()), array(tpl_university::active() => 1)); $data = $db->get_where(); $w = '<option value="">Select ' . tpl_university::university() . '</option>'; foreach ($data as $row) { $w = $w . '<option value="' . $row[tpl_university::id()] . '">' . $row[tpl_university::name()] . '</option>'; } return $w; }
function clear_rep(&$var) { $db = new data_base(); strip_tags(mysqli_real_escape_string($db->get_id_db(), trim($var))); }
public function count_university() { $db = new data_base(tpl_university::university(), array(tpl_university::id()), array(tpl_university::active() => 1)); return count($db->get_where()); }
/** * Метод для массовой рассылки сообщений * @date 18.08.15 * @param $msg - сообщение * @param $phones - массив телефонов * @param $tema - тема сообщения * @param $id * @return $this $result['code'] - вернет 0 при успехе, -1 при ошибке */ public function send_mass(&$msg, &$phones, &$tema, &$id, &$gorod) { $query = "SELECT can FROM want_to_send WHERE id={$id}"; $res = $this->db->super_query($query, false)->get_res() or false; if (!$res['can'] == '1') { $this->set_result(false); return $this; } $query = "DELETE FROM want_to_send WHERE id={$id}"; $this->db->query($query); $url = "https://semysms.net/api/3/sms_more.php"; //Адрес url для отправки СМС $params = array('token' => $this->get_token()); $query = "INSERT INTO sended_mass (phones, date, tema, msg, gorod, user_id)\n VALUES ('" . implode(',', $phones) . "', '" . date("Y-m-d") . "', '{$tema}', '{$msg}', {$gorod}, {$_SESSION['id']})"; $db = new data_base(); $res = $db->query($query); $id = $db->get_last_id(); // id рассылки $_SESSION['last_id'] = $id; unset($db, $res, $query); $sms_on_dev = (int) (count($phones) / count($this->device_class->get_devices())); $last = 0; $inc = 0; $resultat = array(); foreach ($this->device_class->get_devices() as $device) { $inc += $last; while ($last < $sms_on_dev + $inc) { $params['data'][] = array('my_id' => $id, 'device' => $device, 'phone' => $phones[$last], 'msg' => $msg, 'priority' => 0); $last++; } $last += $sms_on_dev; $params = json_encode($params); $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($params))); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $params); $result = curl_exec($curl); curl_close($curl); $result = json_decode($result, TRUE); if ($result['code'] == 0) { foreach ($result['data'] as $key => $item) { $this->to_database($item['id'], $msg, $phones[$key], $device, $item['my_id']); } $this->db->write_log(4, $tema); } $resultat[$device] = $result['code']; } $this->set_result($resultat); return $this; }
public function __construct($table) { parent::__construct($table); }
public function get_all_supervisor() { if (isset($_POST['id_university']) && isset($_POST['id_college'])) { $id_university = $_POST['id_university']; $id_college = $_POST['id_university']; if (!empty($id_university) && !empty($id_college)) { $db = new data_base(tpl_supervisor::supervisor(), array(tpl_supervisor::id(), tpl_supervisor::name()), array(tpl_supervisor::id_university() => $id_university, tpl_supervisor::id_college() => $id_college, tpl_supervisor::active() => 1)); $data = $db->get_where(); $w = ' <option></option>'; foreach ($data as $row) { $w = $w . '<option value="' . $row[tpl_specialty::id()] . '">' . $row[tpl_specialty::name()] . '</option>'; } echo $w; } else { echo json_encode(array('valid' => false, 'title' => 'Oops !!', 'massage' => 'error empty')); } } else { echo json_encode(array('valid' => false, 'title' => 'Oops !!', 'massage' => 'error isset')); } }