function __construct() { require_once dirname(__FILE__) . '/db_connect.php'; // opening db connection $db = new db_connect(); $this->conn = $db->connect(); }
public function __construct() { include_once 'db_connect.php'; include_once 'functions.php'; try { $connect_db = new db_connect(); $this->link = $connect_db->connect(); $this->functions = new db_functions(); } catch (Exception $ex) { return mysqli_error($this->link); } }
public static function getInstance() { if (!self::$_instance) { self::$_instance = new db_connect(); } return self::$_instance; }
static function wisdomRecord($id = 0, $education = 0) { db_connect::connect(); if ($id != 0 && $education == 0) { $information = R::load('information', $id); $information->shortdescription = $_POST['shortdescription']; $information->category_id = $_GET['category']; $information->sharedUser[] = $_SESSION['user']; } elseif ($id == 0 && $education == 0) { $information = R::dispense('information'); $information->shortdescription = $_POST['shortdescription']; $information->category_id = $_GET['category']; $information->sharedUser[] = $_SESSION['user']; } elseif ($id != 0 && $education != 0) { // echo 1; $information = R::load('education', $education); $information->number = $_POST['number']; $information->information_id = $id; } $information->name = $_POST['name']; $information->description = $_POST['description']; $id = R::store($information); // print_r($id); return $id; }
/** * connexion a la BDD */ private static function connect () { self::$db_connect = new mysqli(self::$DB_SRV, self::$DB_USER, self::$DB_MDP, self::$DB_NAME); if (self::$db_connect->connect_error) { die('Erreur de connexion (' . self::$db_connect->connect_errno . ') ' . self::$db_connect->connect_error); } self::$instance = TRUE; }
public static function getInstance() { if (!self::$_instance) { // If no instance then make one self::$_instance = new self(); } return self::$_instance; }
public function __construct() { $this->_db = db_connect::getInstance(); $this->_mysqli = $this->_db->getConnection(); echo $this->PageHeader(); echo $this->LoadPageBody(); echo $this->LoadPageFooter(); $this->_functions = new functions(); }
function __construct($query, $array) { // $this->items = getDataBase::getData("SELECT * // FROM `menu` , `menu_item` // WHERE menu_item.menu_id =" . intval($id) . " // AND menu.menu_id = menu_item.menu_id"); db_connect::connect(); $this->items = R::getAll($query, $array); }
protected static function getData($query) { $out=array(); foreach (self::aaa($query) as $key => $value) { $out[$key] = $value; } parent::connect()->close(); return $out; }
public function __construct($dbo = NULL, $accountId = 0) { parent::__construct($dbo); $this->accountId = $accountId; if ($this->accountId != 0) { $account = new account($this->db, $this->accountId); $deviceId = $account->getGCM_regId(); if (strlen($deviceId) != 0) { $this->addDeviceId($deviceId); } } }
protected static function setData($query) { $out = array(); $result = parent::connect()->query($query); if ($result->num_rows > 0) { foreach ($result as $key => $value) { $out[$key] = $value; } return $out; } return true; }
function getWisdomByType($array, $wisdomArray, $page = 1) { if (!(int) $array[0]) { return false; } $out = ''; db_connect::connect(); if (empty($wisdomArray)) { $out .= "<h2>Ничего не найдено</h2>"; return $out; } foreach ($wisdomArray as $key => $value) { $out .= "<h2>" . $key . "</h2><table class='table table-striped'>\r\n <tr>\r\n <th>Название</th>\r\n <th>Автор</th>\r\n <th>Категория</th>\r\n <th>Субкатегория</th>\r\n </tr>"; foreach ($value as $smallKey => $subValue) { $category = R::load('category', $subValue['subcategory_id']); if ($array[3] && $array[2]) { $step = 10; $page3 = ($page - 1) * $step; $data = $category->withCondition('information.category_id = ? LIMIT ?,?', [$array[3], $page3, $step])->ownInformationList; self::$count_data += $category->withCondition('information.category_id = ? LIMIT ?,?', [$array[3], $page3, $step])->countOwn('information'); self::$path = "?ctrl=wisdom&action=WisdomType&type=" . $array[0] . "&subtype=" . $array[1] . "&category=" . $array[2] . "&subcategory=" . $array[3]; } else { $step = 10; $step1 = 2; // echo $page; $page2 = ($page - 1) * $step; $page1 = ($page - 1) * $step1; $data = $array[1] ? $category->with(' LIMIT ?,?', [$page2, $step])->ownInformationList : $category->with(' LIMIT ?,?', [$page1, $step1])->ownInformationList; self::$count_data += $array[1] ? $category->with(' LIMIT ?,?', [$page2, $step])->countOwn('information') : $category->with(' LIMIT ?,?', [$page1, $step1])->countOwn('information'); // echo " ".self::$count_data." "; self::$path = $array[1] ? "?ctrl=wisdom&action=WisdomType&type=" . $array[0] . "&subtype=" . $array[1] : "?ctrl=wisdom&action=WisdomType&type=" . $array[0]; } foreach ($data as $item) { if (!$item && $array[2]) { $out .= "<tr><td colspan='4'><h4 class='text-center'><b>Ничего не найдено</b></h4></td></tr>"; continue; } $autor = self::getAuthorName($item->id); $out .= "<tr>\r\n <td><a href='?ctrl=wisdom&action=GetWisdomById&id=" . $item->id . "'>" . $item->name . "</a></td>\r\n <td><a href='?ctrl=cabinet&action=UserInfo&id=" . $autor['id'] . "'>" . $autor['login'] . "</a> |\r\n <a href='?ctrl=cabinet&action=UserInfo&id=" . $autor['id'] . "'> " . $autor['surname'] . " " . $autor['name'] . " " . $autor['andername'] . " </a></td>\r\n <td>" . $smallKey . "</td>\r\n <td>" . $subValue['category_name'] . "</td>\r\n\r\n </tr>"; } } $out .= "</table>"; } if ($array[3] && $array[2] && $_SESSION['user']->status == 'teacher' && $_SESSION['user']->block == 0) { $out .= "<a role='button' href='?ctrl=teacher&action=WisdomData&type=" . $array[0] . "&subtype=" . $array[1] . "&category=" . $array[2] . "&subcategory=" . $array[3] . "&page=1' class='btn btn-info btn-block'>Добавить учебный материал</a>"; } return $out; }
static function categorMenu($array, $page = 1) { $open = ''; db_connect::connect(); $data = R::load('type', $array[0]); $item = ''; if (!$array[1]) { $item = $data->ownType; } else { $item = $data->withCondition('id = :id', ["id" => $array[1]])->ownType; } $out = ""; foreach ($item as $i) { $i_count = 0; if (!$array[2]) { $j = $i->ownCategoryList; } else { $j = $i->withCondition('category.id = ? LIMIT 0,3', [$array[2]])->ownCategoryList; } foreach ($j as $v) { $v_count = 0; foreach ($v->ownCategory as $o) { if (!$v_count && $o->name) { $v_count = 1; if ($v->id == $array[2]) { $open = "open"; } if (!$i_count) { $i_count = 1; $out .= "<h4>" . $i->name . "</h4>"; } $out .= "<div class=\"dropdown {$open}\">\r\n <button class=\"btn btn-default btn-block dropdown-toggle\" type=\"button\" id=\"dropdownMenu1\" data-toggle=\"tooltip\"\r\n aria-haspopup=\"true\" aria-expanded=\"true\">\r\n <a href='?ctrl=wisdom&action=WisdomType&type=" . $data->id . "&subtype=" . $i->id . "&category=" . $v->id . "&page=1'>" . $v->name . "<span class=\"caret\"></span></a></button>\r\n <ul class=\"dropdown-menu\" aria-labelledby=\"dropdownMenu1\">"; } if ($o->name) { self::$information_count += $o->countOwn('information'); self::$wisdomArray[$i->name][$o->name]['type_id'] = $data->id; self::$wisdomArray[$i->name][$o->name]['subtype_name'] = $i->name; self::$wisdomArray[$i->name][$o->name]['category_name'] = $v->name; self::$wisdomArray[$i->name][$o->name]['subcategory_id'] = $o->id; $out .= "<li><a href='?ctrl=wisdom&action=WisdomType&type=" . $data->id . "&subtype=" . $i->id . "&category=" . $v->id . "&subcategory=" . $o->id . "&page=1'>" . $o->name . "</a></li>"; } } $out .= "</ul></div>"; } } return $out; }
public function __construct($dbo = NULL, $imgFilename, $photoSize = 160) { parent::__construct($dbo); $this->imgFilename = $imgFilename; $this->photoSize = $photoSize; $this->initialfilesize = filesize($imgFilename); $this->imageproperties = getimagesize($imgFilename); $this->mimetype = image_type_to_mime_type($this->imageproperties[2]); if ($this->imageproperties[2] === IMAGETYPE_JPEG) { $this->imgData = imagecreatefromjpeg($this->imgFilename); } else { $this->imgData = imagecreatefrompng($this->imgFilename); } $srcW = $this->imageproperties[0]; $srcH = $this->imageproperties[1]; if ($srcW > $this->photoSize || $srcH > $this->photoSize) { if ($srcW < $srcH) { $koe = $srcW / $this->photoSize; $destW = $this->photoSize; $destH = ceil($srcH / $koe); $src_x = $destW / 2 - $this->photoSize / 2; $src_y = 0; } else { $koe = $srcH / $this->photoSize; $destH = $this->photoSize; $destW = ceil($srcW / $koe); $src_x = $destW / 2 - $this->photoSize / 2; $src_y = 0; } $copy = imagecreatetruecolor($destW, $destH); imagecopyresampled($copy, $this->imgData, 0, 0, 0, 0, $destW, $destH, imagesx($this->imgData), imagesy($this->imgData)); imagedestroy($this->imgData); imageconvolution($copy, array(array(-1, -1, -1), array(-1, 16, -1), array(-1, -1, -1)), 8, 0); $this->imgData = imagecreatetruecolor($this->photoSize, $this->photoSize); imagecopy($this->imgData, $copy, 0, 0, $src_x, $src_y, $this->photoSize, $this->photoSize); imagedestroy($copy); } }
public function delete(){ $query = "DELETE FROM TRIMESTRE WHERE idTrimestre = ".$this->getIdTrimestre(); if (db_connect::query($query)) return true; return false; }
public function delete(){ $query = "DELETE FROM MATIERE_NIVEAU WHERE idMatiereNiveau = ".$this->getIdMatiereNiveau(); if (db_connect::query($query)) return true; return false; }
<?php /** * Created by PhpStorm. * User: инкогнито * Date: 03.01.2016 * Time: 16:08 */ require_once __DIR__ . '/autoload.php'; require_once __DIR__ . '/application/core/connect/db_connect.php'; //try { if (!isset($_GET['ctrl'])) { $ctrl = "defaultController"; $action = "actionDefault"; } else { $controller = $ctrl = $_GET['ctrl']; $ctrl .= 'Controller'; $action = 'action'; $action .= $_GET['action']; } spl_autoload_register('myAutoload'); db_connect::connect(); $view = new View(); $controller = new $ctrl(); $controller->{$action}($view); // $view = new View(); // $view->abc = 123; //} catch(Exception $e) { // die('Ошибка'); //}
//copyright 2010,2014-2015 C.D.Price $_TEMP_PERMIT = "_LEGAL_"; //a temp permission for the "are you logged in" gate (in prepend) require_once "prepend.php"; require_once "common.php"; require_once "db_" . $_SESSION['_SITE_CONF']['DBMANAGER'] . ".php"; if (isset($_POST["btnSubmit"])) { //logging out throw_the_bum_out("Goodbye!", "Logout: by id=" . $_SESSION["person_id"]); //let prepend take care of it (not really a bum) } $organization = ""; $person = ""; if (isset($_SESSION["person_id"])) { //logged in $db = new db_connect($_SESSION['_SITE_CONF']['DBEDITOR']); $sql = "SELECT name FROM " . $db->prefix . "a00_organization WHERE organization_id=:org"; $stmt = $db->prepare($sql); $stmt->bindValue(':org', $_SESSION["organization_id"], PDO::PARAM_INT); $stmt->execute(); if (!($row = $stmt->fetchObject())) { $organization = "--No Organization--"; } else { $organization = COM_output_edit($row->name); } $stmt->closeCursor(); $sql = "SELECT firstname, lastname FROM " . $db->prefix . "c00_person WHERE person_id=:person"; $stmt = $db->prepare($sql); $stmt->bindValue(':person', $_SESSION["person_id"], PDO::PARAM_INT); $stmt->execute(); $row = $stmt->fetchObject();
function __construct() { require_once 'db_connect.php'; $db = db_connect::getInstance(); $this->conn = $db->getConnection(); }
static function userInfo($id) { db_connect::connect(); $user = R::load('user', $id); $status = $user->status == 'teacher' ? 'Преподаватель' : 'Студент'; $out = "<div class='col-sm-4 text-center'>\r\n <img style=\"max-width: 100%;max-height:100%;margin: 15px; \" src='images/user/" . $user->dossier->image . "'>\r\n </div>\r\n <div class='col-sm-8'>\r\n <h3>" . $user->login . " | " . $user->dossier->surname . " " . $user->dossier->name . " " . $user->dossier->andername . "</h3>"; $out .= "<ul class=\"list-group\">\r\n <li class=\"list-group-item\"><h4>Основная информация</h4></li>\r\n <li class=\"list-group-item\">Статус: " . $status . "</li>\r\n <li class=\"list-group-item\">Страна: " . $user->dossier->land . "</li>\r\n <li class=\"list-group-item\">Город: " . $user->dossier->sity . "</li>\r\n <li class=\"list-group-item\">Электронная почта: " . $user->dossier->email . "</li>\r\n <li class=\"list-group-item\">Количество учебных материалов: " . $user->withCondition('activ = 1 and education_id is null and lesson_id is null')->countShared('information') . " </li>\r\n </ul>\r\n </div>"; $about = $user->dossier->about ? $user->dossier->about : '<h3>Нет инфориации</h3>'; $out .= "<div class='col-sm-12'>\r\n <div class=\"panel panel-primary\">\r\n <div class=\"panel-heading\">О себе</div>\r\n <div class=\"panel-body\">" . $about . "</div>\r\n </div>\r\n </div>"; if ($user->status === 'teacher') { $data = $user->withCondition('activ=1')->sharedInformationList; // print_r($data); $out .= "<div class='col-sm-12'><div class=\"list-group\"><ul style='padding-left:0; '>"; $out .= "<li class=\"list-group-item active\">\r\n <h4 class=\"list-group-item-heading \">Разработанные учебные материалы</h4>\r\n </li>"; foreach ($data as $item) { $short_description = !empty($item->shortdescription) ? $item->shortdescription : 'Краткое описание отсутствует'; $out .= "<li class=\"list-group-item\">\r\n <h4 class=\"list-group-item-heading\"><a href='?ctrl=wisdom&action=GetWisdomById&id=" . $item->id . "'>" . $item->name . "</a></h4>\r\n <p class=\"list-group-item-text\">" . $short_description . "</p>\r\n </li>"; } $out .= "</ul></div></div>"; } return $out; }
public function update(){ $query = " UPDATE BULLETIN SET dateRedaction = '".$this->getDateRedacton()."', contenuBulletin = '".db_connect::escape_string($this->getContenuBulletin())."', idEleve = ".$this->getIdEleve().", idMatiereNiveau = ".$this->getIdMatiereNiveau()." WHERE idBulletin = ".$this->getIdBulletin(); if (db_connect::query($query)){ return true; } return false; }
public function delete(){ $query = "DELETE FROM EVALUATION_POINT_CPT WHERE idEvaluationPointCpt = ".$this->getIdEvaluationPointCpt(); if (db_connect::query($query)) return true; return false; }
public function __construct($dbo = NULL, $accountId = 0) { parent::__construct($dbo); $this->setId($accountId); }
<option value=""></option> </select> </td> </tr> <tr> <td colspan="2"> <input type="button" class="submit" id="btAdd" name="ajouter" value="Ajouter"> <input type="button" class="submit" id="btDel" name="retirer" value="Retirer"> </td> </tr> </table> </fieldset> <fieldset> <legend>Liste des matieres de l'élève</legend> <div id="listeMatiere"> </div> </fieldset> <br> </div> <div style="clear: both"></div> </div> <?php include '../Include/include_footer.php'; db_connect::close(); ?> </div> <script src="affectMatiere.js"></script> </body> </html>
function actionUpdateUserData($view) { $userArray = array(); $errorArray = array(); $session = $_SESSION['user']; if (!empty($_POST['firstPassword']) && !empty($_POST['anderPassword']) && $_POST['firstPassword'] === $_POST['anderPassword']) { $session->password = $_POST['firstPassword']; } elseif (empty($_POST['firstPassword']) && $_POST['firstPassword'] != '' && empty($_POST['anderPassword']) && $_POST['firstPassword'] === $_POST['anderPassword']) { $view->message = ["Пароли не совпадают или не все поля заполненны", "Внимание", 4]; $errorArray = $_POST; $view->data = cabinet::getUserData($userArray, $errorArray); echo $view->render('cabinet.php'); return; } foreach ($_POST as $key => $value) { if ($key == 'firstPassword' || $key == 'anderPassword') { if (empty($value)) { continue; } } if ($key == 'email') { if (preg_match("~([a-zA-Z0-9!#\$%&\\'*+-/=?^_`{|}\\~])@([a-zA-Z0-9-]).([a-zA-Z0-9]{2,4})~", $value)) { $userArray[$key] = htmlspecialchars($value); continue; } else { $errorArray[$key] = htmlspecialchars($value); continue; } } if ($key == 'about') { if (count($value) < 2000) { $userArray[$key] = htmlspecialchars($value); continue; } else { $errorArray[$key] = htmlspecialchars($value); continue; } } if ($key == 'phone') { if (preg_match("/^[+0-9-]{5,30}\$/", $value)) { $userArray[$key] = htmlspecialchars($value); continue; } else { $errorArray[$key] = htmlspecialchars($value); continue; } } if (!preg_match('/^[A-Za-zАаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя0-9_]{2,30}$/', trim($value))) { $errorArray[$key] = htmlspecialchars($value); } else { $userArray[$key] = htmlspecialchars($value); } // } if (!isset($errorArray)) { $view->message = ["Неверные данные или заполненны не все обязательные поля", "Внимание", 4]; } elseif (isset($userArray) && empty($errorArray)) { foreach ($session->dossier as $key => $value) { if ($_SESSION['user']->dossier->{$key} && isset($userArray[$key])) { $session->dossier->{$key} = $userArray[$key]; } } db_connect::connect(); $id = R::store($session); if (!$id) { $view->message = ["Ошибка записи. Проверьте данные", "Ошибка", 4]; } $view->message = ["Ваши личные данные изменены:", "Данные изменены", 1]; $userArray = $errorArray = ''; } else { $view->message = ["Ошибка записи. Проверьте данные", "Ошибка", 4]; } $view->data = cabinet::getUserData($userArray, $errorArray); echo $view->render('cabinet.php'); }
static function getPageById($id) { db_connect::connect(); $page = R::load('page', $id); return $page; }
public function __construct($dbo = NULL) { parent::__construct($dbo); }
public function update() { $query = "UPDATE UTILISATEUR SET " . " nomUtilisateur = '" . db_connect::escape_string(trim($this->getNomUtilisateur())) . "', " . " prenomUtilisateur = '" . db_connect::escape_string(trim($this->getPrenomUtilisateur())) . "', " . " adr1Utilisateur = '" . db_connect::escape_string(trim($this->getAdr1Utilisateur())) . "', " . " adr2Utilisateur = '" . db_connect::escape_string(trim($this->getAdr2Utilisateur())) . "', " . " cpUtilisateur = '" . db_connect::escape_string(trim($this->getCpUtilisateur())) . "', " . " villeUtilisateur = '" . db_connect::escape_string(trim($this->getVilleUtilisateur())) . "', " . " actifUtilisateur = " . ($this->getActifUtilisateur() ? 'true' : 'false') . ", " . " mailUtilisateur = '" . db_connect::escape_string(trim($this->getMailUtilisateur())) . "', " . " dateNaissanceUtilisateur = '" . db_connect::escape_string(trim($this->getDateNaissanceUtilisateur())) . "', " . " dateInscriptionUtilisateur = '" . db_connect::escape_string(trim($this->getDateInscriptionUtilisateur())) . "'" . " WHERE idUtilisateur = " . $this->getIdUtilisateur(); if (db_connect::query($query)) { $connexion = Connexion::getById($this->getIdUtilisateur()); if (empty($connexion->getIdUtilisateur())) $connexion->setIdUtilisateur($this->getIdUtilisateur()); $connexion->setLoginUtilisateur($this->getNomUtilisateur() . '.' . $this->getPrenomUtilisateur()); if (empty($connexion->getMdpUtilisateur())) $connexion->setMdpUtilisateur('123Soleil'); return $connexion->update(); } return FALSE; }
public function update() { $query = "UPDATE ELEVE SET idNiveau = " . db_connect::escape_string(trim($this->getIdNiveau())) . " WHERE idEleve = " . $this->getIdEleve(); return db_connect::query($query); }
public function delete() { $query = "DELETE FROM POINT_CPT WHERE idPointCpt = " . $this->getIdPointCpt(); if (db_connect::query($query)) return TRUE; return FALSE; }