本文整理汇总了PHP中helper::now方法的典型用法代码示例。如果您正苦于以下问题:PHP helper::now方法的具体用法?PHP helper::now怎么用?PHP helper::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper
的用法示例。
在下文中一共展示了helper::now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajaxUpload
/**
* AJAX: the api to recive the file posted through ajax.
*
* @param string $uid
* @access public
* @return array
*/
public function ajaxUpload($uid)
{
if (RUN_MODE == 'front' and !commonModel::isAvailable('forum')) {
exit;
}
if (!$this->loadModel('file')->canUpload()) {
$this->send(array('error' => 1, 'message' => $this->lang->file->uploadForbidden));
}
$file = $this->file->getUpload('imgFile');
$file = $file[0];
if ($file) {
if (!$this->file->checkSavePath()) {
$this->send(array('error' => 1, 'message' => $this->lang->file->errorUnwritable));
}
if (!in_array(strtolower($file['extension']), $this->config->file->imageExtensions)) {
$this->send(array('error' => 1, 'message' => $this->lang->fail));
}
move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname']);
if (in_array(strtolower($file['extension']), $this->config->file->imageExtensions) !== false) {
$this->file->compressImage($this->file->savePath . $file['pathname']);
$imageSize = $this->file->getImageSize($this->file->savePath . $file['pathname']);
$file['width'] = $imageSize['width'];
$file['height'] = $imageSize['height'];
}
$url = $this->file->webPath . $file['pathname'];
$file['addedBy'] = $this->app->user->account;
$file['addedDate'] = helper::now();
$file['editor'] = 1;
unset($file['tmpname']);
$this->dao->insert(TABLE_FILE)->data($file)->exec();
$_SESSION['album'][$uid][] = $this->dao->lastInsertID();
die(json_encode(array('error' => 0, 'url' => $url)));
}
}
示例2: create
/**
* Create resume.
*
* @param int $contactID
* @param object $resume
* @access public
* @return int
*/
public function create($contactID, $resume = null)
{
if (empty($resume)) {
$resume = fixer::input('post')->add('contact', $contactID)->remove('newCustomer,type,size,status,level,name')->get();
if ($this->post->newCustomer) {
$customer = new stdclass();
$customer->name = $this->post->name;
$customer->type = $this->post->type;
$customer->size = $this->post->size;
$customer->status = $this->post->status;
$customer->level = $this->post->level;
$customer->assignedTo = $this->app->user->account;
$customer->createdBy = $this->app->user->account;
$customer->createdDate = helper::now();
$return = $this->loadModel('customer')->create($customer);
if ($return['result'] == 'fail') {
return false;
}
$resume->customer = $return['customerID'];
$this->loadModel('action')->create('customer', $resume->customer, 'Created');
}
}
$this->dao->insert(TABLE_RESUME)->data($resume)->autoCheck()->batchCheck($this->config->resume->require->create, 'notempty')->exec();
if (!dao::isError()) {
$resumeID = $this->dao->lastInsertID();
$this->dao->update(TABLE_CONTACT)->set('resume')->eq($resumeID)->where('id')->eq($contactID)->exec();
return $resumeID;
}
return false;
}
示例3: update
/**
* Update a product.
*
* @param int $productID
* @access public
* @return void
*/
public function update($productID)
{
$oldProduct = $this->getByID($productID);
$product = fixer::input('post')->add('editedBy', $this->app->user->account)->add('editedDate', helper::now())->get();
$this->dao->update(TABLE_PRODUCT)->data($product)->autoCheck()->batchCheck($this->config->product->require->edit, 'notempty')->where('id')->eq($productID)->exec();
if (dao::isError()) {
return false;
}
return commonModel::createChanges($oldProduct, $product);
}
示例4: ping
/**
* keep logon function.
*
* @access public
* @return void
*/
public function ping($notice = '')
{
/* Save attend info. */
$this->loadModel('attend', 'oa')->signOut();
/* Save online status. */
$this->loadModel('user')->online();
/* Get notices. */
$notices = $this->loadModel('action')->getUnreadNotice('', $skipNotice = $notice);
$res = new stdclass();
$res->time = helper::now();
$res->notices = $notices;
die(json_encode($res));
}
示例5: setBasic
/**
* set company basic info.
*
* @access public
* @return void
*/
public function setBasic()
{
if (!empty($_POST)) {
$now = helper::now();
$company = fixer::input('post')->add('setDate', $now)->stripTags('desc,content', $this->config->allowedTags->admin)->remove('uid')->get();
$result = $this->loadModel('setting')->setItems('system.common.company', $company);
if ($result) {
$this->send(array('result' => 'success', 'message' => $this->lang->setSuccess));
}
$this->send(array('result' => 'fail', 'message' => $this->lang->fail));
}
$this->view->title = $this->lang->company->setBasic;
$this->display();
}
示例6: setBasic
/**
* set company basic info.
*
* @access public
* @return void
*/
public function setBasic()
{
if (!empty($_POST)) {
$now = helper::now();
$company = fixer::input('post')->stripTags('content', $this->config->allowedTags->admin)->get();
$company = $this->loadModel('file')->processEditor($company, $this->config->company->editor->setbasic['id']);
$result = $this->loadModel('setting')->setItems('system.sys.common.company', $company);
if ($result) {
$this->send(array('result' => 'success', 'message' => $this->lang->setSuccess));
}
$this->send(array('result' => 'fail', 'message' => $this->lang->fail));
}
$this->view->title = $this->lang->company->setBasic;
$this->display();
}
示例7: create
/**
* Create an consulting.
*
* @param string $type
* @access public
* @return int|bool
*/
public function create()
{
$now = helper::now();
$consulting = fixer::input('post')->setDefault('addedDate', $now)->get();
$consult = $this->dao->select('*')->from(TABLE_CONSULTING)->where('realname')->eq($consulting->realname)->andWhere('mobile')->eq($consulting->mobile)->andWhere('email')->eq($consulting->email)->fetch();
if ($consult) {
return array('result' => 'fail', 'message' => '请不要重复提交!<a href="javascript:history.back();">返回</a>');
} else {
$this->dao->insert(TABLE_CONSULTING)->data($consulting)->exec();
$consultingID = $this->dao->lastInsertID();
if (dao::isError()) {
return array('result' => 'fail', 'message' => dao::getError());
}
return array('result' => 'success', 'message' => '提交成功!');
}
}
示例8: create
/**
* Create a action.
*
* @param string $objectType
* @param int $objectID
* @param string $actionType
* @param string $comment
* @param string $extra the extra info of this action, according to different modules and actions, can set different extra.
* @access public
* @return int
*/
public function create($objectType, $objectID, $actionType, $comment = '', $extra = '')
{
$objectType = str_replace('`', '', $objectType);
$action->objectType = strtolower($objectType);
$action->objectID = $objectID;
$action->actor = $this->app->user->account;
$action->action = strtolower($actionType);
$action->date = helper::now();
$action->comment = htmlspecialchars($comment);
$action->extra = $extra;
/* Get product and project for this object. */
$productAndProject = $this->getProductAndProject($objectType, $objectID);
$action->product = $productAndProject['product'];
$action->project = $productAndProject['project'];
$this->dao->insert(TABLE_ACTION)->data($action)->autoCheck()->exec();
return $this->dbh->lastInsertID();
}
示例9: ajaxUpload
/**
* AJAX: the api to recive the file posted through ajax.
*
* @param string $uid
* @access public
* @return array
*/
public function ajaxUpload($uid)
{
$file = $this->file->getUpload('imgFile');
$file = $file[0];
if ($file) {
if (!$this->file->checkSavePath()) {
$this->send(array('error' => 1, 'message' => $this->lang->file->errorUnwritable));
}
move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname']);
$url = $this->file->webPath . $file['pathname'];
$file['createdBy'] = $this->app->user->account;
$file['createdDate'] = helper::now();
$file['editor'] = 1;
unset($file['tmpname']);
$this->dao->insert(TABLE_FILE)->data($file, false)->exec();
$_SESSION['album'][$uid][] = $this->dao->lastInsertID();
die(json_encode(array('error' => 0, 'url' => $url)));
}
}
示例10: updateBoardStats
/**
* Update status of boards.
*
* @param int $boardID
* @access public
* @return void
*/
public function updateBoardStats($boardID)
{
/* Get threads and replies. */
$stats = $this->dao->select('COUNT(id) as threads, SUM(replies) as replies')->from(TABLE_THREAD)->where('board')->eq($boardID)->andWhere('addedDate')->le(helper::now())->andWhere('hidden')->eq('0')->fetch();
/* Get postID and replyID. */
$post = $this->dao->select('id as postID, replyID, repliedDate as postedDate, repliedBy, author')->from(TABLE_THREAD)->where('board')->eq($boardID)->andWhere('addedDate')->le(helper::now())->andWhere('hidden')->eq('0')->orderBy('repliedDate desc')->limit(1)->fetch();
$data = new stdclass();
$data->threads = $stats->threads;
$data->posts = $stats->threads + $stats->replies;
if ($post) {
$data->postID = $post->postID;
$data->replyID = $post->replyID;
$data->postedDate = $post->postedDate;
$data->postedBy = $post->repliedBy ? $post->repliedBy : $post->author;
} else {
$data->postID = 0;
$data->replyID = 0;
$data->postedBy = '';
}
$this->dao->update(TABLE_CATEGORY)->data($data)->where('id')->eq($boardID)->exec();
}
示例11: getList
/**
* get search results of keywords.
*
* @param string $keywords
* @param object $pager
* @access public
* @return array
*/
public function getList($keywords, $pager)
{
$spliter = $this->app->loadClass('spliter');
$words = explode(' ', seo::unify($keywords, ' '));
$against = '';
foreach ($words as $word) {
$splitedWords = $spliter->utf8Split($word);
$against .= '"' . $splitedWords['words'] . '"';
}
$words = str_replace('"', '', $against);
$words = str_pad($words, 5, '_');
$scoreColumn = "((1 * (MATCH(title) AGAINST('{$against}' IN BOOLEAN MODE))) + (0.6 * (MATCH(title) AGAINST('{$against}' IN BOOLEAN MODE))) )";
$results = $this->dao->select("*, {$scoreColumn} as score")->from(TABLE_SEARCH_INDEX)->where("MATCH(title,content) AGAINST('+{$against}' IN BOOLEAN MODE) >= 1")->andWhere('status')->eq('normal')->andWhere('addedDate')->le(helper::now())->orderBy('score_desc, editedDate_desc')->page($pager)->fetchAll('id');
foreach ($results as $record) {
$record->title = str_replace('</span> ', '</span>', $this->decode($this->markKeywords($record->title, $words)));
$record->title = str_replace('_', '', $this->decode($this->markKeywords($record->title, $words)));
$record->summary = $this->getSummary($record->content, $words);
$record->summary = str_replace('_', '', $record->summary);
}
return $this->processLinks($results);
}
示例12: uploadImg
public function uploadImg($filename = '')
{
if ($_FILES['myFile']['size'] == 0) {
return;
}
$file['title'] = $_FILES['myFile']['name'];
$file['extension'] = $this->getExtension($file['title']);
$file['size'] = $_FILES['myFile']['size'];
$file['pathname'] = $this->setPathName(0, $file['extension']);
$file['objectType'] = 'user';
$file['objectID'] = $this->app->user->id;
$file['addedBy'] = $this->app->user->account;
$file['addedDate'] = helper::now();
$file['extra'] = '';
$oldFile = $this->getFile($this->app->user->id);
if (move_uploaded_file($_FILES['myFile']["tmp_name"], $this->getSavePath() . $file['pathname'])) {
if (!empty($oldFile->id)) {
unlink("../../www/data/upload/{$this->app->company->id}/{$oldFile->pathname}");
}
$this->dao->delete()->from(TABLE_FILE)->where('objectID')->eq((int) $this->app->user->id)->exec();
$this->dao->insert(TABLE_FILE)->data($file)->exec();
}
}
示例13: update
public function update($assetID)
{
$skipFields = '';
$skipFields .= $this->loadModel('custom')->dealWithCustomArrayField();
$oldAsset = $this->getAssetById($assetID);
$now = helper::now();
$address = fixer::input('post')->get('address');
$extendaddress = fixer::input('post')->get('extendaddress');
$devicenumber = fixer::input('post')->get('devicenumber');
$code = fixer::input('post')->get('code');
$module = $this->loadModel('info')->getAllChildId(fixer::input('post')->cleanInt('module')->setDefault('module', 0)->get('module'), 'asset');
$result1 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('address')->eq($extendaddress)->andWhere('address')->ne('IP Format Error')->andWhere('address')->ne('Conflict!')->andWhere('address')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll();
$result2 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('extendaddress')->eq($address)->andWhere('extendaddress')->ne('IP Format Error')->andWhere('extendaddress')->ne('Conflict!')->andWhere('extendaddress')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll();
$asset = fixer::input('post')->cleanInt('module')->setDefault('module', 0)->add('lastEditedBy', $this->app->user->account)->add('lastEditedDate', $now)->setDefault('lenddate', '0000-00-00')->setDefault('returndate', '0000-00-00')->setDefault('product', '0')->setDefault('project', '0')->setIF(!(strlen(trim($extendaddress)) == 0) && !validater::checkIP($extendaddress), 'extendaddress', 'IP Format Error')->setIF(!(strlen(trim($address)) == 0) && !validater::checkIP($address), 'address', 'IP Format Error')->removeIF(trim($address) == trim($extendaddress), 'extendaddress')->setIF($result1, 'extendaddress', 'Conflict!')->setIF($result2, 'address', 'Conflict!')->get();
$condition = "`lib` = '{$asset->lib}' AND module = '{$asset->module}' and id != '{$assetID}'";
$conditionaddress = $condition . " and address != 'IP Format Error' and address != 'Conflict!'";
$conditionextaddress = $condition . " and extendaddress != 'IP Format Error' and extendaddress != 'Conflict!'";
$this->dao->update(TABLE_INFOASSET)->data($asset)->autoCheck($skipFields)->batchCheck($this->config->asset->edit->requiredFields, 'notempty')->check('hostname', 'unique', $condition)->checkIF(!(strlen(trim($address)) == 0), 'address', 'unique', $conditionaddress)->checkIF(!(strlen(trim($extendaddress)) == 0), 'extendaddress', 'unique', $conditionextaddress)->checkIF(!(strlen(trim($devicenumber)) == 0), 'devicenumber', 'unique', $condition)->checkIF(!(strlen(trim($code)) == 0), 'code', 'unique', $condition)->where('id')->eq((int) $assetID)->exec();
$asset->editedCount = $asset->editedCount - 1;
if (!dao::isError()) {
return common::createChanges($oldAsset, $asset);
}
}
示例14: saveVisitor
/**
* Save visitor info.
*
* @access public
* @return object
*/
public function saveVisitor()
{
$browserName = helper::getBrowser();
$browserVersion = helper::getBrowserVersion();
if (!empty($_COOKIE['vid'])) {
$visitor = $this->getVisitorByID($this->cookie->vid);
if (!empty($visitor)) {
$visitor->new = false;
if ($visitor->browserName == $browserName and $visitor->browserVersion = $browserVersion and $visitor->osName == helper::getOS()) {
return $visitor;
}
}
}
$visitor = fixer::input('get')->add('device', $this->app->device)->add('osName', helper::getOS())->add('browserName', helper::getBrowser())->add('browserVersion', helper::getBrowserVersion())->add('createdTime', helper::now())->get();
if ($visitor->browserName == 'ie') {
$visitor->browserName .= $visitor->browserVersion;
}
$this->dao->insert(TABLE_STATVISITOR)->data($visitor, 'referer')->autocheck()->exec();
$visitor->new = true;
$vid = $this->dao->lastInsertId();
setcookie('vid', $vid, strtotime('+5 year'));
$visitor->id = $vid;
return $visitor;
}
示例15: create
/**
* Create a trip.
*
* @access public
* @return bool
*/
public function create()
{
$trip = fixer::input('post')->add('createdBy', $this->app->user->account)->add('createdDate', helper::now())->get();
if (isset($trip->begin) and $trip->begin != '') {
$trip->year = substr($trip->begin, 0, 4);
}
$dates = range(strtotime($trip->begin), strtotime($trip->end), 60 * 60 * 24);
foreach ($dates as $date) {
$date = date('Y-m-d', $date);
$existTrip = $this->getByDate($date, $this->app->user->account);
if ($existTrip) {
return array('result' => 'fail', 'message' => sprintf($this->lang->trip->unique, $date));
}
$existLeave = $this->loadModel('leave')->getByDate($date, $this->app->user->account);
if ($existLeave) {
return array('result' => 'fail', 'message' => sprintf($this->lang->leave->unique, $date));
}
}
$this->dao->insert(TABLE_TRIP)->data($trip)->autoCheck()->batchCheck($this->config->trip->require->create, 'notempty')->check('end', 'ge', $trip->begin)->exec();
if (!dao::isError()) {
$this->loadModel('attend')->batchUpdate($dates, $this->app->user->account, 'trip', '', $trip);
}
return !dao::isError();
}