コード例 #1
0
ファイル: Fields.php プロジェクト: bribrink/crudkiller
 public static function selectgen($name, $label, $table, $required = null, $selected = null)
 {
     if ($required != null) {
         $required = 'required';
     }
     $s = '';
     $s .= '<div class="form-group">
         <label>' . $label . '</label>
         <select class="form-control" name="' . $name . '" required >';
     $s .= '<option value=""    > Select </option>';
     $pdo = DatabaseFactory::getFactory()->getConnection();
     $sql = "SELECT id, name FROM  " . $table;
     $query = $pdo->prepare($sql);
     $query->execute();
     $options = $query->fetchAll();
     foreach ($options as $k => $v) {
         $s .= '<option value="' . $v->id . '" ';
         if ($v->id == $selected) {
             $s .= ' selected ';
         }
         $s .= '    >' . $v->name . '</option>';
     }
     $s .= '</select>
     </div>';
     return $s;
 }
コード例 #2
0
ファイル: Config.php プロジェクト: BuzzyOG/PC-Track
 public static function get($key)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $query = $database->prepare("SELECT `value` FROM `settings` WHERE `setting` = :key LIMIT 1");
     $query->execute(array(':key' => $key));
     $fetched = json_decode(json_encode($query->fetch(PDO::FETCH_ASSOC)), true);
     return $fetched['value'];
 }
コード例 #3
0
ファイル: SetModel.php プロジェクト: vradinolfi/Transmute-v5
 public static function getCardsInSet($setcode)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "SELECT name, setcode, multiverseid, id FROM cards WHERE setcode = '{$setcode}' LIMIT 20";
     $query = $database->prepare($sql);
     $query->execute();
     return $query->fetchAll();
 }
コード例 #4
0
ファイル: LogModel.php プロジェクト: queer1/PC-Track
 /**
  * create a new log entry
  * @param $user_id , add user_id to log
  * @param string $action , create-comment-close-undo
  * @param string $param , addtional parameters that can be stored. (JSON)
  * @return bool feedback
  */
 public static function log($user_id, $action, $param)
 {
     $db = DatabaseFactory::getFactory()->fluentPDO();
     $values = array('ENTRY_ID' => time(), 'action' => $action, 'user_id' => $user_id, 'param' => json_encode($param));
     $query = $db->insertInto('log', $values);
     $query->execute();
     return true;
 }
コード例 #5
0
 public function load($area, $subject, $longBR, $latBR, $longTL, $latTL)
 {
     $geodatabase = DatabaseFactory::getFactory()->getGeoConnection();
     $table_name = $area . "_" . $subject;
     /*
     if ($area == "city") 
         { 
            $table_name = $subject;
            
         }
     if ($area == "county") 
         { 
            $table_name = "oc_" . $subject;
            
         }
     */
     $collection = $geodatabase->{$table_name};
     /*
         if(!empty($latTL) && !empty($longTL) && !empty($latBR) && !empty($longBR)){
     
            //$query = GeoQuery::findbybox(-117.91733264923096,33.676568503347546,-117.90239810943604,33.68606772497501);
           $query = GeoQuery::findbybox($longBR,  $latBR,  $longTL, $latTL);
           $count_ = $collection->count($query);
         }
        else {
            // in case of not box coordinate provide, will find all record
            $query=null;
            $count_ = $collection->count();
        }
     */
     $query = GeoQuery::findbybox($longBR, $latBR, $longTL, $latTL);
     $count_ = $collection->count($query);
     // $count_ = $collection->getSize();
     $_max_row_count = Config::get('Max_Row_Count');
     if ($count_ > 0 and $count_ < $_max_row_count) {
         if (!empty($latTL) && !empty($longTL) && !empty($latBR) && !empty($longBR)) {
             $cursor = $collection->find($query);
         } else {
             $cursor = $collection->find();
         }
         // iterate through the results
         $result = "{ \"type\": \"FeatureCollection\",\"features\": [";
         foreach ($cursor as $document) {
             //echo $document["properties"] . "\n";
             //print_r($document);
             //echo json_encode($document);
             $result = $result . json_encode($document) . ",";
         }
         $result = substr($result, 0, -1);
         $result = $result . "]}";
         echo $result;
     } else {
         echo $count_;
     }
     //else
 }
コード例 #6
0
ファイル: AdminModel.php プロジェクト: evdevgit/huge
 /**
  * Kicks the selected user out of the system instantly by resetting the user's session.
  * This means, the user will be "logged out".
  *
  * @param $userId
  * @return bool
  */
 private static function resetUserSession($userId)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $query = $database->prepare("UPDATE users SET session_id = :session_id  WHERE user_id = :user_id LIMIT 1");
     $query->execute(array(':session_id' => null, ':user_id' => $userId));
     if ($query->rowCount() == 1) {
         Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_USER_SUCCESSFULLY_KICKED'));
         return true;
     }
 }
コード例 #7
0
 public static function getItemInventory($productname)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "SELECT * FROM products WHERE product_name LIKE '%{$productname}%'";
     $sql .= " ORDER BY product_price DESC";
     $sql .= " LIMIT 20";
     $query = $database->prepare($sql);
     $query->execute(array(':item' => $item));
     return $query->fetchAll();
 }
コード例 #8
0
ファイル: UserRoleModel.php プロジェクト: BuzzyOG/PC-Track
 /**
  * @param $user_id
  * @param $removed_perm
  */
 public static function removePerm($user_id, $removed_perm)
 {
     $original = UserRoleModel::getPerms($user_id);
     $being_removed = array_search($removed_perm, $original);
     unset($original[$being_removed]);
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "UPDATE users SET perms = :new WHERE user_id = :user_id";
     $query = $database->prepare($sql);
     $query->execute(array(':new' => json_encode($original), ':user_id' => $user_id));
 }
コード例 #9
0
ファイル: Config.php プロジェクト: queer1/PC-Track
 /**
  * Set a Config option in the Database
  * @param $key
  * @param $setting
  */
 public static function set($key, $setting)
 {
     if (Cache::has($key)) {
         Cache::forget($key);
     }
     if (self::$setQuery === null) {
         self::$setQuery = DatabaseFactory::getFactory()->getConnection()->prepare("UPDATE settings SET `value` = :setting WHERE `key` = :key");
     }
     self::$setQuery->execute(array(':key' => $key, ':setting' => $setting));
 }
コード例 #10
0
ファイル: UserRoleModel.php プロジェクト: queer1/PC-Track
 /**
  * Remove A user permission
  * @param $user_id
  * @param $removed_perm
  */
 public static function removePerm($user_id, $removed_perm)
 {
     if (self::$removePermQuery === null) {
         self::$removePermQuery = DatabaseFactory::getFactory()->getConnection()->prepare("UPDATE users SET perms = :new WHERE user_id = :user_id");
     }
     $original = UserRoleModel::getPerms($user_id);
     $being_removed = array_search($removed_perm, $original);
     unset($original[$being_removed]);
     self::$removePermQuery->execute(array(':new' => json_encode($original), ':user_id' => $user_id));
     Session::add('feedback_positive', 'Removed that permission!');
 }
コード例 #11
0
ファイル: GreeterModel.php プロジェクト: NRWB/TutorQueue
 /**
  * @function setRequestDetails
  * @public
  * @static
  * @returns NONE
  * @desc
  * @param {string} foo Use the 'foo' param for bar.
  * @example NONE
  */
 public static function setRequestDetails($recordID, $tableNo, $subj, $subSubj, $tutName)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     // to do = update according to the settings needed given func's params/args.
     $query = $database->prepare("UPDATE users SET user_deleted = :user_deleted  WHERE user_id = :user_id LIMIT 1");
     $query->execute(array(':user_deleted' => $delete, ':user_id' => $userId));
     // to do = determine if needed below if-statement
     if ($query->rowCount() == 1) {
         Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_SUSPENSION_DELETION_STATUS'));
         return true;
     }
 }
コード例 #12
0
ファイル: Language.php プロジェクト: queer1/PC-Track
 /**
  * Get the user language (if they are logged in)
  * @param null $userID
  * @return mixed|null
  */
 public static function getUserLanguage($userID = null)
 {
     if ($userID === null) {
         return null;
     } else {
         if (self::$userLangQuery === null) {
             self::$userLangQuery = DatabaseFactory::getFactory()->getConnection()->prepare('SELECT user_lang FROM users WHERE user_id = :user_id');
         }
         self::$userLangQuery->execute(array('user_id' => Session::get('user_id')));
         return self::$userLangQuery->fetch();
     }
 }
