示例#1
0
    /**
     * Convert plaintext URI to HTML links.
     *
     * Converts URI, www and ftp, and email addresses. Finishes by fixing links
     * within links.
     *
     * @since 0.71
     *
     * @param string $text Content to convert URIs.
     * @return string Content with converted URIs.
     */
    public static function Process($text)
    {
        $timer = Debug::GetTimer();
        $r = '';
        $textarr = preg_split('/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // split out HTML tags
        foreach ($textarr as $piece) {
            if (empty($piece) || $piece[0] == '<' && !preg_match('|^<\\s*[\\w]{1,20}+://|', $piece)) {
                $r .= $piece;
                continue;
            }
            // Long strings might contain expensive edge cases ...
            if (10000 < strlen($piece)) {
                // ... break it up
                foreach (self::_split_str_by_whitespace($piece, 2100) as $chunk) {
                    // 2100: Extra room for scheme and leading and trailing paretheses
                    if (2101 < strlen($chunk)) {
                        $r .= $chunk;
                        // Too big, no whitespace: bail.
                    } else {
                        $r .= make_clickable($chunk);
                    }
                }
            } else {
                $ret = " {$piece} ";
                // Pad with whitespace to simplify the regexes
                $url_clickable = '~
					([\\s(<.,;:!?])                                        # 1: Leading whitespace, or punctuation
					(                                                      # 2: URL
						[\\w]{1,20}+://                                # Scheme and hier-part prefix
						(?=\\S{1,2000}\\s)                               # Limit to URLs less than about 2000 characters long
						[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+         # Non-punctuation URL character
						(?:                                            # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character
							[\'.,;:!?)]                            # Punctuation URL character
							[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character
						)*
					)
					(\\)?)                                                  # 3: Trailing closing parenthesis (for parethesis balancing post processing)
				~xS';
                // The regex is a non-anchored pattern and does not have a single fixed starting character.
                // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
                $ret = preg_replace_callback($url_clickable, 'self::_make_url_clickable_cb', $ret);
                $ret = preg_replace_callback('#([\\s>])((www|ftp)\\.[\\w\\x80-\\xff\\#$%&~/.\\-;:=,?@\\[\\]+]+)#is', 'self::_make_web_ftp_clickable_cb', $ret);
                $ret = preg_replace_callback('#([\\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\\.)+[0-9a-z]{2,})#i', 'self::_make_email_clickable_cb', $ret);
                $ret = substr($ret, 1, -1);
                // Remove our whitespace padding.
                $r .= $ret;
            }
        }
        // Cleanup of accidental links within links
        $r = preg_replace('#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "\$1\$3</a>", $r);
        Debug::LogEvent(__METHOD__, $timer);
        return $r;
    }
示例#2
0
 /**
  * Constructor
  *
  * @param string|null $country
  * @param string|bool $region
  */
 public function __construct($country = null, $region = false)
 {
     Debug::RecordInstance();
     $timer = Debug::GetTimer();
     if (is_null($country)) {
         throw new InvalidArgumentException("No country was specified");
     }
     parent::__construct();
     $this->load($country, $region);
     Debug::LogEvent(__METHOD__, $timer);
 }
示例#3
0
 /**
  * Constructor
  *
  * @param string $code
  */
 public function __construct($code)
 {
     parent::__construct();
     $this->code = $code;
     $this->url = new Url("/locations/" . strtolower($this->code));
     $countries = ISO_3166::get_countries();
     if (strlen($this->code) == 2) {
         $this->name = $countries[$code]['name'];
     } else {
         foreach ($countries as $cc => $data) {
             if (strtolower($data['name']) == strtolower($this->code)) {
                 $this->code = $cc;
                 $this->url = new Url("/locations/" . strtolower($this->code));
                 $this->name = $data['name'];
             }
         }
     }
     Debug::RecordInstance();
     $timer = Debug::GetTimer();
     if (!$this->loadFromCache() || empty($this->name)) {
         $woe = Place::getWOEData(strtoupper($code));
         if (isset($woe['places']['place'][0]['name'])) {
             $woe = $woe['places']['place'][0];
             $data = ["point" => new Zend_Db_Expr(sprintf("GeomFromText('POINT(%s %s)')", $woe['centroid']['latitude'], $woe['centroid']['longitude'])), "bb_southwest" => new Zend_Db_Expr(sprintf("GeomFromText('POINT(%s %s)')", $woe['boundingBox']['southWest']['latitude'], $woe['boundingBox']['southWest']['longitude'])), "bb_northeast" => new Zend_Db_Expr(sprintf("GeomFromText('POINT(%s %s)')", $woe['boundingBox']['northEast']['latitude'], $woe['boundingBox']['northEast']['longitude'])), "country_code" => $woe['country attrs']['code'], "country_name" => $woe['name'], "timezone" => isset($woe['timezone']) ? $woe['timezone'] : ""];
             $this->db->insert("geoplace", $data);
             $this->name = $woe['name'];
             $this->centre = new stdClass();
             $this->centre->lat = $woe['centroid']['latitude'];
             $this->centre->lon = $woe['centroid']['longitude'];
             $this->boundingBox = new stdClass();
             $this->boundingBox->northEast = new stdClass();
             $this->boundingBox->northEast->lat = $woe['boundingBox']['northEast']['latitude'];
             $this->boundingBox->northEast->lon = $woe['boundingBox']['northEast']['longitude'];
             $this->boundingBox->southWest = new stdClass();
             $this->boundingBox->southWest->lat = $woe['boundingBox']['southWest']['latitude'];
             $this->boundingBox->southWest->lon = $woe['boundingBox']['southWest']['longitude'];
         }
     }
     /**
      * Fetch the WOE (Where On Earth) data from Yahoo
      */
     Debug::LogEvent(__METHOD__, $timer);
 }
示例#4
0
 /**
  * Check SpamCop for the given IP address
  * @since Version 3.10.0
  * @return boolean
  * @param string $ip
  */
 public static function spamCop($ip)
 {
     if (!filter_var($ip, FILTER_VALIDATE_IP)) {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $timer = Debug::GetTimer();
     $reversedIp = implode(".", array_reverse(explode(".", $ip)));
     $host = $reversedIp . ".bl.spamcop.net";
     $response = gethostbyname($host);
     if (stristr($response, "127.0.0")) {
         return true;
     }
     Debug::LogEvent(__METHOD__, $timer);
     return false;
 }
示例#5
0
 /**
  * Fetch the users' timeline
  * @since Version 3.5
  *
  * @param object $dateStart
  * @param object $dateEnd
  *
  * @return array
  */
 public function timeline($dateStart, $dateEnd)
 {
     $timer = Debug::GetTimer();
     $timezzz = (new Timeline())->setUser($this)->generateTimeline($dateStart, $dateEnd);
     Debug::LogEvent(__METHOD__, $timer);
     return $timezzz;
     #return Timeline::GenerateTimeline($this, $date_start, $date_end);
 }
示例#6
0
 /**
  * Find Railpage objects (loco, class, livery) in this image
  *
  * @since Version 3.8.7
  *
  * @param string  $namespace
  * @param boolean $force
  *
  * @return \Railpage\Images\Image;
  * @throws \Exception if $namespace is null or empty
  */
 public function findObjects($namespace = null, $force = false)
 {
     if (is_null($namespace)) {
         throw new Exception("Parameter 1 (namespace) cannot be empty");
     }
     $key = sprintf("railpage:images.image=%d;objects.namespace=%s;lastupdate", $this->id, $namespace);
     $lastupdate = $this->Memcached->fetch($key);
     if (!$force && $lastupdate && $lastupdate > strtotime("1 day ago")) {
         return $this;
     }
     /**
      * Start the debug timer
      */
     $timer = Debug::GetTimer();
     switch ($namespace) {
         case "railpage.locos.loco":
             if (isset($this->meta['tags'])) {
                 foreach ($this->meta['tags'] as $tag) {
                     if (preg_match("@railpage:class=([0-9]+)@", $tag, $matches)) {
                         Debug::LogEvent(__METHOD__ . " :: #1 Instantating new LocoClass object with ID " . $matches[1] . "  ");
                         $LocoClass = LocosFactory::CreateLocoClass($matches[1]);
                     }
                 }
                 foreach ($this->meta['tags'] as $tag) {
                     if (isset($LocoClass) && $LocoClass instanceof LocoClass && preg_match("@railpage:loco=([a-zA-Z0-9]+)@", $tag, $matches)) {
                         Debug::LogEvent(__METHOD__ . " :: #2 Instantating new LocoClass object with class ID " . $LocoClass->id . " and loco number " . $matches[1] . "  ");
                         $Loco = LocosFactory::CreateLocomotive(false, $LocoClass->id, $matches[1]);
                         if (filter_var($Loco->id, FILTER_VALIDATE_INT)) {
                             $this->addLink($Loco->namespace, $Loco->id);
                         }
                     }
                 }
                 foreach ($this->db->fetchAll("SELECT id AS class_id, flickr_tag AS class_tag FROM loco_class") as $row) {
                     foreach ($this->meta['tags'] as $tag) {
                         if (stristr($tag, $row['class_tag']) && strlen(str_replace($row['class_tag'] . "-", "", $tag) > 0)) {
                             $loco_num = str_replace($row['class_tag'] . "-", "", $tag);
                             Debug::LogEvent(__METHOD__ . " :: #3 Instantating new LocoClass object with class ID " . $row['class_id'] . " and loco number " . $loco_num . "  ");
                             $Loco = LocosFactory::CreateLocomotive(false, $row['class_id'], $loco_num);
                             if (filter_var($Loco->id, FILTER_VALIDATE_INT)) {
                                 $this->addLink($Loco->namespace, $Loco->id);
                                 if (!$Loco->hasCoverImage()) {
                                     $Loco->setCoverImage($this);
                                 }
                                 if (!$Loco->Class->hasCoverImage()) {
                                     $Loco->Class->setCoverImage($this);
                                 }
                             }
                         }
                     }
                 }
             }
             break;
         case "railpage.locos.class":
             if (isset($this->meta['tags'])) {
                 foreach ($this->db->fetchAll("SELECT id AS class_id, flickr_tag AS class_tag FROM loco_class") as $row) {
                     foreach ($this->meta['tags'] as $tag) {
                         if ($tag == $row['class_tag']) {
                             $LocoClass = LocosFactory::CreateLocoClass($row['class_id']);
                             if (filter_var($LocoClass->id, FILTER_VALIDATE_INT)) {
                                 $this->addLink($LocoClass->namespace, $LocoClass->id);
                             }
                         }
                     }
                 }
                 foreach ($this->meta['tags'] as $tag) {
                     if (preg_match("@railpage:class=([0-9]+)@", $tag, $matches)) {
                         $LocoClass = LocosFactory::CreateLocoClass($matches[1]);
                         if (filter_var($LocoClass->id, FILTER_VALIDATE_INT)) {
                             $this->addLink($LocoClass->namespace, $LocoClass->id);
                             if (!$LocoClass->hasCoverImage()) {
                                 $LocoClass->setCoverImage($this);
                             }
                         }
                     }
                 }
             }
             break;
         case "railpage.locos.liveries.livery":
             if (isset($this->meta['tags'])) {
                 foreach ($this->meta['tags'] as $tag) {
                     if (preg_match("@railpage:livery=([0-9]+)@", $tag, $matches)) {
                         $Livery = new Livery($matches[1]);
                         if (filter_var($Livery->id, FILTER_VALIDATE_INT)) {
                             $this->addLink($Livery->namespace, $Livery->id);
                         }
                     }
                 }
             }
             break;
     }
     Debug::LogEvent(__METHOD__ . "(\"" . $namespace . "\")", $timer);
     $this->Memcached->save($key, time());
     return $this;
 }
示例#7
0
 /**
  * Constructor
  * @since Version 3.0.1
  * @version 3.0.1
  * @param int $forumid
  * @param object $database
  */
 public function __construct($forumid = false, $getParent = true)
 {
     parent::__construct();
     $timer = Debug::GetTimer();
     $this->Module = new Module("forums");
     if (filter_var($forumid, FILTER_VALIDATE_INT)) {
         $this->load($forumid, $getParent);
     } elseif ($shortname = filter_var($forumid, FILTER_SANITIZE_STRING)) {
         if (!is_null($shortname)) {
             $this->load($shortname, $getParent);
         }
     }
     Debug::LogEvent(__METHOD__, $timer);
 }
    /**
     * Convert a Google Maps link into embedded content
     * @since Version 3.10.0
     * @param \DOMElement $e
     * @return \DOMElement
     */
    public static function EmbedGoogleMap(DOMElement $e)
    {
        $timer = Debug::GetTimer();
        $Config = AppCore::GetConfig();
        $lookup = pq($e)->attr("href");
        // Prevent this from f*****g with links in the middle of sentences
        if (pq($e)->text() != $lookup) {
            return $e;
        }
        if (!preg_match("#google.com(.au)?/maps/(.*)\\@([0-9\\-.]{8,13}),([0-9\\-.]{8,13})#", $lookup, $matches[0]) && !preg_match("#goo.gl/maps/([a-zA-Z0-9]{10,13})#", $lookup, $matches[1])) {
            return $e;
        }
        $basehtml = '<iframe width="%s" height="%s" frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/view?key=%s
&zoom=%d&maptype=%s&center=%s" allowfullscreen>
</iframe>';
        $params = ["100%", 600, $Config->Google->API_Key, 15, "satellite"];
        foreach ($matches as $val) {
            if (!count($val)) {
                continue;
            }
            // Co-ordinates known, great
            if (count($val) === 5) {
                $params[] = $val[3] . "," . $val[4];
                continue;
            }
            // Co-ordinates not known. Shit. Better look 'em up
            if (count($val) !== 2) {
                continue;
            }
            $Memcached = AppCore::GetMemcached();
            $cachekey = sprintf("google:url.shortner=%s", $val[1]);
            if (!($return = $Memcached->fetch($cachekey))) {
                $GuzzleClient = new Client();
                $url = sprintf("https://www.googleapis.com/urlshortener/v1/url?shortUrl=%s&key=%s", $lookup, "AIzaSyC1lUe1h-gwmFqj9xDTDYI9HYVTUxNscCA");
                $response = $GuzzleClient->get($url);
                // F****d it
                if ($response->getStatusCode() != 200) {
                    return $e;
                }
                $return = json_decode($response->getBody(), true);
                $Memcached->save($cachekey, $return);
            }
            // Get out if it looks problematic
            if ($return['status'] != "OK") {
                return $e;
            }
            pq($e)->attr("href", $return['longUrl'])->text($return['longUrl']);
            return self::EmbedGoogleMap($e);
            continue;
        }
        pq($e)->replaceWith(vsprintf($basehtml, $params));
        Debug::LogEvent(__METHOD__, $timer);
        return $e;
    }
示例#9
0
 /**
  * Generate the URL slug
  * @since Version 3.7.5
  * @param int $id
  * @param string $name
  * @return string
  */
 public function createSlug($id = false, $name = false)
 {
     $timer = Debug::GetTimer();
     if (filter_var($id, FILTER_VALIDATE_INT) && !$name) {
         $name = $this->db->fetchOne("SELECT organisation_name FROM organisation WHERE organisation_id = ?", $id);
     } elseif (filter_var($id, FILTER_VALIDATE_INT) && is_string($name)) {
         // Do nothing
     } elseif (isset($this->name) && !empty($this->name)) {
         $name = $this->name;
         $id = $this->id;
     } else {
         return false;
     }
     $proposal = ContentUtility::generateUrlSlug($name, 200);
     /**
      * Check that we haven't used this slug already
      */
     $result = $this->db->fetchAll("SELECT organisation_id FROM organisation WHERE organisation_slug = ? AND organisation_id != ?", array($proposal, $id));
     if (count($result)) {
         $proposal .= count($result);
     }
     if (isset($this->slug) || empty($this->slug)) {
         $this->slug = $proposal;
     }
     /**
      * Add this slug to the database
      */
     $data = array("organisation_slug" => $proposal);
     $where = array("organisation_id = ?" => $id);
     $rs = $this->db->update("organisation", $data, $where);
     Debug::LogEvent(__METHOD__, $timer);
     /**
      * Return it
      */
     return $proposal;
 }
示例#10
0
 /**
  * Make a permalink for this location
  * @since Version 3.7.5
  * @return string
  * @param int $id Optional location ID - inherited by 
  *    Railpage\Locations\Location so will attempt to use $this->id if none provided
  */
 public function makePermalink($id = false)
 {
     $mckey = $id ? "railpage:locations.permalink.id=" . $id : "railpage:locations.permalink.id=" . $this->id;
     $timer = Debug::GetTimer();
     if (!($string = $this->Memcached->fetch($mckey))) {
         if ((!isset($this->country) || !isset($this->region) || !isset($this->slug)) && $id) {
             // Fetch it from the database
             $query = "SELECT country, region, slug FROM location WHERE id = ?";
             $data = $this->db->fetchRow($query, $id);
             if (empty($data['slug'])) {
                 $Location = new Location($id);
                 $data['slug'] = $Location->slug;
             }
         } else {
             $data['country'] = $this->country;
             $data['region'] = $this->region;
             $data['slug'] = $this->slug;
         }
         $params = [$this->Module->url, str_replace(" ", "-", $data['country']), str_replace(" ", "-", $data['region']), $data['slug']];
         $string = strtolower(vsprintf("%s/%s/%s/%s", $params));
         $this->Memcached->save($mckey, $string, strtotime("+1 year"));
     }
     Debug::LogEvent(__METHOD__, $timer);
     return $string;
 }
示例#11
0
 /**
  * Remove an object from Memcache
  * @since Version 3.7.5
  * @param string $key
  * @return mixed
  */
 function remove($key = false)
 {
     if (!$key) {
         throw new Exception("Cannot remove object from memcache - \$key was not specified");
         return false;
     }
     $timer = Debug::GetTimer();
     $rs = $this->cn->delete($key);
     Debug::LogEvent(($rs === false ? "FAILED" : "SUCCEEDED") . " delete " . $key, $timer);
     StatsD::increment("rp.memcached.delete");
     return $rs;
 }
示例#12
0
 /**
  * Process and format the article (the/a/an) of a timeline item
  * @since Version 3.9.1
  * @param array $row
  * @return array
  */
 private function processGrammarArticle($row)
 {
     $timer = Debug::GetTimer();
     $row['event']['article'] = Grammar::getArticle_OfIn($row);
     $row['event']['article'] = Grammar::getArticle_AnA($row);
     if (preg_match("@(date)@Di", $row['event']['object'], $matches) && preg_match("@(edited)@Di", $row['event']['action'], $matches)) {
         $row['event']['preposition'] = "for";
     }
     $row = Grammar::getArticle_The($row);
     Debug::LogEvent(__METHOD__, $timer);
     return $row;
 }
示例#13
0
 /**
  * Get the latest news items
  * @version 3.7.5
  * @since Version 3.0
  * @return mixed
  * @param int $number
  * @param int $offset
  */
 public function latest($number = 5, $offset = 0)
 {
     $return = false;
     $mckey = "railpage:news.latest.count=" . $number . ".offset=" . $offset;
     $mcexp = strtotime("+5 minutes");
     // Store for five minutes
     $Sphinx = $this->getSphinx();
     $query = $Sphinx->select("*")->from("idx_news_article")->orderBy("story_time_unix", "DESC")->where("story_active", "=", 1)->limit($offset, $number);
     $matches = $query->execute();
     /**
      * Attempt to fetch from Sphinx first
      */
     if (is_array($matches) && count($matches)) {
         foreach ($matches as $id => $row) {
             $row['time_relative'] = time2str($row['story_time_unix']);
             $row['time'] = time2str($row['story_time']);
             // Match the first sentence
             $line = explode("\n", str_replace("\r\n", "\n", !empty($row['story_lead']) ? $row['story_lead'] : $row['story_blurb']));
             $row['firstline'] = strip_tags($line[0]);
             $row['hometext'] = wpautop(process_bbcode($row['story_blurb']));
             $row['bodytext'] = wpautop(process_bbcode($row['story_body']));
             $row['title'] = format_topictitle($row['story_title']);
             $row['featured_image'] = $row['story_image'];
             if (empty($row['slug'])) {
                 $row['slug'] = $this->createSlug($row['story_id']);
             }
             $row['url'] = $this->makePermaLink($row['story_slug']);
             $matches[$id] = $row;
         }
         return $matches;
     }
     /**
      * Fall back to database query
      */
     if (!($data = $this->Memcached->fetch($mckey))) {
         $timer = Debug::GetTimer();
         $query = "SELECT s.*, t.topicname, t.topicimage, t.topictext, u.user_id AS informant_id, u.user_id, u.username, u.user_avatar \r\n                        FROM nuke_stories AS s\r\n                        LEFT JOIN nuke_topics AS t ON s.topic = t.topicid\r\n                        LEFT JOIN nuke_users AS u ON s.informant = u.username\r\n                        WHERE s.title != \"\"\r\n                        AND s.approved = ?\r\n                        ORDER BY s.time DESC\r\n                        LIMIT ?, ?";
         if ($result = $this->db_readonly->fetchAll($query, array("1", $offset, $number))) {
             $return = array();
             foreach ($result as $row) {
                 if (function_exists("relative_date")) {
                     $row['time_relative'] = relative_date(strtotime($row['time']));
                 } else {
                     $row['time_relative'] = $row['time'];
                 }
                 // Match the first sentence
                 $line = explode("\n", str_replace("\r\n", "\n", $row['hometext']));
                 $row['firstline'] = strip_tags($line[0]);
                 $row['hometext'] = format_post($row['hometext']);
                 $row['hometext'] = wpautop($row['hometext']);
                 if (empty($row['slug'])) {
                     $row['slug'] = $this->createSlug($row['sid']);
                 }
                 $row['url'] = $this->makePermaLink($row['slug']);
                 $return[] = $row;
             }
             $this->Memcached->save($mckey, $return, $mcexp);
             Debug::LogEvent(__METHOD__, $timer);
         }
         return $return;
     }
 }
示例#14
0
 /**
  * Constructor
  * @since Version 3.0.1
  * @version 3.0.1
  * @param object $database
  * @param int $postid
  */
 public function __construct($postid = false)
 {
     $post_timer_start = Debug::GetTimer();
     parent::__construct();
     $this->Module = new Module("forums");
     $this->timestamp = time();
     $this->mckey = sprintf("railpage:forums;post=%d", $postid);
     $this->Memcached = AppCore::getMemcached();
     if (!($row = $this->Memcached->fetch($this->mckey))) {
         Debug::LogEvent("Could not find forum post in Redis using cache key " . $this->mckey);
         if (filter_var($postid, FILTER_VALIDATE_INT)) {
             $timer = Debug::GetTimer();
             $query = "SELECT p.*, t.*, u.username, u.user_avatar FROM nuke_bbposts p, nuke_bbposts_text t, nuke_users AS u WHERE u.user_id = p.poster_id AND p.post_id = ? AND t.post_id = p.post_id LIMIT 1";
             $row = $this->db->fetchRow($query, $postid);
             $rs = $this->Memcached->save($this->mckey, $row, 43200);
             Debug::LogEvent("Fetch forum post from database", $timer);
             if (!$rs) {
                 Debug::LogEvent("!! Failed to store forum post in cache provider");
             }
         } elseif (is_string($postid)) {
             $query = "SELECT p.*, t.*, u.username, u.user_avatar FROM nuke_bbposts p, nuke_bbposts_text t, nuke_users AS u WHERE u.user_id = p.poster_id AND t.url_slug = ? AND t.post_id = p.post_id LIMIT 1";
             $row = $this->db->fetchRow($query, $postid);
             $rs = $this->Memcached->save($this->mckey, $row, 43200);
         }
     }
     if (isset($row) && is_array($row)) {
         $this->id = $row['post_id'];
         $this->thread = ForumsFactory::CreateThread($row['topic_id']);
         $this->uid = $row['poster_id'];
         $this->username = $row['username'];
         $this->user_avatar = $row['user_avatar'];
         $this->timestamp = $row['post_time'];
         $this->ip = $row['poster_ip'];
         $this->flag_bbCode = $row['enable_bbcode'];
         $this->flag_html = $row['enable_html'];
         $this->flag_smilies = $row['enable_smilies'];
         $this->flag_signature = $row['enable_sig'];
         $this->edit_timestamp = $row['post_edit_time'];
         $this->edit_count = $row['post_edit_count'];
         $this->reported = $row['post_reported'];
         $this->herring_count = $row['post_edit_count'];
         $this->bbcodeuid = $row['bbcode_uid'];
         $this->subject = $row['post_subject'];
         $this->text = stripslashes($row['post_text']);
         $this->old_text = stripslashes($row['post_text']);
         $this->rating = $row['post_rating'];
         $this->bbcode_uid = $row['bbcode_uid'];
         $this->editor_version = $row['editor_version'];
         $this->url_slug = $row['url_slug'];
         $this->pinned = isset($row['pinned']) ? (bool) $row['pinned'] : false;
         if (empty($this->url_slug)) {
             $this->createSlug();
             $this->commit();
         }
         $this->lat = $row['lat'];
         $this->lon = $row['lon'];
         $this->Date = new DateTime();
         $this->Date->setTimestamp($row['post_time']);
         $this->Author = UserFactory::CreateUser($row['poster_id']);
         $this->makeLinks();
     }
     Debug::LogEvent(__METHOD__, $post_timer_start);
 }