コード例 #1
0
 public function update()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE user_power SET `uid`=:uid WHERE id=:id");
     $statement->bindValue(':uid', $this->uid, \PDO::PARAM_INT);
     $statement->bindValue(':id', $this->id, \PDO::PARAM_INT);
     $statement->execute();
     $this->uid = Database::lastInsertId();
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
コード例 #2
0
 function execute()
 {
     if (!Database::beginTransaction()) {
         trigger_error('Cannot initiate transaction.', E_USER_WARNING);
         return false;
         // Must halt explicitly because of data integrity.
     }
     $hasFailure = false;
     $failHandler = function () use(&$hasFailure) {
         $hasFailure = true;
     };
     foreach ($this->callbacks as $callback) {
         $callback()->fail($failHandler);
         if ($hasFailure) {
             break;
         }
     }
     if ($hasFailure) {
         Database::rollback();
     } else {
         Database::commit();
     }
     return !$hasFailure;
 }
コード例 #3
0
ファイル: User.php プロジェクト: gclove/shadowsocks-panel
 /**
  * update User info
  *
  */
 public function updateUser()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE member SET email=:email, `password`=:pwd, sspwd=:sspwd, `port`=:port, nickname=:nickname,\n            `flow_up`=:flow_up, `flow_down`=:flow_down, transfer=:transfer, plan=:plan, `enable`=:enable, invite=:invite, regDateLine=:regDateLine WHERE uid=:userId");
     $statement->bindValue(':email', $this->email, \PDO::PARAM_STR);
     $statement->bindValue(':pwd', $this->password, \PDO::PARAM_STR);
     $statement->bindValue(':sspwd', $this->sspwd, \PDO::PARAM_STR);
     $statement->bindValue(':port', $this->port, \PDO::PARAM_INT);
     $statement->bindValue(':nickname', $this->nickname, \PDO::PARAM_STR);
     $statement->bindValue(':flow_up', $this->flow_up, \PDO::PARAM_INT);
     $statement->bindValue(':flow_down', $this->flow_down, \PDO::PARAM_INT);
     $statement->bindValue(':transfer', $this->transfer, \PDO::PARAM_INT);
     $statement->bindValue(':plan', $this->plan, \PDO::PARAM_STR);
     $statement->bindValue(':enable', $this->enable, \PDO::PARAM_INT);
     $statement->bindValue(':invite', $this->invite, \PDO::PARAM_INT);
     $statement->bindValue(':regDateLine', $this->regDateLine, \PDO::PARAM_INT);
     $statement->bindValue(':userId', $this->uid, \PDO::PARAM_INT);
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
コード例 #4
0
ファイル: Invite.php プロジェクト: vacan/shadowsocks-panel
 public function updateInvite()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE invite SET expiration=:expiration,\n\t\t\t`reguid`=:reguid, `regDateLine`=:regDateLine, `status`=:status, `inviteIp`=:inviteIp WHERE invite=:invite");
     $statement->bindValue(':expiration', $this->expiration, \PDO::PARAM_INT);
     $statement->bindValue(':reguid', $this->reguid, \PDO::PARAM_INT);
     $statement->bindValue(':regDateLine', $this->regDateLine, \PDO::PARAM_INT);
     $statement->bindValue(':status', $this->status, \PDO::PARAM_INT);
     $statement->bindValue(':inviteIp', $this->inviteIp, \PDO::PARAM_STR);
     $statement->bindValue(':invite', $this->invite, \PDO::PARAM_STR);
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
コード例 #5
0
ファイル: User.php プロジェクト: biaoiaoo/KK-Framework
 /**
  * Save new password
  * @param string $password New password
  */
 public function savePassword($password)
 {
     $salt = substr(md5($this->id . $this->email . ENCRYPT_KEY), 8, 16);
     $this->password = substr(md5(md5($password) . $salt), 0, 30) . 'T' . self::ENCRYPT_TYPE_ENHANCE;
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE member SET `password`=:pwd WHERE id=:userId");
     $statement->bindValue(':pwd', $this->password, \PDO::PARAM_STR);
     $statement->bindValue(':userId', $this->id, \PDO::PARAM_INT);
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
コード例 #6
0
ファイル: Process.php プロジェクト: Victopia/prefw
// No waiting jobs in queue.
if (!$process) {
    Database::unlockTables(true);
    Database::rollback();
    Log::debug('No more jobs to do, suicide.');
    die;
}
$processContents = (array) ContentDecoder::json($process[Node::FIELD_VIRTUAL], 1);
unset($process[Node::FIELD_VIRTUAL]);
$process += $processContents;
unset($processContents);
$res = Database::query('UPDATE `' . FRAMEWORK_COLLECTION_PROCESS . '` SET `pid` = ?
    WHERE `id` = ? AND `pid` IS NULL LIMIT 1', [getmypid(), $process['id']]);
// Commit transaction
Database::unlockTables(true);
Database::commit();
if ($res->rowCount() < 1) {
    Log::warning('Unable to update process pid, worker exits.');
    die;
} else {
    $process['pid'] = getmypid();
    $process[Node::FIELD_COLLECTION] = FRAMEWORK_COLLECTION_PROCESS;
}
// Check if $env specified in option
if (@$_SERVER['env']) {
    $_SERVER['env'] = ContentDecoder::json($_SERVER['env'], 1);
}
// More debug logs
Log::debug("Execute process: {$process['command']}");
// Spawn process and retrieve the pid
$proc = false;
コード例 #7
0
 /**
  * 更新 node 信息
  * @param $node
  */
 public function UpdateNode()
 {
     $statement = Database::prepare("UPDATE node SET `name`=:name, `type`=:type,\n\t\t\t`server`=:server, `method`=:method, `info`=:info, `status`:=status, `order`=:order WHERE id=:id");
     $statement->bindValue(':name', $this->name, \PDO::PARAM_STR);
     $statement->bindValue(':type', $this->type, \PDO::PARAM_INT);
     $statement->bindValue(':server', $this->server, \PDO::PARAM_STR);
     $statement->bindValue(':method', $this->method, \PDO::PARAM_STR);
     $statement->bindValue(':info', $this->info, \PDO::PARAM_STR);
     $statement->bindValue(':status', $this->status, \PDO::PARAM_STR);
     $statement->bindValue(':order', $this->order, \PDO::PARAM_INT);
     $statement->bindValue(':id', $this->id, \PDO::PARAM_INT);
     $statement->execute();
     Database::commit();
 }
コード例 #8
0
ファイル: Message.php プロジェクト: gclove/shadowsocks-panel
 /**
  * Update message
  */
 public function update()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE message SET `content`=:content, `pushTime`=:pushTime,\n\t\t\t`addTime`=:addTime, `pushUsers`=:pushUsers, `type`=:type, `pushEndTime`:=pushEndTime,\n\t\t\t `order`=:order WHERE id=:id");
     $statement->bindValue(':content', $this->name, \PDO::PARAM_STR);
     $statement->bindValue(':pushTime', $this->type, \PDO::PARAM_INT);
     $statement->bindValue(':addTime', $this->server, \PDO::PARAM_INT);
     $statement->bindValue(':pushUsers', $this->method, \PDO::PARAM_STR);
     $statement->bindValue(':type', $this->info, \PDO::PARAM_INT);
     $statement->bindValue(':pushEndTime', $this->status, \PDO::PARAM_INT);
     $statement->bindValue(':order', $this->order, \PDO::PARAM_INT);
     $statement->bindValue(':id', $this->order, \PDO::PARAM_INT);
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }