コード例 #1
0
 public function __construct()
 {
     $host = "cache.railpage.com.au";
     $port = 6379;
     $this->Cache = new Redis();
     $this->Cache->connect($host, $port);
     $Smarty = AppCore::GetSmarty();
     $Smarty->caching_type = "redis";
 }
コード例 #2
0
 public function __construct()
 {
     //$this->Cache = AppCore::getMemcached();
     $host = defined("RP_MEMCACHE_HOST") ? RP_MEMCACHE_HOST : "cache.railpage.com.au";
     $port = defined("RP_MEMCACHE_PORT") ? RP_MEMCACHE_PORT : 11211;
     $this->Cache = new PhpMemcached();
     $this->Cache->addServer($host, $port);
     $Smarty = AppCore::GetSmarty();
     $Smarty->caching_type = "memcached";
 }
コード例 #3
0
ファイル: Submenu.php プロジェクト: railpage/railpagecore
 /**
  * Get menu as HTML
  * @return string
  */
 public function GetHTML()
 {
     $Smarty = AppCore::GetSmarty();
     $Smarty->Assign("submenu", $this->menu);
     return $Smarty->Fetch(RP_SITE_ROOT . DS . "content" . DS . "inc.submenu.tpl");
 }
コード例 #4
0
ファイル: Prerender.php プロジェクト: railpage/railpagecore
 /**
  * Constructor
  * @since Version 3.10.0
  */
 public function __construct()
 {
     $this->smarty = AppCore::GetSmarty();
     $this->cacheProvider = AppCore::GetMemcached();
 }
コード例 #5
0
ファイル: Weekly.php プロジェクト: railpage/railpagecore
 /**
  * Fetch our template contents and replace the smarty variables with decoration placeholders
  * @since Version 3.10.0
  * @return \Railpage\Newsletters\Weekly
  */
 private function prepareTemplate()
 {
     $start = 0;
     $num = 10;
     $replacements = [];
     for ($i = $start; $i < $start + $this->num_items; $i++) {
         $replacements[$i] = ["subtitle" => "##block" . $i . ".subtitle##", "featuredimage" => "##block" . $i . ".featuredimage##", "text" => "##block" . $i . ".text##", "link" => "##block" . $i . ".link##", "alt_title" => "##block" . $i . ".alt_title##", "linktext" => "##block" . $i . ".link_text##"];
     }
     $template = $this->Newsletter->template;
     $params = $this->Newsletter->getArray();
     $params['content'] = $replacements;
     $params['unsubscribe'] = "##unsubscribe##";
     $Smarty = AppCore::GetSmarty();
     $Smarty->Assign("newsletter", $params);
     $html = $Smarty->Fetch("string:" . $template['html']);
     #$this->replacements = $replacements;
     $this->html = $html;
     return $this;
 }
コード例 #6
0
 /**
  * Send out a notification to site admins to cast a deciding vote in the event of a tied competition
  * @since Version 3.10.0
  * @param \Railpage\Images\Competition $photoComp
  * @return void
  */
 public static function NotifyTied(Competition $photoComp)
 {
     if (isset($photoComp->meta['notifytied']) && $photoComp->meta['notifytied'] >= strtotime("-1 day")) {
         return;
     }
     $photoComp->meta['notifytied'] = time();
     $photoComp->commit();
     $Smarty = AppCore::GetSmarty();
     // User who will cast the deciding vote
     $Decider = UserFactory::CreateUser(45);
     // Create the push notification
     $Push = new Notification();
     $Push->transport = Notifications::TRANSPORT_PUSH;
     $Push->subject = "Tied photo competition";
     $Push->body = sprintf("The %s photo competition is tied. Cast a deciding vote ASAP.", $photoComp->title);
     $Push->setActionUrl($photoComp->url->tied)->addRecipient($Decider->id, $Decider->username, $Decider->username);
     $Push->commit()->dispatch();
     // Create an email notification as a backup
     $Email = new Notification();
     $Email->subject = "Tied competition: " . $photoComp->title;
     $Email->addRecipient($Decider->id, $Decider->username, $Decider->username);
     $tpl = $Smarty->ResolveTemplate("template.generic");
     $email = array("subject" => $Email->subject, "subtitle" => "Photo competitions", "body" => sprintf("<p>The <a href='%s'>%s</a>photo competition is tied and requires a deciding vote. <a href='%s'>Cast it ASAP</a>.</p>", $photoComp->url->canonical, $photoComp->title, $photoComp->url->tied));
     $Smarty->Assign("email", $email);
     $Email->body = $Smarty->fetch($tpl);
     $Email->commit();
     return;
 }