コード例 #13
0
ファイル: LockModel.php プロジェクト: queer1/PC-Track
 public static function unlock()
 {
     $db = DatabaseFactory::getFactory()->fluentPDO();
     $values = array('user_id' => Session::get('user_id'), 'user_name' => Session::get('user_name'));
     $query = $db->from('user_lock')->where($values);
     $query->execute();
     $result = $query->fetch();
     Session::set('locked', false);
     // dirty manner to turn stdclass to array
     $refer = json_decode(json_encode($result), true);
     $db->deleteFrom('user_lock', Session::get('user_id'));
     // needs to be fixed. currently it can make it end up at: http://HOST.COM/inventory/http://HOST.COM/inventory/login/showProfile
     Redirect::to($refer['refer_page']);
 }
コード例 #14
0
ファイル: TutorModel.php プロジェクト: NRWB/TutorQueue
 /**
  * @function confirmTutorCode
  * @public
  * @static
  * @returns {boolean} True if successful.
  * @desc Created to look up a tutors input code, to see if the input number is a valid tutor code for accessing the tutor view. Logs in as a tutor if the code found is a success.
  * @param NONE
  * @example NONE
  */
 public static function confirmTutorCode()
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $tut_code = Request::post('input_tutor_text_code');
     //    $query = $database->prepare("SELECT * FROM qscTutorList.tblAllTutors WHERE tutcode = :the_tutor_code LIMIT 1");
     $query = $database->prepare("SELECT * FROM qscTutorList.tblAllTutors WHERE tutCode = :the_tutor_code LIMIT 1");
     $query->execute(array(':the_tutor_code' => $tut_code));
     if ($query->rowCount() == 1) {
         Session::set('tmp_tutor_code', $tut_code);
         return true;
     } else {
         return false;
     }
 }
コード例 #15
0
ファイル: UserRoleModel.php プロジェクト: panique/huge
 /**
  * Writes the new account type marker to the database and to the session
  *
  * @param $type
  *
  * @return bool
  */
 public static function saveRoleToDatabase($type)
 {
     // if $type is not 1 or 2
     if (!in_array($type, [1, 2])) {
         return false;
     }
     $database = DatabaseFactory::getFactory()->getConnection();
     $query = $database->prepare("UPDATE users SET user_account_type = :new_type WHERE user_id = :user_id LIMIT 1");
     $query->execute(array(':new_type' => $type, ':user_id' => Session::get('user_id')));
     if ($query->rowCount() == 1) {
         // set account type in session
         Session::set('user_account_type', $type);
         return true;
     }
     return false;
 }
コード例 #16
0
 public static function setAccountSuspensionAndDeletionStatus($suspensionInDays, $softDelete, $userId)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     if ($suspensionInDays > 0) {
         $suspensionTime = time() + $suspensionInDays * 60 * 60 * 24;
     } else {
         $suspensionTime = null;
     }
     // FYI "on" is what a checkbox delivers by default when submitted. Didn't know that for a long time :)
     if ($softDelete == "on") {
         $delete = 1;
     } else {
         $delete = 0;
     }
     $query = $database->prepare("UPDATE users SET user_suspension_timestamp = :user_suspension_timestamp, user_deleted = :user_deleted  WHERE user_id = :user_id LIMIT 1");
     $query->execute(array(':user_suspension_timestamp' => $suspensionTime, ':user_deleted' => $delete, ':user_id' => $userId));
     if ($query->rowCount() == 1) {
         Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_SUSPENSION_DELETION_STATUS'));
         return true;
     }
 }
コード例 #17
0
ファイル: updateTable.php プロジェクト: NRWB/TutorQueue
<?php

