/** * 添加回复 */ public static final function append() { $online = front::online(); if (!$online->user_id) { die('Permission Denied!'); } //需要登录 $time = time(); while (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') { $post = array('doc_id' => isset($_POST['doc_id']) ? $_POST['doc_id'] : '', 'email' => isset($_POST['email']) ? $_POST['email'] : '', 'content' => isset($_POST['content']) ? $_POST['content'] : '', 'ip' => get_onlineip(), 'create_date' => date('Y-m-d', $time), 'create_time' => date('H:i:s', $time)); //$post['content'] = htmlentities($content , ENT_COMPAT ,'utf-8') ; //pecho($post); if (!empty($error)) { break; } $doc_remark = new self(); $doc_remark->doc_remark_id = null; $doc_remark->struct($post); $doc_remark->insert('', 'doc_remark_id'); if ($doc_remark->doc_remark_id) { $doc = new doc(); $doc->doc_id = $doc_remark->doc_id; $doc->last_remark = date('Y-m-d H:i:s', $time); $doc->update(); } //print_r ( $doc_remark); header('Location: ?' . $_GET['query']); return; } }
public static function scanTags($inputTags) { if (!is_array($inputTags)) { return false; } $inputTags = array_unique($inputTags); $result = []; foreach ($inputTags as $v) { if (empty($v)) { continue; } $slug = StringHelper::generateCleanStr($v); if (!$slug) { continue; } $model = static::find()->andWhere(['name' => $slug])->one(); if ($model) { $result[] = $model->mid; } else { $tag = new self(); $tag->name = $tag->slug = $slug; if ($tag->insert(false)) { $result[] = $tag->mid; } } } return $result; }
/** * add new log entry. * * @param int $type The type of add * + 1 = insertion * + 2 = update * + 3 = deletion * @param string $message */ public static function add($type, $message, array $additionalData = []) { $attrs = ['is_insertion' => $type == 1 ? 1 : 0, 'is_update' => $type == 2 ? 1 : 0, 'is_deletion' => $type == 3 ? 1 : 0, 'message' => $message, 'data_json' => $additionalData]; $model = new self(); $model->setAttributes($attrs); return $model->insert(false); }
/** * Insert a new quote. * @param string $username * @param string $text * @return Dog_Quote */ public static function insertQuote($username, $text) { $quote = new self(array('quot_id' => 0, 'quot_text' => $text, 'quot_username' => $username, 'quot_rating' => 0, 'quot_date' => GWF_Time::getDate(14))); if (false === $quote->insert()) { return false; } return $quote; }
/** * @param int $userid * @return Dog_ScumStats */ private static function createStatsRow($userid) { $row = new self(array('scums_userid' => $userid, 'scums_games' => 0, 'scums_won' => 0, 'scums_score' => 0)); if (false === $row->insert()) { return false; } return $row; }
public static function newMessage($sender, $target, $message) { $msg = new self(array('chatmsg_time' => time(), 'chatmsg_from' => $sender, 'chatmsg_to' => $target, 'chatmsg_msg' => $message)); if (false === $msg->insert()) { return false; } return $msg; }
public static function fromCollection(Collection $initialData) { $tree = new self(); foreach ($initialData->toArray() as $element) { $tree->insert($element); } return $tree; }
public static function insertEntry($siteid, $score, $usercount, $challcount, $comment = '') { $entry = new self(array('sitehist_sid' => $siteid, 'sitehist_date' => time(), 'sitehist_score' => $score, 'sitehist_usercount' => $usercount, 'sitehist_challcount' => $challcount, 'sitehist_comment' => $comment)); if (WECHALL_DEBUG_SCORING) { echo WC_HTML::message('Inserting Site History Item...'); } return $entry->insert(); }
private function createSecondaryDispatchRunWithChunkedJobList() { foreach (array_chunk($this->jobs, self::CHUNK_SIZE, true) as $jobList) { $hash = md5(json_encode($jobList)); $job = new self(Title::newFromText('UpdateDispatcherChunkedJobList::' . $hash), array('job-list' => $jobList)); $job->insert(); } }
public static function createSlapRow($type, $name, $damage) { $row = new self(array('lsi_id' => 0, 'lsi_type' => $type, 'lsi_name' => $name, 'lsi_damage' => $damage, 'lsi_count_a' => 0, 'lsi_count_as' => 0)); if (false === $row->insert()) { return false; } return $row; }
private static function newClient($userid) { $client = new self(array('vsc_uid' => $userid, 'vsc_token' => self::generateToken(), 'vsc_modules' => '', 'vsc_designs' => '')); if (false === $client->insert()) { return false; } return $client; }
public static function insertWord($hang_word, $iso = 'en') { $word = new self(array('hangman_id' => 0, 'hangman_text' => $hang_word, 'hangman_iso' => $iso)); if (false === $word->insert()) { return false; } return $word; }
public static function insertToken(Module_Download $module, GWF_Download $dl, $user, $token) { $expires = $dl->expires() ? GWF_Time::getDate(GWF_Date::LEN_SECOND, time() + $dl->getVar('dl_expire')) : ''; $row = new self(array('dlt_dlid' => $dl->getID(), 'dlt_uid' => $user === false ? 0 : $user->getID(), 'dlt_token' => $token, 'dlt_expires' => $expires)); if (false === $row->insert()) { return false; } return true; }
public static function add(CategoryForm $form) { $category = new self(); $category->pid = 0; $category->name = $form->name; $category->status = $form->status; $category->addtime = time(); return $category->insert(); }
public static function addChat($IDParent, $Text, $IDUser = null) { if (!isset($IDUser)) { $IDUser = Zend_Auth::getInstance()->getIdentity()->IDUser; } $TheChat = new self(); $Data = array('IDParent' => $IDParent, 'Text' => $Text, 'IDUser' => $IDUser, 'Date' => new Zend_Db_Expr('NOW()')); return $TheChat->insert($Data); }
/** * Increase or decrease a counter. * @param string $key * @param int $by * @return boolean */ public static function increaseCount($key, $by = 1) { if (false === ($row = self::table(__CLASS__)->getRow($key))) { $row = new self(array('count_key' => $key, 'count_value' => $by)); return $row->insert(); } else { return $row->increase('count_value', $by); } }
public static function insertCrackord(WC_Challenge $chall, $uid, $start, $time, $solved, $count) { if ($count === 0) { return true; } $failed = $count - $solved; $rate = $count > 0 ? $solved / $count * 100 : 0; $entry = new self(array('wccc_id' => 0, 'wccc_uid' => $uid, 'wccc_start' => GWF_Time::getDate(GWF_DATE::LEN_SECOND, intval($start)), 'wccc_time' => intval(round($time)), 'wccc_rate' => round($rate, 2), 'wccc_count' => $count, 'wccc_solved' => $solved, 'wccc_failed' => $failed)); return $entry->insert(); }
public static function insertFirstLink(GWF_User $user, WC_Site $site, $onsitename, $onsitescore) { $table = self::table(__CLASS__); $siteid = $site->getVar('site_id'); if (false !== $table->getRow($onsitename, $siteid)) { return true; } $entry = new self(array('fili_onsitename' => $onsitename, 'fili_sid' => $siteid, 'fili_date' => GWF_Time::getDate(GWF_Date::LEN_DAY), 'fili_uid' => $user->getVar('user_id'), 'fili_username' => $user->getVar('user_name'), 'fili_sitename' => $site->getVar('site_name'), 'fili_percent' => $site->getPercent($onsitescore))); // echo GWF_HTML::message('DEBUG', 'Insert First Link...'); return $entry->insert(); }
public static function insertEntry(GWF_User $user, WC_Site $site, $onsitescore, $comment) { $user = GWF_User::getByID($user->getID()); $max = $site->getOnsiteScore(); $perc = $max <= 0 ? 0 : round($onsitescore / $max * 10000); $entry = new self(array('userhist_uid' => $user->getVar('user_id'), 'userhist_date' => time(), 'userhist_sid' => $site->getVar('site_id'), 'userhist_percent' => $perc, 'userhist_onsitescore' => $onsitescore, 'userhist_rank' => WC_RegAt::calcRank($user), 'userhist_totalscore' => $user->getVar('user_level'), 'userhist_comment' => $comment)); if (WECHALL_DEBUG_SCORING) { echo WC_HTML::message('Inserting User History entry...'); } return $entry->insert(); }
public static function addToIndex($url, $title = null) { $model = self::findOne(['url' => $url]); if ($model) { return false; } $model = new self(); $model->url = $url; $model->title = $title; $model->crawled = 0; return $model->insert(); }
public static function populateFile($basedir, $fullpath) { $mtime = GWF_Time::getDate(GWF_Date::LEN_SECOND, filemtime($fullpath)); if (false === ($row = self::getByPath($fullpath))) { $row = new self(array('vsf_id' => 0, 'vsf_dir' => $basedir, 'vsf_path' => $fullpath, 'vsf_hash' => self::hash(file_get_contents($fullpath)), 'vsf_date' => $mtime)); return $row->insert(); } if ($row->getVar('vsf_date') < $mtime) { return $row->saveVars(array('vsf_hash' => self::hash(file_get_contents($fullpath)), 'vsf_date' => $mtime)); } return true; }
public static function set($name, $value) { $model = self::find()->where(['name' => $name])->one(); if ($model) { $model->value = $value; return $model->update(false); } $model = new self(); $model->value = $value; $model->name = $name; return $model->insert(false); }
public static function getCart() { $sessid = GWF_Session::getSessID(); if (false !== ($cart = self::table(__CLASS__)->selectFirst("orderc_sessid='{$sessid}'"))) { return $cart; } else { $cart = new self(array('orderc_uid' => GWF_Session::getUserID(), 'orderc_sessid' => $sessid)); if (false === $cart->insert()) { return false; } return $cart; } }
public function run() { if ($this->params['usleep'] > 0) { usleep($this->params['usleep']); } if ($this->params['lives'] > 1) { $params = $this->params; $params['lives']--; $job = new self($this->title, $params); $job->insert(); } return true; }
public static function replyMessage($IDParent, $Text, $Sender = null) { if (!isset($Sender)) { $Sender = Zend_Auth::getInstance()->getIdentity()->IDUser; } $Data = array('IDSender' => $Sender, 'Text' => $Text, 'Date' => new Zend_Db_Expr("NOW()"), 'IDParent' => $IDParent); $Message = new self(); $IDMessage = $Message->insert($Data); if ($IDMessage) { $Data = array('IDLastMessage' => $IDMessage, 'DateLastMessage' => new Zend_Db_Expr("NOW()")); $Message->update($Data, "IDMessage = '{$IDParent}'"); } return $IDMessage; }
public static function insertReceivers($IDMessage, $Receivers) { $Ret = true; if (is_array($Receivers)) { foreach ($Receivers as $Receiver) { $Ret &= self::insertReceivers($IDMessage, $Receiver); } } elseif (is_numeric($Receivers)) { $Data = array('IDMessage' => $IDMessage, 'IDUser' => $Receivers); $MessageReceiver = new self(); $Ret = (bool) $MessageReceiver->insert($Data); } return $Ret; }
public static function removePoints($userid, $points) { if (false === ($row = GDO::table(__CLASS__)->getRow($userid))) { $row = new self(array('slapu_uid' => $userid, 'slapu_malus' => $points, 'slapu_malus_c' => 1)); return $row->insert(); } if (false === $row->increase('slapu_malus', $points)) { return false; } if (false === $row->increase('slapu_malus_c', 1)) { return false; } return true; }
public static function addUser($Nome, $Cognome, $Nascita, $Email, $Password) { $TheUser = new self(); $Data = array('Name' => $Nome, 'Surname' => $Cognome, 'DateOfBirth' => $Nascita, 'Email' => $Email, 'Salt' => new Zend_Db_Expr("SHA1('" . mt_rand() . "')"), 'Password' => new Zend_Db_Expr("SHA1(CONCAT('{$Password}', Salt))"), 'RegistrationDate' => new Zend_Db_Expr('NOW()')); $IDUser = $TheUser->insert($Data); if ($IDUser) { $Mail = new Zend_Mail(); $Mail->setFrom(Zend_Registry::get('parameters')->registry->email, Zend_Registry::get('parameters')->registry->emailName); $Mail->addTo($Email); $Mail->setSubject("Nuova registrazione"); $Mail->setBodyText("Benvenuto/a su " . Zend_Registry::get('parameters')->registry->siteTitle . ".\n\nDi seguito vengono riepilogate le tue credenziali:\nEmail: {$Email}\nPassword: {$Password}\n\nPer favore, considera di salvare e/o stampare questa email per ricordarti le tue credenziali.\n\nPer attivare il tuo account è necessario cliccare sul seguente link: " . Zend_Registry::get('parameters')->registry->siteUrl . "/index/confirm/{$IDUser}/" . sha1($IDUser), 'UTF-8', Zend_Mime::ENCODING_8BIT); $Mail->send(); } return $IDUser; }
/** * Update the property of a user or insert it if it does not exist * * @param integer $userId the id of the user * @param string $key the name (key) of the property * @param string $value the value to be set * * @return void */ public function ins($userId, $key, $value) { $table = new self(); $where = '`key` = ' . $this->_db->quote($key) . ' AND user_id = ' . $this->_db->quote($userId); $select = $this->_db->select('id')->from('property')->where($where); $stmt = $this->_db->query($select); $result = $stmt->fetchColumn(); $data = array('value' => $value); if (false === empty($result)) { $table->update($data, $where); } else { $data['user_id'] = $userId; $data['key'] = $key; $table->insert($data); } }
public static function add(MenuForm $form) { $menu = new self(); $menu->cid = $form->cid; $menu->aid = $form->aid; $menu->title = $form->title; $menu->price = $form->price; $menu->favorable_price = $form->favorable_price; $menu->img = ''; $menu->new = $form->new; $menu->provide_time = $form->provide_time; $menu->peppery = $form->peppery; $menu->status = $form->status; $menu->addtime = time(); return $menu->insert(); }