/** * Get settings data from DB. * * @access private * @return array */ private function getDataFromDB() { $data = array(); $query = $this->db->query("\n\t\t\tSELECT setting_name, setting_value\n\t\t\tFROM ts_system_settings\n\t\t\tORDER BY id\n\t\t"); while (($row = $this->db->fetchAssoc($query)) != NULL) { $data[$row['setting_name']] = $row['setting_value']; } return $data; }
public function query($sql, $errorLevel = E_USER_ERROR) { $query = new stdClass(); $query->query = $sql; $query->source = ''; $query->count = 0; $trace = $this->userCaller(); if ($trace) { $query->source = 'Line ' . $trace['line'] . ' in ' . $trace['file']; } $this->queryRecord[] = $query; if (isset($this->allQueries[$sql])) { $cur = isset($this->duplicateQueries[$sql]) ? $this->duplicateQueries[$sql] : $query; if (!isset($cur->count)) { $cur->query = $sql; $cur->count = 0; } $cur->count = $cur->count + 1; if ($cur->count > 2 && !isset($cur->source)) { // lets see where it's coming from $trace = $this->userCaller(); if ($trace) { $cur->source = 'Line ' . $trace['line'] . ' in ' . $trace['file']; } } $this->duplicateQueries[$sql] = $cur; } // mark as having executed this query $this->allQueries[$sql] = true; return parent::query($sql, $errorLevel); }
public function query($sql, $errorLevel = E_USER_ERROR) { if (in_array(strtolower(substr($sql, 0, strpos($sql, ' '))), $this->writeQueries)) { throw new Exception("Attempted to write to readonly database"); } return parent::query($sql, $errorLevel); }
/** * Sets the charset of the database connection. * * @param string $charset */ public function setCharset($charset) { if (function_exists('mysqli_set_charset')) { $this->mySQLi->set_charset($charset); } else { parent::setCharset($charset); } }
/** * @see MySQLDatabase::sendQuery() */ public function sendQuery($query, $limit = 0, $offset = 0) { $startTime = microtime(true); $result = parent::sendQuery($query . ($limit > 0 ? " LIMIT " . $limit . " OFFSET " . $offset : "")); $endTime = microtime(true); $this->time += $endTime - $startTime; return $result; }
function destroy() { // Destructor $this->_mainTableName = null; $this->_defFile->destroy(); $this->_defFile = null; MySQLDatabase::destroy(); }
/** * If a write query is detected, hand it off to the configured write database * * @param string $sql * @param int $errorLevel * @return \MySQLQuery */ public function query($sql, $errorLevel = E_USER_ERROR) { if (in_array(strtolower(substr($sql, 0, strpos($sql, ' '))), $this->writeQueries) || $this->writePerformed) { $alternateReturn = $this->writeDb()->query($sql, $errorLevel); $this->writePerformed = true; return $alternateReturn; } return parent::query($sql, $errorLevel); }
public function __construct($parameters) { if (static::$firstTime) { static::$firstTime = false; // deregister the Silverstripe exception and error handlers restore_exception_handler(); restore_error_handler(); } parent::__construct($parameters); }
public function AddToDatabase() { $this->DB->Prepare("\n\t\t\tINSERT INTO tblIngredients\n\t\t\t\t(userID, type, title, description, baseIngredientID, createStamp, modifyStamp)\n\t\t\t\tVALUES\n\t\t\t\t(:userID, :type, :title, :description, :baseIngredientID, :createStamp, :modifyStamp)\n\t\t"); $id = $this->DB->Execute(array(":userID" => $this->Session->ID, ":type" => $this->Type, ":title" => $this->Title, ":description" => $this->Description, ":baseIngredientID" => Nullable($this->BaseIngredientID()), ":createStamp" => $this->CreateStamp, ":modifyStamp" => microtime(true))); if ($id) { $this->ID = $id; } singleLog("Created ingredient #{$id}"); return $id; }
/** * * @param string $sql * @param integer $errorLevel * @return SS_Query */ public function query($sql, $errorLevel = E_USER_ERROR) { $query = parent::query($sql, $errorLevel); if (isset($_REQUEST['showqueries']) && Director::isDev()) { $count = 1 + (int) Config::inst()->get('MySQLDebuggableDatabase', 'queries_count'); Config::inst()->update('MySQLDebuggableDatabase', 'queries_count', $count); Debug::message(PHP_EOL . 'Query Counts: ' . $count . PHP_EOL, false); } return $query; }
public function __construct($credsVar) { $this->credsVar = $credsVar; $this->logQueries = defined('LOGQUERIES') && LOGQUERIES; $this->uniqueID = 'sqldb-' . session_id(); if (!file_exists(MYSQLVARPATH)) { mkdir(MYSQLVARPATH); } MySQLDatabase::GC(); }
/** * Add new ticket into database. * * @access public * @param int Selected urgency. * @param int Selected category. * @param string Subject of the ticket. * @param string Content of the ticket. */ public function addTicket($urgency, $services, $subject = "", $content = "") { if ($this->validator->required($urgency, $services, $subject, $content)) { $query1 = $this->chkTicketExistance("table", "ts_ticket_topic", "subject", $subject); $query2 = $this->chkTicketExistance("table", "ts_ticket_topic", "content", $content); if (!$query1 && !$query2) { // Later user method whoIsFromStaff $this->db->query("\n\t\t\t\t\tINSERT INTO ts_ticket_topic(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tauthor_id,\n\t\t\t\t\t\trecepient_id,\n\t\t\t\t\t\tsubject,\n\t\t\t\t\t\tdate_time,\n\t\t\t\t\t\tcategory_id,\n\t\t\t\t\t\tpriority_id,\n\t\t\t\t\t\tstatus_id,\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t\tuser_ip\n\t\t\t\t\t) VALUES(\n\t\t\t\t\t\tNULL,\n\t\t\t\t\t\t" . $this->db->escapeVal($_SESSION['id']) . ",\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escapeVal($subject) . "',\n\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t" . $this->db->escapeVal($services) . ",\n\t\t\t\t\t\t" . $this->db->escapeVal($urgency) . ",\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escapeVal($this->validator->eliminateTags($content)) . "',\n\t\t\t\t\t\t'" . $this->db->escapeVal($_SERVER['REMOTE_ADDR']) . "'\n\t\t\t\t\t)\n\t\t\t\t"); } } header("Location: / "); }
/** * Calculate the number of pages. * * @access public * @return int */ public function getNumPages() { if ($this->user->ugroup == 1) { $query = "SELECT COUNT(1) AS total FROM ts_tickets_view WHERE status_name = 'Opened'"; $total = $this->db->fetchAssoc($query); } else { $query = "SELECT COUNT(1) AS total FROM ts_tickets_view WHERE author_id = " . $this->db->escapeVal($this->user->id); $total = $this->db->fetchAssoc($query); } $this->totalEntryNum = (int) $total['total']; $this->numPages = ceil($this->totalEntryNum / $this->entryPerPage); return $this->numPages; }
/** * @param bool|int $id */ public function RefreshIngredients($id = false) { $result = array(); $condition = $id ? "AND tblIngredients.id = " . (int) $id : false; $queryString = "SELECT * FROM tblIngredients WHERE userID = {$this->ID} {$condition}"; $query = $this->DB->Query($queryString); if ($query) { while ($row = $query->Fetch()) { $ingredient = array_key_exists($row['id'], $this->Ingredients) ? $this->Ingredients[$row['id']] : new Ingredient($this, $row); $result[$ingredient->ID] = $ingredient; } } $this->Ingredients = $result; }
/** * Search for user in database. Check whether user is * a numeric value, for example user id or is it an array * of user attributes. * * @access public * @param int | array * @return array | bool */ public function chkUserExistance($user) { if (is_numeric($user)) { $query = "\n\t\t\t\tSELECT id, username, userpass, email, ugroup\n\t\t\t\tFROM ts_users\n\t\t\t\tWHERE id = " . $this->db->escapeVal($user) . "\n\t\t\t\tLIMIT 1\n\t\t\t"; return $query; } else { if (is_array($user)) { $query = "\n\t\t\t\tSELECT id, username, userpass, email, ugroup\n\t\t\t\tFROM ts_users\n\t\t\t\tWHERE username = '******'username']) . "'\n\t\t\t\tOR email = '" . $this->db->escapeVal($user['email']) . "'\n\t\t\t\tLIMIT 1\n\t\t\t"; # If user not found if (!($row = $this->db->fetchAssoc($query))) { return false; } return true; } } }
<?php global $project; $project = 'mysite'; global $databaseConfig; $databaseConfig = array("type" => 'MySQLDatabase', "server" => 'localhost', "username" => 'root', "password" => 'omega', "database" => 'vp', "path" => ''); MySQLDatabase::set_connection_charset('utf8'); // Set the current theme. More themes can be downloaded from // http://www.silverstripe.org/themes/ SSViewer::set_theme('simple'); // Set the site locale i18n::set_locale('en_US'); FulltextSearchable::enable(); // Enable nested URLs for this site (e.g. page/sub-page/) if (class_exists('SiteTree')) { SiteTree::enable_nested_urls(); } Director::set_environment_type("dev"); // add a button to remove formatting HtmlEditorConfig::get('cms')->insertButtonsBefore('styleselect', 'removeformat'); // tell the button which tags it may remove HtmlEditorConfig::get('cms')->setOption('removeformat_selector', 'b,strong,em,i,span,ins'); //remove font->span conversion HtmlEditorConfig::get('cms')->setOption('convert_fonts_to_spans', 'false,'); HtmlEditorConfig::get('cms')->setOptions(array('valid_elements' => "@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],#td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class],small", 'extended_valid_elements' => "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap],#iframe[src|name|width|height|align|frameborder|marginwidth|marginheight|scrolling],object[width|height|data|type],param[name|value],map[class|name|id],area[shape|coords|href|target|alt]")); // TinyMCE cleanup on paste HtmlEditorConfig::get('cms')->setOption('paste_auto_cleanup_on_paste', 'true'); HtmlEditorConfig::get('cms')->setOption('paste_remove_styles', 'true'); HtmlEditorConfig::get('cms')->setOption('paste_remove_styles_if_webkit', 'true'); HtmlEditorConfig::get('cms')->setOption('paste_strip_class_attributes', 'true'); GD::set_default_quality(80);
<?php # Instance of MySQLDatabase $database = new MySQLDatabase(); # Instance of Session $session = new Session(); # Instance of User $user = User::find_by_id($session->id); $application_no = customDecrypt($_GET["app_no"]); ?> <h5 align="center">Transcript Application</h5> <hr> <h6 align="center">All Fields are Required</h6> <form action="" method="POST" class="application_form form-horizontal" > <!-- Fullname --> <div class="control-group"> <label class="control-label" for="inputApplicationFormNumber">Application Number</label> <div class="controls"> <div class="input-prepend"> <span class="add-on"><i class="iconic-hash"></i></span> <input type="text" class="input-xlarge" required id="app_no" name="app_no" value="<?php if (isset($application_no)) { echo $application_no; } ?> " readonly="readonly" /> </div> </div> </div> <!-- Title -->
<?php require_once '../inc/initialize.php'; $db_academic = new MySQLDatabase(); $sql_exam = "SELECT * FROM exam_id"; $result_exam = $db_academic->query($sql_exam); while ($record = $db_academic->fetch_array($result_exam)) { echo '<option value="' . $record['exam_type_id'] . '">' . $record['exam_name'] . '</option>'; }
$zoom = $_REQUEST["zoom"]; // Validate the input parameters if (is_numeric($tllon) && -180.0 <= $tllon && $tllon < 180.0 && is_numeric($tllat) && -90.0 <= $tllat && $tllat <= 90.0 && is_numeric($brlon) && -180.0 <= $brlon && $brlon < 180.0 && is_numeric($brlat) && -90.0 <= $brlat && $brlat <= 90.0 && is_numeric($zoom) && $zoom >= 0 && $zoom < 20) { $min_lat = $tllat < $brlat ? $tllat : $brlat; $max_lat = $tllat > $brlat ? $tllat : $brlat; $min_lon = $tllon < $brlon ? $tllon : $brlon; $max_lon = $tllon > $brlon ? $tllon : $brlon; $key = "poi_" . $min_lat . "_" . $max_lat . "_" . $min_lon . "_" . $max_lon . "_" . $zoom; if (strcmp($cache_type, "FileCache") == 0) { $cache = new FileCache(); } else { $cache = new NoCache(); } $xml = $cache->get($key); if ($xml == FALSE) { $db = new MySQLDatabase($hostname, $database, $username, $password); $db->connect(); $poi = new POIManager($db); $gpx = $poi->getWpts($min_lat, $max_lat, $min_lon, $max_lon, $zoom); $xml = $gpx->toXml(); $db->disconnect(); $cache->put($key, $xml); } header("Content-type: text/xml; charset=utf-8"); print $xml; } else { header("Content-type: text/plain; charset=utf-8"); print "Invalid Input"; } } else { header("Content-type: text/plain; charset=utf-8");
/** * Sets the character set for the MySQL database connection. * * The character set connection should be set to 'utf8' for SilverStripe version 2.4.0 and * later. * * However, sites created before version 2.4.0 should leave this unset or data that isn't 7-bit * safe will be corrupted. As such, the installer comes with this set in mysite/_config.php by * default in versions 2.4.0 and later. */ public static function set_connection_charset($charset = 'utf8') { self::$connection_charset = $charset; }
<!-- //header --> <br> <br> <!-- Content --> <div class="row-fluid"> <?php include_layout_template('admin_menu.php'); ?> <div class="span9"> <h2>Active Notifications</h2> <hr> <?php $database = new MySQLDatabase(); $active_notifications = "SELECT * FROM `applicant_notifications` as app_not JOIN `personal_details` as per WHERE status = 1 AND recipient_id = " . $session->applicant_id . " AND app_not.sender_id=per.applicant_id"; $result = $database->query($active_notifications); $pagecounter = 1; $serialno = 1; $max = 10; $number_of_notifications = $database->num_rows($result); echo '<div class="tabbable"> <div class="tab-content">'; while ($row = $database->fetch_array($result)) { if ($serialno % $max == 1) { if ($pagecounter == 1) { echo '<div class="tab-pane active" id="' . $pagecounter . '">'; } else { echo '<div class="tab-pane" id="' . $pagecounter . '">'; }
<?php require_once "inc/initialize.php"; $database = new MySQLDatabase(); $session = new Session(); $user = User::find_by_id($session->id); ?> <h3 align="center">Select Payment for Transcript Application</h3> <hr> <h6 align="center">All Fields are Required</h6> <form action="pay.php" method="POST" class="create_form form-horizontal" > <!-- Fullname --> <div class="control-group"> <label class="control-label" for="inputEmail">Full Name</label> <div class="controls"> <div class="input-prepend"> <span class="add-on"><i class="icon-user"></i></span> <input type="text" class="input-xlarge" required id="full_name" name="full_name" value="<?php if (isset($user->full_name)) { echo $user->full_name; } ?> " placeholder="Surname, Firstname, middlename" readonly="" /> </div> </div> </div> <!-- Delivery type --> <?php $sql_type = "SELECT * FROM delivery_type WHERE dt_visible = 1"; $result = $database->query($sql_type); ?>
<?php # Instance of Session $session = new Session(); # Instance of MySQLDatabase $db = new MySQLDatabase(); // print_r( $type); // die(); # Count the number of submitted transcript applications for an applicant $query_count = "SELECT count(*) FROM feedbacks WHERE applicant_id ='" . $session->id . "' "; $result_count = $db->query($query_count); $feedbacks_count = $db->fetch_array($result_count); $count = array_shift($feedbacks_count); // 1. the current page number ($current_page) $page = !empty($_GET['page']) ? (int) $_GET['page'] : 1; // 2. records per page ($per_page) $per_page = 3; // 3. total record count ($total_count) $total_count = $count; // use pagination instead $pagination = new Pagination($page, $per_page, $total_count); // Instead of finding all records, just find the records // for this page $sql = "SELECT * FROM feedbacks WHERE applicant_id ='" . $session->id . "' ORDER BY `id` DESC "; $sql .= "LIMIT {$per_page} "; $sql .= "OFFSET {$pagination->offset()}"; $active_feedbacks = Feedback::find_by_sql($sql); // Need to add ?page=$page to all links we want to // maintain the current page (or store $page in $session) $counter = 1; ?>
function form_id_generator($applicant_id, $programme) { //get the length of random number to generate $random_number_length = 6 - strlen($applicant_id); //get d last two digits of the session $database = new MySQLDatabase(); $selectsessionsql = $database->query("SELECT session FROM application_status WHERE id=1"); $result = $database->fetch_array($selectsessionsql); $year = explode('/', $result['session']); $year = substr($year[0], 2, 2); $random_number = rand(pow(10, $random_number_length - 1), pow(10, $random_number_length) - 1); // The function returns year, programme return $year . $programme . $random_number . $applicant_id; }
public function __construct($parameters) { parent::__construct($parameters); }
<?php require_once "../inc/initialize.php"; //checks if admin user is logged in if (!$session->is_admin_logged_in()) { redirect_to('index.php'); } // if($_SESSION["role"] != 1 || $_SESSION["role"] != 6){ // redirect_to('home.php'); // } $database = new MySQLDatabase(); ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>University of Jos, Nigeria</title> <?php require_once LIB_PATH . DS . 'css.php'; ?> <link rel="stylesheet" href="js/plugins/datetimepicker/jquery.datetimepicker.css"> </head> <body> <!-- beginnning of main content--> <!-- header --> <?php include_layout_template('admin_header.php'); ?> <!-- //header -->
<?php require_once "../inc/initialize.php"; //checks if admin user is logged in if (!$session->is_admin_logged_in()) { redirect_to('index.php'); } // if($_SESSION["role"] != 1 || $_SESSION["role"] != 6){ // redirect_to('home.php'); // } $database = new MySQLDatabase(); ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>University of Jos, Nigeria</title> <?php require_once LIB_PATH . DS . 'css.php'; ?> </head> <body> <!-- beginnning of main content--> <!-- header --> <?php include_layout_template('admin_header.php'); ?> <!-- //header --> <br>
<?php require_once "inc/initialize.php"; if (!$session->is_logged_in()) { redirect_to('index.php'); } $user = new User(); $user->applicant_id = $session->applicant_id; $progress = $user->find_by_sql("SELECT progress FROM personal_details WHERE applicant_id='" . $user->applicant_id . "'"); $progress = array_shift($progress); if ($progress->progress != 'Completed') { redirect_to('application_form.php'); } $student_status = $user->get_student_status(); $database = new MySQLDatabase(); ?> <?php $personal_details = $database->query("SELECT * FROM personal_details p, title t, lga l, state s, religion r, nationality n, department d, faculty f, next_of_kin next, marital mar, photographs photo WHERE p.applicant_id='" . $session->applicant_id . "' AND p.title_id=t.title_id AND p.lga_id=l.lga_id AND l.state_id=s.state_id AND p.religion_id=r.religion_id AND p.country_id=n.country_id AND p.programme_applied_id=d.department_id AND d.faculty_id=f.faculty_id AND p.applicant_id=next.applicant_id AND p.applicant_id=photo.applicant_id AND p.marital_status=mar.marital_status_id"); $personal_details = $database->fetch_array($personal_details); ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>University of Jos, Nigeria - <?php echo $personal_details['faculty_name']; ?> Complete Application Form</title> <?php require_once LIB_PATH . DS . 'javascript.php';
<?php require_once "../inc/initialize.php"; //checks if admin user is logged in if (!$session->is_admin_logged_in()) { redirect_to('index.php'); } $role = $_SESSION["role"]; if ($role == 4) { $db = new MySQLDatabase(); $sql = "SELECT `department_name` from `department` WHERE `department_id` = '" . $_SESSION["department_id"] . "'"; $dept = $db->Query($sql); $dept = $db->fetch_array($dept); $dept = array_shift($dept); } function privilege() { global $role; switch ($role) { case 1: $msg = "Main Administrative"; break; case 2: $msg = "Post Graduate Administrative"; break; case 3: $msg = "Non NUC Administrative"; break; case 4: $msg = "Departmental Administrative"; break;
<?php $db = new MySQLDatabase(); $session = new Session(); $applicant_fullname = User::applicant_fullname($session->applicant_id); $result_details = User::find_by_id($session->applicant_id); $display_greeting = greeting(); /**/ $active_sql = "SELECT COUNT(*) FROM `applicant_notifications` WHERE status = 1 AND recipient_id = " . $session->applicant_id; $total_active = $db->query($active_sql); $total_active = $db->fetch_array($total_active); $total_active = array_shift($total_active); $inactive_sql = "SELECT COUNT(*) FROM `applicant_notifications` WHERE status = 2 AND recipient_id = " . $session->applicant_id; $total_inactive = $db->query($inactive_sql); $total_inactive = $db->fetch_array($total_inactive); $total_inactive = array_shift($total_inactive); $admissions = new Admission(); $sql = "select * from admission_status where applicant_id='" . $session->applicant_id . "'"; $admissions = Admission::find_by_sql($sql); foreach ($admissions as $admission) { $time = $admission->time_completed_application; $academic_session = $admission->academic_session; $status = $admission->status; $reason_ = $admission->reason; } ?> <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#"></a> <ul class="nav nav-tabs"> <li class="active"><a href="home.php"><span><i class="icon-home"></i> </span> Home</a></li>