* @param int $uid
* @return string
*/
-function item_new_uri($hostname,$uid) {
+function item_new_uri($hostname,$uid, $guid = "") {
do {
$dups = false;
- $hash = random_string();
+
+ if ($guid == "")
+ $hash = get_guid(32);
+ else {
+ $hash = $guid;
+ $guid = "";
+ }
$uri = "urn:X-dfrn:" . $hostname . ':' . $uid . ':' . $hash;
if((! is_array($a->profile)) || ($a->profile['hide-friends']))
return $o;
- $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0",
- intval($a->profile['uid'])
+ $r = q("SELECT COUNT(*) AS `total` FROM `contact`
+ WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0
+ AND `hidden` = 0 AND `archive` = 0
+ AND `network` IN ('%s', '%s', '%s')",
+ intval($a->profile['uid']),
+ dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_OSTATUS),
+ dbesc(NETWORK_DIASPORA)
);
if(count($r)) {
$total = intval($r[0]['total']);
$micropro = Null;
} else {
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ORDER BY RAND() LIMIT %d",
+ $r = q("SELECT * FROM `contact`
+ WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0
+ AND `hidden` = 0 AND `archive` = 0
+ AND `network` IN ('%s', '%s', '%s') ORDER BY RAND() LIMIT %d",
intval($a->profile['uid']),
+ dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_OSTATUS),
+ dbesc(NETWORK_DIASPORA),
intval($shown)
);
if(count($r)) {
. (($click) ? ' fakelink' : '') . '" '
. (($redir) ? ' target="redir" ' : '')
. (($url) ? ' href="' . $url . '"' : '') . $click . ' ><img class="contact-block-img' . $class . $sparkle . '" src="'
- . proxy_url($contact['micro']) . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name']
+ . proxy_url($contact['micro'], false, PROXY_SIZE_THUMB) . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name']
. '" /></a></div>' . "\r\n";
}
}}
* @param string $url search url
* @param boolean $savedsearch show save search button
*/
-function search($s,$id='search-box',$url='/search',$save = false) {
+function search($s,$id='search-box',$url='/search',$save = false, $aside = true) {
$a = get_app();
- return replace_macros(get_markup_template('searchbox.tpl'), array(
- '$s' => $s,
- '$id' => $id,
- '$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url,
- '$search_label' => t('Search'),
- '$save_label' => t('Save'),
- '$savedsearch' => feature_enabled(local_user(),'savedsearch'),
- ));
+
+ $values = array(
+ '$s' => $s,
+ '$id' => $id,
+ '$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url,
+ '$search_label' => t('Search'),
+ '$save_label' => t('Save'),
+ '$savedsearch' => feature_enabled(local_user(),'savedsearch'),
+ );
+
+ if (!$aside) {
+ $values['$searchoption'] = array(
+ t("Full Text"),
+ t("Tags"),
+ t("Contacts"));
+
+ if (get_config('system','poco_local_search'))
+ $values['$searchoption'][] = t("Forums");
+ }
+
+ return replace_macros(get_markup_template('searchbox.tpl'), $values);
}}
if(! function_exists('valid_email')) {
put_item_in_cache($item, true);
$s = $item["rendered-html"];
- require_once("mod/proxy.php");
- $s = proxy_parse_html($s);
-
$prep_arr = array('item' => $item, 'html' => $s, 'preview' => $preview);
call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html'];
//'href' => $a->get_baseurl()."/display/".$a->user['nickname']."/".$item['id'],
'href' => $a->get_baseurl()."/display/".$item['guid'],
'orig' => $a->get_baseurl()."/display/".$item['guid'],
- 'title' => t('link to source'),
+ 'title' => t('View on separate page'),
+ 'orig_title' => t('view on separate page'),
);
- if (x($item,'plink'))
+ if (x($item,'plink')) {
$ret["href"] = $item['plink'];
+ $ret["title"] = t('link to source');
+ }
} elseif (x($item,'plink') && ($item['private'] != 1))
$ret = array(
function generate_user_guid() {
$found = true;
do {
- $guid = random_string(16);
+ $guid = get_guid(32);
$x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
dbesc($guid)
);
return implode("\n", $lines);
}
+
+function formatBytes($bytes, $precision = 2) {
+ $units = array('B', 'KB', 'MB', 'GB', 'TB');
+
+ $bytes = max($bytes, 0);
+ $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
+ $pow = min($pow, count($units) - 1);
+
+ $bytes /= pow(1024, $pow);
+
+ return round($bytes, $precision) . ' ' . $units[$pow];
+}