コード例 #7
0
ファイル: BanControl.php プロジェクト: railpage/railpagecore
 /**
  * Ban user
  * @since Version 3.2
  * @version 3.2
  * @param int|boolean $userId
  * @param string|boolean $reason
  * @param int|boolean $expiry
  * @param int|boolean $adminUserId
  * @return boolean
  */
 public function banUser($userId = null, $reason = null, $expiry = "0", $adminUserId = null)
 {
     if (!filter_var($userId, FILTER_VALIDATE_INT)) {
         throw new InvalidArgumentException("No user ID supplied");
     }
     if (is_null($reason)) {
         throw new InvalidArgumentException("No reason was supplied");
     }
     if (!filter_var($adminUserId, FILTER_VALIDATE_INT)) {
         throw new InvalidArgumentException("No administrative user ID was supplied");
     }
     /**
      * Empty the cache
      */
     $this->Memcached = AppCore::getMemcached();
     try {
         if ($this->Memcached->Fetch("railpage:bancontrol.users")) {
             $this->Memcached->delete("railpage:bancontrol.users");
         }
         if ($this->Memcached->Fetch(self::CACHE_KEY_ALL)) {
             $this->Memcached->delete(self::CACHE_KEY_ALL);
         }
     } catch (Exception $e) {
         // throw it away
     }
     try {
         $this->Redis->delete("railpage:bancontrol");
     } catch (Exception $e) {
         // throw it away
     }
     $data = array("user_id" => $userId, "ban_active" => 1, "ban_time" => time(), "ban_reason" => $reason, "banned_by" => $adminUserId, "ban_expire" => $expiry);
     $this->db->insert("bancontrol", $data);
     $cachekey_user = sprintf(self::CACHE_KEY_USER, $userId);
     $expire = $expiry > 0 ? $expiry : 0;
     $this->Memcached->save($cachekey_user, true, $expire);
     /**
      * Update the cache
      */
     $this->cacheAll(true);
     /**
      * Tell the world that they've been naughty
      */
     $ThisUser = UserFactory::CreateUser($userId);
     $ThisUser->active = 0;
     $ThisUser->location = "Banned";
     $ThisUser->signature = "Banned";
     $ThisUser->avatar = "";
     $ThisUser->interests = "";
     $ThisUser->occupation = "";
     $ThisUser->commit(true);
     $ThisUser->addNote("Banned", $adminUserId);
     $Smarty = AppCore::GetSmarty();
     // Send the ban email
     $Smarty->Assign("userdata_username", $ThisUser->username);
     $Smarty->Assign("ban_reason", $reason);
     if ($expiry > 0) {
         $Smarty->Assign("ban_expire_nice", date($ThisUser->date_format, $expiry));
     }
     // Send the confirmation email
     $Notification = new Notification();
     if ($adminUserId !== false) {
         $Notification->setAuthor(UserFactory::CreateUser($adminUserId));
     }
     $Notification->addRecipient($ThisUser->id, $ThisUser->username, $ThisUser->contact_email);
     $Notification->body = $Smarty->Fetch($Smarty->ResolveTemplate("email.ban"));
     $Notification->subject = "Railpage account suspension";
     $Notification->transport = Notifications::TRANSPORT_EMAIL;
     $Notification->commit()->dispatch();
     return true;
 }
コード例 #8
0
ファイル: Pagination.php プロジェクト: railpage/railpagecore
 /**
  * Constructor
  * @since Version 3.10.0
  * @param string $urlFormat
  * @param int $currentPage
  * @param int $totalItems
  * @param int $itemsPerPage
  */
 public function __construct($urlFormat, $currentPage, $totalItems, $itemsPerPage = 25)
 {
     $this->Smarty = AppCore::GetSmarty();
     $this->setParam("current_page", $currentPage)->setParam("url_format", $urlFormat)->setParam("num_items", $totalItems)->setParam("per_page", $itemsPerPage);
 }