diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Contact.php | 17 | ||||
-rw-r--r-- | include/Photo.php | 2 | ||||
-rw-r--r-- | include/gprobe.php | 52 | ||||
-rw-r--r-- | include/group.php | 16 | ||||
-rw-r--r-- | include/nav.php | 2 | ||||
-rw-r--r-- | include/network.php | 2 | ||||
-rw-r--r-- | include/text.php | 75 | ||||
-rw-r--r-- | include/zot.php | 5 |
8 files changed, 77 insertions, 94 deletions
diff --git a/include/Contact.php b/include/Contact.php index ff798ed74..e52b5c9cf 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -2,9 +2,22 @@ function vcard_from_xchan($xchan) { + + $connect = false; + if(local_user()) { + $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($xchan['xchan_hash']), + intval(local_user()) + ); + if(! $r) + $connect = t('Connect'); + } + return replace_macros(get_markup_template('xchan_vcard.tpl'),array( - '$name' => $xchan['xchan_name'], - '$photo' => $xchan['xchan_photo_l'] + '$name' => $xchan['xchan_name'], + '$photo' => $xchan['xchan_photo_l'], + '$url' => $xchan['xchan_addr'], + '$connect' => $connect )); } diff --git a/include/Photo.php b/include/Photo.php index f77605b98..c3165cc9f 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -528,7 +528,7 @@ class Photo { $x = q("select id from photo where `resource_id` = '%s' and uid = %d and `xchan` = '%s' and `scale` = %d limit 1", dbesc($rid), intval($uid), - intval($xchan), + dbesc($xchan), intval($scale) ); if(count($x)) { diff --git a/include/gprobe.php b/include/gprobe.php index 377d40209..e66635302 100644 --- a/include/gprobe.php +++ b/include/gprobe.php @@ -1,61 +1,31 @@ <?php -require_once("boot.php"); -require_once('include/Scrape.php'); -require_once('include/socgraph.php'); +require_once('include/cli_startup.php'); +require_once('include/zot.php'); function gprobe_run($argv, $argc){ - global $a, $db; - if(is_null($a)) { - $a = new App; - } - - if(is_null($db)) { - @include(".htconfig.php"); - require_once("dba.php"); - $db = new dba($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); - }; - - require_once('include/session.php'); - require_once('include/datetime.php'); - - load_config('config'); - load_config('system'); + cli_startup(); - $a->set_baseurl(get_config('system','baseurl')); - - load_hooks(); + $a = get_app(); if($argc != 2) return; $url = hex2bin($argv[1]); - $r = q("select * from gcontact where nurl = '%s' limit 1", + $r = q("select * from xchan where xchan_addr = '%s' limit 1", dbesc(normalise_link($url)) ); - if(! count($r)) { - - $arr = probe_url($url); - if(count($arr) && x($arr,'network') && $arr['network'] === NETWORK_DFRN) { - q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`) - values ( '%s', '%s', '%s', '%s') ", - dbesc($arr['name']), - dbesc($arr['url']), - dbesc(normalise_link($arr['url'])), - dbesc($arr['photo']) - ); + if(! $r) { + $x = zot_finger($url,null); + if($x) { + $j = json_decode($x,true); + $y = import_xchan($j); } - $r = q("select * from gcontact where nurl = '%s' limit 1", - dbesc(normalise_link($url)) - ); } - if(count($r)) - poco_load(0,0,$r[0]['id'], str_replace('/channel/','/poco/',$r[0]['url'])); - + return; } diff --git a/include/group.php b/include/group.php index 1019daa9c..35ec72167 100644 --- a/include/group.php +++ b/include/group.php @@ -26,8 +26,20 @@ function group_add($uid,$name) { } return true; } - $r = q("INSERT INTO `group` ( `uid`, `name` ) - VALUES( %d, '%s' ) ", + + do { + $dups = false; + $hash = random_string() . $name; + + $r = q("SELECT id FROM group WHERE hash = '%s' LIMIT 1", dbesc($hash)); + if(count($r)) + $dups = true; + } while($dups == true); + + + $r = q("INSERT INTO `group` ( hash, uid, name ) + VALUES( '%s', %d, '%s' ) ", + dbesc($hash), intval($uid), dbesc($name) ); diff --git a/include/nav.php b/include/nav.php index eacb0f29a..7db053741 100644 --- a/include/nav.php +++ b/include/nav.php @@ -23,7 +23,7 @@ function nav(&$a) { minChars: 2, width: 250, }); - a.setOptions({ params: { autoSubmit: true, type: 'x' }}); + a.setOptions({ autoSubmit: true, params: { type: 'x' }}); }); diff --git a/include/network.php b/include/network.php index 47fa1d939..333e0e83f 100644 --- a/include/network.php +++ b/include/network.php @@ -1044,7 +1044,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false) // replace the special char encoding - $s = htmlspecialchars($s,ENT_QUOTES,'UTF-8'); + $s = htmlspecialchars($s,ENT_COMPAT,'UTF-8'); return $s; } diff --git a/include/text.php b/include/text.php index b97b21981..3ca0b3b6d 100644 --- a/include/text.php +++ b/include/text.php @@ -70,7 +70,7 @@ function notags($string) { if(! function_exists('escape_tags')) { function escape_tags($string) { - return(htmlspecialchars($string, ENT_QUOTES, 'UTF-8', false)); + return(htmlspecialchars($string, ENT_COMPAT, 'UTF-8', false)); }} @@ -331,7 +331,7 @@ function expand_acl($s) { if(! function_exists('sanitise_acl')) { function sanitise_acl(&$item) { - if(intval($item)) + if(strlen($item)) $item = '<' . notags(trim($item)) . '>'; else unset($item); @@ -545,7 +545,7 @@ function contact_block() { $total = intval($r[0]['total']); } if(! $total) { - $contacts = t('No contacts'); + $contacts = t('No connnections'); $micropro = Null; } else { @@ -556,7 +556,7 @@ function contact_block() { ); if(count($r)) { - $contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total); + $contacts = sprintf( tt('%d Connection','%d Connections', $total),$total); $micropro = Array(); foreach($r as $rr) { $micropro[] = micropro($rr,true,'mpfriend'); @@ -568,7 +568,7 @@ function contact_block() { $o = replace_macros($tpl, array( '$contacts' => $contacts, '$nickname' => $a->profile['nickname'], - '$viewcontacts' => t('View Contacts'), + '$viewcontacts' => t('View Connnections'), '$micropro' => $micropro, )); @@ -579,46 +579,35 @@ function contact_block() { }} + +function chanlink_hash($s) { + return z_root() . '/chanview?f=&hash=' . urlencode($s); +} + +function chanlink_url($s) { + return z_root() . '/chanview?f=&url=' . urlencode($s); +} + + +function chanlink_cid($d) { + return z_root() . '/chanview?f=&cid=' . intval($d); +} + + + if(! function_exists('micropro')) { function micropro($contact, $redirect = false, $class = '', $textmode = false) { - if($class) - $class = ' ' . $class; - - $url = $contact['xchan_url']; - $sparkle = ''; - $redir = false; + $url = chanlink_hash($contact['xchan_hash']); - if($redirect) { - $a = get_app(); - $redirect_url = $a->get_baseurl() . '/magic/' . $contact['abook_id']; - if(local_user() && ($contact['abook_channel'] == local_user()) && ($contact['xchan_network'] === NETWORK_ZOT)) { - $redir = true; - $url = $redirect_url; - $sparkle = ' sparkle'; - } - else - $url = zid($url); - } - $click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : ''); - if($click) - $url = ''; - if($textmode) { - return '<div class="contact-block-textdiv' . $class . '"><a class="contact-block-link' . $class . $sparkle - . (($click) ? ' fakelink' : '') . '" ' - . (($redir) ? ' ' : '') - . (($url) ? ' href="' . $url . '"' : '') . $click - . '" title="' . $contact['xchan_name'] . ' [' . $contact['xchan_url'] . ']" alt="' . $contact['xchan_name'] - . '" >'. $contact['xchan_name'] . '</a></div>' . "\r\n"; - } - else { - return '<div class="contact-block-div' . $class . '"><a class="contact-block-link' . $class . $sparkle - . (($click) ? ' fakelink' : '') . '" ' - . (($redir) ? ' ' : '') - . (($url) ? ' href="' . $url . '"' : '') . $click . ' ><img class="contact-block-img' . $class . $sparkle . '" src="' - . $contact['xchan_photo_s'] . '" title="' . $contact['xchan_name'] . ' [' . $contact['xchan_url'] . ']" alt="' . $contact['xchan_name'] - . '" /></a></div>' . "\r\n"; - } + return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),array( + '$click' => $click, + '$class' => $class, + '$url' => $url, + '$photo' => $contact['xchan_photo_s'], + '$name' => $contact['xchan_name'], + '$title' => $contact['xchan_name'] . ' [' . $contact['xchan_addr'] . ']', + )); }} @@ -963,7 +952,7 @@ function prepare_body($item,$attach = false) { foreach($terms as $t) { if(strlen($x)) $x .= ','; - $x .= htmlspecialchars($t['term'],ENT_QUOTES,'UTF-8') + $x .= htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') . ((local_user() == $item['uid']) ? ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . urlencode($t['term']) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>' : ''); } if(strlen($x)) @@ -978,7 +967,7 @@ function prepare_body($item,$attach = false) { foreach($terms as $t) { if(strlen($x)) $x .= ' '; - $x .= htmlspecialchars($t['term'],ENT_QUOTES,'UTF-8') + $x .= htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') . ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . urlencode($t['term']) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>'; } if(strlen($x) && (local_user() == $item['uid'])) diff --git a/include/zot.php b/include/zot.php index 2d2bc92c6..31f0e8771 100644 --- a/include/zot.php +++ b/include/zot.php @@ -406,7 +406,7 @@ function import_xchan_from_json($j) { require_once("Photo.php"); - $photos = import_profile_photo($j->photo,0,$xchan_hash); + $photos = import_profile_photo($j->photo,$xchan_hash); $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s' limit 1", dbesc($j->photo_updated), @@ -524,7 +524,7 @@ function import_xchan($arr) { require_once("Photo.php"); - $photos = import_profile_photo($arr['photo'],0,$xchan_hash); + $photos = import_profile_photo($arr['photo'],$xchan_hash); $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s' limit 1", dbesc($arr['photo_updated']), @@ -870,7 +870,6 @@ function delete_imported_item($sender,$item,$uid) { } function process_mail_delivery($sender,$arr,$deliveries) { - foreach($deliveries as $d) { $r = q("select * from channel where channel_hash = '%s' limit 1", |