$database = DatabaseFactory::getFactory()->getConnection();
$query = $database->prepare("SELECT * FROM qscQueue.tblRequests WHERE serviceState IN ('wait', 'progress', 'done')");
$query->execute();
$result = $query->fetchAll();
$count = 0;
echo "\n    <thead>\n      <tr>\n        <th>Table Number</th>\n        <th>Subject </th>\n        <th>Sub-Subject </th>\n        <th>Requested Tutor</th>\n        <th>Time In</th>\n        <th>Wait Time Elapsed</th>\n        <th>Help Time Elapsed</th>\n        <th>Responding Tutor</th>\n      </tr>\n    </thead>\n  ";
foreach ($result as $record) {
    echo "<tr><td>";
    echo $record->tableNo;
    echo "</td><td>";
    echo $record->subject;
    echo "</td><td>";
    echo $record->subSubject;
    echo "</td><td>";
    echo $record->tutorRequested;
    echo "</td><td>";
    // More info on MySQL timestap = http://dev.mysql.com/doc/refman/5.7/en/datetime.html
    // time in (time stamp)
    echo substr($record->tsRequest, 10);
    echo "</td><td>";
    // wait time (counter)
    $orig = substr($record->tsRequest, 10);
    $hh1 = substr($orig, 0, 3);
    $mm1 = substr($orig, 4, 2);
    $ss1 = substr($orig, 7, 2);
    $curr = new DateTime("now");
    $str = substr(date_format($curr, 'Y-m-d H:i:s'), 10);
    $hh2 = substr($str, 0, 3);
    $mm2 = substr($str, 4, 3);
コード例 #18
0
ファイル: UserModel.php プロジェクト: queer1/PC-Track
 public static function getUsernameById($user_id)
 {
     $db = DatabaseFactory::getFactory()->fluentPDO();
     $query = $db->from('users')->select('user_name')->where('user_id', $user_id);
     $result = $query->execute()->fetch();
     $data = json_decode(json_encode($result), true);
     return $data['user_name'];
 }
コード例 #19
0
 /**
  * Writes the new password to the database
  *
  * @param string $user_name username
  * @param string $user_password_hash
  * @param string $user_password_reset_hash
  *
  * @return bool
  */
 public static function saveNewUserPassword($user_name, $user_password_hash, $user_password_reset_hash)
 {
     if (self::$saveNewPasswordQuery === null) {
         self::$saveNewPasswordQuery = DatabaseFactory::getFactory()->getConnection()->prepare("UPDATE users SET user_password_hash = :user_password_hash, user_password_reset_hash = NULL,\n                       user_password_reset_timestamp = NULL\n                 WHERE user_name = :user_name AND user_password_reset_hash = :user_password_reset_hash\n                       AND user_provider_type = :user_provider_type LIMIT 1");
     }
     self::$saveNewPasswordQuery->execute(array(':user_password_hash' => $user_password_hash, ':user_name' => $user_name, ':user_password_reset_hash' => $user_password_reset_hash, ':user_provider_type' => 'DEFAULT'));
     // if one result exists, return true, else false. Could be written even shorter btw.
     return self::$saveNewPasswordQuery->rowCount() == 1 ? true : false;
 }
コード例 #20
0
 private function delete($id)
 {
     $pdo = DatabaseFactory::getFactory()->getConnection();
     $sql = "DELETE FROM " . $this->table . " WHERE id = " . $id;
     $query = $pdo->prepare($sql);
     $query->execute();
     return;
 }
コード例 #21
0
 public static function getQuestionText($book_id, $num_paragraphs)
 {
     // Get the number of sections of the book.
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "SELECT `sections` FROM `books` WHERE `book_id` = :book_id;";
     $query = $database->prepare($sql);
     $query->execute(array(':book_id' => $book_id));
     $numSections = (int) $query->fetch()->sections;
     // Get the start section of the book.
     $sql = "SELECT `section_id` from `sections` WHERE `book_id` = :book_id;";
     $query = $database->prepare($sql);
     $query->execute(array(':book_id' => $book_id));
     $bookStart = (int) $query->fetch()->section_id;
     // Get a randomly-generated start of the excerpt.
     $excerptStart = rand($bookStart, $bookStart + ($numSections - $num_paragraphs));
     // Generates random excerptStart from the first to the last-num_paragraphs sections.
     // Create a string, excerptText, which contains the text with the desired number of paragraphs.
     $excerptText = '';
     $sql = "SELECT `section_text` FROM `sections` WHERE `section_id` = :section_id;";
     $query = $database->prepare($sql);
     for ($i = 0; $i < $num_paragraphs; $i++) {
         $query->execute(array(':section_id' => $excerptStart + $i));
         $excerptText .= $query->fetch()->section_text;
         $excerptText .= "<br><br>";
     }
     Session::set('excerptStart', $excerptStart);
     Session::set('excerptSize', $num_paragraphs);
     return $excerptText;
 }
コード例 #22
0
ファイル: Formkiller.php プロジェクト: bribrink/crudkiller
    private function datatables($id = null)
    {
        //get the columns, and the foreign key-tables
        $pdo = DatabaseFactory::getFactory()->getConnection();
        $sql = "SHOW FULL COLUMNS FROM " . $this->table;
        $query = $pdo->prepare($sql);
        $query->execute();
        $columns = $query->fetchAll();
        //create foreign keys/tables
        $foreigntable = [];
        $fields = [];
        foreach ($columns as $k => $v) {
            //set fields for later
            $fields[] = $v->Field;
            if (strpos($v->Field, '_id') !== false) {
                $foreigntable[$v->Field] = lcfirst(str_replace(['_id'], '', $v->Field));
            }
        }
        $select = "{$this->table}.*";
        $pdo = DatabaseFactory::getFactory()->getConnection();
        //set up our strings to manipulate
        $sql = null;
        $sqljoin = null;
        $sqlwhere = null;
        if (count($foreigntable) > 0) {
            foreach ($foreigntable as $k => $v) {
                $sqljoin .= " LEFT JOIN " . $v . "\n                ON " . $v . ".id = " . $this->table . "." . ucfirst($v) . "_id  ";
                //add a name to select from the table
                $select .= ",  {$v}.name as " . $v . "_name";
            }
            $sqljoin = rtrim($sqljoin, ',');
        }
        //now add in the $select, if it has changed from about
        $sql = "SELECT {$select} FROM " . $this->table;
        if (!is_null($id)) {
            $sqlwhere .= " WHERE {$this->table}.id = " . $id;
        }
        /*
                        if (isset($id)){
                            $sqlwhere .=  " WHERE $this->table.id = ".$id;
                        } */
        $sqlmaster = $sql . $sqljoin . $sqlwhere;
        $query = $pdo->prepare($sqlmaster);
        $query->execute();
        $values = $query->fetchAll();
        ?>
        <div class="container">

        <?php 
        $t = ' ';
        $t .= "<table id='modeltable' class='table table-striped' width='100%'>";
        $t .= "<thead>";
        foreach ($fields as $h) {
            if (in_array($h, $this->fields)) {
                $t .= "<th>" . $h . "</th>";
            }
        }
        $t .= "<th>Actions</th>";
        $t .= "</thead>";
        $t .= "<tbody>";
        foreach ($values as $tr) {
            $id = $tr->id;
            $t .= "<tr data-row='" . $tr->id . "' class='gettable'>";
            foreach ($tr as $k => $v) {
                if (in_array($k, $this->fields)) {
                    if (isset($foreigntable[$k])) {
                        $tmp = $foreigntable[$k] . "_name";
                        $v = $tr->{$tmp};
                    }
                    $t .= "<td>" . $v . "</td>";
                }
            }
            $t .= "<td>\n                            <div class=\"btn-group-xs\">\n                                <a class=\"btn btn-primary btn-xs\" href=\"?action=view&table=" . $this->table . "&id=" . $id . " \"><span class='glyphicon glyphicon-eye-open'></span></a>\n                                <a class=\"btn btn-info btn-xs\" href=\"?action=edit&id=" . $id . "&table=" . $this->table . " \"><span class='glyphicon glyphicon-edit'></span></a>\n                                <a class=\"btn btn-danger btn-xs\" href=\"?action=delete&id=" . $id . "&table=" . $this->table . "\"><span class='glyphicon glyphicon-ban-circle'></span></a>\n                            </div>\n                      </td>";
            $t .= "</tr>";
        }
        $t .= "</tbody>";
        $t .= "</table>";
        $addbutton = '<a class="btn btn-success" href="?action=add&table=' . $this->table . '" />
                            Add
                          </a><br/>';
        return $addbutton . $t;
    }
コード例 #23
0
ファイル: LoginModel.php プロジェクト: BuzzyOG/PC-Track
 /**
  * Write remember-me token into database and into cookie
  * Maybe splitting this into database and cookie part ?
  *
  * @param $user_id
  */
 public static function setRememberMeInDatabaseAndCookie($user_id)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     // generate 64 char random string
     $random_token_string = hash('sha256', mt_rand());
     // write that token into database
     $sql = "UPDATE users SET user_remember_me_token = :user_remember_me_token WHERE user_id = :user_id LIMIT 1";
     $sth = $database->prepare($sql);
     $sth->execute(array(':user_remember_me_token' => $random_token_string, ':user_id' => $user_id));
     // generate cookie string that consists of user id, random string and combined hash of both
     $cookie_string_first_part = $user_id . ':' . $random_token_string;
     $cookie_string_hash = hash('sha256', $cookie_string_first_part);
     $cookie_string = $cookie_string_first_part . ':' . $cookie_string_hash;
     // set cookie
     setcookie('remember_me', $cookie_string, time() + Config::get('COOKIE_RUNTIME'), Config::get('COOKIE_PATH'));
 }
