public function frontend($variables) { #Syntax = Number of results to display require_once 'classes/database.php'; global $classDatabase; if (!isset($classDatabase)) { $classDatabase = new database(); } global $classPageInfo; //POST REPORT THREAD //Only post if a $_GET['et'] is given if (isset($_POST["et"])) { echo "<div class='reportPost postInformation'>"; $classDatabase->psReportsInsertETBoolAndPostID($_POST["et"], $_POST["id"]); echo "</div>"; } //VIEW BOARD $threads = $classDatabase->psThreadsSelectIDTitleLinkTextCreateTimeUserIDPinnedTotalRepliesWhereBoardIDEqualsOrderByorderPointINLIMIT($variables, $classPageInfo->pageNum, $classPageInfo->boardID); $threadIDs = $threads[0]; $threadTitles = $threads[1]; $threadLinks = $threads[2]; $threadTexts = $threads[3]; $threadCreateTimes = $threads[4]; $threadUserIDs = $threads[5]; $threadPinned = $threads[6]; $threadTotalReplies = $threads[7]; echo "<div class='boardView'>"; for ($i = 0; $i < count($threadIDs); ++$i) { echo "<div class='boardView thread'>" . "<div class='boardView preview'><a href='" . $threadLinks[$i] . "'><img src='/resources/icons/link.png'></a></div>" . "<div class='boardView info'>" . "<div class='boardView title'><a href='/boards/" . $classPageInfo->boardTitle . "/thread/" . $threadIDs[$i] . "'>" . $threadTitles[$i] . "</a></div>" . "<div class='boardView moreInfo'>" . "<div class='boardView user'>Posted by - " . $classDatabase->psUserSelectUsernameWhereIDEquals($threadUserIDs[$i]) . "</div>" . "<div class='boardView id'>Thread ID - " . $threadIDs[$i] . "</div>" . "<div class='boardView date'>Posted on - " . $threadCreateTimes[$i] . "</div>" . "<div class='boardView replies'>" . $threadTotalReplies[$i] . " replies</div>" . "<div class='boardView options'>Options" . "<div class='boardView optionsMenu'>" . "Options: <BR>" . "<form method='post' action=''?''><input type='hidden' name='et' value='1'><input type='hidden' name='id' value='" . $threadIDs[$i] . "'><input type='submit' value='Report Post'></form><BR>" . "</div>" . "</div>" . "</div></div></div>"; } echo "</div>"; }
public function gc($maxlifetime) { $db = new database(); $db->query("DELETE FROM tbl_session\n WHERE session_lastaccesstime < DATE_SUB(NOW(),\n INTERVAL " . $maxlifetime . " SECOND)"); $db->execute(); return true; }
public function update($user_id) { $database = new database(); $query = "update users set email = '{$this->email}'," . "username = '******'," . "profile_pic = '{$this->profilePic}'," . "job = '{$this->job}'," . "address = '{$this->address}'," . "gender = '{$this->gender}'" . "WHERE user_id={$user_id}"; $result = $database->performQuery($query); return $result ? TRUE : FALSE; }
public function __construct() { //connect to the database if not connected if (!$this->db) { require_once "resources/classes/database.php"; $database = new database(); $database->connect(); $this->db = $database->db; } //add multi-lingual support $language = new text(); $text = $language->get(); //get the ringback types $sql = "select * from v_vars "; $sql .= "where var_cat = 'Defaults' "; $sql .= "and var_name LIKE '%-ring' "; $sql .= "order by var_name asc "; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); $ringbacks = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset($prep_statement, $sql); foreach ($ringbacks as $ringback) { $ringback = $ringback['var_name']; $label = $text['label-' . $ringback]; if ($label == "") { $label = $ringback; } $ringback_list[$ringback] = $label; } $this->ringbacks = $ringback_list; unset($ringback_list); //get the default_ringback label /* $sql = "select * from v_vars where var_name = 'ringback' "; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetch(); unset ($prep_statement, $sql); $default_ringback = (string) $result['var_value']; $default_ringback = preg_replace('/\A\$\${/',"",$default_ringback); $default_ringback = preg_replace('/}\z/',"",$default_ringback); #$label = $text['label-'.$default_ringback]; #if($label == "") { $label = $default_ringback; #} $this->default_ringback_label = $label; unset($results, $default_ringback, $label); */ //get music on hold and recordings if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/music_on_hold')) { require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; $music = new switch_music_on_hold(); $this->music_list = $music->get(); } if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/recordings')) { require_once "app/recordings/resources/classes/switch_recordings.php"; $recordings = new switch_recordings(); $this->recordings_list = $recordings->list_recordings(); } }
public static function get($id = null) { $database = new database(); $q = ' SELECT ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.*, ' . RUDE_DATABASE_TABLE_FACULTIES . '.' . RUDE_DATABASE_FIELD_NAME . ' AS faculty_name, ' . RUDE_DATABASE_TABLE_FACULTIES . '.' . RUDE_DATABASE_FIELD_SHORTNAME . ' AS faculty_shortname, ' . RUDE_DATABASE_TABLE_QUALIFICATIONS . '.' . RUDE_DATABASE_FIELD_NAME . ' AS qualification_name FROM ' . RUDE_DATABASE_TABLE_SPECIALTIES . ' LEFT JOIN ' . RUDE_DATABASE_TABLE_FACULTIES . ' ON ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_FACULTY_ID . ' = ' . RUDE_DATABASE_TABLE_FACULTIES . '.' . RUDE_DATABASE_FIELD_ID . ' LEFT JOIN ' . RUDE_DATABASE_TABLE_QUALIFICATIONS . ' ON ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_QUALIFICATION_ID . ' = ' . RUDE_DATABASE_TABLE_QUALIFICATIONS . '.' . RUDE_DATABASE_FIELD_ID . ' '; if ($id !== null) { $q .= PHP_EOL . 'WHERE ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_ID . ' = ' . (int) $id; } $q .= ' GROUP BY ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_ID; $database->query($q); if ($id !== null) { return $database->get_object(); } return $database->get_object_list(); }
public static function getProximosCursos() { $db = new database(); $sql = "SELECT * FROM cursos WHERE id=3"; $db->query($sql); return $db->cargaMatriz(); }
public function login() { $database = new database(); if ($database->get_type() == 'mysql') { $db_arr = $database->connect(); if ($db_arr[0] == 1) { return array(1, $db_arr[1]); } $this->db = $db_arr[1]; // continue implementing login check $this->username = $this->db->escape_string(stripslashes($this->username)); $this->password = $this->db->escape_string(stripslashes($this->password)); $getuserquery = "SELECT * FROM user WHERE user_name='" . $this->username . "' AND user_password='******'"; $getuserresult = $this->db->query($getuserquery); $getuserresult_count = $getuserresult->num_rows; if ($getuserresult_count == 0) { $this->authstatus = false; return array(2, 'Username and password incorrect.'); } elseif ($getuserresult_count == 1) { $this->authstatus = true; return array(0, $this->authstatus); } else { return array(2, 'MySQL returning weird things.'); } } elseif ($database->get_type() == 'sqlite') { $db_arr = $database->connect_sqlite(); $this->db = $db_arr; // do things that have yet to be decided } }
function DLog($api_call, $securityLevel, $message, $account_id) { $database = new database(); $sql = "INSERT INTO Log(Api_call, ReqSecurityLevel, Comment, ID) VALUES ({$api_call}, {$securityLevel}, {$message}, {$account_id})"; mysqli_query($database->getConnection(), $sql); $database->close(); }
function __construct(database $db, user $user) { $this->db =& $db; $this->user =& $user; $usertype = Kit::GetParam('usertype', _SESSION, _INT, 0); $this->groupid = Kit::GetParam('groupid', _REQUEST, _INT, 0); // Do we have a user group selected? if ($this->groupid != 0) { // If so then we will need to get some information about it $SQL = <<<END \t\t\tSELECT \tgroup.GroupID, \t\t\t\t\tgroup.Group \t\t\tFROM `group` \t\t\tWHERE groupID = %d END; $SQL = sprintf($SQL, $this->groupid); if (!($results = $db->query($SQL))) { trigger_error($db->error()); trigger_error(__("Can not get Group information."), E_USER_ERROR); } $aRow = $db->get_assoc_row($results); $this->group = $aRow['Group']; } // Include the group data classes include_once 'lib/data/usergroup.data.class.php'; }
/** * Fetches hashed data from db and put into instance */ private function __save() { $class = $this->class; $database = new database($class::$database); if ($this->get_attributes()) { $columns = "(`{$class::$entity_id_column}`, `{$class::$key_column}`, `{$class::$value_column}`, `date_added`, `date_updated`)"; $placeholders = $values = $duplicate_keys = array(); foreach ($this->get_attributes() as $key => $value) { $placeholders[] = "(%d, %s, %s, NOW(), NOW())"; $values[] = $this->entity_id; $values[] = $key; $values[] = $value; $duplicate_keys[] = "`{$class::$value_column}` = VALUES(`{$class::$value_column}`)"; } $duplicate_keys[] = '`date_updated` = VALUES(`date_updated`)'; $database->query("INSERT INTO {$class::$table} {$columns} VALUES " . implode(', ', $placeholders) . " ON DUPLICATE KEY UPDATE " . implode(', ', $duplicate_keys), $values); } if ($unset_keys = array_diff($this->original_keys, array_keys($this->get_attributes()))) { // we unset something print_r(array($this->entity_id, $unset_keys)); database::enable_log(); $database->query("DELETE FROM {$class::$table} WHERE `{$class::$entity_id_column}` = %d AND `{$class::$key_column}` IN (%s)", array($this->entity_id, $unset_keys)); } return true; }
public static function getFondos() { $db = new database(); $sql = "select subtitulos,img_cursos from cursos WHERE id<=4;"; $db->query($sql); return $db->cargaMatriz(); }
public function details() { // details combines seeing with editing $id = $_GET['id']; $columns = array('nom, prenom, nom_khmer, prenom_khmer, sex_id, active_id'); $neat_columns = array('Last Name', 'First Name', 'Last Name Khmer', 'First Name Khmer', 'Genre', 'Active', 'Update', 'Delete'); $form = array('action' => '?controller=teachers&action=update&id=' . $id, 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", 'action_links' => array(1 => array('delete', '?controller=teachers&action=delete&id=')), 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('text' => 'nom'), 2 => array('text' => 'prenom'), 3 => array('text' => 'nom_khmer'), 4 => array('text' => 'prenom_khmer'), 5 => array('drop_down' => 'sex_id'), 6 => array('drop_down' => 'active_id'), 7 => array('submit' => 'update'))); $connection = new database(); $table = new simple_table_ops(); $sql = 'SELECT sex_id, sex FROM sexes'; $sex_result = $connection->query($sql); $sql2 = 'SELECT active_id, active FROM actives'; $active_result = $connection->query($sql2); $drop_down = array('sex_id' => array('sex' => $sex_result), 'active_id' => array('active' => $active_result)); $table->set_table_name('teachers'); $table->set_id_column('teacher_id'); $table->set_table_column_names($columns); $table->set_html_table_column_names($neat_columns); $table->set_values_form(); // set values found in database into form elements when building top_form $table->set_drop_down($drop_down); $table->set_form_array($form); $content = '<table>'; $content .= $table->details(); $content .= '</table>'; $output['content'] = $content; return $output; }
function upload($file_name, $file_type, $file_path, $file_title) { if (!empty($_FILES["fileUpload"]) && !empty($_POST["imgTitle"])) { $file_type = $_FILES['fileUpload']['type']; $file_title = $_POST["imgTitle"]; if ($file_type == "image/gif") { $file_path = $_FILES['fileUpload']['tmp_name']; $file_name = $_FILES['fileUpload']['name']; $new_path = "upload/img/" . $file_name; $file_error = $_FILES["fileUpload"]["error"]; if ($file_error == 0 && move_uploaded_file($file_path, $new_path)) { $sql = "INSERT INTO gif.images (`title_img`, `name_img`, `id_user`) VALUES ('{$file_title}','{$file_name}', '0');"; $upload = new database(); $upload->connect(); $query = $upload->query($sql); if (!empty($query)) { $success = "Upload file và ghi dư liệu thành công."; return $success; } else { $success = "Upload file thành công."; return $success; } } return $file_error; } else { $error = "File không đúng định dạng GIF"; return $error; } } }
function adlib($id, $type) { // create adlib xml basic structure $XML = new simpleXmlElement("<?xml version='1.0' encoding='utf-8'?><adlibXML xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.adlibsoft.com/adlibXML.xsd' />"); echoall("Start Adlib XML export"); echoall("Connect database"); $daba = new database(); $daba->connect("localhost", "iggmp", "1s87J37r0"); if ($daba->select("thesaurus")) { echoall("Database connected"); } else { die("***ERROR - Database connection failed"); } $termType = thesaurus::get_name($id); echoall("Starte bei <b>'" . thesaurus::get_name($id) . "'</b>"); //------------------------------------------------------------------------------ // create recordList xml_insert($XML, new simpleXmlElement("<recordList />")); // insert records in recordList $subXml = _subtree($id, $termType); if ($subXml) { xml_insert($XML->recordList, $subXml); } echoall("XML export completed<hr>"); echoall($XML); return $XML->asXML(); }
public function get_db() { $database = new database(); $dbtype = $database->get_type(); if ($dbtype == 'mysql') { $db_arr = $database->connect(); if ($db_arr[0] == 1) { return array(1, $db_arr[1]); } $this->db = $db_arr[1]; $get_query = "SELECT * FROM user WHERE user_name='" . $this->username . "'"; $get_result = $this->db->query($get_query); $get_result_arr = $get_result->fetch_assoc(); $get_result_count = $get_result->num_rows; if ($get_result_count != 1) { return array(2, 'Name not found'); } } elseif ($dbtype == 'sqlite') { $db_arr = $database->connect_sqlite(); $this->db = $db_arr; // to be implemented } $this->id = $get_result_arr['user_id']; $this->username = $get_result_arr['user_name']; $this->email = $get_result_arr['user_email']; $this->groupname = $this->group_id_to_name($get_result_arr['user_group']); $this->firstname = $get_result_arr['first_name']; $this->middlename = $get_result_arr['middle_name']; $this->lastname = $get_result_arr['last_name']; }
public function __construct() { $dbobj = new database(); $this->db = $dbobj->get(); $this->session = new session($this->db); $this->email = new email(); }
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } //$theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conexion , $theValue) : mysqli_escape_string( $conexion , $theValue); if (function_exist) { $obj = new database(); $link = $obj->connect(); $theValue = mysqli_real_escape_string($link, $theValue); } switch ($theType) { case "text": $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = $theValue != "" ? intval($theValue) : "NULL"; break; case "double": $theValue = $theValue != "" ? doubleval($theValue) : "NULL"; break; case "date": $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = $theValue != "" ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; }
/** * Layout Page Logic * @return * @param $db Object */ function __construct(database $db, user $user) { $this->db =& $db; $this->user =& $user; $this->sub_page = Kit::GetParam('sp', _GET, _WORD, 'view'); $this->layoutid = Kit::GetParam('layoutid', _REQUEST, _INT); // If we have modify selected then we need to get some info if ($this->layoutid != '') { // get the permissions Debug::LogEntry('audit', 'Loading permissions for layoutid ' . $this->layoutid); $this->auth = $user->LayoutAuth($this->layoutid, true); if (!$this->auth->edit) { trigger_error(__("You do not have permissions to edit this layout"), E_USER_ERROR); } $this->sub_page = "edit"; $sql = " SELECT layout, description, userid, retired, xml FROM layout "; $sql .= sprintf(" WHERE layoutID = %d ", $this->layoutid); if (!($results = $db->query($sql))) { trigger_error($db->error()); trigger_error(__("Cannot retrieve the Information relating to this layout. The layout may be corrupt."), E_USER_ERROR); } if ($db->num_rows($results) == 0) { $this->has_permissions = false; } while ($aRow = $db->get_row($results)) { $this->layout = Kit::ValidateParam($aRow[0], _STRING); $this->description = Kit::ValidateParam($aRow[1], _STRING); $this->retired = Kit::ValidateParam($aRow[3], _INT); $this->xml = $aRow[4]; } } }
function __construct() { include_once 'class.database.php'; $conn = new database(); $this->link = $conn->connect(); return $this->link; }
public function __construct() { //connect to the database if not connected if (!$this->db) { require_once "resources/classes/database.php"; $database = new database(); $database->connect(); $this->db = $database->db; } //set the application specific uuid $this->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044'; //set the domain_uuid if not provided if (strlen($this->domain_uuid) == 0) { $this->domain_uuid = $_SESSION['domain_uuid']; } //get the voicemail_id if (!isset($this->voicemail_id)) { $sql = "select voicemail_id from v_voicemails "; $sql .= "where domain_uuid = '" . $this->domain_uuid . "' "; $sql .= "and voicemail_uuid = '" . $this->voicemail_uuid . "' "; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); if (is_array($result)) { foreach ($result as &$row) { $this->voicemail_id = $row["voicemail_id"]; } } unset($prep_statement); } }
function connect_2_db($cfg) { if (!defined('NO_DSN')) { define('NO_DSN', FALSE); } if (strlen(trim($cfg['db_name'])) == 0) { echo '<span class="notok">Failed!</span><p />Database Name is empty'; $db = null; } else { $db = new database($cfg['db_type']); @($conn_result = $db->connect(NO_DSN, $cfg['db_server'], $cfg['db_admin_name'], $cfg['db_admin_pass'], $cfg['db_name'])); if ($conn_result['status'] == 0) { echo '<span class="notok">Failed!</span><p />Please check the database login details and try again.'; echo '<br>Database Error Message: ' . $db->error_msg() . "<br>"; $db = null; } else { if (!isset($cfg['db_type']) || strtolower($cfg['db_type']) == 'mysql') { // 20071103 - BUGID 771 eagleas $db->exec_query("SET CHARACTER SET utf8;"); $db->exec_query("SET collation_connection = 'utf8_general_ci';"); } echo "<span class='ok'>OK!</span><p />"; } } return $db; }
public function makeLanguageBar($arr, $divider = " | ") { // make a new connection to the database $database = new database($arr); $result = $database->executeQuery("SELECT * FROM languages"); if ($result) { $type = null; switch ($this->languageType) { case 0: default: $type = "short"; break; case 1: $type = "long"; break; case 2: $type = "flag"; break; } for ($i = 1; $i <= count($result); ++$i) { $url = getNewUrl('l', $i); if ($i == $this->language) { echo "<strong><a href=\"" . $url . "\">" . $result[$i - 1][$type] . "</a></strong>"; } else { echo "<a href=\"" . $url . "\">" . $result[$i - 1][$type] . "</a>"; } if ($i < count($result)) { echo $divider; } } } else { // make a new connection echo "There is a problem with the connection with the database, try again later.<br />"; } }
public function index() { $database = new database(); $query = $database->query(); date_default_timezone_set('Europe/London'); require_once "database.php"; $now = time(); $hour = $now - 60 * 60; $day = $now - 24 * 60 * 60; $month = $now - 30 * 24 * 60 * 60; // fetch clicks -hour $sql = "SELECT name, COUNT(*) as clicks FROM clicks WHERE time >=" . $hour . " GROUP BY name"; $clicksMinusHour = $query->fetch($sql); // fetch clicks -day $sql = "SELECT name, COUNT(*) as clicks FROM clicks WHERE time >=" . $day . " GROUP BY name"; $clicksMinusDay = $query->fetch($sql); // fetch clicks -month $sql = "SELECT name, COUNT(*) as clicks FROM clicks WHERE time >=" . $month . " GROUP BY name"; $clicksMinusMonth = $query->fetch($sql); if (count($clicksMinusHour) < 1) { $array = array('name' => 'null', 'clicks' => 'null'); $clicksMinusHour[] = $array; } if (count($clicksMinusDay) < 1) { $array = array('name' => 'null', 'clicks' => 'null'); $clicksMinusDay[] = $array; } if (count($clicksMinusMonth) < 1) { $array = array('name' => 'null', 'clicks' => 'null'); $clicksMinusMonth[] = $array; } $this->setVar('clicksMinusHour', $clicksMinusHour); $this->setVar('clicksMinusDay', $clicksMinusDay); $this->setVar('clicksMinusMonth', $clicksMinusMonth); }
public function index() { $database = new database(); $query = $database->query(); $images = new image($query); $currentActive = $images->fetchCurrentActive(); $this->setVar('currentActive', $currentActive); }
public function eliminarCliente($id) { $db = new database('127.0.0.1:3307', 'cedsa', 'root', 'mat23net90'); $db->conectaDB(); $query = "delete from clientes where id_cliente = '{$id}'"; $db->ejecutaSQL($query); $db->desconectaDB(); }
public function __construct(database $database) { //ACCESS TO DATABASE CLASS $this->database = $database; if ($database->getDBStatus() == false) { echo 'MESSAGE <b>There is no database connection</b>'; } }
public function eliminarAdministrador($id) { $db = new database('127.0.0.1:3307', 'cedsa', 'root', 'mat23net90'); $db->conectaDB(); $query = "delete from administradores where id_administrador = '{$id}'"; $db->ejecutaSQL($query); $db->desconectaDB(); }
public static function registro() { $db = new database(); $sql = 'INSERT INTO usuarios VALUES (NULL, :nombre, :apellidos, :fecha_nacimiento, :localidad, :email, :nick, :clave, :roll)'; $params = array(':nombre' => $_POST['nombre'], ':apellidos' => $_POST['apellidos'], ':fecha_nacimiento' => $_POST['fecha_nacimiento'], ':localidad' => $_POST['localidad'], ':email' => $_POST['email'], ':nick' => $_POST['nick'], ':clave' => $_POST['clave'], ':roll' => 1); $db->query($sql, $params); return $db->affectedRows(); }
public static function altaUsuario($id, $idUsuario) { $db = new database(); $sql = "INSERT INTO cursan(id_usuario, id_curso) VALUES (:id_usuario,:id);"; $params = array(':id' => $id, ':id_usuario' => $idUsuario); $db->query($sql, $params); return $db->cargaFila(); }
public static function nuevoMensaje() { $db = new database(); $sql = 'INSERT INTO contacto VALUES (NULL, :nombre, :apellidos, :email, :asunto, :mensaje)'; $params = array(':nombre' => $_POST['nombre'], ':apellidos' => $_POST['apellidos'], ':email' => $_POST['email'], ':asunto' => $_POST['asunto'], ':mensaje' => $_POST['mensaje']); $db->query($sql, $params); return $db->affectedRows(); }