* @return string substituted string
*/
function replace_macros($s,$r) {
-
+
$stamp1 = microtime(true);
$a = get_app();
if(! function_exists('notags')) {
/**
- * This is our primary input filter.
+ * This is our primary input filter.
*
* The high bit hack only involved some old IE browser, forget which (IE5/Mac?)
* that had an XSS attack vector due to stripping the high-bit on an 8-bit character
$stripped = str_replace('q=','',$stripped);
$stripped = trim($stripped,'/');
$pagenum = $a->pager['page'];
- $url = $a->get_baseurl() . '/' . $stripped;
+ if (($a->page_offset != "") AND !strstr($stripped, "&offset="))
+ $stripped .= "&offset=".urlencode($a->page_offset);
+ if (!strpos($stripped, "?")) {
+ if ($pos = strpos($stripped, "&"))
+ $stripped = substr($stripped, 0, $pos)."?".substr($stripped, $pos + 1);
+ }
+
+ $url = $a->get_baseurl() . '/' . $stripped;
$data = array();
- function _l(&$d, $name, $url, $text, $class="") {
-
+ function _l(&$d, $name, $url, $text, $class="") {
+
$d[$name] = array('url'=>$url, 'text'=>$text, 'class'=>$class);
}
if($a->pager['page']>1)
_l($data, "prev", $url.'&page='.($a->pager['page'] - 1), t('newer'));
if($count>0)
- _l($data, "next", $url.'&page='.($a->pager['page'] - 1), t('older'));
+ _l($data, "next", $url.'&page='.($a->pager['page'] + 1), t('older'));
} else {
// full pager
if($a->pager['total'] > $a->pager['itemspage']) {
_l($data, "first", $url."&page=1", t('first'));
-
+
$numpages = $a->pager['total'] / $a->pager['itemspage'];
$numstart = 1;
$lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages);
_l($data, "last", $url."&page=$lastpage", t('last'));
-
+
if(($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0)
_l($data, "next", $url."&page=".($a->pager['page'] + 1), t('next'));
- }
+ }
}
return $data;
* @return string html for pagination #FIXME remove html
*/
function paginate(&$a) {
-
+
$data = paginate_data($a);
$tpl = get_markup_template("paginate.tpl");
return replace_macros($tpl, array("pager" => $data));
$data = paginate_data($a, $i);
$tpl = get_markup_template("paginate.tpl");
return replace_macros($tpl, array('pager' => $data));
-
+
}}
if(! function_exists('expand_acl')) {
/**
* Turn user/group ACLs stored as angle bracketed text into arrays
- *
+ *
* @param string $s
* @return array
*/
/**
* Generate a guaranteed unique photo ID.
* safe from birthday paradox
- *
+ *
* @return string
- */
+ */
function photo_new_resource() {
do {
* @deprecated
* wrapper to load a view template, checking for alternate
* languages before falling back to the default
- *
+ *
* @global string $lang
* @global App $a
* @param string $s view name
* @param string $s
*/
function linkify($s) {
- $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\'\%\$\!\+]*)/", ' <a href="$1" target="external-link">$1</a>', $s);
+ $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\'\%\$\!\+]*)/", ' <a href="$1" target="_blank">$1</a>', $s);
$s = preg_replace("/\<(.*?)(src|href)=(.*?)\&\;(.*?)\>/ism",'<$1$2=$3&$4>',$s);
return($s);
}}
* @hook prepare_body ('item'=>item array, 'html'=>body string) after first bbcode to html
* @hook prepare_body_final ('item'=>item array, 'html'=>body string) after attach icons and blockquote special case handling (spoiler, author)
*/
-function prepare_body($item,$attach = false) {
+function prepare_body(&$item,$attach = false) {
$a = get_app();
call_hooks('prepare_body_init', $item);
+ $searchpath = $a->get_baseurl()."/search?tag=";
+
+ $tags=array();
+ $hashtags = array();
+ $mentions = array();
+
+ if (!get_config('system','suppress_tags')) {
+ $taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`",
+ intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
+
+ foreach($taglist as $tag) {
+
+ if ($tag["url"] == "")
+ $tag["url"] = $searchpath.strtolower($tag["term"]);
+
+ if ($tag["type"] == TERM_HASHTAG) {
+ $hashtags[] = "#<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
+ $prefix = "#";
+ } elseif ($tag["type"] == TERM_MENTION) {
+ $mentions[] = "@<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
+ $prefix = "@";
+ }
+ $tags[] = $prefix."<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
+ }
+ }
+
+ $item['tags'] = $tags;
+ $item['hashtags'] = $hashtags;
+ $item['mentions'] = $mentions;
+
+
//$cachefile = get_cachefile($item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']));
$cachefile = get_cachefile($item["guid"]."-".hash("md5", $item['body']));
$title = ((strlen(trim($mtch[4]))) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1]));
$title .= ' ' . $mtch[2] . ' ' . t('bytes');
- $as .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="external-link" >' . $icon . '</a>';
+ $as .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="_blank" >' . $icon . '</a>';
}
}
}
* @return string hub link xml elements
*/
function feed_hublinks() {
-
+ $a = get_app();
$hub = get_config('system','huburl');
$hubxml = '';
$h = trim($h);
if(! strlen($h))
continue;
+ if ($h === '[internal]')
+ $h = $a->get_baseurl() . '/pubsubhubbub';
$hubxml .= '<link rel="hub" href="' . xmlify($h) . '" />' . "\n" ;
}
}
* @return boolean|array False if item has not plink, otherwise array('href'=>plink url, 'title'=>translated title)
*/
function get_plink($item) {
- $a = get_app();
- if (x($item,'plink') && ($item['private'] != 1)) {
- return array(
- 'href' => $item['plink'],
+ $a = get_app();
+ $ret = array(
+ 'href' => $a->get_baseurl()."/display/".$a->user['nickname']."/".$item['id'],
'title' => t('link to source'),
);
- }
- else {
- return false;
- }
+
+ $ret["orig"] = $ret["href"];
+
+ //if (x($item,'plink') && ($item['private'] != 1))
+ if (x($item,'plink'))
+ $ret["href"] = $item['plink'];
+
+ return($ret);
}}
if(! function_exists('unamp')) {
);
if(count($r)) {
if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']'))
- q("update item set file = '%s' where id = %d and uid = %d limit 1",
+ q("update item set file = '%s' where id = %d and uid = %d",
dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'),
intval($item),
intval($uid)
if(! count($r))
return false;
- q("update item set file = '%s' where id = %d and uid = %d limit 1",
+ q("update item set file = '%s' where id = %d and uid = %d",
dbesc(str_replace($pattern,'',$r[0]['file'])),
intval($item),
intval($uid)