use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Render\FriendicaSmarty;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
+use Friendica\Util\Proxy as ProxyUtils;
-require_once "mod/proxy.php";
require_once "include/conversation.php";
/**
// pass $baseurl to all templates
$r['$baseurl'] = System::baseUrl();
- $t = $a->template_engine();
+ $t = $a->getTemplateEngine();
try {
$output = $t->replaceMacros($s, $r);
} catch (Exception $e) {
killme();
}
- $a->save_timestamp($stamp1, "rendering");
+ $a->saveTimestamp($stamp1, "rendering");
return $output;
}
$stamp1 = microtime(true);
$a = get_app();
- $t = $a->template_engine();
+ $t = $a->getTemplateEngine();
try {
$template = $t->getTemplateFile($s, $root);
} catch (Exception $e) {
killme();
}
- $a->save_timestamp($stamp1, "file");
+ $a->saveTimestamp($stamp1, "file");
return $template;
}
$stamp1 = microtime(true);
@file_put_contents($logfile, $logline, FILE_APPEND);
- $a->save_timestamp($stamp1, "file");
+ $a->saveTimestamp($stamp1, "file");
}
/**
$stamp1 = microtime(true);
@file_put_contents($logfile, $logline, FILE_APPEND);
- $a->save_timestamp($stamp1, "file");
+ $a->saveTimestamp($stamp1, "file");
}
AND NOT `pending` AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s')",
intval($a->profile['uid']),
- dbesc(NETWORK_DFRN),
- dbesc(NETWORK_OSTATUS),
- dbesc(NETWORK_DIASPORA)
+ DBA::escape(Protocol::DFRN),
+ DBA::escape(Protocol::OSTATUS),
+ DBA::escape(Protocol::DIASPORA)
);
if (DBA::isResult($r)) {
$total = intval($r[0]['total']);
AND `network` IN ('%s', '%s', '%s')
ORDER BY RAND() LIMIT %d",
intval($a->profile['uid']),
- dbesc(NETWORK_DFRN),
- dbesc(NETWORK_OSTATUS),
- dbesc(NETWORK_DIASPORA),
+ DBA::escape(Protocol::DFRN),
+ DBA::escape(Protocol::OSTATUS),
+ DBA::escape(Protocol::DIASPORA),
intval($shown)
);
if (DBA::isResult($r)) {
$contacts[] = $contact["id"];
}
$r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact` WHERE `id` IN (%s)",
- dbesc(implode(",", $contacts)));
+ DBA::escape(implode(",", $contacts)));
if (DBA::isResult($r)) {
$contacts = L10n::tt('%d Contact', '%d Contacts', $total);
'$click' => defaults($contact, 'click', ''),
'$class' => $class,
'$url' => $url,
- '$photo' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
+ '$photo' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
'$name' => $contact['name'],
'title' => $contact['name'] . ' [' . $contact['addr'] . ']',
'$parkle' => $sparkle,
continue;
}
- if ((local_user() == $item['uid']) && ($item['private'] == 1) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) {
+ if ((local_user() == $item['uid']) && ($item['private'] == 1) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == Protocol::DFRN)) {
$img_url = 'redir?f=1&quiet=1&url=' . urlencode($mtch[1]) . '&conurl=' . urlencode($item['author-link']);
$item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']);
}
$a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), [
'$baseurl' => System::baseUrl(),
]);
- $a->page['end'] .= replace_macros(get_markup_template('videos_end.tpl'), [
- '$baseurl' => System::baseUrl(),
- ]);
}
$url_parts = explode('/', $the_url);
];
if (x($item, 'plink')) {
- $ret["href"] = $a->remove_baseurl($item['plink']);
+ $ret["href"] = $a->removeBaseURL($item['plink']);
$ret["title"] = L10n::t('link to source');
}
}
}
-
-/**
- * @return string
- */
-function generate_user_guid() {
- $found = true;
- do {
- $guid = System::createGUID(32);
- $x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
- dbesc($guid)
- );
- if (!DBA::isResult($x)) {
- $found = false;
- }
- } while ($found == true);
-
- return $guid;
-}
-
-
/**
* @param string $s
* @param boolean $strip_padding
} else {
$str = preg_quote('<' . str_replace('%', '%%', file_tag_encode($s)) . '>');
}
- return " AND " . (($table) ? dbesc($table) . '.' : '') . "file regexp '" . dbesc($str) . "' ";
+ return " AND " . (($table) ? DBA::escape($table) . '.' : '') . "file regexp '" . DBA::escape($str) . "' ";
}
// ex. given music,video return <music><video> or [music][video]
foreach ($deleted_tags as $key => $tag) {
$r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
- dbesc($tag),
+ DBA::escape($tag),
intval(TERM_OBJ_POST),
intval($termtype),
intval($uid));
Item::update($fields, ['id' => $item_id]);
$r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
- dbesc($file),
+ DBA::escape($file),
intval(TERM_OBJ_POST),
intval($termtype),
intval($uid)
return $network_name;
}
}
-
-/**
- * @brief Syntax based code highlighting for popular languages.
- * @param string $s Code block
- * @param string $lang Programming language
- * @return string Formated html
- */
-function text_highlight($s, $lang) {
- if ($lang === 'js') {
- $lang = 'javascript';
- }
-
- if ($lang === 'bash') {
- $lang = 'sh';
- }
-
- // @TODO: Replace Text_Highlighter_Renderer_Html by scrivo/highlight.php
-
- // Autoload the library to make constants available
- class_exists('Text_Highlighter_Renderer_Html');
-
- $options = [
- 'numbers' => HL_NUMBERS_LI,
- 'tabsize' => 4,
- ];
-
- $tag_added = false;
- $s = trim(html_entity_decode($s, ENT_COMPAT));
- $s = str_replace(' ', "\t", $s);
-
- /*
- * The highlighter library insists on an opening php tag for php code blocks. If
- * it isn't present, nothing is highlighted. So we're going to see if it's present.
- * If not, we'll add it, and then quietly remove it after we get the processed output back.
- */
- if ($lang === 'php' && strpos($s, '<?php') !== 0) {
- $s = '<?php' . "\n" . $s;
- $tag_added = true;
- }
-
- $renderer = new Text_Highlighter_Renderer_Html($options);
- $factory = new Text_Highlighter();
- $hl = $factory->factory($lang);
- $hl->setRenderer($renderer);
- $o = $hl->highlight($s);
- $o = str_replace("\n", '', $o);
-
- if ($tag_added) {
- $b = substr($o, 0, strpos($o, '<li>'));
- $e = substr($o, strpos($o, '</li>'));
- $o = $b . $e;
- }
-
- return '<code>' . $o . '</code>';
-}