コード例 #1
0
ファイル: groups.php プロジェクト: regality/Zombie-PHP
 public function update($id, $name)
 {
     $query = new MysqlQuery("UPDATE groups\n          SET name = \$2\n          WHERE id = \$1");
     $query->addParam($id);
     $query->addParam($name);
     return $query->exec();
 }
コード例 #2
0
ファイル: MysqlQuery.php プロジェクト: regality/zombie-core
 /**
  * Construct a new query.
  *
  * @param string $query the query to be executed.
  * @param string $connector the connector from the config file.
  */
 public function __construct($query = '', $connector = 'mysql')
 {
     if (MysqlQuery::$db == null) {
         $config = getZombieConfig();
         MysqlQuery::$db = mysql_connect($config[$connector]['host'], $config[$connector]['user'], $config[$connector]['pass']);
         mysql_select_db($config[$connector]['database'], MysqlQuery::$db);
     }
     if (get_magic_quotes_gpc()) {
         $this->magic_quotes_on = true;
     }
     $this->query = $query;
 }
コード例 #3
0
ファイル: MysqlInsert.php プロジェクト: regality/zombie-core
 /**
  * Create an insert query;
  * @param string $insert_into the table to insert into.
  * @param string $connector the connector to use from the config file
  */
 public function __construct($insert_into = '', $connector = 'mysql')
 {
     parent::__construct('', $connector);
     $this->insertInto($insert_into);
     return $this;
 }
コード例 #4
0
ファイル: MysqlUpdate.php プロジェクト: regality/zombie-core
 /**
  * Create an update query;
  * @param string $update the table to update.
  * @param string $connector the connector to use from the config file
  */
 public function __construct($update = '', $connector = 'mysql')
 {
     parent::__construct('', $connector);
     $this->update($update);
     return $this;
 }
コード例 #5
0
ファイル: MysqlSelect.php プロジェクト: regality/zombie-core
 /**
  * Create a delete query;
  * @param string $select the columns to select.
  * @param string $connector the connector to use from the config file
  */
 public function __construct($select = '', $connector = 'mysql')
 {
     parent::__construct('', $connector);
     $this->select($select);
     return $this;
 }
コード例 #6
0
$query->addParam("admin");
$query->addParam("users");
echo "Info for admin user:\n";
echo "username: "******"firstname: ";
$firstname = trim(fgets(STDIN));
echo "lastname: ";
$lastname = trim(fgets(STDIN));
echo "password: "******"sha256", trim(fgets(STDIN)));
$rand_bits = strongRand(32);
$rand_bits = preg_replace('/[\\/=+]/', '', $rand_bits);
$rand_bits = substr($rand_bits, 0, 22);
$salt = '$2a$07$' . $rand_bits . '$';
$hash = crypt($password, $salt);
$query = new MysqlQuery('
   INSERT INTO users VALUES
   (username,
    firstname,
    lastname,
    salt,
    password)
   VALUES
   ($1, $2, $3, $4, $5)
');
$query->addParam($username);
$query->addParam($firstname);
$query->addParam($lastname);
$query->addParam($salt);
$query->addParam($password);
コード例 #7
0
ファイル: users.php プロジェクト: regality/Zombie-PHP
 public function updatePassword($user_id, $new_password)
 {
     $salt = $this->genBcryptSalt();
     $pass_hash = $this->bcrypt($new_password, $salt);
     $query = new MysqlQuery('UPDATE users
       SET salt = $1
         , password = $2
       WHERE id = $3');
     $query->addParam($salt);
     $query->addParam($pass_hash);
     $query->addParam($user_id);
     return $query->exec();
 }
コード例 #8
0
ファイル: template.php プロジェクト: regality/zombie-core
 function getTableJoinField($table)
 {
     $query = new MysqlQuery();
     $fields = $query->describe($table);
     $field_name = '';
     foreach ($fields as $field) {
         if ($field['Field'] == 'name') {
             return 'name';
         }
         if ($field_name == '' && $field['Field'] != 'id' && preg_match('/_id$/', $field['Field']) == 0) {
             $field_name = $field['Field'];
         }
     }
     return $field_name;
 }
コード例 #9
0
ファイル: MysqlDelete.php プロジェクト: regality/zombie-core
 /**
  * Create a delete query;
  * @param string $delete_from the table to delete from.
  * @param string $connector the connector to use from the config file
  */
 public function __construct($delete_from = '', $connector = 'mysql')
 {
     parent::__construct('', $connector);
     $this->deleteFrom($delete_from);
     return $this;
 }