コード例 #24
0
ファイル: AvatarModel.php プロジェクト: revelade/huge
 /**
  * Delete a user's avatar
  *
  * @param int $userId
  * @return bool success
  */
 public static function deleteAvatar($userId)
 {
     if (!ctype_digit($userId)) {
         Session::add("feedback_negative", Text::get("FEEDBACK_AVATAR_IMAGE_DELETE_FAILED"));
         return false;
     }
     // try to delete image, but still go on regardless of file deletion result
     self::deleteAvatarImageFile($userId);
     $database = DatabaseFactory::getFactory()->getConnection();
     $sth = $database->prepare("UPDATE users SET user_has_avatar = 0 WHERE user_id = :user_id LIMIT 1");
     $sth->bindValue(":user_id", (int) $userId, PDO::PARAM_INT);
     $sth->execute();
     if ($sth->rowCount() == 1) {
         Session::set('user_avatar_file', self::getPublicUserAvatarFilePathByUserId($userId));
         Session::add("feedback_positive", Text::get("FEEDBACK_AVATAR_IMAGE_DELETE_SUCCESSFUL"));
         return true;
     } else {
         Session::add("feedback_negative", Text::get("FEEDBACK_AVATAR_IMAGE_DELETE_FAILED"));
         return false;
     }
 }
