diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/account.php | 6 | ||||
-rw-r--r-- | include/acl_selectors.php | 4 | ||||
-rw-r--r-- | include/api.php | 26 | ||||
-rw-r--r-- | include/attach.php | 26 | ||||
-rw-r--r-- | include/bbcode.php | 14 | ||||
-rw-r--r-- | include/channel.php | 194 | ||||
-rw-r--r-- | include/config.php | 161 | ||||
-rw-r--r-- | include/contact_widgets.php | 4 | ||||
-rw-r--r-- | include/conversation.php | 16 | ||||
-rw-r--r-- | include/crypto.php | 18 | ||||
-rwxr-xr-x | include/dba/dba_driver.php | 7 | ||||
-rw-r--r-- | include/event.php | 173 | ||||
-rw-r--r-- | include/feedutils.php | 14 | ||||
-rw-r--r-- | include/group.php | 20 | ||||
-rw-r--r-- | include/import.php | 38 | ||||
-rwxr-xr-x | include/items.php | 88 | ||||
-rw-r--r-- | include/language.php | 4 | ||||
-rw-r--r-- | include/network.php | 2 | ||||
-rw-r--r-- | include/oauth.php | 12 | ||||
-rw-r--r-- | include/photo/photo_driver.php | 50 | ||||
-rw-r--r-- | include/photos.php | 28 | ||||
-rwxr-xr-x | include/plugin.php | 38 | ||||
-rw-r--r-- | include/sharedwithme.php | 4 | ||||
-rw-r--r-- | include/taxonomy.php | 18 | ||||
-rw-r--r-- | include/text.php | 41 | ||||
-rw-r--r-- | include/widgets.php | 24 | ||||
-rw-r--r-- | include/zot.php | 49 |
27 files changed, 420 insertions, 659 deletions
diff --git a/include/account.php b/include/account.php index a442f3073..caf12878e 100644 --- a/include/account.php +++ b/include/account.php @@ -229,7 +229,7 @@ function verify_email_address($arr) { $hash = random_string(); - $r = q("INSERT INTO register ( hash, created, uid, password, language ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", + $r = q("INSERT INTO register ( hash, created, uid, password, lang ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", dbesc($hash), dbesc(datetime_convert()), intval($arr['account']['account_id']), @@ -283,7 +283,7 @@ function send_reg_approval_email($arr) { $hash = random_string(); - $r = q("INSERT INTO register ( hash, created, uid, password, language ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", + $r = q("INSERT INTO register ( hash, created, uid, password, lang ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", dbesc($hash), dbesc(datetime_convert()), intval($arr['account']['account_id']), @@ -387,7 +387,7 @@ function account_allow($hash) { intval($register[0]['uid']) ); - push_lang($register[0]['language']); + push_lang($register[0]['lang']); $email_tpl = get_intltext_template("register_open_eml.tpl"); $email_tpl = replace_macros($email_tpl, array( diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 54ea0304b..89d054e3b 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -15,7 +15,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n"; - $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", + $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `gname` ASC", intval(local_channel()) ); @@ -32,7 +32,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { $selected = " selected=\"selected\" "; else $selected = ''; - $trimmed = mb_substr($rr['name'],0,12); + $trimmed = mb_substr($rr['gname'],0,12); $o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}\" >$trimmed</option>\r\n"; } diff --git a/include/api.php b/include/api.php index af5a22a74..f0d886d9b 100644 --- a/include/api.php +++ b/include/api.php @@ -368,7 +368,7 @@ require_once('include/api_auth.php'); else $redirect = trim($_REQUEST['redirect_uris']); $icon = trim($_REQUEST['logo_uri']); - $r = q("INSERT INTO clients (client_id, pw, name, redirect_uri, icon, uid) + $r = q("INSERT INTO clients (client_id, pw, clname, redirect_uri, icon, uid) VALUES ('%s','%s','%s','%s','%s',%d)", dbesc($key), dbesc($secret), @@ -554,7 +554,7 @@ require_once('include/api_auth.php'); dbesc($_REQUEST['file_id']) ); if($r) { - unset($r[0]['data']); + unset($r[0]['content']); $ret = array('attach' => $r[0]); json_return_and_die($ret); } @@ -580,21 +580,21 @@ require_once('include/api_auth.php'); $length = intval($ptr['filesize']); if($ptr['is_dir']) - $ptr['data'] = ''; + $ptr['content'] = ''; elseif(! intval($r[0]['os_storage'])) { $ptr['start'] = $start; - $x = substr(dbunescbin($ptr['data'],$start,$length)); + $x = substr(dbunescbin($ptr['content'],$start,$length)); $ptr['length'] = strlen($x); - $ptr['data'] = base64_encode($x); + $ptr['content'] = base64_encode($x); } else { - $fp = fopen(dbunescbin($ptr['data']),'r'); + $fp = fopen(dbunescbin($ptr['content']),'r'); if($fp) { $seek = fseek($fp,$start,SEEK_SET); $x = fread($fp,$length); $ptr['start'] = $start; $ptr['length'] = strlen($x); - $ptr['data'] = base64_encode($x); + $ptr['content'] = base64_encode($x); } } @@ -617,11 +617,11 @@ require_once('include/api_auth.php'); ); if($r) { if($r[0]['is_dir']) - $r[0]['data'] = ''; + $r[0]['content'] = ''; elseif(intval($r[0]['os_storage'])) - $r[0]['data'] = base64_encode(file_get_contents(dbunescbin($r[0]['data']))); + $r[0]['content'] = base64_encode(file_get_contents(dbunescbin($r[0]['content']))); else - $r[0]['data'] = base64_encode(dbunescbin($r[0]['data'])); + $r[0]['content'] = base64_encode(dbunescbin($r[0]['content'])); $ret = array('attach' => $r[0]); json_return_and_die($ret); @@ -647,16 +647,16 @@ require_once('include/api_auth.php'); if (api_user()===false) return false; if(! $_REQUEST['photo_id']) return false; $scale = ((array_key_exists('scale',$_REQUEST)) ? intval($_REQUEST['scale']) : 0); - $r = q("select * from photo where uid = %d and resource_id = '%s' and scale = %d limit 1", + $r = q("select * from photo where uid = %d and resource_id = '%s' and imgscale = %d limit 1", intval(local_channel()), dbesc($_REQUEST['photo_id']), intval($scale) ); if($r) { - $data = dbunescbin($r[0]['data']); + $data = dbunescbin($r[0]['content']); if(array_key_exists('os_storage',$r[0]) && intval($r[0]['os_storage'])) $data = file_get_contents($data); - $r[0]['data'] = base64_encode($data); + $r[0]['content'] = base64_encode($data); $ret = array('photo' => $r[0]); $i = q("select id from item where uid = %d and resource_type = 'photo' and resource_id = '%s' limit 1", intval(local_channel()), diff --git a/include/attach.php b/include/attach.php index d9cd30f6d..78efde51f 100644 --- a/include/attach.php +++ b/include/attach.php @@ -720,7 +720,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $edited = $created; if($options === 'replace') { - $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, data = '%s', edited = '%s' where id = %d and uid = %d", + $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, content = '%s', edited = '%s' where id = %d and uid = %d", dbesc($filename), dbesc($mimetype), dbesc($folder_hash), @@ -734,7 +734,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { ); } elseif($options === 'revise') { - $r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid ) + $r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, allow_cid, allow_gid, deny_cid, deny_gid ) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($x[0]['aid']), intval($channel_id), @@ -775,7 +775,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { } else { - $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, data, created, edited, allow_cid, allow_gid,deny_cid, deny_gid ) + $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, allow_cid, allow_gid,deny_cid, deny_gid ) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($channel['channel_account_id']), intval($channel_id), @@ -1032,7 +1032,7 @@ function attach_mkdir($channel, $observer_hash, $arr = null) { $created = datetime_convert(); - $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_dir, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid ) + $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_dir, content, created, edited, allow_cid, allow_gid, deny_cid, deny_gid ) VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($channel['channel_account_id']), intval($channel_id), @@ -1275,16 +1275,16 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { // delete a file from filesystem if(intval($r[0]['os_storage'])) { - $y = q("SELECT data FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1", + $y = q("SELECT content FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1", dbesc($resource), intval($channel_id) ); if($y) { - if(strpos($y[0]['data'],'store') === false) - $f = 'store/' . $channel_address . '/' . $y[0]['data']; + if(strpos($y[0]['content'],'store') === false) + $f = 'store/' . $channel_address . '/' . $y[0]['content']; else - $f = $y[0]['data']; + $f = $y[0]['content']; if(is_dir($f)) @rmdir($f); @@ -1585,7 +1585,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $arr['deny_gid'] = perms2str($u_arr_deny_gid); $arr['item_private'] = $private; $arr['verb'] = ACTIVITY_UPDATE; - $arr['object'] = $u_jsonobject; + $arr['obj'] = $u_jsonobject; $arr['body'] = ''; $post = item_store($arr); @@ -1620,7 +1620,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $arr['deny_gid'] = perms2str($arr_deny_gid); $arr['item_private'] = $private; $arr['verb'] = (($update) ? ACTIVITY_UPDATE : ACTIVITY_POST); - $arr['object'] = (($update) ? $u_jsonobject : $jsonobject); + $arr['obj'] = (($update) ? $u_jsonobject : $jsonobject); $arr['body'] = ''; $post = item_store($arr); @@ -1854,21 +1854,19 @@ function attach_export_data($channel, $resource_id, $deleted = false) { } while($hash_ptr); - - $paths = array_reverse($paths); $ret['attach'] = $paths; if($attach_ptr['is_photo']) { - $r = q("select * from photo where resource_id = '%s' and uid = %d order by scale asc", + $r = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale asc", dbesc($resource_id), intval($channel['channel_id']) ); if($r) { for($x = 0; $x < count($r); $x ++) { - $r[$x]['data'] = base64_encode($r[$x]['data']); + $r[$x]['content'] = base64_encode($r[$x]['content']); } $ret['photo'] = $r; } diff --git a/include/bbcode.php b/include/bbcode.php index f47dc6f2e..42741b392 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -477,9 +477,12 @@ function bb_observer($Text) { return $Text; } - - - +function bb_code($match) { + if(strpos($match[0], "<br />")) + return '<code>' . trim($match[1]) . '</code>'; + else + return '<code class="inline-code">' . trim($match[1]) . '</code>'; +} @@ -785,12 +788,9 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) $Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "<span style=\"font-family: $1;\">$2</span>", $Text); } - // Declare the format for [code] layout - $CodeLayout = '<code>$1</code>'; - // Check for [code] text if (strpos($Text,'[code]') !== false) { - $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism", "$CodeLayout", $Text); + $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism", 'bb_code', $Text); } // Check for [spoiler] text diff --git a/include/channel.php b/include/channel.php index 35084741f..087bd4162 100644 --- a/include/channel.php +++ b/include/channel.php @@ -337,7 +337,7 @@ function create_identity($arr) { // Not checking return value. // It's ok for this to fail if it's an imported channel, and therefore the hash is a duplicate - $r = q("INSERT INTO profile ( aid, uid, profile_guid, profile_name, is_default, publish, name, photo, thumb) + $r = q("INSERT INTO profile ( aid, uid, profile_guid, profile_name, is_default, publish, fullname, photo, thumb) VALUES ( %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s') ", intval($ret['channel']['channel_account_id']), intval($newuid), @@ -392,7 +392,7 @@ function create_identity($arr) { // if our role_permissions indicate that we're using a default collection ACL, add it. if(is_array($role_permissions) && $role_permissions['default_collection']) { - $r = q("select hash from groups where uid = %d and name = '%s' limit 1", + $r = q("select hash from groups where uid = %d and gname = '%s' limit 1", intval($newuid), dbesc( t('Friends') ) ); @@ -550,18 +550,18 @@ function identity_basic_export($channel_id, $items = false) { if($r) $ret['config'] = $r; - $r = q("select type, data, os_storage from photo where scale = 4 and photo_usage = %d and uid = %d limit 1", + $r = q("select mimetype, content, os_storage from photo where imgscale = 4 and photo_usage = %d and uid = %d limit 1", intval(PHOTO_PROFILE), intval($channel_id) ); if($r) { - $ret['photo'] = array('type' => $r[0]['type'], 'data' => (($r[0]['os_storage']) ? base64url_encode(file_get_contents($r[0]['data'])) : base64url_encode($r[0]['data']))); + $ret['photo'] = array('type' => $r[0]['mimetype'], 'data' => (($r[0]['os_storage']) ? base64url_encode(file_get_contents($r[0]['content'])) : base64url_encode($r[0]['content']))); } // All other term types will be included in items, if requested. - $r = q("select * from term where type in (%d,%d) and uid = %d", + $r = q("select * from term where ttype in (%d,%d) and uid = %d", intval(TERM_SAVEDSEARCH), intval(TERM_THING), intval($channel_id) @@ -1108,156 +1108,12 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa } -/** - * @FIXME or remove - */ - function get_birthdays() { - - $o = ''; - - if(! local_channel()) - return $o; - - $bd_format = t('g A l F d') ; // 8 AM Friday January 18 - $bd_short = t('F d'); - - $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event` - LEFT JOIN `contact` ON `contact`.`id` = `event`.`cid` - WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s' - ORDER BY `start` ASC ", - intval(local_channel()), - dbesc(datetime_convert('UTC','UTC','now + 6 days')), - dbesc(datetime_convert('UTC','UTC','now')) - ); - - if($r && count($r)) { - $total = 0; - $now = strtotime('now'); - $cids = array(); - - $istoday = false; - foreach($r as $rr) { - if(strlen($rr['name'])) - $total ++; - if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) - $istoday = true; - } - $classtoday = $istoday ? ' birthday-today ' : ''; - if($total) { - foreach($r as &$rr) { - if(! strlen($rr['name'])) - continue; - - // avoid duplicates - - if(in_array($rr['cid'],$cids)) - continue; - $cids[] = $rr['cid']; - - $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false); - $sparkle = ''; - $url = $rr['url']; - if($rr['network'] === NETWORK_DFRN) { - $sparkle = " sparkle"; - $url = z_root() . '/redir/' . $rr['cid']; - } - - $rr['link'] = $url; - $rr['title'] = $rr['name']; - $rr['date'] = day_translate(datetime_convert('UTC', App::$timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : ''); - $rr['startime'] = Null; - $rr['today'] = $today; - } - } - } - $tpl = get_markup_template("birthdays_reminder.tpl"); - return replace_macros($tpl, array( - '$baseurl' => z_root(), - '$classtoday' => $classtoday, - '$count' => $total, - '$event_reminders' => t('Birthday Reminders'), - '$event_title' => t('Birthdays this week:'), - '$events' => $r, - '$lbr' => '{', // raw brackets mess up if/endif macro processing - '$rbr' => '}' - )); - } - - -/** - * @FIXME - */ - function get_events() { - - require_once('include/bbcode.php'); - - if(! local_channel()) - return $o; - - $bd_format = t('g A l F d') ; // 8 AM Friday January 18 - $bd_short = t('F d'); - - $r = q("SELECT `event`.* FROM `event` - WHERE `event`.`uid` = %d AND `type` != 'birthday' AND `start` < '%s' AND `start` > '%s' - ORDER BY `start` ASC ", - intval(local_channel()), - dbesc(datetime_convert('UTC','UTC','now + 6 days')), - dbesc(datetime_convert('UTC','UTC','now - 1 days')) - ); - - if($r && count($r)) { - $now = strtotime('now'); - $istoday = false; - foreach($r as $rr) { - if(strlen($rr['name'])) - $total ++; - - $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start'],'Y-m-d'); - if($strt === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) - $istoday = true; - } - $classtoday = (($istoday) ? 'event-today' : ''); - - foreach($r as &$rr) { - if($rr['adjust']) - $md = datetime_convert('UTC',App::$timezone,$rr['start'],'Y/m'); - else - $md = datetime_convert('UTC','UTC',$rr['start'],'Y/m'); - $md .= "/#link-".$rr['id']; - - $title = substr(strip_tags(bbcode($rr['desc'])),0,32) . '... '; - if(! $title) - $title = t('[No description]'); - - $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start']); - $today = ((substr($strt,0,10) === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) ? true : false); - - $rr['link'] = $md; - $rr['title'] = $title; - $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? App::$timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); - $rr['startime'] = $strt; - $rr['today'] = $today; - } - } - - $tpl = get_markup_template("events_reminder.tpl"); - return replace_macros($tpl, array( - '$baseurl' => z_root(), - '$classtoday' => $classtoday, - '$count' => count($r), - '$event_reminders' => t('Event Reminders'), - '$event_title' => t('Events this week:'), - '$events' => $r, - )); - } - - function advanced_profile(&$a) { require_once('include/text.php'); if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_profile')) return ''; - if(App::$profile['name']) { + if(App::$profile['fullname']) { $profile_fields_basic = get_profile_fields_basic(); $profile_fields_advanced = get_profile_fields_advanced(); @@ -1281,7 +1137,7 @@ function advanced_profile(&$a) { $profile = array(); - $profile['fullname'] = array( t('Full Name:'), App::$profile['name'] ) ; + $profile['fullname'] = array( t('Full Name:'), App::$profile['fullname'] ) ; if(App::$profile['gender']) $profile['gender'] = array( t('Gender:'), App::$profile['gender'] ); @@ -1329,8 +1185,8 @@ function advanced_profile(&$a) { if(App::$profile['marital']) $profile['marital'] = array( t('Status:'), App::$profile['marital']); - if(App::$profile['with']) - $profile['marital']['with'] = bbcode(App::$profile['with']); + if(App::$profile['partner']) + $profile['marital']['partner'] = bbcode(App::$profile['partner']); if(strlen(App::$profile['howlong']) && App::$profile['howlong'] !== NULL_DATE) { $profile['howlong'] = relative_date(App::$profile['howlong'], t('for %1$d %2$s')); @@ -1370,7 +1226,7 @@ function advanced_profile(&$a) { if($txt = prepare_text(App::$profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt); - if($txt = prepare_text(App::$profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt); + if($txt = prepare_text(App::$profile['employment'])) $profile['employment'] = array( t('Work/employment:'), $txt); if($txt = prepare_text(App::$profile['education'])) $profile['education'] = array( t('School/education:'), $txt ); @@ -1658,7 +1514,7 @@ function get_profile_fields_basic($filter = 0) { $profile_fields_basic = (($filter == 0) ? get_config('system','profile_fields_basic') : null); if(! $profile_fields_basic) - $profile_fields_basic = array('name','pdesc','chandesc','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact'); + $profile_fields_basic = array('fullname','pdesc','chandesc','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact'); $x = array(); if($profile_fields_basic) @@ -1673,7 +1529,7 @@ function get_profile_fields_advanced($filter = 0) { $basic = get_profile_fields_basic($filter); $profile_fields_advanced = (($filter == 0) ? get_config('system','profile_fields_advanced') : null); if(! $profile_fields_advanced) - $profile_fields_advanced = array('with','howlong','politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','work','education'); + $profile_fields_advanced = array('partner','howlong','politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','employment','education'); $x = array(); if($basic) @@ -1785,7 +1641,7 @@ function auto_channel_create($account_id) { function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_1200) { - $r = q("select height, width, resource_id, type from photo where uid = %d and scale = %d and photo_usage = %d", + $r = q("select height, width, resource_id, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d", intval($channel_id), intval($res), intval(PHOTO_COVER) @@ -1808,8 +1664,8 @@ function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_ default: $output = array( 'width' => $r[0]['width'], - 'height' => $r[0]['type'], - 'type' => $r[0]['type'], + 'height' => $r[0]['height'], + 'type' => $r[0]['mimetype'], 'url' => $url ); break; @@ -1834,19 +1690,19 @@ function get_zcard($channel,$observer_hash = '',$args = array()) { $width = 425; $size = 'hz_small'; $cover_size = PHOTO_RES_COVER_425; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); + $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); } elseif($maxwidth <= 900) { $width = 900; $size = 'hz_medium'; $cover_size = PHOTO_RES_COVER_850; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); + $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); } elseif($maxwidth <= 1200) { $width = 1200; $size = 'hz_large'; $cover_size = PHOTO_RES_COVER_1200; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); + $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); } // $scale = (float) $maxwidth / $width; @@ -1856,7 +1712,7 @@ function get_zcard($channel,$observer_hash = '',$args = array()) { $channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname(); $zcard = array('chan' => $channel); - $r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d", + $r = q("select height, width, resource_id, imgscale, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d", intval($channel['channel_id']), intval($cover_size), intval(PHOTO_COVER) @@ -1864,7 +1720,7 @@ function get_zcard($channel,$observer_hash = '',$args = array()) { if($r) { $cover = $r[0]; - $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale']; + $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } else { $cover = $pphoto; @@ -1900,25 +1756,25 @@ function get_zcard_embed($channel,$observer_hash = '',$args = array()) { $width = 425; $size = 'hz_small'; $cover_size = PHOTO_RES_COVER_425; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); + $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); } elseif($maxwidth <= 900) { $width = 900; $size = 'hz_medium'; $cover_size = PHOTO_RES_COVER_850; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); + $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); } elseif($maxwidth <= 1200) { $width = 1200; $size = 'hz_large'; $cover_size = PHOTO_RES_COVER_1200; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); + $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); } $channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname(); $zcard = array('chan' => $channel); - $r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d", + $r = q("select height, width, resource_id, imgscale, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d", intval($channel['channel_id']), intval($cover_size), intval(PHOTO_COVER) @@ -1926,7 +1782,7 @@ function get_zcard_embed($channel,$observer_hash = '',$args = array()) { if($r) { $cover = $r[0]; - $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale']; + $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } else { $cover = $pphoto; diff --git a/include/config.php b/include/config.php index 3017c3865..fe7cbead6 100644 --- a/include/config.php +++ b/include/config.php @@ -1,17 +1,13 @@ <?php + /** * @file include/config.php * @brief Arbitrary configuration storage. * - * @note Please do not store booleans - convert to 0/1 integer values. - * The get_?config() functions return boolean false for keys that are unset, - * and this could lead to subtle bugs. - * - * Arrays get stored as serialize strings. - * - * @todo There are a few places in the code (such as the admin panel) where - * boolean configurations need to be fixed as of 10/08/2011. + * Arrays get stored as serialized strings. + * Booleans are stored as integer 0/1. * + * - <b>config</b> is used for hub specific configurations. It overrides the * configurations from .htconfig file. The storage is of size TEXT. * - <b>pconfig</b> is used for channel specific configurations and takes a @@ -34,163 +30,39 @@ * */ -/** - * @brief Loads the hub's configuration from database to a cached storage. - * - * Retrieve a category ($family) of config variables from database to a cached - * storage in the global App::$config[$family]. - * - * @param string $family - * The category of the configuration value - */ -function load_config($family) { - if(! array_key_exists($family, App::$config)) - App::$config[$family] = array(); +use Zotlabs\Lib as Zlib; - if(! array_key_exists('config_loaded', App::$config[$family])) { - $r = q("SELECT * FROM config WHERE cat = '%s'", dbesc($family)); - if($r !== false) { - if($r) { - foreach($r as $rr) { - $k = $rr['k']; - App::$config[$family][$k] = $rr['v']; - } - } - App::$config[$family]['config_loaded'] = true; - } - } -} -/** - * @brief Get a particular config variable given the category name ($family) - * and a key. - * - * Get a particular config variable from the given category ($family) and the - * $key from a cached storage in App::$config[$family]. If a key is found in the - * DB but does not exist in local config cache, pull it into the cache so we - * do not have to hit the DB again for this item. - * - * Returns false if not set. - * - * @param string $family - * The category of the configuration value - * @param string $key - * The configuration key to query - * @return mixed Return value or false on error or if not set - */ -function get_config($family, $key) { - if((! array_key_exists($family, App::$config)) || (! array_key_exists('config_loaded', App::$config[$family]))) - load_config($family); +function load_config($family) { + + Zlib\Config::Load($family); - if(array_key_exists('config_loaded', App::$config[$family])) { - if(! array_key_exists($key, App::$config[$family])) { - return false; - } - return ((! is_array(App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', App::$config[$family][$key])) - ? unserialize(App::$config[$family][$key]) - : App::$config[$family][$key] - ); - } - return false; } -/** - * @brief Returns a value directly from the database configuration storage. - * - * This function queries directly the database and bypasses the chached storage - * from get_config($family, $key). - * - * @param string $family - * The category of the configuration value - * @param string $key - * The configuration key to query - * @return mixed - */ +function get_config($family, $key) { + + return Zlib\Config::Get($family,$key); -function get_config_from_storage($family, $key) { - $ret = q("SELECT * FROM config WHERE cat = '%s' AND k = '%s' LIMIT 1", - dbesc($family), - dbesc($key) - ); - return $ret; } -/** - * @brief Sets a configuration value for the hub. - * - * Stores a config value ($value) in the category ($family) under the key ($key). - * - * @note Please do not store booleans - convert to 0/1 integer values! - * - * @param string $family - * The category of the configuration value - * @param string $key - * The configuration key to set - * @param mixed $value - * The value to store in the configuration - * @return mixed - * Return the set value, or false if the database update failed - */ function set_config($family, $key, $value) { - // manage array value - $dbvalue = ((is_array($value)) ? serialize($value) : $value); - $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); - - if(get_config($family, $key) === false || (! get_config_from_storage($family, $key))) { - $ret = q("INSERT INTO config ( cat, k, v ) VALUES ( '%s', '%s', '%s' ) ", - dbesc($family), - dbesc($key), - dbesc($dbvalue) - ); - if($ret) { - App::$config[$family][$key] = $value; - $ret = $value; - } - return $ret; - } + return Zlib\Config::Set($family,$key,$value); - $ret = q("UPDATE config SET v = '%s' WHERE cat = '%s' AND k = '%s'", - dbesc($dbvalue), - dbesc($family), - dbesc($key) - ); - - if($ret) { - App::$config[$family][$key] = $value; - $ret = $value; - } - return $ret; } -/** - * @brief Deletes the given key from the hub's configuration database. - * - * Removes the configured value from the stored cache in App::$config[$family] - * and removes it from the database. - * - * @param string $family - * The category of the configuration value - * @param string $key - * The configuration key to delete - * @return mixed - */ function del_config($family, $key) { - $ret = false; + return Zlib\Config::Delete($family,$key); - if(array_key_exists($family, App::$config) && array_key_exists($key, App::$config[$family])) - unset(App::$config[$family][$key]); - $ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'", - dbesc($family), - dbesc($key) - ); - return $ret; } + + + /** * @brief Loads all configuration values of a channel into a cached storage. * @@ -201,6 +73,7 @@ function del_config($family, $key) { * The channel_id * @return void|false Nothing or false if $uid is false */ + function load_pconfig($uid) { if($uid === false) diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 14d26e257..85c46b0d1 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -39,7 +39,7 @@ function fileas_widget($baseurl,$selected = '') { return ''; $terms = array(); - $r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", + $r = q("select distinct(term) from term where uid = %d and ttype = %d order by term asc", intval(local_channel()), intval(TERM_FILE) ); @@ -72,7 +72,7 @@ function categories_widget($baseurl,$selected = '') { from term join item on term.oid = item.id where item.uid = %d and term.uid = item.uid - and term.type = %d + and term.ttype = %d and term.otype = %d and item.owner_xchan = '%s' and item.item_wall = 1 diff --git a/include/conversation.php b/include/conversation.php index dabe2ca93..518193b08 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -93,15 +93,15 @@ function localize_item(&$item){ if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){ - if(! $item['object']) + if(! $item['obj']) return; if(intval($item['item_thread_top'])) return; - $obj = json_decode_plus($item['object']); - if((! $obj) && ($item['object'])) { - logger('localize_item: failed to decode object: ' . print_r($item['object'],true)); + $obj = json_decode_plus($item['obj']); + if((! $obj) && ($item['obj'])) { + logger('localize_item: failed to decode object: ' . print_r($item['obj'],true)); } if($obj['author'] && $obj['author']['link']) @@ -186,7 +186,7 @@ function localize_item(&$item){ $Alink = $item['author']['xchan_url']; - $obj= json_decode_plus($item['object']); + $obj= json_decode_plus($item['obj']); $Blink = $Bphoto = ''; @@ -219,7 +219,7 @@ function localize_item(&$item){ $Aname = $item['author']['xchan_name']; $Alink = $item['author']['xchan_url']; - $obj= json_decode_plus($item['object']); + $obj= json_decode_plus($item['obj']); $Blink = $Bphoto = ''; @@ -299,7 +299,7 @@ function localize_item(&$item){ } $plink = '[zrl=' . $obj['plink'] . ']' . $post_type . '[/zrl]'; - $parsedobj = parse_xml_string($xmlhead.$item['object']); + $parsedobj = parse_xml_string($xmlhead.$item['obj']); $tag = sprintf('#[zrl=%s]%s[/zrl]', $parsedobj->id, $parsedobj->content); $item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag ); @@ -316,7 +316,7 @@ function localize_item(&$item){ $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; - $obj = parse_xml_string($xmlhead.$item['object']); + $obj = parse_xml_string($xmlhead.$item['obj']); if(strlen($obj->id)) { $r = q("select * from item where mid = '%s' and uid = %d limit 1", dbesc($obj->id), diff --git a/include/crypto.php b/include/crypto.php index 42aa45b72..bc798d919 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -49,26 +49,12 @@ function AES256CBC_encrypt($data,$key,$iv) { return openssl_encrypt($data,'aes-256-cbc',str_pad($key,32,"\0"),OPENSSL_RAW_DATA,str_pad($iv,16,"\0")); -/* deprecated in php 7.1 - return mcrypt_encrypt( - MCRYPT_RIJNDAEL_128, - str_pad($key,32,"\0"), - pkcs5_pad($data,16), - MCRYPT_MODE_CBC, - str_pad($iv,16,"\0")); -*/ } function AES256CBC_decrypt($data,$key,$iv) { + return openssl_decrypt($data,'aes-256-cbc',str_pad($key,32,"\0"),OPENSSL_RAW_DATA,str_pad($iv,16,"\0")); -/* deprecated in php 7.1 - return pkcs5_unpad(mcrypt_decrypt( - MCRYPT_RIJNDAEL_128, - str_pad($key,32,"\0"), - $data, - MCRYPT_MODE_CBC, - str_pad($iv,16,"\0"))); -*/ + } function crypto_encapsulate($data,$pubkey,$alg='aes256cbc') { diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index 0ab5830ed..df072ed76 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -12,7 +12,7 @@ class DBA { static public $dba = null; static public $dbtype = null; - + static public $logging = false; /** * @brief Returns the database driver object. @@ -421,8 +421,13 @@ function db_getfunc($f) { function db_logger($s,$level = LOGGER_NORMAL,$syslog = LOG_INFO) { + if(\DBA::$logging) + return; + $saved = \DBA::$dba->debug; \DBA::$dba->debug = false; + \DBA::$logging = true; logger($s,$level,$syslog); + \DBA::$logging = false; \DBA::$dba->debug = $saved; }
\ No newline at end of file diff --git a/include/event.php b/include/event.php index db67dac64..a4118ec78 100644 --- a/include/event.php +++ b/include/event.php @@ -28,22 +28,22 @@ function format_event_html($ev) { $o .= '<div class="event-title"><h3><i class="fa fa-calendar"></i> ' . bbcode($ev['summary']) . '</h3></div>' . "\r\n"; $o .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span> <span class="dtstart" title="' - . datetime_convert('UTC', 'UTC', $ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) + . datetime_convert('UTC', 'UTC', $ev['dtstart'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) . '" >' . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), - $ev['start'] , $bd_format )) + $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', - $ev['start'] , $bd_format))) + $ev['dtstart'] , $bd_format))) . '</span></div>' . "\r\n"; if(! $ev['nofinish']) $o .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span> <span class="dtend" title="' - . datetime_convert('UTC','UTC',$ev['finish'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) + . datetime_convert('UTC','UTC',$ev['dtend'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) . '" >' . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), - $ev['finish'] , $bd_format )) + $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', - $ev['finish'] , $bd_format ))) + $ev['dtend'] , $bd_format ))) . '</span></div>' . "\r\n"; $o .= '<div class="event-description">' . bbcode($ev['description']) . '</div>' . "\r\n"; @@ -58,6 +58,37 @@ function format_event_html($ev) { return $o; } +function format_event_obj($jobject) { + $event = array(); + + $object = json_decode($jobject,true); + + //ensure compatibility with older items - this check can be removed at a later point + if(array_key_exists('description', $object)) { + + $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM + + $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( + '$title' => bbcode($object['title']), + '$dtstart_label' => t('Starts:'), + '$dtstart_title' => datetime_convert('UTC', 'UTC', $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), + '$finish' => (($object['nofinish']) ? false : true), + '$dtend_label' => t('Finishes:'), + '$dtend_title' => datetime_convert('UTC','UTC',$object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))) + )); + + $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( + '$description' => bbcode($object['description']), + '$location_label' => t('Location:'), + '$location' => bbcode($object['location']) + )); + + } + + return $event; +} function ical_wrapper($ev) { @@ -68,7 +99,7 @@ function ical_wrapper($ev) { $o .= "\r\nVERSION:2.0"; $o .= "\r\nMETHOD:PUBLISH"; $o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . Zotlabs\Lib\System::get_platform_name() . "//" . strtoupper(App::$language). "\r\n"; - if(array_key_exists('start', $ev)) + if(array_key_exists('dtstart', $ev)) $o .= format_event_ical($ev); else { foreach($ev as $e) { @@ -82,7 +113,7 @@ function ical_wrapper($ev) { function format_event_ical($ev) { - if($ev['type'] === 'task') + if($ev['etype'] === 'task') return format_todo_ical($ev); $o = ''; @@ -92,10 +123,10 @@ function format_event_ical($ev) { $o .= "\r\nCREATED:" . datetime_convert('UTC','UTC', $ev['created'],'Ymd\\THis\\Z'); $o .= "\r\nLAST-MODIFIED:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z'); $o .= "\r\nDTSTAMP:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z'); - if($ev['start']) - $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['start'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); - if($ev['finish'] && ! $ev['nofinish']) - $o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['finish'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); + if($ev['dtstart']) + $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); + if($ev['dtend'] && ! $ev['nofinish']) + $o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); if($ev['summary']) $o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']); if($ev['location']) @@ -119,10 +150,10 @@ function format_todo_ical($ev) { $o .= "\r\nCREATED:" . datetime_convert('UTC','UTC', $ev['created'],'Ymd\\THis\\Z'); $o .= "\r\nLAST-MODIFIED:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z'); $o .= "\r\nDTSTAMP:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z'); - if($ev['start']) - $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['start'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); - if($ev['finish'] && ! $ev['nofinish']) - $o .= "\r\nDUE:" . datetime_convert('UTC','UTC', $ev['finish'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); + if($ev['dtstart']) + $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); + if($ev['dtend'] && ! $ev['nofinish']) + $o .= "\r\nDUE:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); if($ev['summary']) $o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']); if($ev['event_status']) { @@ -166,11 +197,11 @@ function format_event_bbcode($ev) { if($ev['description']) $o .= '[event-description]' . $ev['description'] . '[/event-description]'; - if($ev['start']) - $o .= '[event-start]' . $ev['start'] . '[/event-start]'; + if($ev['dtstart']) + $o .= '[event-start]' . $ev['dtstart'] . '[/event-start]'; - if(($ev['finish']) && (! $ev['nofinish'])) - $o .= '[event-finish]' . $ev['finish'] . '[/event-finish]'; + if(($ev['dtend']) && (! $ev['nofinish'])) + $o .= '[event-finish]' . $ev['dtend'] . '[/event-finish]'; if($ev['location']) $o .= '[event-location]' . $ev['location'] . '[/event-location]'; @@ -207,10 +238,10 @@ function bbtoevent($s) { $ev['description'] = $match[1]; $match = ''; if(preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is",$s,$match)) - $ev['start'] = $match[1]; + $ev['dtstart'] = $match[1]; $match = ''; if(preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is",$s,$match)) - $ev['finish'] = $match[1]; + $ev['dtend'] = $match[1]; $match = ''; if(preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is",$s,$match)) $ev['location'] = $match[1]; @@ -220,11 +251,11 @@ function bbtoevent($s) { $match = ''; if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match)) $ev['adjust'] = $match[1]; - if(array_key_exists('start',$ev)) { - if(array_key_exists('finish',$ev)) { - if($ev['finish'] === $ev['start']) + if(array_key_exists('dtstart',$ev)) { + if(array_key_exists('dtend',$ev)) { + if($ev['dtend'] === $ev['dtstart']) $ev['nofinish'] = 1; - elseif($ev['finish']) + elseif($ev['dtend']) $ev['nofinish'] = 0; else $ev['nofinish'] = 1; @@ -260,8 +291,8 @@ function sort_by_date($arr) { */ function ev_compare($a, $b) { - $date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['start']) : $a['start']); - $date_b = (($b['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$b['start']) : $b['start']); + $date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['dtstart']) : $a['dtstart']); + $date_b = (($b['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$b['dtstart']) : $b['dtstart']); if ($date_a === $date_b) return strcasecmp($a['description'], $b['description']); @@ -274,7 +305,7 @@ function event_store_event($arr) { $arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert()); $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert()); - $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); + $arr['etype'] = (($arr['etype']) ? $arr['etype'] : 'event' ); $arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : ''); $arr['event_priority'] = (($arr['event_priority']) ? $arr['event_priority'] : 0); @@ -324,12 +355,12 @@ function event_store_event($arr) { $r = q("UPDATE `event` SET `edited` = '%s', - `start` = '%s', - `finish` = '%s', + `dtstart` = '%s', + `dtend` = '%s', `summary` = '%s', `description` = '%s', `location` = '%s', - `type` = '%s', + `etype` = '%s', `adjust` = %d, `nofinish` = %d, `event_status` = '%s', @@ -345,12 +376,12 @@ function event_store_event($arr) { WHERE `id` = %d AND `uid` = %d", dbesc($arr['edited']), - dbesc($arr['start']), - dbesc($arr['finish']), + dbesc($arr['dtstart']), + dbesc($arr['dtend']), dbesc($arr['summary']), dbesc($arr['description']), dbesc($arr['location']), - dbesc($arr['type']), + dbesc($arr['etype']), intval($arr['adjust']), intval($arr['nofinish']), dbesc($arr['event_status']), @@ -378,7 +409,7 @@ function event_store_event($arr) { else $hash = random_string() . '@' . App::get_hostname(); - $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type, + $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,dtstart,dtend,summary,description,location,etype, adjust,nofinish, event_status, event_status_date, event_percent, event_repeat, event_sequence, event_priority, allow_cid,allow_gid,deny_cid,deny_gid) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s' ) ", intval($arr['uid']), @@ -387,12 +418,12 @@ function event_store_event($arr) { dbesc($hash), dbesc($arr['created']), dbesc($arr['edited']), - dbesc($arr['start']), - dbesc($arr['finish']), + dbesc($arr['dtstart']), + dbesc($arr['dtend']), dbesc($arr['summary']), dbesc($arr['description']), dbesc($arr['location']), - dbesc($arr['type']), + dbesc($arr['etype']), intval($arr['adjust']), intval($arr['nofinish']), dbesc($arr['event_status']), @@ -441,7 +472,7 @@ function event_addtocal($item_id, $uid) { $ev = bbtoevent($r[0]['body']); - if(x($ev,'summary') && x($ev,'start')) { + if(x($ev,'summary') && x($ev,'dtstart')) { $ev['event_xchan'] = $item['author_xchan']; $ev['uid'] = $channel['channel_id']; $ev['account'] = $channel['channel_account_id']; @@ -554,20 +585,20 @@ function event_import_ical($ical, $uid) { // logger('dtstart: ' . var_export($dtstart,true)); - $ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', $dtstart->format(\DateTime::W3C)); if(isset($ical->DTEND)) { $dtend = $ical->DTEND->getDateTime(); - $ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', $dtend->format(\DateTime::W3C)); } else $ev['nofinish'] = 1; - if($ev['start'] === $ev['finish']) + if($ev['dtstart'] === $ev['dtend']) $ev['nofinish'] = 1; if(isset($ical->CREATED)) { @@ -601,7 +632,7 @@ function event_import_ical($ical, $uid) { $ev['external_id'] = $evuid; } - if($ev['summary'] && $ev['start']) { + if($ev['summary'] && $ev['dtstart']) { $ev['event_xchan'] = $channel['channel_hash']; $ev['uid'] = $channel['channel_id']; $ev['account'] = $channel['channel_account_id']; @@ -640,29 +671,24 @@ function event_import_ical_task($ical, $uid) { $dtstart = $ical->DTSTART->getDateTime(); + $ev['adjust'] = (($ical->DTSTART->isFloating()) ? 1 : 0); + // logger('dtstart: ' . var_export($dtstart,true)); - if(($dtstart->timezone_type == 2) || (($dtstart->timezone_type == 3) && ($dtstart->timezone === 'UTC'))) { - $ev['adjust'] = 1; - } - else { - $ev['adjust'] = 0; - } - - $ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', $dtstart->format(\DateTime::W3C)); if(isset($ical->DUE)) { $dtend = $ical->DUE->getDateTime(); - $ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', $dtend->format(\DateTime::W3C)); } else $ev['nofinish'] = 1; - if($ev['start'] === $ev['finish']) + if($ev['dtstart'] === $ev['dtend']) $ev['nofinish'] = 1; if(isset($ical->CREATED)) { @@ -727,9 +753,9 @@ function event_import_ical_task($ical, $uid) { $ev['event_percent'] = (string) $ical->{'PERCENT-COMPLETE'} ; } - $ev['type'] = 'task'; + $ev['etype'] = 'task'; - if($ev['summary'] && $ev['start']) { + if($ev['summary'] && $ev['dtstart']) { $ev['event_xchan'] = $channel['channel_hash']; $ev['uid'] = $channel['channel_id']; $ev['account'] = $channel['channel_account_id']; @@ -781,7 +807,7 @@ function event_store_item($arr, $event) { if(($event) && array_key_exists('event_hash',$event) && (! array_key_exists('event_hash',$arr))) $arr['event_hash'] = $event['event_hash']; - if($event['type'] === 'birthday') { + if($event['etype'] === 'birthday') { if(! is_sys_channel($arr['uid'])) $prefix = t('This event has been added to your calendar.'); // $birthday = true; @@ -805,21 +831,22 @@ function event_store_item($arr, $event) { 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], 'title' => $arr['summary'], - 'start' => $arr['start'], - 'finish' => $arr['finish'], + 'dtstart' => $arr['dtstart'], + 'dtend' => $arr['dtend'], 'nofinish' => $arr['nofinish'], 'description' => $arr['description'], 'location' => $arr['location'], 'adjust' => $arr['adjust'], 'content' => format_event_bbcode($arr), 'author' => array( - 'name' => $r[0]['xchan_name'], - 'address' => $r[0]['xchan_addr'], - 'guid' => $r[0]['xchan_guid'], - 'guid_sig' => $r[0]['xchan_guid_sig'], - 'link' => array( - array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']), - array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m'])), + 'name' => $r[0]['xchan_name'], + 'address' => $r[0]['xchan_addr'], + 'guid' => $r[0]['xchan_guid'], + 'guid_sig' => $r[0]['xchan_guid_sig'], + 'link' => array( + array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']), + array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m']) + ), ), )); @@ -830,7 +857,7 @@ function event_store_item($arr, $event) { $sig = ''; - q("UPDATE item SET title = '%s', body = '%s', object = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', sig = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d", + q("UPDATE item SET title = '%s', body = '%s', obj = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', sig = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d", dbesc($arr['summary']), dbesc($prefix . format_event_bbcode($arr)), dbesc($object), @@ -854,12 +881,12 @@ function event_store_item($arr, $event) { if(($arr['term']) && (is_array($arr['term']))) { foreach($arr['term'] as $t) { - q("insert into term (uid,oid,otype,type,term,url) + q("insert into term (uid,oid,otype,ttype,term,url) values(%d,%d,%d,%d,'%s','%s') ", intval($arr['uid']), intval($r[0]['id']), intval(TERM_OBJ_POST), - intval($t['type']), + intval($t['ttype']), dbesc($t['term']), dbesc($t['url']) ); @@ -946,12 +973,12 @@ function event_store_item($arr, $event) { dbesc($arr['event_xchan']) ); if($x) { - $item_arr['object'] = json_encode(array( + $item_arr['obj'] = json_encode(array( 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $event['event_hash'], 'title' => $arr['summary'], - 'start' => $arr['start'], - 'finish' => $arr['finish'], + 'dtstart' => $arr['dtstart'], + 'dtend' => $arr['dtend'], 'nofinish' => $arr['nofinish'], 'description' => $arr['description'], 'location' => $arr['location'], @@ -1001,7 +1028,7 @@ function tasks_fetch($arr) { if($arr && $arr['all'] == 1) $sql_extra = ''; - $r = q("select * from event where type = 'task' and uid = %d $sql_extra order by created desc", + $r = q("select * from event where etype = 'task' and uid = %d $sql_extra order by created desc", intval(local_channel()) ); diff --git a/include/feedutils.php b/include/feedutils.php index f370c540a..685b2f982 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -144,9 +144,9 @@ function construct_verb($item) { function construct_activity_object($item) { - if($item['object']) { + if($item['obj']) { $o = '<as:object>' . "\r\n"; - $r = json_decode($item['object'],false); + $r = json_decode($item['obj'],false); if(! $r) return ''; @@ -515,7 +515,7 @@ function get_atom_elements($feed, $item, &$author) { if($termterm) { $terms[] = array( 'otype' => TERM_OBJ_POST, - 'type' => $termtype, + 'ttype' => $termtype, 'url' => $termurl, 'term' => $termterm, ); @@ -582,7 +582,7 @@ function get_atom_elements($feed, $item, &$author) { $obj['content'] = $body; } - $res['object'] = $obj; + $res['obj'] = $obj; } $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'target'); @@ -1163,12 +1163,12 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { } if(activity_match($item['obj_type'],ACTIVITY_OBJ_EVENT) && activity_match($item['verb'],ACTIVITY_POST)) { - $obj = ((is_array($item['obj'])) ? $item['object'] : json_decode($item['object'],true)); + $obj = ((is_array($item['obj'])) ? $item['obj'] : json_decode($item['obj'],true)); $o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n"; $o .= '<summary xmlns="urn:ietf:params:xml:ns:xcal">' . xmlify(bbcode($obj['title'])) . '</summary>' . "\r\n"; - $o .= '<dtstart xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['start'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtstart>' . "\r\n"; - $o .= '<dtend xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['finish'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtend>' . "\r\n"; + $o .= '<dtstart xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['dtstart'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtstart>' . "\r\n"; + $o .= '<dtend xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['dtend'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtend>' . "\r\n"; $o .= '<location xmlns="urn:ietf:params:xml:ns:xcal">' . xmlify(bbcode($obj['location'])) . '</location>' . "\r\n"; $o .= '<content type="' . $type . '" >' . xmlify(bbcode($obj['description'])) . '</content>' . "\r\n"; } diff --git a/include/group.php b/include/group.php index 748ec0c13..a4938b848 100644 --- a/include/group.php +++ b/include/group.php @@ -18,7 +18,7 @@ function group_add($uid,$name,$public = 0) { intval($r) ); if(count($z) && $z[0]['deleted']) { - /*$r = q("UPDATE `groups` SET `deleted` = 0 WHERE `uid` = %d AND `name` = '%s' LIMIT 1", + /*$r = q("UPDATE `groups` SET `deleted` = 0 WHERE `uid` = %d AND `gname` = '%s' LIMIT 1", intval($uid), dbesc($name) );*/ @@ -38,7 +38,7 @@ function group_add($uid,$name,$public = 0) { } while($dups == true); - $r = q("INSERT INTO `groups` ( hash, uid, visible, name ) + $r = q("INSERT INTO `groups` ( hash, uid, visible, gname ) VALUES( '%s', %d, %d, '%s' ) ", dbesc($hash), intval($uid), @@ -57,7 +57,7 @@ function group_add($uid,$name,$public = 0) { function group_rmv($uid,$name) { $ret = false; if(x($uid) && x($name)) { - $r = q("SELECT id, hash FROM `groups` WHERE `uid` = %d AND `name` = '%s' LIMIT 1", + $r = q("SELECT id, hash FROM `groups` WHERE `uid` = %d AND `gname` = '%s' LIMIT 1", intval($uid), dbesc($name) ); @@ -108,7 +108,7 @@ function group_rmv($uid,$name) { ); // remove group - $r = q("UPDATE `groups` SET `deleted` = 1 WHERE `uid` = %d AND `name` = '%s'", + $r = q("UPDATE `groups` SET `deleted` = 1 WHERE `uid` = %d AND `gname` = '%s'", intval($uid), dbesc($name) ); @@ -125,7 +125,7 @@ function group_rmv($uid,$name) { function group_byname($uid,$name) { if((! $uid) || (! strlen($name))) return false; - $r = q("SELECT * FROM `groups` WHERE `uid` = %d AND `name` = '%s' LIMIT 1", + $r = q("SELECT * FROM `groups` WHERE `uid` = %d AND `gname` = '%s' LIMIT 1", intval($uid), dbesc($name) ); @@ -232,13 +232,13 @@ function mini_group_select($uid,$group = '') { $grps = array(); $o = ''; - $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", + $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `gname` ASC", intval($uid) ); $grps[] = array('name' => '', 'hash' => '0', 'selected' => ''); if(count($r)) { foreach($r as $rr) { - $grps[] = array('name' => $rr['name'], 'id' => $rr['hash'], 'selected' => (($group == $rr['hash']) ? 'true' : '')); + $grps[] = array('name' => $rr['gname'], 'id' => $rr['hash'], 'selected' => (($group == $rr['hash']) ? 'true' : '')); } } @@ -271,7 +271,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id ); - $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", + $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `gname` ASC", intval($_SESSION['uid']) ); $member_of = array(); @@ -296,7 +296,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id 'id' => $rr['id'], 'enc_cid' => base64url_encode($cid), 'cid' => $cid, - 'text' => $rr['name'], + 'text' => $rr['gname'], 'selected' => $selected, 'href' => (($mode == 0) ? $each.'?f=&gid='.$rr['id'] : $each."/".$rr['id']) . ((x($_GET,'new')) ? '&new=' . $_GET['new'] : '') . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : ''), 'edit' => $groupedit, @@ -340,7 +340,7 @@ function expand_groups($a) { function member_of($c) { - $r = q("SELECT `groups`.`name`, `groups`.`id` FROM `groups` LEFT JOIN `group_member` ON `group_member`.`gid` = `groups`.`id` WHERE `group_member`.`xchan` = '%s' AND `groups`.`deleted` = 0 ORDER BY `groups`.`name` ASC ", + $r = q("SELECT `groups`.`gname`, `groups`.`id` FROM `groups` LEFT JOIN `group_member` ON `group_member`.`gid` = `groups`.`id` WHERE `group_member`.`xchan` = '%s' AND `groups`.`deleted` = 0 ORDER BY `groups`.`gname` ASC ", dbesc($c) ); diff --git a/include/import.php b/include/import.php index 132306621..6fcb08416 100644 --- a/include/import.php +++ b/include/import.php @@ -332,7 +332,9 @@ function import_apps($channel,$apps) { ); if($x) { foreach($term as $t) { - store_item_tag($channel['channel_id'],$x[0]['id'],TERM_OBJ_APP,$t['type'],escape_tags($t['term']),escape_tags($t['url'])); + if(array_key_exists('type',$t)) + $t['ttype'] = $t['type']; + store_item_tag($channel['channel_id'],$x[0]['id'],TERM_OBJ_APP,$t['ttype'],escape_tags($t['term']),escape_tags($t['url'])); } } } @@ -400,7 +402,9 @@ function sync_apps($channel,$apps) { if($exists && $term) { foreach($term as $t) { - store_item_tag($channel['channel_id'],$exists['id'],TERM_OBJ_APP,$t['type'],escape_tags($t['term']),escape_tags($t['url'])); + if(array_key_exists('type',$t)) + $t['ttype'] = $t['type']; + store_item_tag($channel['channel_id'],$exists['id'],TERM_OBJ_APP,$t['ttype'],escape_tags($t['term']),escape_tags($t['url'])); } } @@ -436,7 +440,9 @@ function sync_apps($channel,$apps) { ); if($x) { foreach($term as $t) { - store_item_tag($channel['channel_id'],$x[0]['id'],TERM_OBJ_APP,$t['type'],escape_tags($t['term']),escape_tags($t['url'])); + if(array_key_exists('type',$t)) + $t['ttype'] = $t['type']; + store_item_tag($channel['channel_id'],$x[0]['id'],TERM_OBJ_APP,$t['ttype'],escape_tags($t['term']),escape_tags($t['url'])); } } } @@ -968,6 +974,11 @@ function sync_files($channel,$files) { $attachment_stored = false; foreach($f['attach'] as $att) { + if(array_key_exists('data',$att)) { + $att['content'] = $att['data']; + unset($att['data']); + } + if($att['deleted']) { attach_delete($channel,$att['hash']); continue; @@ -1037,7 +1048,7 @@ function sync_files($channel,$files) { // @fixme - update attachment structures if they are modified rather than created - $att['data'] = $newfname; + $att['content'] = $newfname; // Note: we use $att['hash'] below after it has been escaped to // fetch the file contents. @@ -1119,6 +1130,15 @@ function sync_files($channel,$files) { $p['aid'] = $channel['channel_account_id']; $p['uid'] = $channel['channel_id']; + if(array_key_exists('data',$p)) { + $p['content'] = $p['data']; + unset($p['data']); + } + if(array_key_exists('scale',$p)) { + $p['imgscale'] = $p['scale']; + unset($p['scale']); + } + // if this is a profile photo, undo the profile photo bit // for any other photo which previously held it. @@ -1144,15 +1164,15 @@ function sync_files($channel,$files) { ); } - if($p['scale'] === 0 && $p['os_storage']) - $p['data'] = $store_path; + if($p['imgscale'] === 0 && $p['os_storage']) + $p['content'] = $store_path; else - $p['data'] = base64_decode($p['data']); + $p['content'] = base64_decode($p['content']); - $exists = q("select * from photo where resource_id = '%s' and scale = %d and uid = %d limit 1", + $exists = q("select * from photo where resource_id = '%s' and imgscale = %d and uid = %d limit 1", dbesc($p['resource_id']), - intval($p['scale']), + intval($p['imgscale']), intval($channel['channel_id']) ); diff --git a/include/items.php b/include/items.php index a60c10bdd..f473b2bac 100755 --- a/include/items.php +++ b/include/items.php @@ -666,7 +666,7 @@ function get_item_elements($x,$allow_code = false) { $arr['diaspora_meta'] = (($x['diaspora_signature']) ? $x['diaspora_signature'] : ''); - $arr['object'] = activity_sanitise($x['object']); + $arr['obj'] = activity_sanitise($x['object']); $arr['target'] = activity_sanitise($x['target']); $arr['attach'] = activity_sanitise($x['attach']); @@ -1055,8 +1055,8 @@ function encode_item($item,$mirror = false) { $x['owner'] = encode_item_xchan($item['owner']); $x['author'] = encode_item_xchan($item['author']); - if($item['object']) - $x['object'] = json_decode_plus($item['object']); + if($item['obj']) + $x['object'] = json_decode_plus($item['obj']); if($item['target']) $x['target'] = json_decode_plus($item['target']); if($item['attach']) @@ -1182,8 +1182,8 @@ function encode_item_terms($terms,$mirror = false) { if($terms) { foreach($terms as $term) { - if(in_array($term['type'],$allowed_export_terms)) - $ret[] = array('tag' => $term['term'], 'url' => $term['url'], 'type' => termtype($term['type'])); + if(in_array($term['ttype'],$allowed_export_terms)) + $ret[] = array('tag' => $term['term'], 'url' => $term['url'], 'ttype' => termtype($term['type'])); } } @@ -1240,39 +1240,41 @@ function decode_tags($t) { $ret = array(); foreach($t as $x) { $tag = array(); + if(array_key_exists('type',$x)) + $x['ttype'] = $x['type']; $tag['term'] = htmlspecialchars($x['tag'], ENT_COMPAT, 'UTF-8', false); $tag['url'] = htmlspecialchars($x['url'], ENT_COMPAT, 'UTF-8', false); - switch($x['type']) { + switch($x['ttype']) { case 'hashtag': - $tag['type'] = TERM_HASHTAG; + $tag['ttype'] = TERM_HASHTAG; break; case 'mention': - $tag['type'] = TERM_MENTION; + $tag['ttype'] = TERM_MENTION; break; case 'category': - $tag['type'] = TERM_CATEGORY; + $tag['ttype'] = TERM_CATEGORY; break; case 'private_category': - $tag['type'] = TERM_PCATEGORY; + $tag['ttype'] = TERM_PCATEGORY; break; case 'file': - $tag['type'] = TERM_FILE; + $tag['ttype'] = TERM_FILE; break; case 'search': - $tag['type'] = TERM_SEARCH; + $tag['ttype'] = TERM_SEARCH; break; case 'thing': - $tag['type'] = TERM_THING; + $tag['ttype'] = TERM_THING; break; case 'bookmark': - $tag['type'] = TERM_BOOKMARK; + $tag['ttype'] = TERM_BOOKMARK; break; case 'communitytag': - $tag['type'] = TERM_COMMUNITYTAG; + $tag['ttype'] = TERM_COMMUNITYTAG; break; default: case 'unknown': - $tag['type'] = TERM_UNKNOWN; + $tag['ttype'] = TERM_UNKNOWN; break; } $ret[] = $tag; @@ -1593,9 +1595,9 @@ function item_store($arr, $allow_exec = false, $deliver = true) { } } - if((x($arr,'object')) && is_array($arr['object'])) { - activity_sanitise($arr['object']); - $arr['object'] = json_encode($arr['object']); + if((x($arr,'obj')) && is_array($arr['obj'])) { + activity_sanitise($arr['obj']); + $arr['obj'] = json_encode($arr['obj']); } if((x($arr,'target')) && is_array($arr['target'])) { @@ -1626,7 +1628,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { $arr['thr_parent'] = ((x($arr,'thr_parent')) ? notags(trim($arr['thr_parent'])) : $arr['parent_mid']); $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ACTIVITY_POST); $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ACTIVITY_OBJ_NOTE); - $arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : ''); + $arr['obj'] = ((x($arr,'obj')) ? trim($arr['obj']) : ''); $arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : ''); $arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : ''); $arr['plink'] = ((x($arr,'plink')) ? notags(trim($arr['plink'])) : ''); @@ -1695,7 +1697,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { return $ret; } - if(($arr['obj_type'] == ACTIVITY_OBJ_NOTE) && (! $arr['object'])) + if(($arr['obj_type'] == ACTIVITY_OBJ_NOTE) && (! $arr['obj'])) $arr['obj_type'] = ACTIVITY_OBJ_COMMENT; // is the new message multi-level threaded? @@ -1855,12 +1857,12 @@ function item_store($arr, $allow_exec = false, $deliver = true) { if(($terms) && (is_array($terms))) { foreach($terms as $t) { - q("insert into term (uid,oid,otype,type,term,url) + q("insert into term (uid,oid,otype,ttype,term,url) values(%d,%d,%d,%d,'%s','%s') ", intval($arr['uid']), intval($current_post), intval(TERM_OBJ_POST), - intval($t['type']), + intval($t['ttype']), dbesc($t['term']), dbesc($t['url']) ); @@ -1989,9 +1991,9 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) { } } - if((x($arr,'object')) && is_array($arr['object'])) { - activity_sanitise($arr['object']); - $arr['object'] = json_encode($arr['object']); + if((x($arr,'obj')) && is_array($arr['obj'])) { + activity_sanitise($arr['obj']); + $arr['obj'] = json_encode($arr['obj']); } if((x($arr,'target')) && is_array($arr['target'])) { @@ -2033,7 +2035,7 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) { $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : $orig[0]['coord']); $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : $orig[0]['verb']); $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : $orig[0]['obj_type']); - $arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : $orig[0]['object']); + $arr['obj'] = ((x($arr,'obj')) ? trim($arr['obj']) : $orig[0]['obj']); $arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : $orig[0]['tgt_type']); $arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : $orig[0]['target']); $arr['plink'] = ((x($arr,'plink')) ? notags(trim($arr['plink'])) : $orig[0]['plink']); @@ -2134,12 +2136,12 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) { if(is_array($terms)) { foreach($terms as $t) { - q("insert into term (uid,oid,otype,type,term,url) + q("insert into term (uid,oid,otype,ttype,term,url) values(%d,%d,%d,%d,'%s','%s') ", intval($uid), intval($orig_post_id), intval(TERM_OBJ_POST), - intval($t['type']), + intval($t['ttype']), dbesc($t['term']), dbesc($t['url']) ); @@ -2367,10 +2369,10 @@ function tag_deliver($uid, $item_id) { if (stristr($item['verb'],ACTIVITY_POKE)) { $poke_notify = true; - if(($item['obj_type'] == "") || ($item['obj_type'] !== ACTIVITY_OBJ_PERSON) || (! $item['object'])) + if(($item['obj_type'] == "") || ($item['obj_type'] !== ACTIVITY_OBJ_PERSON) || (! $item['obj'])) $poke_notify = false; - $obj = json_decode_plus($item['object']); + $obj = json_decode_plus($item['obj']); if($obj) { if($obj['id'] !== $u[0]['channel_hash']) $poke_notify = false; @@ -2414,7 +2416,7 @@ function tag_deliver($uid, $item_id) { intval($u[0]['channel_id']) ); if($p) { - $j_obj = json_decode_plus($item['object']); + $j_obj = json_decode_plus($item['obj']); logger('tag_deliver: tag object: ' . print_r($j_obj,true), LOGGER_DATA); if($j_obj && $j_obj['id'] && $j_obj['title']) { if(is_array($j_obj['link'])) @@ -2720,7 +2722,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) { foreach($tags as $tt) { $tt = trim($tt); if($tt) { - q("insert into term (uid,oid,otype,type,term,url) + q("insert into term (uid,oid,otype,ttype,term,url) values(%d,%d,%d,%d,'%s','%s') ", intval($channel['channel_id']), intval($item_id), @@ -2863,7 +2865,7 @@ function check_item_source($uid, $item) { foreach($words as $word) { if(substr($word,0,1) === '#' && $tags) { foreach($tags as $t) - if((($t['type'] == TERM_HASHTAG) || ($t['type'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) + if((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) return true; } elseif((strpos($word,'/') === 0) && preg_match($word,$text)) @@ -2916,7 +2918,7 @@ function post_is_importable($item,$abook) { continue; if(substr($word,0,1) === '#' && $tags) { foreach($tags as $t) - if((($t['type'] == TERM_HASHTAG) || ($t['type'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) + if((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) return false; } elseif((strpos($word,'/') === 0) && preg_match($word,$text)) @@ -2937,7 +2939,7 @@ function post_is_importable($item,$abook) { continue; if(substr($word,0,1) === '#' && $tags) { foreach($tags as $t) - if((($t['type'] == TERM_HASHTAG) || ($t['type'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) + if((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) return true; } elseif((strpos($word,'/') === 0) && preg_match($word,$text)) @@ -3091,7 +3093,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) { if($x) { $res = substr($i,$x+1); $i = substr($i,0,$x); - $r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `scale` = %d AND `uid` = %d", + $r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `imgscale` = %d AND `uid` = %d", dbesc($i), intval($res), intval($uid) @@ -3214,7 +3216,7 @@ function item_getfeedtags($item) { if(count($terms)) { foreach($terms as $term) { - if(($term['type'] == TERM_HASHTAG) || ($term['type'] == TERM_COMMUNITYTAG)) + if(($term['ttype'] == TERM_HASHTAG) || ($term['ttype'] == TERM_COMMUNITYTAG)) $ret[] = array('#',$term['url'],$term['term']); else $ret[] = array('@',$term['url'],$term['term']); @@ -3685,7 +3687,7 @@ function fetch_post_tags($items,$link = false) { for($x = 0; $x < count($items); $x ++) { if($tags) { foreach($tags as $t) { - if(($link) && ($t['type'] == TERM_MENTION)) + if(($link) && ($t['ttype'] == TERM_MENTION)) $t['url'] = chanlink_url($t['url']); if(array_key_exists('item_id',$items[$x])) { if($t['oid'] == $items[$x]['item_id']) { @@ -3895,8 +3897,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C } $contact_str = ''; - /** @FIXME $group is undefined */ - $contacts = group_get_members($group); + + $contacts = group_get_members($r[0]['id']); if ($contacts) { foreach($contacts as $c) { if($contact_str) @@ -3913,7 +3915,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent $item_normal ) "; $x = group_rec_byhash($uid,$r[0]['hash']); - $result['headline'] = sprintf( t('Privacy group: %s'),$x['name']); + $result['headline'] = sprintf( t('Privacy group: %s'),$x['gname']); } elseif($arr['cid'] && $uid) { @@ -4261,7 +4263,7 @@ function send_profile_photo_activity($channel,$photo,$profile) { $arr['obj_type'] = ACTIVITY_OBJ_PHOTO; $arr['verb'] = ACTIVITY_UPDATE; - $arr['object'] = json_encode(array( + $arr['obj'] = json_encode(array( 'type' => $arr['obj_type'], 'id' => z_root() . '/photo/profile/l/' . $channel['channel_id'], 'link' => array('rel' => 'photo', 'type' => $photo['type'], 'href' => z_root() . '/photo/profile/l/' . $channel['channel_id']) diff --git a/include/language.php b/include/language.php index 238c23028..96d3e48a9 100644 --- a/include/language.php +++ b/include/language.php @@ -132,10 +132,10 @@ function load_translation_table($lang, $install = false) { } if(! $install) { - $plugins = q("SELECT name FROM addon WHERE installed=1;"); + $plugins = q("SELECT aname FROM addon WHERE installed=1;"); if ($plugins !== false) { foreach($plugins as $p) { - $name = $p['name']; + $name = $p['aname']; if(file_exists("addon/$name/lang/$lang/hstrings.php")) { include("addon/$name/lang/$lang/hstrings.php"); } diff --git a/include/network.php b/include/network.php index dd266f5d1..0dd10e29b 100644 --- a/include/network.php +++ b/include/network.php @@ -1967,7 +1967,7 @@ function get_site_info() { $r = q("select * from addon where hidden = 0"); if(count($r)) foreach($r as $rr) - $visible_plugins[] = $rr['name']; + $visible_plugins[] = $rr['aname']; } sort($visible_plugins); diff --git a/include/oauth.php b/include/oauth.php index ec41a5dd2..984e0e6c6 100644 --- a/include/oauth.php +++ b/include/oauth.php @@ -37,7 +37,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore { logger(__function__.":".$consumer.", ". $token_type.", ".$token, LOGGER_DEBUG); - $r = q("SELECT id, secret, scope, expires, uid FROM tokens WHERE client_id = '%s' AND scope = '%s' AND id = '%s'", + $r = q("SELECT id, secret, auth_scope, expires, uid FROM tokens WHERE client_id = '%s' AND auth_scope = '%s' AND id = '%s'", dbesc($consumer->key), dbesc($token_type), dbesc($token) @@ -45,7 +45,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore { if (count($r)){ $ot=new OAuth1Token($r[0]['id'],$r[0]['secret']); - $ot->scope=$r[0]['scope']; + $ot->scope=$r[0]['auth_scope']; $ot->expires = $r[0]['expires']; $ot->uid = $r[0]['uid']; return $ot; @@ -79,7 +79,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore { $k = $consumer; } - $r = q("INSERT INTO tokens (id, secret, client_id, scope, expires) VALUES ('%s','%s','%s','%s', %d)", + $r = q("INSERT INTO tokens (id, secret, client_id, auth_scope, expires) VALUES ('%s','%s','%s','%s', %d)", dbesc($key), dbesc($sec), dbesc($k), @@ -110,7 +110,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore { $key = $this->gen_token(); $sec = $this->gen_token(); - $r = q("INSERT INTO tokens (id, secret, client_id, scope, expires, uid) VALUES ('%s','%s','%s','%s', %d, %d)", + $r = q("INSERT INTO tokens (id, secret, client_id, auth_scope, expires, uid) VALUES ('%s','%s','%s','%s', %d, %d)", dbesc($key), dbesc($sec), dbesc($consumer->key), @@ -249,7 +249,7 @@ class FKOAuth2 extends OAuth2 { protected function getAuthCode($code) { - $r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'", + $r = q("SELECT id, client_id, redirect_uri, expires, auth_scope FROM auth_codes WHERE id = '%s'", dbesc($code)); if (count($r)) @@ -259,7 +259,7 @@ class FKOAuth2 extends OAuth2 { protected function setAuthCode($code, $client_id, $redirect_uri, $expires, $scope = NULL) { $r = q("INSERT INTO auth_codes - (id, client_id, redirect_uri, expires, scope) VALUES + (id, client_id, redirect_uri, expires, auth_scope) VALUES ('%s', '%s', '%s', %d, '%s')", dbesc($code), dbesc($client_id), diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index e57a9165a..6de75d497 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -316,7 +316,7 @@ abstract class photo_driver { $p['resource_id'] = (($arr['resource_id']) ? $arr['resource_id'] : ''); $p['filename'] = (($arr['filename']) ? $arr['filename'] : ''); $p['album'] = (($arr['album']) ? $arr['album'] : ''); - $p['scale'] = ((intval($arr['scale'])) ? intval($arr['scale']) : 0); + $p['imgscale'] = ((intval($arr['imgscale'])) ? intval($arr['imgscale']) : 0); $p['allow_cid'] = (($arr['allow_cid']) ? $arr['allow_cid'] : ''); $p['allow_gid'] = (($arr['allow_gid']) ? $arr['allow_gid'] : ''); $p['deny_cid'] = (($arr['deny_cid']) ? $arr['deny_cid'] : ''); @@ -329,14 +329,14 @@ abstract class photo_driver { $p['os_storage'] = intval($arr['os_storage']); $p['os_path'] = $arr['os_path']; - if(! intval($p['scale'])) - logger('save: ' . print_r($arr,true)); + if(! intval($p['imgscale'])) + logger('save: ' . print_r($arr,true), LOGGER_DATA); - $x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and `scale` = %d limit 1", + $x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and imgscale = %d limit 1", dbesc($p['resource_id']), intval($p['uid']), dbesc($p['xchan']), - intval($p['scale']) + intval($p['imgscale']) ); if($x) { $r = q("UPDATE `photo` set @@ -347,14 +347,14 @@ abstract class photo_driver { `created` = '%s', `edited` = '%s', `filename` = '%s', - `type` = '%s', + `mimetype` = '%s', `album` = '%s', `height` = %d, `width` = %d, - `data` = '%s', + `content` = '%s', `os_storage` = %d, - `size` = %d, - `scale` = %d, + `filesize` = %d, + `imgscale` = %d, `photo_usage` = %d, `title` = '%s', `description` = '%s', @@ -378,7 +378,7 @@ abstract class photo_driver { (intval($p['os_storage']) ? dbesc($p['os_path']) : dbescbin($this->imageString())), intval($p['os_storage']), intval(strlen($this->imageString())), - intval($p['scale']), + intval($p['imgscale']), intval($p['photo_usage']), dbesc($p['title']), dbesc($p['description']), @@ -391,7 +391,7 @@ abstract class photo_driver { } else { $r = q("INSERT INTO `photo` - ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `os_storage`, `size`, `scale`, `photo_usage`, `title`, `description`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` ) + ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, mimetype, `album`, `height`, `width`, `content`, `os_storage`, `filesize`, `imgscale`, `photo_usage`, `title`, `description`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` ) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s' )", intval($p['aid']), intval($p['uid']), @@ -407,7 +407,7 @@ abstract class photo_driver { (intval($p['os_storage']) ? dbesc($p['os_path']) : dbescbin($this->imageString())), intval($p['os_storage']), intval(strlen($this->imageString())), - intval($p['scale']), + intval($p['imgscale']), intval($p['photo_usage']), dbesc($p['title']), dbesc($p['description']), @@ -422,7 +422,7 @@ abstract class photo_driver { public function store($aid, $uid, $xchan, $rid, $filename, $album, $scale, $usage = PHOTO_NORMAL, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') { - $x = q("select id from photo where `resource_id` = '%s' and uid = %d and `xchan` = '%s' and `scale` = %d limit 1", + $x = q("select id from photo where `resource_id` = '%s' and uid = %d and `xchan` = '%s' and `imgscale` = %d limit 1", dbesc($rid), intval($uid), dbesc($xchan), @@ -437,13 +437,13 @@ abstract class photo_driver { `created` = '%s', `edited` = '%s', `filename` = '%s', - `type` = '%s', + `mimetype` = '%s', `album` = '%s', `height` = %d, `width` = %d, - `data` = '%s', - `size` = %d, - `scale` = %d, + `content` = '%s', + `filesize` = %d, + `imgscale` = %d, `photo_usage` = %d, `allow_cid` = '%s', `allow_gid` = '%s', @@ -475,7 +475,7 @@ abstract class photo_driver { } else { $r = q("INSERT INTO `photo` - ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `size`, `scale`, `photo_usage`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` ) + ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, mimetype, `album`, `height`, `width`, `content`, `filesize`, `imgscale`, `photo_usage`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` ) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s' )", intval($aid), intval($uid), @@ -588,7 +588,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) { if($thing) $hash = photo_new_resource(); else { - $r = q("select resource_id from photo where xchan = '%s' and photo_usage = %d and scale = 4 limit 1", + $r = q("select resource_id from photo where xchan = '%s' and photo_usage = %d and imgscale = 4 limit 1", dbesc($xchan), intval(PHOTO_XCHAN) ); @@ -654,7 +654,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) { else $photo_failure = true; - $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_usage' => $flags, 'scale' => 4); + $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_usage' => $flags, 'imgscale' => 4); $r = $img->save($p); @@ -662,7 +662,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) { $photo_failure = true; $img->scaleImage(80); - $p['scale'] = 5; + $p['imgscale'] = 5; $r = $img->save($p); @@ -670,7 +670,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) { $photo_failure = true; $img->scaleImage(48); - $p['scale'] = 6; + $p['imgscale'] = 6; $r = $img->save($p); @@ -715,7 +715,7 @@ function import_channel_photo($photo,$type,$aid,$uid) { $img->scaleImageSquare(300); - $p = array('aid' => $aid, 'uid' => $uid, 'resource_id' => $hash, 'filename' => $filename, 'album' => t('Profile Photos'), 'photo_usage' => PHOTO_PROFILE, 'scale' => 4); + $p = array('aid' => $aid, 'uid' => $uid, 'resource_id' => $hash, 'filename' => $filename, 'album' => t('Profile Photos'), 'photo_usage' => PHOTO_PROFILE, 'imgscale' => 4); $r = $img->save($p); @@ -723,7 +723,7 @@ function import_channel_photo($photo,$type,$aid,$uid) { $photo_failure = true; $img->scaleImage(80); - $p['scale'] = 5; + $p['imgscale'] = 5; $r = $img->save($p); @@ -731,7 +731,7 @@ function import_channel_photo($photo,$type,$aid,$uid) { $photo_failure = true; $img->scaleImage(48); - $p['scale'] = 6; + $p['imgscale'] = 6; $r = $img->save($p); diff --git a/include/photos.php b/include/photos.php index c333a4d04..1cc64f6fa 100644 --- a/include/photos.php +++ b/include/photos.php @@ -71,17 +71,17 @@ function photo_upload($channel, $observer, $args) { $type = $args['getimagesize']['mime']; $os_storage = 1; } - elseif ($args['data']) { + elseif ($args['data'] || $args['content']) { // allow an import from a binary string representing the image. // This bypasses the upload step and max size limit checking - $imagedata = $args['data']; + $imagedata = (($args['content']) ? $args['content'] : $args['data']); $filename = $args['filename']; $filesize = strlen($imagedata); // this is going to be deleted if it exists $src = '/tmp/deletemenow'; - $type = $args['type']; + $type = (($args['mimetype']) ? $args['mimetype'] : $args['type']); } else { $f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''); @@ -125,7 +125,7 @@ function photo_upload($channel, $observer, $args) { $imagedata = @file_get_contents($src); } - $r = q("select sum(size) as total from photo where aid = %d and scale = 0 ", + $r = q("select sum(filesize) as total from photo where aid = %d and imgscale = 0 ", intval($account_id) ); @@ -172,7 +172,7 @@ function photo_upload($channel, $observer, $args) { $errors = false; $p = array('aid' => $account_id, 'uid' => $channel_id, 'xchan' => $visitor, 'resource_id' => $photo_hash, - 'filename' => $filename, 'album' => $album, 'scale' => 0, 'photo_usage' => PHOTO_NORMAL, + 'filename' => $filename, 'album' => $album, 'imgscale' => 0, 'photo_usage' => PHOTO_NORMAL, 'allow_cid' => $ac['allow_cid'], 'allow_gid' => $ac['allow_gid'], 'deny_cid' => $ac['deny_cid'], 'deny_gid' => $ac['deny_gid'], 'os_storage' => $os_storage, 'os_path' => $args['os_path'] @@ -205,7 +205,7 @@ function photo_upload($channel, $observer, $args) { if(($width > 1024 || $height > 1024) && (! $errors)) $ph->scaleImage(1024); - $p['scale'] = 1; + $p['imgscale'] = 1; $r1 = $ph->save($p); $link[1] = array( 'rel' => 'alternate', @@ -220,7 +220,7 @@ function photo_upload($channel, $observer, $args) { if(($width > 640 || $height > 640) && (! $errors)) $ph->scaleImage(640); - $p['scale'] = 2; + $p['imgscale'] = 2; $r2 = $ph->save($p); $link[2] = array( 'rel' => 'alternate', @@ -235,7 +235,7 @@ function photo_upload($channel, $observer, $args) { if(($width > 320 || $height > 320) && (! $errors)) $ph->scaleImage(320); - $p['scale'] = 3; + $p['imgscale'] = 3; $r3 = $ph->save($p); $link[3] = array( 'rel' => 'alternate', @@ -332,7 +332,7 @@ function photo_upload($channel, $observer, $args) { $item['body'] = $args['body']; $item['obj_type'] = ACTIVITY_OBJ_PHOTO; - $item['object'] = json_encode($object); + $item['obj'] = json_encode($object); $item['tgt_type'] = ACTIVITY_OBJ_ALBUM; $item['target'] = json_encode($target); @@ -389,8 +389,8 @@ function photo_upload($channel, $observer, $args) { $arr['deny_cid'] = $ac['deny_cid']; $arr['deny_gid'] = $ac['deny_gid']; $arr['verb'] = ACTIVITY_POST; - $arr['obj_type'] = ACTIVITY_OBJ_PHOTO; - $arr['object'] = json_encode($object); + $arr['obj_type'] = ACTIVITY_OBJ_PHOTO; + $arr['obj'] = json_encode($object); $arr['tgt_type'] = ACTIVITY_OBJ_ALBUM; $arr['target'] = json_encode($target); $arr['item_wall'] = 1; @@ -535,7 +535,7 @@ function photos_list_photos($channel, $observer, $album = '') { $ret = array('success' => false); - $r = q("select resource_id, created, edited, title, description, album, filename, type, height, width, size, scale, photo_usage, allow_cid, allow_gid, deny_cid, deny_gid from photo where uid = %d and photo_usage in ( %d, %d ) $sql_extra ", + $r = q("select resource_id, created, edited, title, description, album, filename, mimetype, height, width, filesize, imgscale, photo_usage, allow_cid, allow_gid, deny_cid, deny_gid from photo where uid = %d and photo_usage in ( %d, %d ) $sql_extra ", intval($channel_id), intval(PHOTO_NORMAL), intval(PHOTO_PROFILE) @@ -543,7 +543,7 @@ function photos_list_photos($channel, $observer, $album = '') { if($r) { for($x = 0; $x < count($r); $x ++) { - $r[$x]['src'] = z_root() . '/photo/' . $r[$x]['resource_id'] . '-' . $r[$x]['scale']; + $r[$x]['src'] = z_root() . '/photo/' . $r[$x]['resource_id'] . '-' . $r[$x]['imgscale']; } $ret['success'] = true; $ret['photos'] = $r; @@ -661,7 +661,7 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid']; $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' - . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]' + . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['imgscale'] . '[/zmg]' . '[/zrl]'; $result = item_store($arr); diff --git a/include/plugin.php b/include/plugin.php index 6c108fcc5..be4e92f03 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -41,7 +41,7 @@ function uninstall_plugin($plugin) { $func(); } - q("DELETE FROM `addon` WHERE `name` = '%s' ", + q("DELETE FROM `addon` WHERE `aname` = '%s' ", dbesc($plugin) ); } @@ -66,7 +66,7 @@ function install_plugin($plugin) { $plugin_admin = (function_exists($plugin . '_plugin_admin') ? 1 : 0); - q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ", + q("INSERT INTO `addon` (`aname`, `installed`, `tstamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ", dbesc($plugin), intval($t), $plugin_admin @@ -111,7 +111,7 @@ function load_plugin($plugin) { } function plugin_is_installed($name) { - $r = q("select name from addon where name = '%s' and installed = 1 limit 1", + $r = q("select aname from addon where aname = '%s' and installed = 1 limit 1", dbesc($name) ); if($r) @@ -143,8 +143,8 @@ function reload_plugins() { if(file_exists($fname)) { $t = @filemtime($fname); foreach($installed as $i) { - if(($i['name'] == $pl) && ($i['timestamp'] != $t)) { - logger('Reloading plugin: ' . $i['name']); + if(($i['aname'] == $pl) && ($i['tstamp'] != $t)) { + logger('Reloading plugin: ' . $i['aname']); @include_once($fname); if(function_exists($pl . '_unload')) { @@ -155,7 +155,7 @@ function reload_plugins() { $func = $pl . '_load'; $func(); } - q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d", + q("UPDATE `addon` SET `tstamp` = %d WHERE `id` = %d", intval($t), intval($i['id']) ); @@ -178,7 +178,7 @@ function reload_plugins() { * @return mixed|bool */ function register_hook($hook, $file, $function, $priority = 0) { - $r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1", + $r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `fn` = '%s' LIMIT 1", dbesc($hook), dbesc($file), dbesc($function) @@ -186,7 +186,7 @@ function register_hook($hook, $file, $function, $priority = 0) { if($r) return true; - $r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' )", + $r = q("INSERT INTO `hook` (`hook`, `file`, `fn`, `priority`) VALUES ( '%s', '%s', '%s', '%s' )", dbesc($hook), dbesc($file), dbesc($function), @@ -206,7 +206,7 @@ function register_hook($hook, $file, $function, $priority = 0) { * @return array */ function unregister_hook($hook, $file, $function) { - $r = q("DELETE FROM hook WHERE hook = '%s' AND `file` = '%s' AND `function` = '%s'", + $r = q("DELETE FROM hook WHERE hook = '%s' AND `file` = '%s' AND `fn` = '%s'", dbesc($hook), dbesc($file), dbesc($function) @@ -233,7 +233,7 @@ function load_hooks() { if(! array_key_exists($rr['hook'],App::$hooks)) App::$hooks[$rr['hook']] = array(); - App::$hooks[$rr['hook']][] = array($rr['file'],$rr['function'],$rr['priority'],$rr['hook_version']); + App::$hooks[$rr['hook']][] = array($rr['file'],$rr['fn'],$rr['priority'],$rr['hook_version']); } } //logger('hooks: ' . print_r(App::$hooks,true)); @@ -300,12 +300,18 @@ function call_hooks($name, &$data = null) { $func($data); else $func($a, $data); - } else { - q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND function = '%s'", - dbesc($name), - dbesc($hook[0]), - dbesc($origfn) - ); + } + else { + + // Don't do any DB write calls if we're currently logging a possibly failed DB call. + if(! DBA::$logging) { + // The hook should be removed so we don't process it. + q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND fn = '%s'", + dbesc($name), + dbesc($hook[0]), + dbesc($origfn) + ); + } } } } diff --git a/include/sharedwithme.php b/include/sharedwithme.php index b01764ad3..b342f51d5 100644 --- a/include/sharedwithme.php +++ b/include/sharedwithme.php @@ -3,7 +3,7 @@ function apply_updates() { //check for updated items and remove them - $x = q("SELECT mid, max(object) AS object FROM item WHERE verb = '%s' AND obj_type = '%s' GROUP BY mid", + $x = q("SELECT mid, max(obj) AS obj FROM item WHERE verb = '%s' AND obj_type = '%s' GROUP BY mid", dbesc(ACTIVITY_UPDATE), dbesc(ACTIVITY_OBJ_FILE) ); @@ -12,7 +12,7 @@ function apply_updates() { foreach($x as $xx) { - $object = json_decode($xx['object'],true); + $object = json_decode($xx['obj'],true); $d_mid = $object['d_mid']; $u_mid = $xx['mid']; diff --git a/include/taxonomy.php b/include/taxonomy.php index e43f5e5d0..177215fe8 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -20,7 +20,7 @@ function file_tag_file_query($table,$s,$type = 'file') { else $termtype = TERM_CATEGORY; - return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", + return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.ttype = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", intval($termtype), protect_sprintf(dbesc($s)) ); @@ -29,14 +29,14 @@ function file_tag_file_query($table,$s,$type = 'file') { function term_query($table,$s,$type = TERM_UNKNOWN, $type2 = '') { if($type2) { - return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type in (%d, %d) and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", + return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.ttype in (%d, %d) and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", intval($type), intval($type2), protect_sprintf(dbesc($s)) ); } else { - return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", + return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.ttype = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", intval($type), protect_sprintf(dbesc($s)) ); @@ -49,7 +49,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') { return false; $r = q("select * from term - where uid = %d and oid = %d and otype = %d and type = %d + where uid = %d and oid = %d and otype = %d and ttype = %d and term = '%s' and url = '%s' ", intval($uid), intval($iid), @@ -61,7 +61,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') { if($r) return false; - $r = q("insert into term (uid, oid, otype, type, term, url) + $r = q("insert into term (uid, oid, otype, ttype, term, url) values( %d, %d, %d, %d, '%s', '%s') ", intval($uid), intval($iid), @@ -85,7 +85,7 @@ function get_terms_oftype($arr,$type) { foreach($type as $t) foreach($arr as $x) - if($x['type'] == $t) + if($x['ttype'] == $t) $ret[] = $x; return $ret; @@ -93,9 +93,9 @@ function get_terms_oftype($arr,$type) { function format_term_for_display($term) { $s = ''; - if(($term['type'] == TERM_HASHTAG) || ($term['type'] == TERM_COMMUNITYTAG)) + if(($term['ttype'] == TERM_HASHTAG) || ($term['ttype'] == TERM_COMMUNITYTAG)) $s .= '#'; - elseif($term['type'] == TERM_MENTION) + elseif($term['ttype'] == TERM_MENTION) $s .= '@'; else return $s; @@ -142,7 +142,7 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re // Fetch tags $r = q("select term, count(term) as total from term left join item on term.oid = item.id - where term.uid = %d and term.type = %d + where term.uid = %d and term.ttype = %d and otype = %d and item_type = %d and item_private = 0 $sql_options $item_normal group by term order by total desc %s", diff --git a/include/text.php b/include/text.php index 375a89d3f..834eec920 100644 --- a/include/text.php +++ b/include/text.php @@ -734,6 +734,10 @@ function get_tags($s) { // '=' needs to be avoided because when the replacement is made (in handle_tag()) it has to be ignored there // Feel free to allow '=' if the issue with '=' is solved in handle_tag() // added / ? and [ to avoid issues with hashchars in url paths + + // added ; to single word tags to allow emojis and other unicode character constructs in bbcode + // (this would actually be &#xnnnnn; but the ampersand will have been escaped to & by the time we see it.) + if(preg_match_all('/(?<![a-zA-Z0-9=\/\?])(@[^ \x0D\x0A,:?\[]+ [^ \x0D\x0A@,:?\[]+)/',$s,$match)) { foreach($match[1] as $mtch) { if(substr($mtch,-1,1) === '.') @@ -746,7 +750,7 @@ function get_tags($s) { // Otherwise pull out single word tags. These can be @nickname, @first_last // and #hash tags. - if(preg_match_all('/(?<![a-zA-Z0-9=\/\?])([@#][^ \x0D\x0A,;:?\[]+)/',$s,$match)) { + if(preg_match_all('/(?<![a-zA-Z0-9=\/\?\;])([@#][^ \x0D\x0A,;:?\[]+)/',$s,$match)) { foreach($match[1] as $mtch) { if(substr($mtch,-1,1) === '.') $mtch = substr($mtch,0,-1); @@ -810,7 +814,7 @@ function get_mentions($item,$tags) { return $o; foreach($tags as $x) { - if($x['type'] == TERM_MENTION) { + if($x['ttype'] == TERM_MENTION) { $o .= "\t\t" . '<link rel="mentioned" href="' . $x['url'] . '" />' . "\r\n"; $o .= "\t\t" . '<link rel="ostatus:attention" href="' . $x['url'] . '" />' . "\r\n"; } @@ -1458,37 +1462,6 @@ function generate_named_map($location) { return (($arr['html']) ? $arr['html'] : $location); } -function format_event($jobject) { - $event = array(); - - $object = json_decode($jobject,true); - - //ensure compatibility with older items - this check can be removed at a later point - if(array_key_exists('description', $object)) { - - $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM - - $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( - '$title' => bbcode($object['title']), - '$dtstart_label' => t('Starts:'), - '$dtstart_title' => datetime_convert('UTC', 'UTC', $object['start'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['start'] , $bd_format))), - '$finish' => (($object['nofinish']) ? false : true), - '$dtend_label' => t('Finishes:'), - '$dtend_title' => datetime_convert('UTC','UTC',$object['finish'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['finish'] , $bd_format ))) - )); - - $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( - '$description' => bbcode($object['description']), - '$location_label' => t('Location:'), - '$location' => bbcode($object['location']) - )); - - } - - return $event; -} function prepare_body(&$item,$attach = false) { @@ -1516,7 +1489,7 @@ function prepare_body(&$item,$attach = false) { $s .= prepare_text($item['body'],$item['mimetype'], false); - $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event($item['object']) : false); + $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false); $prep_arr = array( 'item' => $item, diff --git a/include/widgets.php b/include/widgets.php index d9dac1afa..b5c3b425a 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -212,13 +212,13 @@ function widget_savedsearch($arr) { $search = ((x($_GET,'search')) ? $_GET['search'] : ''); if(x($_GET,'searchsave') && $search) { - $r = q("select * from `term` where `uid` = %d and `type` = %d and `term` = '%s' limit 1", + $r = q("select * from `term` where `uid` = %d and `ttype` = %d and `term` = '%s' limit 1", intval(local_channel()), intval(TERM_SAVEDSEARCH), dbesc($search) ); if(! $r) { - q("insert into `term` ( `uid`,`type`,`term` ) values ( %d, %d, '%s') ", + q("insert into `term` ( `uid`,`ttype`,`term` ) values ( %d, %d, '%s') ", intval(local_channel()), intval(TERM_SAVEDSEARCH), dbesc($search) @@ -227,7 +227,7 @@ function widget_savedsearch($arr) { } if(x($_GET,'searchremove') && $search) { - q("delete from `term` where `uid` = %d and `type` = %d and `term` = '%s'", + q("delete from `term` where `uid` = %d and `ttype` = %d and `term` = '%s'", intval(local_channel()), intval(TERM_SAVEDSEARCH), dbesc($search) @@ -254,7 +254,7 @@ function widget_savedsearch($arr) { $o = ''; - $r = q("select `tid`,`term` from `term` WHERE `uid` = %d and `type` = %d ", + $r = q("select `tid`,`term` from `term` WHERE `uid` = %d and `ttype` = %d ", intval(local_channel()), intval(TERM_SAVEDSEARCH) ); @@ -296,7 +296,7 @@ function widget_filer($arr) { $selected = ((x($_REQUEST,'file')) ? $_REQUEST['file'] : ''); $terms = array(); - $r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", + $r = q("select distinct(term) from term where uid = %d and ttype = %d order by term asc", intval(local_channel()), intval(TERM_FILE) ); @@ -1197,7 +1197,7 @@ function widget_photo_rand($arr) { $filtered = array(); if($ret['success'] && $ret['photos']) foreach($ret['photos'] as $p) - if($p['scale'] == $scale) + if($p['imgscale'] == $scale) $filtered[] = $p['src']; if($filtered) { @@ -1468,7 +1468,7 @@ function widget_admin($arr) { $plugins = array(); if($r) { foreach ($r as $h){ - $plugin = $h['name']; + $plugin = $h['aname']; $plugins[] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin'); // temp plugins with admin App::$plugins_admin[] = $plugin; @@ -1530,9 +1530,9 @@ function widget_album($args) { $order = 'DESC'; - $r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.scale, p.description, p.created FROM photo p INNER JOIN - (SELECT resource_id, max(scale) scale FROM photo WHERE uid = %d AND album = '%s' AND scale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph - ON (p.resource_id = ph.resource_id AND p.scale = ph.scale) + $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.imgscale, p.description, p.created FROM photo p INNER JOIN + (SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph + ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale) ORDER BY created $order ", intval($owner_uid), dbesc($album), @@ -1553,7 +1553,7 @@ function widget_album($args) { else $twist = 'rotright'; - $ext = $phototypes[$rr['type']]; + $ext = $phototypes[$rr['mimetype']]; $imgalt_e = $rr['filename']; $desc_e = $rr['description']; @@ -1566,7 +1566,7 @@ function widget_album($args) { 'twist' => ' ' . $twist . rand(2,4), 'link' => $imagelink, 'title' => t('View Photo'), - 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext, + 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['imgscale'] . '.' .$ext, 'alt' => $imgalt_e, 'desc'=> $desc_e, 'ext' => $ext, diff --git a/include/zot.php b/include/zot.php index ecfbfa128..af79b5723 100644 --- a/include/zot.php +++ b/include/zot.php @@ -352,8 +352,6 @@ function zot_refresh($them, $channel = null, $force = false) { } - $token = random_string(); - $rhs = '/.well-known/zot-info'; $result = z_post_url($url . $rhs,$postvars); @@ -1048,8 +1046,9 @@ function zot_process_response($hub, $arr, $outq) { /** * @brief * - * We received a notification packet (in mod/post.php) that a message is waiting for us, and we've verified the sender. - * Now send back a pickup message, using our message tracking ID ($arr['secret']), which we will sign with our site private key. + * We received a notification packet (in mod_post) that a message is waiting for us, and we've verified the sender. + * Now send back a pickup message, using our message tracking ID ($arr['secret']), which we will sign with our site + * private key. * The entire pickup message is encrypted with the remote site's public key. * If everything checks out on the remote end, we will receive back a packet containing one or more messages, * which will be processed and delivered before this function ultimately returns. @@ -1123,6 +1122,7 @@ function zot_fetch($arr) { * * [1] => \e string $delivery_status * * [2] => \e string $address */ + function zot_import($arr, $sender_url) { $data = json_decode($arr['body'], true); @@ -1953,7 +1953,7 @@ function remove_community_tag($sender, $arr, $uid) { return; } - q("delete from term where uid = %d and oid = %d and otype = %d and type in ( %d, %d ) and term = '%s' and url = '%s'", + q("delete from term where uid = %d and oid = %d and otype = %d and ttype in ( %d, %d ) and term = '%s' and url = '%s'", intval($uid), intval($r[0]['id']), intval(TERM_OBJ_POST), @@ -2402,11 +2402,14 @@ function sync_locations($sender, $arr, $absolute = false) { $current_site = false; + $t = datetime_convert('UTC','UTC','now - 15 minutes'); + if(array_key_exists('site',$arr) && $location['url'] == $arr['site']['url']) { - q("update hubloc set hubloc_connected = '%s', hubloc_updated = '%s' where hubloc_id = %d", + q("update hubloc set hubloc_connected = '%s', hubloc_updated = '%s' where hubloc_id = %d and hubloc_connected < '%s'", dbesc(datetime_convert()), dbesc(datetime_convert()), - intval($r[0]['hubloc_id']) + intval($r[0]['hubloc_id']), + dbesc($t) ); $current_site = true; } @@ -3048,7 +3051,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { } if($groups_changed) { - $r = q("select hash as collection, visible, deleted, name from groups where uid = %d", + $r = q("select hash as collection, visible, deleted, gname as name from groups where uid = %d", intval($uid) ); if($r) @@ -3341,10 +3344,10 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { } } if($found) { - if(($y['name'] != $cl['name']) + if(($y['gname'] != $cl['name']) || ($y['visible'] != $cl['visible']) || ($y['deleted'] != $cl['deleted'])) { - q("update groups set name = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d", + q("update groups set gname = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d", dbesc($cl['name']), intval($cl['visible']), intval($cl['deleted']), @@ -3360,7 +3363,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { } } if(! $found) { - $r = q("INSERT INTO `groups` ( hash, uid, visible, deleted, name ) + $r = q("INSERT INTO `groups` ( hash, uid, visible, deleted, gname ) VALUES( '%s', %d, %d, %d, '%s' ) ", dbesc($cl['collection']), intval($channel['channel_id']), @@ -3467,7 +3470,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('profile',$arr) && is_array($arr['profile']) && count($arr['profile'])) { - $disallowed = array('id','aid','uid'); + $disallowed = array('id','aid','uid','guid'); foreach($arr['profile'] as $profile) { $x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1", @@ -3491,13 +3494,22 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { foreach($profile as $k => $v) { if(in_array($k,$disallowed)) continue; + + if($k === 'name') + $clean['fullname'] = $v; + elseif($k === 'with') + $clean['partner'] = $v; + elseif($k === 'work') + $clean['employment'] = $v; + elseif(array_key_exists($k,$x[0])) + $clean[$k] = $v; - $clean[$k] = $v; /** - * @TODO check if these are allowed, otherwise we'll error + * @TODO * We also need to import local photos if a custom photo is selected */ } + if(count($clean)) { foreach($clean as $k => $v) { $r = dbq("UPDATE profile set `" . dbesc($k) . "` = '" . dbesc($v) @@ -4125,7 +4137,7 @@ function update_hub_connected($hub,$sitekey = '') { $sitekey = $hub['sitekey']; } - // $sender['sitekey'] is a new addition to the protcol to distinguish + // $sender['sitekey'] is a new addition to the protocol to distinguish // hublocs coming from re-installed sites. Older sites will not provide // this field and we have to still mark them valid, since we can't tell // if this hubloc has the same sitekey as the packet we received. @@ -4134,10 +4146,13 @@ function update_hub_connected($hub,$sitekey = '') { // Update our DB to show when we last communicated successfully with this hub // This will allow us to prune dead hubs from using up resources - $r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d and hubloc_sitekey = '%s' ", + $t = datetime_convert('UTC','UTC','now - 15 minutes'); + + $r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d and hubloc_sitekey = '%s' and hubloc_connected < '%s' ", dbesc(datetime_convert()), intval($hub['hubloc_id']), - dbesc($sitekey) + dbesc($sitekey), + dbesc($t) ); // a dead hub came back to life - reset any tombstones we might have |