示例#1
0
 /**
  *  Push a job onto the Queue for processing. 
  *
  *
  *  @param \Closure|string $job Either a \Closure to execute or a Class method pair like 'DB@query'.
  *  @param int $delay The delay to wait before begining execution of the $job.
  *  @param null|string|array $vars The variables to pass to the $job.
  *
  *  @return void
  */
 public function push($job, $delay = 0, $vars = null)
 {
     if ($vars == null) {
         $vars = 'disco-no-variable';
     } else {
         $vars = base64_encode(serialize($vars));
     }
     //el
     $domain = \App::domain();
     if ($job instanceof \Closure) {
         $obj = new \Jeremeamia\SuperClosure\SerializableClosure($job);
         $method = 'closure';
     } else {
         if (stripos($job, '@') !== false) {
             $obj = explode('@', $job);
             $method = $obj[1];
             $obj = $obj[0];
         } else {
             $obj = $job;
             $method = 'work';
         }
     }
     //el
     $obj = base64_encode(serialize($obj));
     $command = "php %1\$s/public/index.php resolve %2\$s '%3\$s' '%4\$s' %5\$s %6\$s > /dev/null 2>/dev/null &";
     $command = sprintf($command, \App::path(), $delay, $obj, $method, $vars, $domain);
     error_log($command);
     exec($command);
 }
示例#2
0
 /**
  * Create FQDN link.
  *
  * @param string $p The path of the resource.
  *
  * @return string The FQDN.
  */
 public static function localUrl($p)
 {
     return \App::domain() . $p;
 }
示例#3
0
 /**
  * From the passed arguements all public variables of this class can be derived and will be set.
  *
  *
  * @param int $currentPage The current page being paginated.
  * @param int $totalItems The total items being paginated.
  * @param int $limit The limit used in the query for results to be paginated.
  */
 public function __construct($currentPage, $totalItems, $limit)
 {
     self::$paginateUsed = true;
     if (\App::configKeyExists('paginate')) {
         $this->format = \App::config('paginate');
     }
     //if
     if ($currentPage == 0) {
         $currentPage = 1;
     }
     //if
     $this->uri = explode('?', $_SERVER['REQUEST_URI'])[0];
     $currentPageFormat = $this->fromFormat($currentPage);
     if (strpos($this->uri, $currentPageFormat) === false) {
         if (substr($this->format, 0, 1) == '/' && substr($this->uri, -1) == '/') {
             $this->uri = rtrim($this->uri, '/');
         }
         //elif
         $this->uri .= $currentPageFormat;
     }
     //if
     //public vars
     $this->currentPage = $currentPage;
     $this->limit = $limit;
     $this->totalItems = $totalItems;
     $this->totalPages = ceil($this->totalItems / $this->limit);
     $this->perPage = $limit;
     $this->total = $this->totalItems;
     $this->first = ($this->currentPage - 1) * $this->limit + 1;
     if ($this->totalPages != $this->currentPage) {
         $this->totalDisplayed = $this->limit;
     } else {
         $this->totalDisplayed = $this->totalItems % $this->limit;
         if ($this->totalDisplayed == 0) {
             $this->totalDisplayed = $this->limit;
         }
         //if
     }
     //el
     $this->last = $this->first + $this->totalDisplayed - 1;
     if ($this->totalPages < $this->currentPage) {
         self::$pageDoesNotExist = true;
     }
     //if
     $this->firstUrl = $this->getPageUrl(1);
     $this->currentUrl = $this->getPageUrl($this->currentPage);
     $this->lastUrl = $this->getPageUrl($this->totalPages);
     if (!self::$pageDoesNotExist) {
         $domain = \App::domain();
         if ($currentPage != 1) {
             $this->prevUrl = $this->getPageUrl($currentPage - 1);
             \View::headExtra("<link rel='prev' href='{$domain}{$this->prevUrl}'>");
         }
         //if
         if ($this->currentPage != $this->totalPages && $this->totalPages != 0) {
             $this->nextUrl = $this->getPageUrl($currentPage + 1);
             \View::headExtra("<link rel='next' href='{$domain}{$this->nextUrl}'>");
         }
         //if
         if ($currentPage == 1 && $this->uri != $this->currentUrl) {
             \View::headExtra("<link rel='canonical' href='{$domain}{$this->currentUrl}'/>");
         }
         //if
     }
     //if
 }
示例#4
0
文件: User.php 项目: discophp/project
 /**
  * Send a user a password reset email if their email is found.
  *
  *
  * @param string $email The email of the user.
  *
  * @return boolean
  */
 public function sendPasswordResetEmail($email)
 {
     $user = $this->User->select('id')->where('email=?', $email)->first();
     if (!$user['id']) {
         return false;
     }
     //if
     $token = $this->generateToken($user['id'], 'password');
     $data = array();
     $data['url'] = \App::domain() . self::PW_RESET_SLUG . $token;
     $data['link'] = \Html::a(array('href' => $data['url']), 'Reset Password');
     $data['to'] = $email;
     try {
         return \Email::send($data['to'], 'Password Reset Request', \Template::render('user/email/password-reset.html', $data));
     } catch (\Exception $e) {
         \App::log("Error sending account activation email to user : `{$record['id']}`");
         return false;
     }
     //catch
 }