コード例 #25
0
ファイル: PasswordResetModel.php プロジェクト: panique/huge
 /**
  * Validates current and new passwords
  *
  * @param string $user_name
  * @param string $user_password_current
  * @param string $user_password_new
  * @param string $user_password_repeat
  *
  * @return bool
  */
 public static function validatePasswordChange($user_name, $user_password_current, $user_password_new, $user_password_repeat)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "SELECT user_password_hash, user_failed_logins FROM users WHERE user_name = :user_name LIMIT 1;";
     $query = $database->prepare($sql);
     $query->execute(array(':user_name' => $user_name));
     $user = $query->fetch();
     if ($query->rowCount() == 1) {
         $user_password_hash = $user->user_password_hash;
     } else {
         Session::add('feedback_negative', Text::get('FEEDBACK_USER_DOES_NOT_EXIST'));
         return false;
     }
     if (!password_verify($user_password_current, $user_password_hash)) {
         Session::add('feedback_negative', Text::get('FEEDBACK_PASSWORD_CURRENT_INCORRECT'));
         return false;
     } else {
         if (empty($user_password_new) || empty($user_password_repeat)) {
             Session::add('feedback_negative', Text::get('FEEDBACK_PASSWORD_FIELD_EMPTY'));
             return false;
         } else {
             if ($user_password_new !== $user_password_repeat) {
                 Session::add('feedback_negative', Text::get('FEEDBACK_PASSWORD_REPEAT_WRONG'));
                 return false;
             } else {
                 if (strlen($user_password_new) < 6) {
                     Session::add('feedback_negative', Text::get('FEEDBACK_PASSWORD_TOO_SHORT'));
                     return false;
                 } else {
                     if ($user_password_current == $user_password_new) {
                         Session::add('feedback_negative', Text::get('FEEDBACK_PASSWORD_NEW_SAME_AS_CURRENT'));
                         return false;
                     }
                 }
             }
         }
     }
     return true;
 }
コード例 #26
0
ファイル: Session.php プロジェクト: AstroTheCoder/huge
 /**
  * checks for session concurrency
  *
  * This is done as the following:
  * UserA logs in with his session id('123') and it will be stored in the database.
  * Then, UserB logs in also using the same email and password of UserA from another PC,
  * and also store the session id('456') in the database
  *
  * Now, Whenever UserA performs any action,
  * You then check the session_id() against the last one stored in the database('456'),
  * If they don't match then log both of them out.
  *
  * @access public
  * @static static method
  * @return bool
  * @see Session::updateSessionId()
  * @see http://stackoverflow.com/questions/6126285/php-stop-concurrent-user-logins
  */
 public static function isConcurrentSessionExists()
 {
     $session_id = session_id();
     $userId = Session::get('user_id');
     if (isset($userId) && isset($session_id)) {
         $database = DatabaseFactory::getFactory()->getConnection();
         $sql = "SELECT session_id FROM users WHERE user_id = :user_id LIMIT 1";
         $query = $database->prepare($sql);
         $query->execute(array(":user_id" => $userId));
         $result = $query->fetch();
         $userSessionId = !empty($result) ? $result->session_id : null;
         return $session_id !== $userSessionId;
     }
     return false;
 }
コード例 #27
0
ファイル: GameModel.php プロジェクト: shx13/php-wars
 public static function get_ranking()
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     if ($database != false) {
         $sql = "SELECT *\n            FROM ranking\n            ORDER BY points DESC;";
         $query = $database->prepare($sql);
         $query->execute();
         return $query->fetchAll();
     }
 }
コード例 #28
0
ファイル: AdminModel.php プロジェクト: NRWB/TutorQueue
 /**
  * @function 
  * @public
  * @static
  * @returns NONE
  * @desc
  * @param {string} foo Use the 'foo' param for bar.
  * @example NONE
  */
 public static function getQuickNotes()
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "SELECT * FROM qscQueue.tblTutorQuickNotes";
     return $database->query($sql);
 }
コード例 #29
0
ファイル: RegistrationModel.php プロジェクト: NRWB/TutorQueue
 /**
  * @function 
  * @public
  * @static
  * @returns NONE
  * @desc
  * @param {string} foo Use the 'foo' param for bar.
  * @example NONE
  */
 public static function verifyNewUser($user_id, $user_activation_verification_code)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     $sql = "UPDATE users SET user_active = 1, user_activation_hash = NULL\n            WHERE user_id = :user_id AND user_activation_hash = :user_activation_hash LIMIT 1";
     $query = $database->prepare($sql);
     $query->execute(array(':user_id' => $user_id, ':user_activation_hash' => $user_activation_verification_code));
     if ($query->rowCount() == 1) {
         Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_ACTIVATION_SUCCESSFUL'));
         return true;
     }
     Session::add('feedback_negative', Text::get('FEEDBACK_ACCOUNT_ACTIVATION_FAILED'));
     return false;
 }
コード例 #30
0
ファイル: UserModel.php プロジェクト: vradinolfi/Transmute-v5
 /**
  * Gets the user's data by user's id and a token (used by login-via-cookie process)
  *
  * @param $user_id
  * @param $token
  *
  * @return mixed Returns false if user does not exist, returns object with user's data when user exists
  */
 public static function getUserDataByUserIdAndToken($user_id, $token)
 {
     $database = DatabaseFactory::getFactory()->getConnection();
     // get real token from database (and all other data)
     $query = $database->prepare("SELECT user_id, user_name, user_email, user_password_hash, user_active,\n                                          user_account_type,  user_has_avatar, user_failed_logins, user_last_failed_login\n                                     FROM users\n                                     WHERE user_id = :user_id\n                                       AND user_remember_me_token = :user_remember_me_token\n                                       AND user_remember_me_token IS NOT NULL\n                                       AND user_provider_type = :provider_type LIMIT 1");
     $query->execute(array(':user_id' => $user_id, ':user_remember_me_token' => $token, ':provider_type' => 'DEFAULT'));
     // return one row (we only have one result or nothing)
     return $query->fetch();
 }