diff options
Diffstat (limited to 'Zotlabs/Module')
94 files changed, 1313 insertions, 981 deletions
diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index 5c14ab599..2bc4ba62d 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -53,30 +53,32 @@ class Acl extends \Zotlabs\Web\Controller { if ($type=='' || $type=='g'){ - $r = q("SELECT `groups`.`id`, `groups`.`hash`, `groups`.`name` + $r = q("SELECT `groups`.`id`, `groups`.`hash`, `groups`.`gname` FROM `groups`,`group_member` WHERE `groups`.`deleted` = 0 AND `groups`.`uid` = %d AND `group_member`.`gid`=`groups`.`id` $sql_extra GROUP BY `groups`.`id` - ORDER BY `groups`.`name` + ORDER BY `groups`.`gname` LIMIT %d OFFSET %d", intval(local_channel()), intval($count), intval($start) ); - - foreach($r as $g){ - // logger('acl: group: ' . $g['name'] . ' members: ' . group_get_members_xchan($g['id'])); - $groups[] = array( - "type" => "g", - "photo" => "images/twopeople.png", - "name" => $g['name'], - "id" => $g['id'], - "xid" => $g['hash'], - "uids" => group_get_members_xchan($g['id']), - "link" => '' - ); + + if($r) { + foreach($r as $g){ + // logger('acl: group: ' . $g['gname'] . ' members: ' . group_get_members_xchan($g['id'])); + $groups[] = array( + "type" => "g", + "photo" => "images/twopeople.png", + "name" => $g['gname'], + "id" => $g['id'], + "xid" => $g['hash'], + "uids" => group_get_members_xchan($g['id']), + "link" => '' + ); + } } } @@ -204,7 +206,7 @@ class Acl extends \Zotlabs\Web\Controller { else $r = array(); - if(count($r)) { + if($r) { foreach($r as $g){ // remove RSS feeds from ACLs - they are inaccessible @@ -260,7 +262,7 @@ class Acl extends \Zotlabs\Web\Controller { // logger('navbar_complete'); - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { return; } diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index e2e6146f8..085d13fd7 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -32,8 +32,8 @@ class Admin extends \Zotlabs\Web\Controller { case 'site': $this->admin_page_site_post($a); break; - case 'users': - $this->admin_page_users_post($a); + case 'accounts': + $this->admin_page_accounts_post($a); break; case 'channels': $this->admin_page_channels_post($a); @@ -127,8 +127,8 @@ class Admin extends \Zotlabs\Web\Controller { case 'site': $o = $this->admin_page_site($a); break; - case 'users': - $o = $this->admin_page_users($a); + case 'accounts': + $o = $this->admin_page_accounts($a); break; case 'channels': $o = $this->admin_page_channels($a); @@ -872,20 +872,20 @@ class Admin extends \Zotlabs\Web\Controller { } /** - * @brief Handle POST actions on users admin page. + * @brief Handle POST actions on accounts admin page. * * This function is called when on the admin user/account page the form was * submitted to handle multiple operations at once. If one of the icons next - * to an entry are pressed the function admin_page_users() will handle this. + * to an entry are pressed the function admin_page_accounts() will handle this. * * @param App $a */ - function admin_page_users_post($a) { + function admin_page_accounts_post($a) { $pending = ( x($_POST, 'pending') ? $_POST['pending'] : array() ); $users = ( x($_POST, 'user') ? $_POST['user'] : array() ); $blocked = ( x($_POST, 'blocked') ? $_POST['blocked'] : array() ); - check_form_security_token_redirectOnErr('/admin/users', 'admin_users'); + check_form_security_token_redirectOnErr('/admin/accounts', 'admin_accounts'); // change to switch structure? // account block/unblock button was submitted @@ -901,8 +901,7 @@ class Admin extends \Zotlabs\Web\Controller { notice( sprintf( tt("%s account blocked/unblocked", "%s account blocked/unblocked", count($users)), count($users)) ); } // account delete button was submitted - if (x($_POST, 'page_users_delete')) { - require_once('include/Contact.php'); + if (x($_POST, 'page_accounts_delete')) { foreach ($users as $uid){ account_remove($uid, true, false); } @@ -921,20 +920,20 @@ class Admin extends \Zotlabs\Web\Controller { } } - goaway(z_root() . '/admin/users' ); + goaway(z_root() . '/admin/accounts' ); } /** - * @brief Generate users admin page and handle single item operations. + * @brief Generate accounts admin page and handle single item operations. * - * This function generates the users/account admin page and handles the actions + * This function generates the accounts/account admin page and handles the actions * if an icon next to an entry was clicked. If several items were selected and - * the form was submitted it is handled by the function admin_page_users_post(). + * the form was submitted it is handled by the function admin_page_accounts_post(). * * @param App &$a * @return string */ - function admin_page_users(&$a){ + function admin_page_accounts(&$a){ if (argc() > 2) { $uid = argv(3); $account = q("SELECT * FROM account WHERE account_id = %d", @@ -943,15 +942,14 @@ class Admin extends \Zotlabs\Web\Controller { if (! $account) { notice( t('Account not found') . EOL); - goaway(z_root() . '/admin/users' ); + goaway(z_root() . '/admin/accounts' ); } - check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); + check_form_security_token_redirectOnErr('/admin/accounts', 'admin_accounts', 't'); switch (argv(2)){ case 'delete': // delete user - require_once('include/Contact.php'); account_remove($uid,true,false); notice( sprintf(t("Account '%s' deleted"), $account[0]['account_email']) . EOL); @@ -974,7 +972,7 @@ class Admin extends \Zotlabs\Web\Controller { break; } - goaway(z_root() . '/admin/users' ); + goaway(z_root() . '/admin/accounts' ); } /* get pending */ @@ -982,7 +980,7 @@ class Admin extends \Zotlabs\Web\Controller { intval(ACCOUNT_PENDING) ); - /* get users */ + /* get accounts */ $total = q("SELECT count(*) as total FROM account"); if (count($total)) { @@ -990,22 +988,20 @@ class Admin extends \Zotlabs\Web\Controller { \App::set_pager_itemspage(100); } - - // We'll still need to link email addresses to admin/users/channels or some such, but this bit doesn't exist yet. - // That's where we need to be doing last post/channel flags/etc, not here. - $serviceclass = (($_REQUEST['class']) ? " and account_service_class = '" . dbesc($_REQUEST['class']) . "' " : ''); + + $key = (($_REQUEST['key']) ? dbesc($_REQUEST['key']) : 'account_id'); + $dir = 'asc'; + if(array_key_exists('dir',$_REQUEST)) + $dir = ((intval($_REQUEST['dir'])) ? 'asc' : 'desc'); + + $base = z_root() . '/admin/accounts?f='; + $odir = (($dir === 'asc') ? '0' : '1'); - $order = " order by account_email asc "; - if($_REQUEST['order'] === 'expires') - $order = " order by account_expires desc "; - if($_REQUEST['order'] === 'created') - $order = " order by account_created desc "; - - $users = q("SELECT `account_id` , `account_email`, `account_lastlog`, `account_created`, `account_expires`, " . "`account_service_class`, ( account_flags & %d )>0 as `blocked`, " . + $users = q("SELECT `account_id` , `account_email`, `account_lastlog`, `account_created`, `account_expires`, " . "`account_service_class`, ( account_flags & %d ) > 0 as `blocked`, " . "(SELECT %s FROM channel as ch " . "WHERE ch.channel_account_id = ac.account_id and ch.channel_removed = 0 ) as `channels` " . - "FROM account as ac where true $serviceclass $order limit %d offset %d ", + "FROM account as ac where true $serviceclass order by $key $dir limit %d offset %d ", intval(ACCOUNT_BLOCKED), db_concat('ch.channel_address', ' '), intval(\App::$pager['itemspage']), @@ -1028,14 +1024,14 @@ class Admin extends \Zotlabs\Web\Controller { // } // $users = array_map("_setup_users", $users); - $t = get_markup_template('admin_users.tpl'); + $t = get_markup_template('admin_accounts.tpl'); $o = replace_macros($t, array( // strings // '$title' => t('Administration'), - '$page' => t('Users'), + '$page' => t('Accounts'), '$submit' => t('Submit'), '$select_all' => t('select all'), - '$h_pending' => t('User registrations waiting for confirm'), + '$h_pending' => t('Registrations waiting for confirm'), '$th_pending' => array( t('Request date'), t('Email') ), '$no_pending' => t('No registrations.'), '$approve' => t('Approve'), @@ -1043,14 +1039,22 @@ class Admin extends \Zotlabs\Web\Controller { '$delete' => t('Delete'), '$block' => t('Block'), '$unblock' => t('Unblock'), - - '$h_users' => t('Users'), - '$th_users' => array( t('ID'), t('Email'), t('All Channels'), t('Register date'), t('Last login'), t('Expires'), t('Service Class')), + '$odir' => $odir, + '$base' => $base, + '$h_users' => t('Accounts'), + '$th_users' => array( + [ t('ID'), 'account_id' ], + [ t('Email'), 'account_email' ], + [ t('All Channels'), 'channels' ], + [ t('Register date'), 'account_created' ], + [ t('Last login'), 'account_lastlog' ], + [ t('Expires'), 'account_expires' ], + [ t('Service Class'), 'account_service_class'] ), '$confirm_delete_multi' => t('Selected accounts will be deleted!\n\nEverything these accounts had posted on this site will be permanently deleted!\n\nAre you sure?'), '$confirm_delete' => t('The account {0} will be deleted!\n\nEverything this account has posted on this site will be permanently deleted!\n\nAre you sure?'), - '$form_security_token' => get_form_security_token("admin_users"), + '$form_security_token' => get_form_security_token("admin_accounts"), // values // '$baseurl' => z_root(), @@ -1082,7 +1086,7 @@ class Admin extends \Zotlabs\Web\Controller { intval(PAGE_CENSORED), intval( $uid ) ); - proc_run('php','include/directory.php',$uid,'nopush'); + \Zotlabs\Daemon\Master::Summon(array('Directory',$uid,'nopush')); } notice( sprintf( tt("%s channel censored/uncensored", "%s channels censored/uncensored", count($channels)), count($channels)) ); } @@ -1096,7 +1100,6 @@ class Admin extends \Zotlabs\Web\Controller { notice( sprintf( tt("%s channel code allowed/disallowed", "%s channels code allowed/disallowed", count($channels)), count($channels)) ); } if (x($_POST,'page_channels_delete')){ - require_once("include/Contact.php"); foreach($channels as $uid){ channel_remove($uid,true); } @@ -1128,7 +1131,6 @@ class Admin extends \Zotlabs\Web\Controller { case "delete":{ check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't'); // delete channel - require_once("include/Contact.php"); channel_remove($uid,true); notice( sprintf(t("Channel '%s' deleted"), $channel[0]['channel_name']) . EOL); @@ -1141,7 +1143,7 @@ class Admin extends \Zotlabs\Web\Controller { intval($pflags), intval( $uid ) ); - proc_run('php','include/directory.php',$uid,'nopush'); + \Zotlabs\Daemon\Master::Summon(array('Directory',$uid,'nopush')); notice( sprintf( (($pflags & PAGE_CENSORED) ? t("Channel '%s' censored"): t("Channel '%s' uncensored")) , $channel[0]['channel_name'] . ' (' . $channel[0]['channel_address'] . ')' ) . EOL); }; break; @@ -1162,6 +1164,17 @@ class Admin extends \Zotlabs\Web\Controller { } goaway(z_root() . '/admin/channels' ); } + + + $key = (($_REQUEST['key']) ? dbesc($_REQUEST['key']) : 'channel_id'); + $dir = 'asc'; + if(array_key_exists('dir',$_REQUEST)) + $dir = ((intval($_REQUEST['dir'])) ? 'asc' : 'desc'); + + $base = z_root() . '/admin/channels?f='; + $odir = (($dir === 'asc') ? '0' : '1'); + + /* get channels */ @@ -1170,14 +1183,12 @@ class Admin extends \Zotlabs\Web\Controller { \App::set_pager_total($total[0]['total']); \App::set_pager_itemspage(100); } - - $order = " order by channel_name asc "; - - $channels = q("SELECT * from channel where channel_removed = 0 and channel_system = 0 $order limit %d offset %d ", + + $channels = q("SELECT * from channel where channel_removed = 0 and channel_system = 0 order by $key $dir limit %d offset %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']) ); - + if($channels) { for($x = 0; $x < count($channels); $x ++) { if($channels[$x]['channel_pageflags'] & PAGE_CENSORED) @@ -1205,7 +1216,12 @@ class Admin extends \Zotlabs\Web\Controller { '$code' => t('Allow Code'), '$uncode' => t('Disallow Code'), '$h_channels' => t('Channel'), - '$th_channels' => array( t('UID'), t('Name'), t('Address')), + '$base' => $base, + '$odir' => $odir, + '$th_channels' => array( + [ t('UID'), 'channel_id' ], + [ t('Name'), 'channel_name' ], + [ t('Address'), 'channel_address' ]), '$confirm_delete_multi' => t('Selected channels will be deleted!\n\nEverything that was posted in these channels on this site will be permanently deleted!\n\nAre you sure?'), '$confirm_delete' => t('The channel {0} will be deleted!\n\nEverything that was posted in this channel on this site will be permanently deleted!\n\nAre you sure?'), @@ -1295,7 +1311,7 @@ class Admin extends \Zotlabs\Web\Controller { $admin_form = ''; - $r = q("select * from addon where plugin_admin = 1 and name = '%s' limit 1", + $r = q("select * from addon where plugin_admin = 1 and aname = '%s' limit 1", dbesc($plugin) ); @@ -1408,7 +1424,9 @@ class Admin extends \Zotlabs\Web\Controller { '$plugins' => $plugins, '$disabled' => t('Disabled - version incompatibility'), '$form_security_token' => get_form_security_token('admin_plugins'), - '$addrepo' => t('Add Plugin Repo'), + '$managerepos' => t('Manage Repos'), + '$installedtitle' => t('Installed Plugin Repositories'), + '$addnewrepotitle' => t('Install a New Plugin Repository'), '$expandform' => false, '$form' => $admin_plugins_add_repo_form, '$newRepoModal' => $newRepoModal, @@ -1423,13 +1441,15 @@ class Admin extends \Zotlabs\Web\Controller { function listAddonRepos() { $addonrepos = []; $addonDir = __DIR__ . '/../../extend/addon/'; - if ($handle = opendir($addonDir)) { - while (false !== ($entry = readdir($handle))) { - if ($entry != "." && $entry != "..") { - $addonrepos[] = $entry; + if(is_dir($addonDir)) { + if ($handle = opendir($addonDir)) { + while (false !== ($entry = readdir($handle))) { + if ($entry != "." && $entry != "..") { + $addonrepos[] = $entry; + } } + closedir($handle); } - closedir($handle); } return $addonrepos; } @@ -1718,7 +1738,7 @@ class Admin extends \Zotlabs\Web\Controller { // name, label, value, help string, extra data... '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""), - '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Red top-level directory.")), + '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your top-level webserver directory.")), '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices), '$form_security_token' => get_form_security_token('admin_logs'), @@ -1733,7 +1753,7 @@ class Admin extends \Zotlabs\Web\Controller { } else { json_return_and_die(array('message' => 'No repo name provided.', 'success' => false)); } - $extendDir = __DIR__ . '/../../store/git/sys/extend'; + $extendDir = __DIR__ . '/../../store/[data]/git/sys/extend'; $addonDir = $extendDir . '/addon'; if (!file_exists($extendDir)) { if (!mkdir($extendDir, 0770, true)) { @@ -1746,7 +1766,7 @@ class Admin extends \Zotlabs\Web\Controller { } } } - $repoDir = __DIR__ . '/../../store/git/sys/extend/addon/' . $repoName; + $repoDir = __DIR__ . '/../../store/[data]/git/sys/extend/addon/' . $repoName; if (!is_dir($repoDir)) { logger('Repo directory does not exist: ' . $repoDir); json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false)); @@ -1758,6 +1778,18 @@ class Admin extends \Zotlabs\Web\Controller { $git = new GitRepo('sys', null, false, $repoName, $repoDir); try { if ($git->pull()) { + $files = array_diff(scandir($repoDir), array('.', '..')); + foreach ($files as $file) { + if (is_dir($repoDir . '/' . $file) && $file !== '.git') { + $source = '../extend/addon/' . $repoName . '/' . $file; + $target = realpath(__DIR__ . '/../../addon/') . '/' . $file; + unlink($target); + if (!symlink($source, $target)) { + logger('Error linking addons to /addon'); + json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false)); + } + } + } json_return_and_die(array('message' => 'Repo updated.', 'success' => true)); } else { json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false)); @@ -1771,7 +1803,7 @@ class Admin extends \Zotlabs\Web\Controller { } else { json_return_and_die(array('message' => 'No repo name provided.', 'success' => false)); } - $extendDir = __DIR__ . '/../../store/git/sys/extend'; + $extendDir = __DIR__ . '/../../store/[data]/git/sys/extend'; $addonDir = $extendDir . '/addon'; if (!file_exists($extendDir)) { if (!mkdir($extendDir, 0770, true)) { @@ -1784,7 +1816,7 @@ class Admin extends \Zotlabs\Web\Controller { } } } - $repoDir = __DIR__ . '/../../store/git/sys/extend/addon/' . $repoName; + $repoDir = __DIR__ . '/../../store/[data]/git/sys/extend/addon/' . $repoName; if (!is_dir($repoDir)) { logger('Repo directory does not exist: ' . $repoDir); json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false)); @@ -1804,7 +1836,7 @@ class Admin extends \Zotlabs\Web\Controller { if (array_key_exists('repoURL', $_REQUEST)) { require __DIR__ . '/../../library/PHPGit.autoload.php'; // Load PHPGit dependencies $repoURL = $_REQUEST['repoURL']; - $extendDir = __DIR__ . '/../../store/git/sys/extend'; + $extendDir = __DIR__ . '/../../store/[data]/git/sys/extend'; $addonDir = $extendDir . '/addon'; if (!file_exists($extendDir)) { if (!mkdir($extendDir, 0770, true)) { @@ -1832,7 +1864,7 @@ class Admin extends \Zotlabs\Web\Controller { json_return_and_die(array('message' => 'Invalid git repo', 'success' => false)); } $repoDir = $addonDir . '/' . $repoName; - $tempRepoBaseDir = __DIR__ . '/../../store/git/sys/temp/'; + $tempRepoBaseDir = __DIR__ . '/../../store/[data]/git/sys/temp/'; $tempAddonDir = $tempRepoBaseDir . $repoName; if (!is_writable($addonDir) || !is_writable($tempAddonDir)) { @@ -1866,9 +1898,9 @@ class Admin extends \Zotlabs\Web\Controller { if (array_key_exists('repoURL', $_REQUEST)) { require __DIR__ . '/../../library/PHPGit.autoload.php'; // Load PHPGit dependencies $repoURL = $_REQUEST['repoURL']; - $extendDir = __DIR__ . '/../../store/git/sys/extend'; + $extendDir = __DIR__ . '/../../store/[data]/git/sys/extend'; $addonDir = $extendDir . '/addon'; - $tempAddonDir = __DIR__ . '/../../store/git/sys/temp'; + $tempAddonDir = __DIR__ . '/../../store/[data]/git/sys/temp'; if (!file_exists($extendDir)) { if (!mkdir($extendDir, 0770, true)) { logger('Error creating extend folder: ' . $extendDir); @@ -1880,6 +1912,12 @@ class Admin extends \Zotlabs\Web\Controller { } } } + if (!is_dir($tempAddonDir)) { + if (!mkdir($tempAddonDir, 0770, true)) { + logger('Error creating temp plugin repo folder: ' . $tempAddonDir); + json_return_and_die(array('message' => 'Error creating temp plugin repo folder: ' . $tempAddonDir, 'success' => false)); + } + } $repoName = null; if (array_key_exists('repoName', $_REQUEST) && $_REQUEST['repoName'] !== '') { $repoName = $_REQUEST['repoName']; diff --git a/Zotlabs/Module/Api.php b/Zotlabs/Module/Api.php index 3e7f23b6c..e4744c29f 100644 --- a/Zotlabs/Module/Api.php +++ b/Zotlabs/Module/Api.php @@ -107,7 +107,7 @@ class Api extends \Zotlabs\Web\Controller { $r = q("SELECT `clients`.* FROM `clients`, `tokens` WHERE `clients`.`client_id`=`tokens`.`client_id` - AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'", + AND `tokens`.`id`='%s' AND `tokens`.`auth_scope`='request'", dbesc($token)); if (!count($r)) diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php index ba2a64f35..a200e986a 100644 --- a/Zotlabs/Module/Appman.php +++ b/Zotlabs/Module/Appman.php @@ -2,8 +2,9 @@ namespace Zotlabs\Module; -require_once('include/apps.php'); +//require_once('include/apps.php'); +use \Zotlabs\Lib as Zlib; class Appman extends \Zotlabs\Web\Controller { @@ -30,16 +31,16 @@ class Appman extends \Zotlabs\Web\Controller { 'categories' => escape_tags($_REQUEST['categories']) ); - $_REQUEST['appid'] = app_install(local_channel(),$arr); + $_REQUEST['appid'] = Zlib\Apps::app_install(local_channel(),$arr); - if(app_installed(local_channel(),$arr)) + if(Zlib\Apps::app_installed(local_channel(),$arr)) info( t('App installed.') . EOL); return; } - $papp = app_decode($_POST['papp']); + $papp = Zlib\Apps::app_decode($_POST['papp']); if(! is_array($papp)) { notice( t('Malformed app.') . EOL); @@ -47,13 +48,13 @@ class Appman extends \Zotlabs\Web\Controller { } if($_POST['install']) { - app_install(local_channel(),$papp); - if(app_installed(local_channel(),$papp)) + Zlib\Apps::app_install(local_channel(),$papp); + if(Zlib\Apps::app_installed(local_channel(),$papp)) info( t('App installed.') . EOL); } if($_POST['delete']) { - app_destroy(local_channel(),$papp); + Zlib\Apps::app_destroy(local_channel(),$papp); } if($_POST['edit']) { @@ -100,7 +101,7 @@ class Appman extends \Zotlabs\Web\Controller { } } - $embed = array('embed', t('Embed code'), app_encode($app,true),'', 'onclick="this.select();"'); + $embed = array('embed', t('Embed code'), Zlib\Apps::app_encode($app,true),'', 'onclick="this.select();"'); } diff --git a/Zotlabs/Module/Apps.php b/Zotlabs/Module/Apps.php index 33259b319..4bdec4573 100644 --- a/Zotlabs/Module/Apps.php +++ b/Zotlabs/Module/Apps.php @@ -1,8 +1,9 @@ <?php namespace Zotlabs\Module; -require_once('include/apps.php'); +//require_once('include/apps.php'); +use \Zotlabs\Lib as Zlib; class Apps extends \Zotlabs\Web\Controller { @@ -19,25 +20,25 @@ class Apps extends \Zotlabs\Web\Controller { if(local_channel()) { - import_system_apps(); + Zlib\Apps::import_system_apps(); $syslist = array(); - $list = app_list(local_channel(), false, $_GET['cat']); + $list = Zlib\Apps::app_list(local_channel(), false, $_GET['cat']); if($list) { foreach($list as $x) { - $syslist[] = app_encode($x); + $syslist[] = Zlib\Apps::app_encode($x); } } - translate_system_apps($syslist); + Zlib\Apps::translate_system_apps($syslist); } else - $syslist = get_system_apps(true); + $syslist = Zlib\Apps::get_system_apps(true); - usort($syslist,'app_name_compare'); + usort($syslist,'Zotlabs\\Lib\\Apps::app_name_compare'); // logger('apps: ' . print_r($syslist,true)); foreach($syslist as $app) { - $apps[] = app_render($app,$mode); + $apps[] = Zlib\Apps::app_render($app,$mode); } return replace_macros(get_markup_template('myapps.tpl'), array( diff --git a/Zotlabs/Module/Attach.php b/Zotlabs/Module/Attach.php index 8948b66d7..de941d52c 100644 --- a/Zotlabs/Module/Attach.php +++ b/Zotlabs/Module/Attach.php @@ -40,7 +40,7 @@ class Attach extends \Zotlabs\Web\Controller { header('Content-disposition: attachment; filename="' . $r['data']['filename'] . '"'); if(intval($r['data']['os_storage'])) { - $fname = dbunescbin($r['data']['data']); + $fname = dbunescbin($r['data']['content']); if(strpos($fname,'store') !== false) $istream = fopen($fname,'rb'); else @@ -53,7 +53,7 @@ class Attach extends \Zotlabs\Web\Controller { } } else - echo dbunescbin($r['data']['data']); + echo dbunescbin($r['data']['content']); killme(); } diff --git a/Zotlabs/Module/Blocks.php b/Zotlabs/Module/Blocks.php index ed702befb..32650a090 100644 --- a/Zotlabs/Module/Blocks.php +++ b/Zotlabs/Module/Blocks.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); diff --git a/Zotlabs/Module/Cal.php b/Zotlabs/Module/Cal.php index 958ce5aa6..1da42684d 100644 --- a/Zotlabs/Module/Cal.php +++ b/Zotlabs/Module/Cal.php @@ -6,14 +6,12 @@ require_once('include/bbcode.php'); require_once('include/datetime.php'); require_once('include/event.php'); require_once('include/items.php'); -require_once('include/Contact.php'); - class Cal extends \Zotlabs\Web\Controller { function init() { - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { return; } @@ -47,13 +45,12 @@ class Cal extends \Zotlabs\Web\Controller { - function get() { + function get() { - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { return; } - - + $channel = null; if(argc() > 1) { @@ -94,7 +91,7 @@ class Cal extends \Zotlabs\Web\Controller { $mode = 'view'; $y = 0; $m = 0; - $ignored = ((x($_REQUEST,'ignored')) ? " and ignored = " . intval($_REQUEST['ignored']) . " " : ''); + $ignored = ((x($_REQUEST,'ignored')) ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : ''); // logger('args: ' . print_r(\App::$argv,true)); @@ -149,7 +146,7 @@ class Cal extends \Zotlabs\Web\Controller { $ftext = datetime_convert('UTC',$tz,$fdt); $ftext = substr($ftext,0,14) . "00:00"; - $type = ((x($orig_event)) ? $orig_event['type'] : 'event'); + $type = ((x($orig_event)) ? $orig_event['etype'] : 'event'); $f = get_config('system','event_input_format'); if(! $f) @@ -160,7 +157,7 @@ class Cal extends \Zotlabs\Web\Controller { $show_bd = perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_contacts'); if(! $show_bd) { - $sql_extra .= " and event.type != 'birthday' "; + $sql_extra .= " and event.etype != 'birthday' "; } @@ -228,8 +225,8 @@ class Cal extends \Zotlabs\Web\Controller { $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan from event left join item on event_hash = resource_id where resource_type = 'event' and event.uid = %d $ignored - AND (( adjust = 0 AND ( finish >= '%s' or nofinish = 1 ) AND start <= '%s' ) - OR ( adjust = 1 AND ( finish >= '%s' or nofinish = 1 ) AND start <= '%s' )) $sql_extra ", + AND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' ) + OR ( adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) $sql_extra ", intval($channel['channel_id']), dbesc($start), dbesc($finish), @@ -250,7 +247,7 @@ class Cal extends \Zotlabs\Web\Controller { if($r) { foreach($r as $rr) { - $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); + $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j')); if(! x($links,$j)) $links[$j] = z_root() . '/' . \App::$cmd . '#link-' . $j; } @@ -265,15 +262,15 @@ class Cal extends \Zotlabs\Web\Controller { foreach($r as $rr) { - $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); - $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt)); + $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j')); + $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], $fmt) : datetime_convert('UTC','UTC',$rr['dtstart'],$fmt)); $d = day_translate($d); - $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c')); + $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'c') : datetime_convert('UTC','UTC',$rr['dtstart'],'c')); if ($rr['nofinish']){ $end = null; } else { - $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c')); + $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtend'], 'c') : datetime_convert('UTC','UTC',$rr['dtend'],'c')); } diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index f55705442..29bfcbc3c 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -13,353 +13,355 @@ require_once('include/PermissionDescription.php'); class Channel extends \Zotlabs\Web\Controller { -function init() { - - $which = null; - if(argc() > 1) - $which = argv(1); - if(! $which) { - if(local_channel()) { - $channel = \App::get_channel(); - if($channel && $channel['channel_address']) - $which = $channel['channel_address']; + function init() { + + $which = null; + if(argc() > 1) + $which = argv(1); + if(! $which) { + if(local_channel()) { + $channel = \App::get_channel(); + if($channel && $channel['channel_address']) + $which = $channel['channel_address']; + } + } + if(! $which) { + notice( t('You must be logged in to see this page.') . EOL ); + return; } - } - if(! $which) { - notice( t('You must be logged in to see this page.') . EOL ); - return; - } - $profile = 0; - $channel = \App::get_channel(); + $profile = 0; + $channel = \App::get_channel(); - if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) { - $which = $channel['channel_address']; - $profile = argv(1); - } + if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) { + $which = $channel['channel_address']; + $profile = argv(1); + } - \App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Posts and comments') . '" href="' . z_root() . '/feed/' . $which . '" />' . "\r\n" ; - \App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Only posts') . '" href="' . z_root() . '/feed/' . $which . '?top=1" />' . "\r\n" ; + \App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Posts and comments') . '" href="' . z_root() . '/feed/' . $which . '" />' . "\r\n" ; + \App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" title="' . t('Only posts') . '" href="' . z_root() . '/feed/' . $which . '?top=1" />' . "\r\n" ; -// Not yet ready for prime time -// \App::$page['htmlhead'] .= '<link rel="openid.server" href="' . z_root() . '/id/' . $which .'?f=" />' . "\r\n" ; -// \App::$page['htmlhead'] .= '<link rel="openid.delegate" href="' . z_root() . '/channel/' . $which .'" />' . "\r\n" ; + // Not yet ready for prime time + // \App::$page['htmlhead'] .= '<link rel="openid.server" href="' . z_root() . '/id/' . $which .'?f=" />' . "\r\n" ; + // \App::$page['htmlhead'] .= '<link rel="openid.delegate" href="' . z_root() . '/channel/' . $which .'" />' . "\r\n" ; - // Run profile_load() here to make sure the theme is set before - // we start loading content + // Run profile_load() here to make sure the theme is set before + // we start loading content - profile_load($a,$which,$profile); + profile_load($a,$which,$profile); -} + } -function get($update = 0, $load = false) { + function get($update = 0, $load = false) { - if($load) - $_SESSION['loadtime'] = datetime_convert(); + if($load) + $_SESSION['loadtime'] = datetime_convert(); - $checkjs = new \Zotlabs\Web\CheckJS(1); + $checkjs = new \Zotlabs\Web\CheckJS(1); - $category = $datequery = $datequery2 = ''; + $category = $datequery = $datequery2 = ''; - $mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); + $mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); - $datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : ''); - $datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : ''); + $datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : ''); + $datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : ''); - if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) { + if(observer_prohibited(true)) { return login(); - } + } - $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); - $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); + $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); + $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); - $groups = array(); + $groups = array(); - $o = ''; + $o = ''; - if($update) { - // Ensure we've got a profile owner if updating. - \App::$profile['profile_uid'] = \App::$profile_uid = $update; - } - else { - if(\App::$profile['profile_uid'] == local_channel()) { - nav_set_selected('home'); + if($update) { + // Ensure we've got a profile owner if updating. + \App::$profile['profile_uid'] = \App::$profile_uid = $update; + } + else { + if(\App::$profile['profile_uid'] == local_channel()) { + nav_set_selected('home'); + } } - } - $is_owner = (((local_channel()) && (\App::$profile['profile_uid'] == local_channel())) ? true : false); + $is_owner = (((local_channel()) && (\App::$profile['profile_uid'] == local_channel())) ? true : false); - $channel = \App::get_channel(); - $observer = \App::get_observer(); - $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + $channel = \App::get_channel(); + $observer = \App::get_observer(); + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); - $perms = get_all_perms(\App::$profile['profile_uid'],$ob_hash); + $perms = get_all_perms(\App::$profile['profile_uid'],$ob_hash); - if(! $perms['view_stream']) { + if(! $perms['view_stream']) { // We may want to make the target of this redirect configurable if($perms['view_profile']) { notice( t('Insufficient permissions. Request redirected to profile page.') . EOL); goaway (z_root() . "/profile/" . \App::$profile['channel_address']); } - notice( t('Permission denied.') . EOL); - return; - } + notice( t('Permission denied.') . EOL); + return; + } - if(! $update) { + if(! $update) { - $o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']); + $o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']); - $o .= common_friends_visitor_widget(\App::$profile['profile_uid']); + $o .= common_friends_visitor_widget(\App::$profile['profile_uid']); - if($channel && $is_owner) { - $channel_acl = array( - 'allow_cid' => $channel['channel_allow_cid'], - 'allow_gid' => $channel['channel_allow_gid'], - 'deny_cid' => $channel['channel_deny_cid'], - 'deny_gid' => $channel['channel_deny_gid'] - ); - } - else - $channel_acl = array(); - - - if($perms['post_wall']) { - - $x = array( - 'is_owner' => $is_owner, - 'allow_location' => ((($is_owner || $observer) && (intval(get_pconfig(\App::$profile['profile_uid'],'system','use_browser_location')))) ? true : false), - 'default_location' => (($is_owner) ? \App::$profile['channel_location'] : ''), - 'nickname' => \App::$profile['channel_address'], - 'lockstate' => (((strlen(\App::$profile['channel_allow_cid'])) || (strlen(\App::$profile['channel_allow_gid'])) || (strlen(\App::$profile['channel_deny_cid'])) || (strlen(\App::$profile['channel_deny_gid']))) ? 'lock' : 'unlock'), - 'acl' => (($is_owner) ? populate_acl($channel_acl,true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : ''), - 'showacl' => (($is_owner) ? 'yes' : ''), - 'bang' => '', - 'visitor' => (($is_owner || $observer) ? true : false), - 'profile_uid' => \App::$profile['profile_uid'], - 'editor_autocomplete' => true, - 'bbco_autocomplete' => 'bbcode', - 'bbcode' => true - ); - - $o .= status_editor($a,$x); - } + if($channel && $is_owner) { + $channel_acl = array( + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] + ); + } + else + $channel_acl = array(); + + + if($perms['post_wall']) { + + $x = array( + 'is_owner' => $is_owner, + 'allow_location' => ((($is_owner || $observer) && (intval(get_pconfig(\App::$profile['profile_uid'],'system','use_browser_location')))) ? true : false), + 'default_location' => (($is_owner) ? \App::$profile['channel_location'] : ''), + 'nickname' => \App::$profile['channel_address'], + 'lockstate' => (((strlen(\App::$profile['channel_allow_cid'])) || (strlen(\App::$profile['channel_allow_gid'])) || (strlen(\App::$profile['channel_deny_cid'])) || (strlen(\App::$profile['channel_deny_gid']))) ? 'lock' : 'unlock'), + 'acl' => (($is_owner) ? populate_acl($channel_acl,true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : ''), + 'showacl' => (($is_owner) ? 'yes' : ''), + 'bang' => '', + 'visitor' => (($is_owner || $observer) ? true : false), + 'profile_uid' => \App::$profile['profile_uid'], + 'editor_autocomplete' => true, + 'bbco_autocomplete' => 'bbcode', + 'bbcode' => true + ); + + $o .= status_editor($a,$x); + } - } + } - /** - * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups - */ + /** + * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups + */ - $item_normal = item_normal(); - $sql_extra = item_permissions_sql(\App::$profile['profile_uid']); + $item_normal = item_normal(); + $sql_extra = item_permissions_sql(\App::$profile['profile_uid']); - if(get_pconfig(\App::$profile['profile_uid'],'system','channel_list_mode') && (! $mid)) - $page_mode = 'list'; - else - $page_mode = 'client'; + if(get_pconfig(\App::$profile['profile_uid'],'system','channel_list_mode') && (! $mid)) + $page_mode = 'list'; + else + $page_mode = 'client'; - $abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " "; + $abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " "; - $simple_update = (($update) ? " AND item_unseen = 1 " : ''); + $simple_update = (($update) ? " AND item_unseen = 1 " : ''); - \App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string) . '" title="oembed" />' . "\r\n"; + \App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string) . '" title="oembed" />' . "\r\n"; - if($update && $_SESSION['loadtime']) - $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; - if($load) - $simple_update = ''; - - if(($update) && (! $load)) { - - if ($mid) { - $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal - AND item_wall = 1 AND item_unseen = 1 $sql_extra limit 1", - dbesc($mid . '%'), - intval(\App::$profile['profile_uid']) - ); - } else { - $r = q("SELECT distinct parent AS `item_id`, created from item - left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) - WHERE uid = %d $item_normal - AND item_wall = 1 $simple_update - AND (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra - ORDER BY created DESC", - intval(\App::$profile['profile_uid']) - ); - $_SESSION['loadtime'] = datetime_convert(); - } - - } - else { - - if(x($category)) { - $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY)); - } - if(x($hashtags)) { - $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); - } - - if($datequery) { - $sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery)))); - } - if($datequery2) { - $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); - } + if($update && $_SESSION['loadtime']) + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; + if($load) + $simple_update = ''; - $itemspage = get_pconfig(local_channel(),'system','itemspage'); - \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); - $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); + if(($update) && (! $load)) { - if($load || ($checkjs->disabled())) { - if ($mid) { - $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal - AND item_wall = 1 $sql_extra limit 1", - dbesc($mid), + if($mid) { + $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal + AND item_wall = 1 AND item_unseen = 1 $sql_extra limit 1", + dbesc($mid . '%'), intval(\App::$profile['profile_uid']) ); - if (! $r) { - notice( t('Permission denied.') . EOL); - } - - } else { - $r = q("SELECT distinct id AS item_id, created FROM item - left join abook on item.author_xchan = abook.abook_xchan + } + else { + $r = q("SELECT distinct parent AS `item_id`, created from item + left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE uid = %d $item_normal - AND item_wall = 1 and item_thread_top = 1 - AND (abook_blocked = 0 or abook.abook_flags is null) - $sql_extra $sql_extra2 - ORDER BY created DESC $pager_sql ", + AND item_wall = 1 $simple_update + AND (abook.abook_blocked = 0 or abook.abook_flags is null) + $sql_extra + ORDER BY created DESC", intval(\App::$profile['profile_uid']) ); + $_SESSION['loadtime'] = datetime_convert(); } + } else { - $r = array(); - } - } - if($r) { + if(x($category)) { + $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY)); + } + if(x($hashtags)) { + $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); + } - $parents_str = ids_to_querystr($r,'item_id'); - - $items = q("SELECT `item`.*, `item`.`id` AS `item_id` - FROM `item` - WHERE `item`.`uid` = %d $item_normal - AND `item`.`parent` IN ( %s ) - $sql_extra ", - intval(\App::$profile['profile_uid']), - dbesc($parents_str) - ); - - xchan_query($items); - $items = fetch_post_tags($items, true); - $items = conv_sort($items,'created'); - - if ($load && $mid && (! count($items))) { - // This will happen if we don't have sufficient permissions - // to view the parent item (or the item itself if it is toplevel) - notice( t('Permission denied.') . EOL); + if($datequery) { + $sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery)))); + } + if($datequery2) { + $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); + } + + $itemspage = get_pconfig(local_channel(),'system','itemspage'); + \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); + + if($load || ($checkjs->disabled())) { + if($mid) { + $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal + AND item_wall = 1 $sql_extra limit 1", + dbesc($mid), + intval(\App::$profile['profile_uid']) + ); + if (! $r) { + notice( t('Permission denied.') . EOL); + } + + } + else { + $r = q("SELECT distinct id AS item_id, created FROM item + left join abook on item.author_xchan = abook.abook_xchan + WHERE uid = %d $item_normal + AND item_wall = 1 and item_thread_top = 1 + AND (abook_blocked = 0 or abook.abook_flags is null) + $sql_extra $sql_extra2 + ORDER BY created DESC $pager_sql ", + intval(\App::$profile['profile_uid']) + ); + } + } + else { + $r = array(); + } } - } else { - $items = array(); - } + if($r) { - if((! $update) && (! $load)) { - - // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, - // because browser prefetching might change it on us. We have to deliver it with the page. - - $maxheight = get_pconfig(\App::$profile['profile_uid'],'system','channel_divmore_height'); - if(! $maxheight) - $maxheight = 400; - - $o .= '<div id="live-channel"></div>' . "\r\n"; - $o .= "<script> var profile_uid = " . \App::$profile['profile_uid'] - . "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] - . "; divmore_height = " . intval($maxheight) . "; </script>\r\n"; - - \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( - '$baseurl' => z_root(), - '$pgtype' => 'channel', - '$uid' => ((\App::$profile['profile_uid']) ? \App::$profile['profile_uid'] : '0'), - '$gid' => '0', - '$cid' => '0', - '$cmin' => '0', - '$cmax' => '0', - '$star' => '0', - '$liked' => '0', - '$conv' => '0', - '$spam' => '0', - '$nouveau' => '0', - '$wall' => '1', - '$fh' => '0', - '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), - '$search' => '', - '$order' => '', - '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), - '$file' => '', - '$cats' => (($category) ? $category : ''), - '$tags' => (($hashtags) ? $hashtags : ''), - '$mid' => $mid, - '$verb' => '', - '$dend' => $datequery, - '$dbegin' => $datequery2 - )); + $parents_str = ids_to_querystr($r,'item_id'); + + $items = q("SELECT `item`.*, `item`.`id` AS `item_id` + FROM `item` + WHERE `item`.`uid` = %d $item_normal + AND `item`.`parent` IN ( %s ) + $sql_extra ", + intval(\App::$profile['profile_uid']), + dbesc($parents_str) + ); + xchan_query($items); + $items = fetch_post_tags($items, true); + $items = conv_sort($items,'created'); - } + if($load && $mid && (! count($items))) { + // This will happen if we don't have sufficient permissions + // to view the parent item (or the item itself if it is toplevel) + notice( t('Permission denied.') . EOL); + } - $update_unseen = ''; + } + else { + $items = array(); + } - if($page_mode === 'list') { + if((! $update) && (! $load)) { + + // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, + // because browser prefetching might change it on us. We have to deliver it with the page. + + $maxheight = get_pconfig(\App::$profile['profile_uid'],'system','channel_divmore_height'); + if(! $maxheight) + $maxheight = 400; + + $o .= '<div id="live-channel"></div>' . "\r\n"; + $o .= "<script> var profile_uid = " . \App::$profile['profile_uid'] + . "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] + . "; divmore_height = " . intval($maxheight) . "; </script>\r\n"; + + \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( + '$baseurl' => z_root(), + '$pgtype' => 'channel', + '$uid' => ((\App::$profile['profile_uid']) ? \App::$profile['profile_uid'] : '0'), + '$gid' => '0', + '$cid' => '0', + '$cmin' => '0', + '$cmax' => '0', + '$star' => '0', + '$liked' => '0', + '$conv' => '0', + '$spam' => '0', + '$nouveau' => '0', + '$wall' => '1', + '$fh' => '0', + '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), + '$search' => '', + '$order' => '', + '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), + '$file' => '', + '$cats' => (($category) ? $category : ''), + '$tags' => (($hashtags) ? $hashtags : ''), + '$mid' => $mid, + '$verb' => '', + '$dend' => $datequery, + '$dbegin' => $datequery2 + )); - /** - * in "list mode", only mark the parent item and any like activities as "seen". - * We won't distinguish between comment likes and post likes. The important thing - * is that the number of unseen comments will be accurate. The SQL to separate the - * comment likes could also get somewhat hairy. - */ - if($parents_str) { - $update_unseen = " AND ( id IN ( " . dbesc($parents_str) . " )"; - $update_unseen .= " OR ( parent IN ( " . dbesc($parents_str) . " ) AND verb in ( '" . dbesc(ACTIVITY_LIKE) . "','" . dbesc(ACTIVITY_DISLIKE) . "' ))) "; - } - } - else { - if($parents_str) { - $update_unseen = " AND parent IN ( " . dbesc($parents_str) . " )"; } - } - if($is_owner && $update_unseen) { - $r = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 and item_wall = 1 AND uid = %d $update_unseen", - intval(local_channel()) - ); - } + $update_unseen = ''; + if($page_mode === 'list') { - if($checkjs->disabled()) { - $o .= conversation($a,$items,'channel',$update,'traditional'); - } else { - $o .= conversation($a,$items,'channel',$update,$page_mode); - } + /** + * in "list mode", only mark the parent item and any like activities as "seen". + * We won't distinguish between comment likes and post likes. The important thing + * is that the number of unseen comments will be accurate. The SQL to separate the + * comment likes could also get somewhat hairy. + */ - if((! $update) || ($checkjs->disabled())) { - $o .= alt_pager($a,count($items)); - if ($mid && $items[0]['title']) - \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title']; - } + if($parents_str) { + $update_unseen = " AND ( id IN ( " . dbesc($parents_str) . " )"; + $update_unseen .= " OR ( parent IN ( " . dbesc($parents_str) . " ) AND verb in ( '" . dbesc(ACTIVITY_LIKE) . "','" . dbesc(ACTIVITY_DISLIKE) . "' ))) "; + } + } + else { + if($parents_str) { + $update_unseen = " AND parent IN ( " . dbesc($parents_str) . " )"; + } + } + + if($is_owner && $update_unseen) { + $r = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 and item_wall = 1 AND uid = %d $update_unseen", + intval(local_channel()) + ); + } - if($mid) - $o .= '<div id="content-complete"></div>'; - return $o; -} + if($checkjs->disabled()) { + $o .= conversation($a,$items,'channel',$update,'traditional'); + } + else { + $o .= conversation($a,$items,'channel',$update,$page_mode); + } + if((! $update) || ($checkjs->disabled())) { + $o .= alt_pager($a,count($items)); + if ($mid && $items[0]['title']) + \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title']; + } + if($mid) + $o .= '<div id="content-complete"></div>'; + + return $o; + } }
\ No newline at end of file diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php index f70444816..c6dd07eb7 100644 --- a/Zotlabs/Module/Chanview.php +++ b/Zotlabs/Module/Chanview.php @@ -1,10 +1,8 @@ <?php namespace Zotlabs\Module; -require_once('include/Contact.php'); require_once('include/zot.php'); - class Chanview extends \Zotlabs\Web\Controller { function get() { @@ -62,18 +60,15 @@ class Chanview extends \Zotlabs\Web\Controller { } if($_REQUEST['address']) { - $ret = zot_finger($_REQUEST['address'],null); - if($ret['success']) { - $j = json_decode($ret['body'],true); - if($j) - import_xchan($j); + $j = \Zotlabs\Zot\Finger::run($_REQUEST['address'],null); + if($j['success']) { + import_xchan($j); $r = q("select * from xchan where xchan_addr = '%s' limit 1", dbesc($_REQUEST['address']) ); if($r) \App::$poi = $r[0]; } - } } diff --git a/Zotlabs/Module/Chat.php b/Zotlabs/Module/Chat.php index 9508ed3de..026e8369a 100644 --- a/Zotlabs/Module/Chat.php +++ b/Zotlabs/Module/Chat.php @@ -1,9 +1,11 @@ -<?php -namespace Zotlabs\Module; /** @file */ +<?php /** @file */ + +namespace Zotlabs\Module; + -require_once('include/chat.php'); require_once('include/bookmarks.php'); +use \Zotlabs\Lib as Zlib; class Chat extends \Zotlabs\Web\Controller { @@ -41,7 +43,7 @@ class Chat extends \Zotlabs\Web\Controller { } - function post() { + function post() { if($_POST['room_name']) $room = strip_tags(trim($_POST['room_name'])); @@ -54,7 +56,7 @@ class Chat extends \Zotlabs\Web\Controller { if($_POST['action'] === 'drop') { logger('delete chatroom'); - chatroom_destroy($channel,array('cr_name' => $room)); + Zlib\Chatroom::destroy($channel,array('cr_name' => $room)); goaway(z_root() . '/chat/' . $channel['channel_address']); } @@ -67,7 +69,7 @@ class Chat extends \Zotlabs\Web\Controller { if(intval($arr['expire']) < 0) $arr['expire'] = 0; - chatroom_create($channel,$arr); + Zlib\Chatroom::create($channel,$arr); $x = q("select * from chatroom where cr_name = '%s' and cr_uid = %d limit 1", dbesc($room), @@ -87,7 +89,7 @@ class Chat extends \Zotlabs\Web\Controller { } - function get() { + function get() { if(local_channel()) $channel = \App::get_channel(); @@ -105,7 +107,7 @@ class Chat extends \Zotlabs\Web\Controller { } if((argc() > 3) && intval(argv(2)) && (argv(3) === 'leave')) { - chatroom_leave($observer,argv(2),$_SERVER['REMOTE_ADDR']); + Zlib\Chatroom::leave($observer,argv(2),$_SERVER['REMOTE_ADDR']); goaway(z_root() . '/channel/' . argv(1)); } @@ -158,7 +160,7 @@ class Chat extends \Zotlabs\Web\Controller { $room_id = intval(argv(2)); $bookmark_link = get_bookmark_link($ob); - $x = chatroom_enter($observer,$room_id,'online',$_SERVER['REMOTE_ADDR']); + $x = Zlib\Chatroom::enter($observer,$room_id,'online',$_SERVER['REMOTE_ADDR']); if(! $x) return; $x = q("select * from chatroom where cr_id = %d and cr_uid = %d $sql_extra limit 1", @@ -238,10 +240,10 @@ class Chat extends \Zotlabs\Web\Controller { )); } - $rooms = chatroom_list(\App::$profile['profile_uid']); + $rooms = Zlib\Chatroom::roomlist(\App::$profile['profile_uid']); $o .= replace_macros(get_markup_template('chatrooms.tpl'), array( - '$header' => sprintf( t('%1$s\'s Chatrooms'), \App::$profile['name']), + '$header' => sprintf( t('%1$s\'s Chatrooms'), \App::$profile['fullname']), '$name' => t('Name'), '$baseurl' => z_root(), '$nickname' => \App::$profile['channel_address'], diff --git a/Zotlabs/Module/Chatsvc.php b/Zotlabs/Module/Chatsvc.php index a9bc97301..6a28a7c4d 100644 --- a/Zotlabs/Module/Chatsvc.php +++ b/Zotlabs/Module/Chatsvc.php @@ -1,14 +1,16 @@ -<?php -namespace Zotlabs\Module; /** @file */ +<?php /** @file */ + +namespace Zotlabs\Module; require_once('include/security.php'); +use \Zotlabs\Lib as Zlib; class Chatsvc extends \Zotlabs\Web\Controller { function init() { - //logger('chatsvc'); + //logger('chatsvc'); $ret = array('success' => false); @@ -27,7 +29,7 @@ class Chatsvc extends \Zotlabs\Web\Controller { } - function post() { + function post() { $ret = array('success' => false); @@ -65,7 +67,7 @@ class Chatsvc extends \Zotlabs\Web\Controller { json_return_and_die($ret); } - function get() { + function get() { $status = strip_tags($_REQUEST['status']); $room_id = intval(\App::$data['chat']['room_id']); diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php index f3767e3f0..b691475ce 100644 --- a/Zotlabs/Module/Cloud.php +++ b/Zotlabs/Module/Cloud.php @@ -100,9 +100,12 @@ class Cloud extends \Zotlabs\Web\Controller { // require_once('\Zotlabs\Storage/QuotaPlugin.php'); // $server->addPlugin(new \Zotlabs\Storage\\QuotaPlugin($auth)); + ob_start(); // All we need to do now, is to fire up the server $server->exec(); - + + ob_end_flush(); + killme(); } diff --git a/Zotlabs/Module/Connect.php b/Zotlabs/Module/Connect.php index 6ef3577d7..f68e0baac 100644 --- a/Zotlabs/Module/Connect.php +++ b/Zotlabs/Module/Connect.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; /** @file */ -require_once('include/Contact.php'); + require_once('include/contact_widgets.php'); require_once('include/items.php'); @@ -47,7 +47,8 @@ class Connect extends \Zotlabs\Web\Controller { intval(PAGE_PREMIUM), intval(local_channel()) ); - proc_run('php','include/notifier.php','refresh_all',\App::$data['channel']['channel_id']); + + \Zotlabs\Daemon\Master::Summon(array('Notifier','refresh_all',\App::$data['channel']['channel_id'])); } set_pconfig(\App::$data['channel']['channel_id'],'system','selltext',$text); // reload the page completely to get fresh data diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index 564f4e527..a412d16ae 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -1,9 +1,9 @@ <?php namespace Zotlabs\Module; -require_once('include/Contact.php'); + require_once('include/socgraph.php'); -require_once('include/contact_selectors.php'); +require_once('include/selectors.php'); require_once('include/group.php'); require_once('include/contact_widgets.php'); require_once('include/zot.php'); diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index a1268510d..33deac4c8 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -7,9 +7,9 @@ namespace Zotlabs\Module; * */ -require_once('include/Contact.php'); + require_once('include/socgraph.php'); -require_once('include/contact_selectors.php'); +require_once('include/selectors.php'); require_once('include/group.php'); require_once('include/contact_widgets.php'); require_once('include/zot.php'); @@ -176,7 +176,7 @@ class Connedit extends \Zotlabs\Web\Controller { $record = $z[0]['xlink_id']; } if($record) { - proc_run('php','include/ratenotif.php','rating',$record); + \Zotlabs\Daemon\Master::Summon(array('Ratenotif','rating',$record)); } } @@ -230,7 +230,7 @@ class Connedit extends \Zotlabs\Web\Controller { if(\App::$poi && \App::$poi['abook_my_perms'] != $abook_my_perms && (! intval(\App::$poi['abook_self']))) { - proc_run('php', 'include/notifier.php', (($new_friend) ? 'permission_create' : 'permission_update'), $contact_id); + \Zotlabs\Daemon\Master::Summon(array('Notifier', (($new_friend) ? 'permission_create' : 'permission_update'), $contact_id)); } if($new_friend) { @@ -270,7 +270,7 @@ class Connedit extends \Zotlabs\Web\Controller { array('rel' => 'photo', 'type' => \App::$poi['xchan_photo_mimetype'], 'href' => \App::$poi['xchan_photo_l']) ), ); - $xarr['object'] = json_encode($obj); + $xarr['obj'] = json_encode($obj); $xarr['obj_type'] = ACTIVITY_OBJ_PERSON; $xarr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t('is now connected to') . ' ' . '[zrl=' . \App::$poi['xchan_url'] . ']' . \App::$poi['xchan_name'] . '[/zrl]'; @@ -283,7 +283,7 @@ class Connedit extends \Zotlabs\Web\Controller { // pull in a bit of content if there is any to pull in - proc_run('php','include/onepoll.php',$contact_id); + \Zotlabs\Daemon\Master::Summon(array('Onepoll',$contact_id)); } @@ -414,7 +414,7 @@ class Connedit extends \Zotlabs\Web\Controller { if($cmd === 'update') { // pull feed and consume it, which should subscribe to the hub. - proc_run('php',"include/poller.php","$contact_id"); + \Zotlabs\Daemon\Master::Summon(array('Poller',$contact_id)); goaway(z_root() . '/connedit/' . $contact_id); } @@ -427,7 +427,7 @@ class Connedit extends \Zotlabs\Web\Controller { else { // if you are on a different network we'll force a refresh of the connection basic info - proc_run('php','include/notifier.php','permission_update',$contact_id); + Zotlabs\Daemon\Master::Summon(array('Notifier','permission_update',$contact_id)); } goaway(z_root() . '/connedit/' . $contact_id); } @@ -485,7 +485,6 @@ class Connedit extends \Zotlabs\Web\Controller { if($cmd === 'drop') { - require_once('include/Contact.php'); // FIXME // We need to send either a purge or a refresh packet to the other side (the channel being unfriended). @@ -583,8 +582,6 @@ class Connedit extends \Zotlabs\Web\Controller { if(intval($contact['abook_self'])) $self = true; - require_once('include/contact_selectors.php'); - $tpl = get_markup_template("abook_edit.tpl"); if(feature_enabled(local_channel(),'affinity')) { diff --git a/Zotlabs/Module/Contactgroup.php b/Zotlabs/Module/Contactgroup.php index 497442ff4..bbe56b4ad 100644 --- a/Zotlabs/Module/Contactgroup.php +++ b/Zotlabs/Module/Contactgroup.php @@ -41,10 +41,10 @@ class Contactgroup extends \Zotlabs\Web\Controller { if($change) { if(in_array($change,$preselected)) { - group_rmv_member(local_channel(),$group['name'],$change); + group_rmv_member(local_channel(),$group['gname'],$change); } else { - group_add_member(local_channel(),$group['name'],$change); + group_add_member(local_channel(),$group['gname'],$change); } } } diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index be27a99ef..a72c3389f 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -8,7 +8,7 @@ namespace Zotlabs\Module; */ require_once('include/photo/photo_driver.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); @@ -80,7 +80,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { $profile = $r[0]; } - $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND scale = 0 LIMIT 1", + $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND imgscale = 0 LIMIT 1", dbesc($image_id), intval(local_channel()) ); @@ -88,9 +88,9 @@ class Cover_photo extends \Zotlabs\Web\Controller { if($r) { $base_image = $r[0]; - $base_image['data'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['data']) : dbunescbin($base_image['data'])); + $base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['content']) : dbunescbin($base_image['content'])); - $im = photo_factory($base_image['data'], $base_image['type']); + $im = photo_factory($base_image['content'], $base_image['mimetype']); if($im->is_valid()) { // We are scaling and cropping the relative pixel locations to the original photo instead of the @@ -99,7 +99,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { // First load the scaled photo to check its size. (Should probably pass this in the post form and save // a query.) - $g = q("select width, height from photo where resource_id = '%s' and uid = %d and scale = 3", + $g = q("select width, height from photo where resource_id = '%s' and uid = %d and imgscale = 3", dbesc($image_id), intval(local_channel()) ); @@ -133,26 +133,26 @@ class Cover_photo extends \Zotlabs\Web\Controller { $p = array('aid' => $aid, 'uid' => local_channel(), 'resource_id' => $base_image['resource_id'], 'filename' => $base_image['filename'], 'album' => t('Cover Photos')); - $p['scale'] = 7; + $p['imgscale'] = 7; $p['photo_usage'] = PHOTO_COVER; $r1 = $im->save($p); $im->doScaleImage(850,310); - $p['scale'] = 8; + $p['imgscale'] = 8; $r2 = $im->save($p); $im->doScaleImage(425,160); - $p['scale'] = 9; + $p['imgscale'] = 9; $r3 = $im->save($p); if($r1 === false || $r2 === false || $r3 === false) { // if one failed, delete them all so we can start over. notice( t('Image resize failed.') . EOL ); - $x = q("delete from photo where resource_id = '%s' and uid = %d and scale >= 7 ", + $x = q("delete from photo where resource_id = '%s' and uid = %d and imgscale >= 7 ", dbesc($base_image['resource_id']), local_channel() ); @@ -183,7 +183,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { logger('attach_store: ' . print_r($res,true)); if($res && intval($res['data']['is_photo'])) { - $i = q("select * from photo where resource_id = '%s' and uid = %d and scale = 0", + $i = q("select * from photo where resource_id = '%s' and uid = %d and imgscale = 0", dbesc($hash), intval(local_channel()) ); @@ -195,10 +195,10 @@ class Cover_photo extends \Zotlabs\Web\Controller { $os_storage = false; foreach($i as $ii) { - $smallest = intval($ii['scale']); + $smallest = intval($ii['imgscale']); $os_storage = intval($ii['os_storage']); - $imagedata = $ii['data']; - $filetype = $ii['type']; + $imagedata = $ii['content']; + $filetype = $ii['mimetype']; } } @@ -224,10 +224,10 @@ class Cover_photo extends \Zotlabs\Web\Controller { $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/' . $photo['resource_id'] . '-7', - 'link' => array('rel' => 'photo', 'type' => $photo['type'], 'href' => z_root() . '/photo/' . $photo['resource_id'] . '-7') + 'link' => array('rel' => 'photo', 'type' => $photo['mimetype'], 'href' => z_root() . '/photo/' . $photo['resource_id'] . '-7') )); if($profile && stripos($profile['gender'],t('female')) !== false) @@ -295,7 +295,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { $resource_id = argv(2); - $r = q("SELECT id, album, scale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY scale ASC", + $r = q("SELECT id, album, imgscale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY imgscale ASC", intval(local_channel()), dbesc($resource_id) ); @@ -305,11 +305,11 @@ class Cover_photo extends \Zotlabs\Web\Controller { } $havescale = false; foreach($r as $rr) { - if($rr['scale'] == 7) + if($rr['imgscale'] == 7) $havescale = true; } - $r = q("SELECT `data`, `type`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", + $r = q("SELECT `content`, `mimetype`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", intval($r[0]['id']), intval(local_channel()) @@ -320,15 +320,15 @@ class Cover_photo extends \Zotlabs\Web\Controller { } if(intval($r[0]['os_storage'])) - $data = @file_get_contents($r[0]['data']); + $data = @file_get_contents($r[0]['content']); else - $data = dbunescbin($r[0]['data']); + $data = dbunescbin($r[0]['content']); - $ph = photo_factory($data, $r[0]['type']); + $ph = photo_factory($data, $r[0]['mimetype']); $smallest = 0; if($ph->is_valid()) { // go ahead as if we have just uploaded a new photo to crop - $i = q("select resource_id, scale from photo where resource_id = '%s' and uid = %d and scale = 0", + $i = q("select resource_id, imgscale from photo where resource_id = '%s' and uid = %d and imgscale = 0", dbesc($r[0]['resource_id']), intval(local_channel()) ); @@ -336,7 +336,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { if($i) { $hash = $i[0]['resource_id']; foreach($i as $ii) { - $smallest = intval($ii['scale']); + $smallest = intval($ii['imgscale']); } } } diff --git a/Zotlabs/Module/Dav.php b/Zotlabs/Module/Dav.php index 549c992cc..2fddabe19 100644 --- a/Zotlabs/Module/Dav.php +++ b/Zotlabs/Module/Dav.php @@ -64,6 +64,7 @@ class Dav extends \Zotlabs\Web\Controller { $auth = new \Zotlabs\Storage\BasicAuth(); + $auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . 'WebDAV'); // $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function($userName,$password) { // if(account_verify_password($userName,$password)) diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index b8bac53bb..560038ffc 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -57,9 +57,9 @@ class Directory extends \Zotlabs\Web\Controller { } } - function get() { + function get() { - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { notice( t('Public access denied.') . EOL); return; } diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 2a5a04a2a..c1a0d84bc 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -7,17 +7,13 @@ class Display extends \Zotlabs\Web\Controller { function get($update = 0, $load = false) { - // logger("mod-display: update = $update load = $load"); - - $checkjs = new \Zotlabs\Web\CheckJS(1); - if($load) $_SESSION['loadtime'] = datetime_convert(); - if(intval(get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { notice( t('Public access denied.') . EOL); return; } @@ -185,7 +181,7 @@ class Display extends \Zotlabs\Web\Controller { if($load || ($checkjs->disabled())) { $r = null; - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); $sysid = $sys['channel_id']; @@ -233,7 +229,7 @@ class Display extends \Zotlabs\Web\Controller { elseif($update && !$load) { $r = null; - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); $sysid = $sys['channel_id']; diff --git a/Zotlabs/Module/Editblock.php b/Zotlabs/Module/Editblock.php index a79962033..fb86557f2 100644 --- a/Zotlabs/Module/Editblock.php +++ b/Zotlabs/Module/Editblock.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/acl_selectors.php'); require_once('include/conversation.php'); diff --git a/Zotlabs/Module/Editlayout.php b/Zotlabs/Module/Editlayout.php index c5b50235a..5028882d2 100644 --- a/Zotlabs/Module/Editlayout.php +++ b/Zotlabs/Module/Editlayout.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/acl_selectors.php'); require_once('include/conversation.php'); diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index 43edf2c00..da859de3e 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -87,11 +87,11 @@ class Editpost extends \Zotlabs\Web\Controller { 'hide_location' => true, 'mimetype' => $itm[0]['mimetype'], 'ptyp' => $itm[0]['obj_type'], - 'body' => undo_post_tagging($itm[0]['body']), + 'body' => htmlspecialchars_decode(undo_post_tagging($itm[0]['body']),ENT_COMPAT), 'post_id' => $post_id, 'defloc' => $channel['channel_location'], 'visitor' => true, - 'title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'), + 'title' => htmlspecialchars_decode($itm[0]['title'],ENT_COMPAT), 'category' => $category, 'showacl' => false, 'profile_uid' => $owner_uid, diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index c2346c53b..1b5c320a0 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/acl_selectors.php'); require_once('include/conversation.php'); require_once('include/PermissionDescription.php'); diff --git a/Zotlabs/Module/Events.php b/Zotlabs/Module/Events.php index 9519ca11b..3f3f9fb4c 100644 --- a/Zotlabs/Module/Events.php +++ b/Zotlabs/Module/Events.php @@ -171,7 +171,7 @@ class Events extends \Zotlabs\Web\Controller { foreach($cats as $cat) { $post_tags[] = array( 'uid' => $profile_uid, - 'type' => TERM_CATEGORY, + 'ttype' => TERM_CATEGORY, 'otype' => TERM_OBJ_POST, 'term' => trim($cat), 'url' => $channel['xchan_url'] . '?f=&cat=' . urlencode(trim($cat)) @@ -180,12 +180,12 @@ class Events extends \Zotlabs\Web\Controller { } $datarray = array(); - $datarray['start'] = $start; - $datarray['finish'] = $finish; + $datarray['dtstart'] = $start; + $datarray['dtend'] = $finish; $datarray['summary'] = $summary; $datarray['description'] = $desc; $datarray['location'] = $location; - $datarray['type'] = $type; + $datarray['etype'] = $type; $datarray['adjust'] = $adjust; $datarray['nofinish'] = $nofinish; $datarray['uid'] = local_channel(); @@ -232,7 +232,7 @@ class Events extends \Zotlabs\Web\Controller { } if($share) - proc_run('php',"include/notifier.php","event","$item_id"); + \Zotlabs\Daemon\Master::Summon(array('Notifier','event',$item_id)); } @@ -269,14 +269,14 @@ class Events extends \Zotlabs\Web\Controller { nav_set_selected('all_events'); if((argc() > 2) && (argv(1) === 'ignore') && intval(argv(2))) { - $r = q("update event set ignore = 1 where id = %d and uid = %d", + $r = q("update event set dismissed = 1 where id = %d and uid = %d", intval(argv(2)), intval(local_channel()) ); } if((argc() > 2) && (argv(1) === 'unignore') && intval(argv(2))) { - $r = q("update event set ignore = 0 where id = %d and uid = %d", + $r = q("update event set dismissed = 0 where id = %d and uid = %d", intval(argv(2)), intval(local_channel()) ); @@ -301,7 +301,7 @@ class Events extends \Zotlabs\Web\Controller { $mode = 'view'; $y = 0; $m = 0; - $ignored = ((x($_REQUEST,'ignored')) ? " and ignored = " . intval($_REQUEST['ignored']) . " " : ''); + $ignored = ((x($_REQUEST,'ignored')) ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : ''); // logger('args: ' . print_r(\App::$argv,true)); @@ -358,9 +358,9 @@ class Events extends \Zotlabs\Web\Controller { if(x($_REQUEST,'summary')) $orig_event['summary'] = $_REQUEST['summary']; if(x($_REQUEST,'description')) $orig_event['description'] = $_REQUEST['description']; if(x($_REQUEST,'location')) $orig_event['location'] = $_REQUEST['location']; - if(x($_REQUEST,'start')) $orig_event['start'] = $_REQUEST['start']; - if(x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish']; - if(x($_REQUEST,'type')) $orig_event['type'] = $_REQUEST['type']; + if(x($_REQUEST,'start')) $orig_event['dtstart'] = $_REQUEST['start']; + if(x($_REQUEST,'finish')) $orig_event['dtend'] = $_REQUEST['finish']; + if(x($_REQUEST,'type')) $orig_event['etype'] = $_REQUEST['type']; */ $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : ''); @@ -380,9 +380,9 @@ class Events extends \Zotlabs\Web\Controller { if($orig_event['event_xchan']) $sh_checked .= ' disabled="disabled" '; - $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now'); + $sdt = ((x($orig_event)) ? $orig_event['dtstart'] : 'now'); - $fdt = ((x($orig_event)) ? $orig_event['finish'] : '+1 hour'); + $fdt = ((x($orig_event)) ? $orig_event['dtend'] : '+1 hour'); $tz = date_default_timezone_get(); if(x($orig_event)) @@ -406,7 +406,7 @@ class Events extends \Zotlabs\Web\Controller { $ftext = datetime_convert('UTC',$tz,$fdt); $ftext = substr($ftext,0,14) . "00:00"; - $type = ((x($orig_event)) ? $orig_event['type'] : 'event'); + $type = ((x($orig_event)) ? $orig_event['etype'] : 'event'); $f = get_config('system','event_input_format'); if(! $f) @@ -536,8 +536,8 @@ class Events extends \Zotlabs\Web\Controller { ); } elseif($export) { $r = q("SELECT * from event where uid = %d - AND (( `adjust` = 0 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' ) - OR ( `adjust` = 1 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' )) ", + AND (( `adjust` = 0 AND ( `dtend` >= '%s' or nofinish = 1 ) AND `dtstart` <= '%s' ) + OR ( `adjust` = 1 AND ( `dtend` >= '%s' or nofinish = 1 ) AND `dtstart` <= '%s' )) ", intval(local_channel()), dbesc($start), dbesc($finish), @@ -554,8 +554,8 @@ class Events extends \Zotlabs\Web\Controller { $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan from event left join item on event_hash = resource_id where resource_type = 'event' and event.uid = %d $ignored - AND (( adjust = 0 AND ( finish >= '%s' or nofinish = 1 ) AND start <= '%s' ) - OR ( adjust = 1 AND ( finish >= '%s' or nofinish = 1 ) AND start <= '%s' )) ", + AND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' ) + OR ( adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) ", intval(local_channel()), dbesc($start), dbesc($finish), @@ -576,7 +576,7 @@ class Events extends \Zotlabs\Web\Controller { if($r) { foreach($r as $rr) { - $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); + $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j')); if(! x($links,$j)) $links[$j] = z_root() . '/' . \App::$cmd . '#link-' . $j; } @@ -591,15 +591,15 @@ class Events extends \Zotlabs\Web\Controller { foreach($r as $rr) { - $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); - $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt)); + $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j')); + $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], $fmt) : datetime_convert('UTC','UTC',$rr['dtstart'],$fmt)); $d = day_translate($d); - $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c')); + $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'c') : datetime_convert('UTC','UTC',$rr['dtstart'],'c')); if ($rr['nofinish']){ $end = null; } else { - $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c')); + $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtend'], 'c') : datetime_convert('UTC','UTC',$rr['dtend'],'c')); } diff --git a/Zotlabs/Module/Fbrowser.php b/Zotlabs/Module/Fbrowser.php index eef3cb67d..c534e8f72 100644 --- a/Zotlabs/Module/Fbrowser.php +++ b/Zotlabs/Module/Fbrowser.php @@ -45,10 +45,10 @@ class Fbrowser extends \Zotlabs\Web\Controller { $album = hex2bin(\App::$argv[2]); $sql_extra = sprintf("AND `album` = '%s' ",dbesc($album)); $sql_extra2 = ""; - $path[]=array(z_root()."/fbrowser/image/".\App::$argv[2]."/", $album); + $path[]=array(z_root() . "/fbrowser/image/" . \App::$argv[2] . "/", $album); } - $r = q("SELECT `resource_id`, `id`, `filename`, type, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `description` + $r = q("SELECT `resource_id`, `id`, `filename`, type, min(`imgscale`) AS `hiq`,max(`imgscale`) AS `loq`, `description` FROM `photo` WHERE `uid` = %d $sql_extra GROUP BY `resource_id` $sql_extra2", intval(local_channel()) diff --git a/Zotlabs/Module/Feed.php b/Zotlabs/Module/Feed.php index 9d33ba2c3..47871eafb 100644 --- a/Zotlabs/Module/Feed.php +++ b/Zotlabs/Module/Feed.php @@ -31,7 +31,7 @@ class Feed extends \Zotlabs\Web\Controller { $channel = $r[0]; - if((intval(get_config('system','block_public'))) && (! get_account_id())) + if(observer_prohibited(true)) killme(); logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']); diff --git a/Zotlabs/Module/Filer.php b/Zotlabs/Module/Filer.php index 607d088db..6a57cdb2a 100644 --- a/Zotlabs/Module/Filer.php +++ b/Zotlabs/Module/Filer.php @@ -39,7 +39,7 @@ class Filer extends \Zotlabs\Web\Controller { } else { $filetags = 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) ); diff --git a/Zotlabs/Module/Filerm.php b/Zotlabs/Module/Filerm.php index eb9a42c1e..cbf6a118d 100644 --- a/Zotlabs/Module/Filerm.php +++ b/Zotlabs/Module/Filerm.php @@ -22,7 +22,7 @@ class Filerm extends \Zotlabs\Web\Controller { logger('filerm: tag ' . $term . ' item ' . $item_id); if($item_id && strlen($term)) { - $r = q("delete from term where uid = %d and type = %d and oid = %d and term = '%s'", + $r = q("delete from term where uid = %d and ttype = %d and oid = %d and term = '%s'", intval(local_channel()), intval(($category) ? TERM_CATEGORY : TERM_FILE), intval($item_id), diff --git a/Zotlabs/Module/Follow.php b/Zotlabs/Module/Follow.php index 1701328bf..1df382a89 100644 --- a/Zotlabs/Module/Follow.php +++ b/Zotlabs/Module/Follow.php @@ -53,14 +53,13 @@ class Follow extends \Zotlabs\Web\Controller { // If we can view their stream, pull in some posts if(($result['abook']['abook_their_perms'] & PERMS_R_STREAM) || ($result['abook']['xchan_network'] === 'rss')) - proc_run('php','include/onepoll.php',$result['abook']['abook_id']); + \Zotlabs\Daemon\Master::Summon(array('Onepoll',$result['abook']['abook_id'])); goaway(z_root() . '/connedit/' . $result['abook']['abook_id'] . '?f=&follow=1'); } - function get() { - + function get() { if(! local_channel()) { return login(); } diff --git a/Zotlabs/Module/Fsuggest.php b/Zotlabs/Module/Fsuggest.php deleted file mode 100644 index 143fd34e1..000000000 --- a/Zotlabs/Module/Fsuggest.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php -namespace Zotlabs\Module; - - - -class Fsuggest extends \Zotlabs\Web\Controller { - - function post() { - - if(! local_channel()) { - return; - } - - if(\App::$argc != 2) - return; - - $contact_id = intval(\App::$argv[1]); - - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval(local_channel()) - ); - if(! count($r)) { - notice( t('Contact not found.') . EOL); - return; - } - $contact = $r[0]; - - $new_contact = intval($_POST['suggest']); - - $hash = random_string(); - - $note = escape_tags(trim($_POST['note'])); - - if($new_contact) { - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($new_contact), - intval(local_channel()) - ); - if(count($r)) { - - $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`) - VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')", - intval(local_channel()), - intval($contact_id), - dbesc($r[0]['name']), - dbesc($r[0]['url']), - dbesc($r[0]['request']), - dbesc($r[0]['photo']), - dbesc($hash), - dbesc(datetime_convert()) - ); - $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1", - dbesc($hash), - intval(local_channel()) - ); - if(count($r)) { - $fsuggest_id = $r[0]['id']; - q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d", - dbesc($note), - intval($fsuggest_id), - intval(local_channel()) - ); - proc_run('php', 'include/notifier.php', 'suggest' , $fsuggest_id); - } - - info( t('Friend suggestion sent.') . EOL); - } - - } - - - } - - - - function get() { - - require_once('include/acl_selectors.php'); - - if(! local_channel()) { - notice( t('Permission denied.') . EOL); - return; - } - - if(\App::$argc != 2) - return; - - $contact_id = intval(\App::$argv[1]); - - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval(local_channel()) - ); - if(! count($r)) { - notice( t('Contact not found.') . EOL); - return; - } - $contact = $r[0]; - - $o = '<h3>' . t('Suggest Friends') . '</h3>'; - - $o .= '<div id="fsuggest-desc" >' . sprintf( t('Suggest a friend for %s'), $contact['name']) . '</div>'; - - $o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >'; - - // FIXME contact_selector deprecated, removed - // $o .= contact_selector('suggest','suggest-select', false, - // array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true)); - - - $o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>'; - $o .= '</form>'; - - return $o; - } -} diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php index 6999e77e8..09d761887 100644 --- a/Zotlabs/Module/Getfile.php +++ b/Zotlabs/Module/Getfile.php @@ -21,7 +21,6 @@ namespace Zotlabs\Module; -require_once('include/Contact.php'); require_once('include/attach.php'); diff --git a/Zotlabs/Module/Group.php b/Zotlabs/Module/Group.php index 144797baf..254ee6ef2 100644 --- a/Zotlabs/Module/Group.php +++ b/Zotlabs/Module/Group.php @@ -47,8 +47,8 @@ class Group extends \Zotlabs\Web\Controller { $groupname = notags(trim($_POST['groupname'])); $public = intval($_POST['public']); - if((strlen($groupname)) && (($groupname != $group['name']) || ($public != $group['visible']))) { - $r = q("UPDATE `groups` SET `name` = '%s', visible = %d WHERE `uid` = %d AND `id` = %d", + if((strlen($groupname)) && (($groupname != $group['gname']) || ($public != $group['visible']))) { + $r = q("UPDATE `groups` SET `gname` = '%s', visible = %d WHERE `uid` = %d AND `id` = %d", dbesc($groupname), intval($public), intval(local_channel()), @@ -106,7 +106,7 @@ class Group extends \Zotlabs\Web\Controller { intval(local_channel()) ); if($r) - $result = group_rmv(local_channel(),$r[0]['name']); + $result = group_rmv(local_channel(),$r[0]['gname']); if($result) info( t('Privacy group removed.') . EOL); else @@ -156,10 +156,10 @@ class Group extends \Zotlabs\Web\Controller { if($change) { if(in_array($change,$preselected)) { - group_rmv_member(local_channel(),$group['name'],$change); + group_rmv_member(local_channel(),$group['gname'],$change); } else { - group_add_member(local_channel(),$group['name'],$change); + group_add_member(local_channel(),$group['gname'],$change); } $members = group_get_members($group['id']); @@ -181,7 +181,7 @@ class Group extends \Zotlabs\Web\Controller { $context = $context + array( '$title' => t('Privacy group editor'), - '$gname' => array('groupname',t('Privacy group name: '),$group['name'], ''), + '$gname' => array('groupname',t('Privacy group name: '),$group['gname'], ''), '$gid' => $group['id'], '$drop' => $drop_txt, '$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''), @@ -209,7 +209,7 @@ class Group extends \Zotlabs\Web\Controller { $groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode); } else - group_rmv_member(local_channel(),$group['name'],$member['xchan_hash']); + group_rmv_member(local_channel(),$group['gname'],$member['xchan_hash']); } $r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc", diff --git a/Zotlabs/Module/Help.php b/Zotlabs/Module/Help.php index 4842c56c6..cc46c550b 100644 --- a/Zotlabs/Module/Help.php +++ b/Zotlabs/Module/Help.php @@ -37,7 +37,7 @@ class Help extends \Zotlabs\Web\Controller { $path = trim(substr($dirname,4),'/'); $o .= '<li><a href="help/' . (($path) ? $path . '/' : '') . $fname . '" >' . ucwords(str_replace('_',' ',notags($fname))) . '</a><br />' . - str_replace('$Projectname',\Zotlabs\Project\System::get_platform_name(),substr($rr['text'],0,200)) . '...<br /><br /></li>'; + str_replace('$Projectname',\Zotlabs\Lib\System::get_platform_name(),substr($rr['text'],0,200)) . '...<br /><br /></li>'; } $o .= '</ul>'; diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index dadbf8ff1..122e27e90 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -4,9 +4,9 @@ namespace Zotlabs\Module; // Import a channel, either by direct file upload or via // connection to original server. -require_once('include/Contact.php'); + require_once('include/zot.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/import.php'); @@ -408,8 +408,12 @@ class Import extends \Zotlabs\Web\Controller { $saved = array(); foreach($groups as $group) { $saved[$group['hash']] = array('old' => $group['id']); + if(array_key_exists('name',$group)) { + $group['gname'] = $group['name']; + unset($group['name']); + } unset($group['id']); - $group['uid'] = $channel['channel_id']; + $group['uid'] = $channel['channel_id']; dbesc_array($group); $r = dbq("INSERT INTO groups (`" . implode("`, `", array_keys($group)) @@ -496,11 +500,11 @@ class Import extends \Zotlabs\Web\Controller { // send out refresh requests // notify old server that it may no longer be primary. - proc_run('php','include/notifier.php','location',$channel['channel_id']); + \Zotlabs\Daemon\Master::Summon(array('Notifier','location',$channel['channel_id'])); // This will indirectly perform a refresh_all *and* update the directory - proc_run('php', 'include/directory.php', $channel['channel_id']); + \Zotlabs\Daemon\Master::Summon(array('Directory', $channel['channel_id'])); notice( t('Import completed.') . EOL); diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 93570fdec..2601feb0a 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -17,10 +17,10 @@ namespace Zotlabs\Module; */ require_once('include/crypto.php'); -require_once('include/enotify.php'); require_once('include/items.php'); require_once('include/attach.php'); +use \Zotlabs\Lib as Zlib; class Item extends \Zotlabs\Web\Controller { @@ -56,7 +56,7 @@ class Item extends \Zotlabs\Web\Controller { $remote_xchan = $remote_observer = false; $profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0); - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); if($sys && $profile_uid && ($sys['channel_id'] == $profile_uid) && is_site_admin()) { $uid = intval($sys['channel_id']); @@ -581,7 +581,7 @@ class Item extends \Zotlabs\Web\Controller { if($success['replaced']) { $post_tags[] = array( 'uid' => $profile_uid, - 'type' => $success['termtype'], + 'ttype' => $success['termtype'], 'otype' => TERM_OBJ_POST, 'term' => $success['term'], 'url' => $success['url'] @@ -666,7 +666,7 @@ class Item extends \Zotlabs\Web\Controller { foreach($cats as $cat) { $post_tags[] = array( 'uid' => $profile_uid, - 'type' => TERM_CATEGORY, + 'ttype' => TERM_CATEGORY, 'otype' => TERM_OBJ_POST, 'term' => trim($cat), 'url' => $owner_xchan['xchan_url'] . '?f=&cat=' . urlencode(trim($cat)) @@ -676,7 +676,7 @@ class Item extends \Zotlabs\Web\Controller { if($orig_post) { // preserve original tags - $t = q("select * from term where oid = %d and otype = %d and uid = %d and type in ( %d, %d, %d )", + $t = q("select * from term where oid = %d and otype = %d and uid = %d and ttype in ( %d, %d, %d )", intval($orig_post['id']), intval(TERM_OBJ_POST), intval($profile_uid), @@ -688,7 +688,7 @@ class Item extends \Zotlabs\Web\Controller { foreach($t as $t1) { $post_tags[] = array( 'uid' => $profile_uid, - 'type' => $t1['type'], + 'ttype' => $t1['type'], 'otype' => TERM_OBJ_POST, 'term' => $t1['term'], 'url' => $t1['url'], @@ -901,7 +901,7 @@ class Item extends \Zotlabs\Web\Controller { } } if(! $nopush) - proc_run('php', "include/notifier.php", 'edit_post', $post_id); + \Zotlabs\Daemon\Master::Summon(array('Notifier', 'edit_post', $post_id)); if((x($_REQUEST,'return')) && strlen($return_path)) { logger('return: ' . $return_path); @@ -925,7 +925,7 @@ class Item extends \Zotlabs\Web\Controller { // otherwise it will happen during delivery if(($datarray['owner_xchan'] != $datarray['author_xchan']) && (intval($parent_item['item_wall']))) { - notification(array( + Zlib\Enotify::submit(array( 'type' => NOTIFY_COMMENT, 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], @@ -943,7 +943,7 @@ class Item extends \Zotlabs\Web\Controller { $parent = $post_id; if(($datarray['owner_xchan'] != $datarray['author_xchan']) && ($datarray['item_type'] == ITEM_TYPE_POST)) { - notification(array( + Zlib\Enotify::submit(array( 'type' => NOTIFY_WALL, 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], @@ -1008,7 +1008,7 @@ class Item extends \Zotlabs\Web\Controller { call_hooks('post_local_end', $datarray); if(! $nopush) - proc_run('php', 'include/notifier.php', $notify_type, $post_id); + \Zotlabs\Daemon\Master::Summon(array('Notifier', $notify_type, $post_id)); logger('post_complete'); diff --git a/Zotlabs/Module/Layouts.php b/Zotlabs/Module/Layouts.php index 8a7207fc2..9b9fc22f3 100644 --- a/Zotlabs/Module/Layouts.php +++ b/Zotlabs/Module/Layouts.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index ac8791950..1ca37d646 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -346,7 +346,7 @@ class Like extends \Zotlabs\Web\Controller { // drop_item was not done interactively, so we need to invoke the notifier // in order to push the changes to connections - proc_run('php','include/notifier.php','drop',$rr['id']); + \Zotlabs\Daemon\Master::Summon(array('Notifier','drop',$rr['id'])); } @@ -483,7 +483,7 @@ class Like extends \Zotlabs\Web\Controller { $arr['verb'] = $activity; $arr['obj_type'] = $objtype; - $arr['object'] = $object; + $arr['obj'] = $object; if($target) { $arr['tgt_type'] = $tgttype; @@ -531,7 +531,7 @@ class Like extends \Zotlabs\Web\Controller { } - proc_run('php',"include/notifier.php","like","$post_id"); + \Zotlabs\Daemon\Master::Summon(array('Notifier','like',$post_id)); if($interactive) { notice( t('Action completed.') . EOL); diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php index ef34bb465..e1a3a6abe 100644 --- a/Zotlabs/Module/Linkinfo.php +++ b/Zotlabs/Module/Linkinfo.php @@ -115,7 +115,7 @@ class Linkinfo extends \Zotlabs\Web\Controller { // If this is a Red site, use zrl rather than url so they get zids sent to them by default - if( x($siteinfo,'generator') && (strpos($siteinfo['generator'], \Zotlabs\Project\System::get_platform_name() . ' ') === 0)) + if( x($siteinfo,'generator') && (strpos($siteinfo['generator'], \Zotlabs\Lib\System::get_platform_name() . ' ') === 0)) $template = str_replace('url','zrl',$template); if($siteinfo["title"] == "") { diff --git a/Zotlabs/Module/Lockview.php b/Zotlabs/Module/Lockview.php index 0df0dd4da..4776e1c56 100644 --- a/Zotlabs/Module/Lockview.php +++ b/Zotlabs/Module/Lockview.php @@ -88,10 +88,10 @@ class Lockview extends \Zotlabs\Web\Controller { stringify_array_elms($deny_users,true); if(count($allowed_groups)) { - $r = q("SELECT name FROM `groups` WHERE hash IN ( " . implode(', ', $allowed_groups) . " )"); + $r = q("SELECT gname FROM `groups` WHERE hash IN ( " . implode(', ', $allowed_groups) . " )"); if($r) foreach($r as $rr) - $l[] = '<li><b>' . $rr['name'] . '</b></li>'; + $l[] = '<li><b>' . $rr['gname'] . '</b></li>'; } if(count($allowed_users)) { $r = q("SELECT xchan_name FROM xchan WHERE xchan_hash IN ( " . implode(', ',$allowed_users) . " )"); @@ -100,10 +100,10 @@ class Lockview extends \Zotlabs\Web\Controller { $l[] = '<li>' . $rr['xchan_name'] . '</li>'; } if(count($deny_groups)) { - $r = q("SELECT name FROM `groups` WHERE hash IN ( " . implode(', ', $deny_groups) . " )"); + $r = q("SELECT gname FROM `groups` WHERE hash IN ( " . implode(', ', $deny_groups) . " )"); if($r) foreach($r as $rr) - $l[] = '<li><b><strike>' . $rr['name'] . '</strike></b></li>'; + $l[] = '<li><b><strike>' . $rr['gname'] . '</strike></b></li>'; } if(count($deny_users)) { $r = q("SELECT xchan_name FROM xchan WHERE xchan_hash IN ( " . implode(', ', $deny_users) . " )"); diff --git a/Zotlabs/Module/Locs.php b/Zotlabs/Module/Locs.php index 4b5d58df5..4b1e3ffe2 100644 --- a/Zotlabs/Module/Locs.php +++ b/Zotlabs/Module/Locs.php @@ -34,7 +34,7 @@ class Locs extends \Zotlabs\Web\Controller { dbesc($channel['channel_hash']) ); - proc_run('php','include/notifier.php','location',$channel['channel_id']); + \Zotlabs\Daemon\Master::Summon(array('Notifier','location',$channel['channel_id'])); return; } } @@ -72,7 +72,7 @@ class Locs extends \Zotlabs\Web\Controller { intval($hubloc_id), dbesc($channel['channel_hash']) ); - proc_run('php','include/notifier.php','location',$channel['channel_id']); + \Zotlabs\Daemon\Master::Summon(array('Notifier','location',$channel['channel_id'])); return; } } @@ -91,7 +91,7 @@ class Locs extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); if($_REQUEST['sync']) { - proc_run('php','include/notifier.php','location',$channel['channel_id']); + \Zotlabs\Daemon\Master::Summon(array('Notifier','location',$channel['channel_id'])); info( t('Syncing locations') . EOL); goaway(z_root() . '/locs'); } diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 63db4a317..6798f72a9 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -47,11 +47,9 @@ class Magic extends \Zotlabs\Web\Controller { * */ - $ret = zot_finger((($addr) ? $addr : '[system]@' . $parsed['host']),null); - if($ret['success']) { - $j = json_decode($ret['body'],true); - if($j) - import_xchan($j); + $j = \Zotlabs\Zot\Finger::run((($addr) ? $addr : '[system]@' . $parsed['host']),null); + if($j['success']) { + import_xchan($j); // Now try again diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 35cb3b9bf..aae7585c4 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -5,7 +5,7 @@ require_once('include/acl_selectors.php'); require_once('include/message.php'); require_once('include/zot.php'); require_once("include/bbcode.php"); -require_once('include/Contact.php'); + @@ -32,17 +32,16 @@ class Mail extends \Zotlabs\Web\Controller { if(! $recipient) { $channel = \App::get_channel(); - $ret = zot_finger($rstr,$channel); + $j = \Zotlabs\Zot\Finger::run($rstr,$channel); - if(! $ret['success']) { + if(! $j['success']) { notice( t('Unable to lookup recipient.') . EOL); return; } - $j = json_decode($ret['body'],true); logger('message_post: lookup: ' . $url . ' ' . print_r($j,true)); - if(! ($j['success'] && $j['guid'])) { + if(! $j['guid']) { notice( t('Unable to communicate with requested channel.')); return; } @@ -173,7 +172,7 @@ class Mail extends \Zotlabs\Web\Controller { build_sync_packet(local_channel(),array('mail' => encode_mail($x[0],true))); } - proc_run('php','include/notifier.php','mail',intval(argv(3))); + \Zotlabs\Daemon\Master::Summon(array('Notifier','mail',intval(argv(3)))); if($r) { info( t('Message recalled.') . EOL ); @@ -306,11 +305,6 @@ class Mail extends \Zotlabs\Web\Controller { else \App::$poi = $messages[0]['to']; - // require_once('include/Contact.php'); - - // \App::set_widget('mail_conversant',vcard_from_xchan(\App::$poi,$get_observer_hash,'mail')); - - $tpl = get_markup_template('msg-header.tpl'); \App::$page['htmlhead'] .= replace_macros($tpl, array( diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php index 5ae79dbb2..4ca044c4a 100644 --- a/Zotlabs/Module/Manage.php +++ b/Zotlabs/Module/Manage.php @@ -93,9 +93,9 @@ class Manage extends \Zotlabs\Web\Controller { $channels[$x]['mail'] = intval($mails[0]['total']); - $events = q("SELECT type, start, adjust FROM `event` - WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0 - ORDER BY `start` ASC ", + $events = q("SELECT etype, dtstart, adjust FROM `event` + WHERE `event`.`uid` = %d AND dtstart < '%s' AND dtstart > '%s' and `dismissed` = 0 + ORDER BY `dtstart` ASC ", intval($channels[$x]['channel_id']), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) @@ -108,14 +108,14 @@ class Manage extends \Zotlabs\Web\Controller { $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d'); foreach($events as $e) { $bd = false; - if($e['type'] === 'birthday') { + if($e['etype'] === 'birthday') { $channels[$x]['birthdays'] ++; $bd = true; } else { $channels[$x]['events'] ++; } - if(datetime_convert('UTC', ((intval($e['adjust'])) ? date_default_timezone_get() : 'UTC'), $e['start'], 'Y-m-d') === $str_now) { + if(datetime_convert('UTC', ((intval($e['adjust'])) ? date_default_timezone_get() : 'UTC'), $e['dtstart'], 'Y-m-d') === $str_now) { $channels[$x]['all_events_today'] ++; if($bd) $channels[$x]['birthdays_today'] ++; diff --git a/Zotlabs/Module/Menu.php b/Zotlabs/Module/Menu.php index 9ada63911..e98053f8c 100644 --- a/Zotlabs/Module/Menu.php +++ b/Zotlabs/Module/Menu.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; require_once('include/menu.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); class Menu extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Message.php b/Zotlabs/Module/Message.php index 58a138899..ea2127a1d 100644 --- a/Zotlabs/Module/Message.php +++ b/Zotlabs/Module/Message.php @@ -5,8 +5,6 @@ require_once('include/acl_selectors.php'); require_once('include/message.php'); require_once('include/zot.php'); require_once("include/bbcode.php"); -require_once('include/Contact.php'); - class Message extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Mood.php b/Zotlabs/Module/Mood.php index b1007fd06..d1bd44526 100644 --- a/Zotlabs/Module/Mood.php +++ b/Zotlabs/Module/Mood.php @@ -97,7 +97,7 @@ class Mood extends \Zotlabs\Web\Controller { $item_id = $post['item_id']; if($item_id) { - proc_run('php',"include/notifier.php","activity", $item_id); + \Zotlabs\Daemon\Master::Summon(array('Notifier','activity', $item_id)); } call_hooks('post_local_end', $arr); diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index c88258a78..87ed326e2 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -223,7 +223,7 @@ class Network extends \Zotlabs\Web\Controller { if($x) { $title = replace_macros(get_markup_template("section_title.tpl"),array( - '$title' => t('Privacy group: ') . $x['name'] + '$title' => t('Privacy group: ') . $x['gname'] )); } @@ -385,7 +385,7 @@ class Network extends \Zotlabs\Web\Controller { $abook_uids = " and abook.abook_channel = " . local_channel() . " "; if($firehose && (! get_config('system','disable_discover_tab'))) { - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); $uids = " and item.uid = " . intval($sys['channel_id']) . " "; \App::$data['firehose'] = intval($sys['channel_id']); diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index 3dca1b0b4..30d7c83c6 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/permissions.php'); diff --git a/Zotlabs/Module/Notifications.php b/Zotlabs/Module/Notifications.php index d51d2861c..9da28a360 100644 --- a/Zotlabs/Module/Notifications.php +++ b/Zotlabs/Module/Notifications.php @@ -80,18 +80,18 @@ class Notifications extends \Zotlabs\Web\Controller { $not_tpl = get_markup_template('notify.tpl'); require_once('include/bbcode.php'); - $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc", + $r = q("SELECT * from notify where uid = %d and seen = 0 order by created desc", intval(local_channel()) ); - if (count($r) > 0) { + if ($r > 0) { $notifications_available =1; foreach ($r as $it) { $notif_content .= replace_macros($not_tpl,array( '$item_link' => z_root().'/notify/view/'. $it['id'], '$item_image' => $it['photo'], '$item_text' => strip_tags(bbcode($it['msg'])), - '$item_when' => relative_date($it['date']) + '$item_when' => relative_date($it['created']) )); } } else { diff --git a/Zotlabs/Module/Notify.php b/Zotlabs/Module/Notify.php index 227491145..f592f6f37 100644 --- a/Zotlabs/Module/Notify.php +++ b/Zotlabs/Module/Notify.php @@ -39,7 +39,7 @@ class Notify extends \Zotlabs\Web\Controller { $not_tpl = get_markup_template('notify.tpl'); require_once('include/bbcode.php'); - $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc", + $r = q("SELECT * from notify where uid = %d and seen = 0 order by created desc", intval(local_channel()) ); @@ -49,7 +49,7 @@ class Notify extends \Zotlabs\Web\Controller { '$item_link' => z_root().'/notify/view/'. $it['id'], '$item_image' => $it['photo'], '$item_text' => strip_tags(bbcode($it['msg'])), - '$item_when' => relative_date($it['date']) + '$item_when' => relative_date($it['created']) )); } } diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php index 638ea7e2d..dc0547a42 100644 --- a/Zotlabs/Module/Oep.php +++ b/Zotlabs/Module/Oep.php @@ -181,8 +181,8 @@ class Oep extends \Zotlabs\Web\Controller { function oep_profile_reply($args) { - require_once('include/identity.php'); - require_once('include/Contact.php'); + require_once('include/channel.php'); + $url = $args['url']; if(preg_match('#//(.*?)/(.*?)/(.*?)(/|\?|&|$)#',$url,$matches)) { @@ -249,7 +249,7 @@ class Oep extends \Zotlabs\Web\Controller { $sql_extra = permissions_sql($c[0]['channel_id']); - $p = q("select resource_id from photo where album = '%s' and uid = %d and scale = 0 $sql_extra order by created desc limit 1", + $p = q("select resource_id from photo where album = '%s' and uid = %d and imgscale = 0 $sql_extra order by created desc limit 1", dbesc($res), intval($c[0]['channel_id']) ); @@ -258,7 +258,7 @@ class Oep extends \Zotlabs\Web\Controller { $res = $p[0]['resource_id']; - $r = q("select height, width, scale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by scale asc", + $r = q("select height, width, imgscale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by imgscale asc", intval($c[0]['channel_id']), dbesc($res) ); @@ -276,7 +276,7 @@ class Oep extends \Zotlabs\Web\Controller { if($foundres) { $ret['type'] = 'link'; - $ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['scale']; + $ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['imgscale']; $ret['thumbnail_width'] = $rr['width']; $ret['thumbnail_height'] = $rr['height']; } @@ -310,7 +310,7 @@ class Oep extends \Zotlabs\Web\Controller { $sql_extra = permissions_sql($c[0]['channel_id']); - $p = q("select resource_id from photo where uid = %d and scale = 0 $sql_extra order by created desc limit 1", + $p = q("select resource_id from photo where uid = %d and imgscale = 0 $sql_extra order by created desc limit 1", intval($c[0]['channel_id']) ); if(! $p) @@ -318,7 +318,7 @@ class Oep extends \Zotlabs\Web\Controller { $res = $p[0]['resource_id']; - $r = q("select height, width, scale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by scale asc", + $r = q("select height, width, imgscale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by imgscale asc", intval($c[0]['channel_id']), dbesc($res) ); @@ -336,7 +336,7 @@ class Oep extends \Zotlabs\Web\Controller { if($foundres) { $ret['type'] = 'link'; - $ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['scale']; + $ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['imgscale']; $ret['thumbnail_width'] = $rr['width']; $ret['thumbnail_height'] = $rr['height']; } @@ -372,7 +372,7 @@ class Oep extends \Zotlabs\Web\Controller { $sql_extra = permissions_sql($c[0]['channel_id']); - $r = q("select height, width, scale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by scale asc", + $r = q("select height, width, imgscale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by imgscale asc", intval($c[0]['channel_id']), dbesc($res) ); @@ -390,7 +390,7 @@ class Oep extends \Zotlabs\Web\Controller { if($foundres) { $ret['type'] = 'link'; - $ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['scale']; + $ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['imgscale']; $ret['thumbnail_width'] = $rr['width']; $ret['thumbnail_height'] = $rr['height']; } diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 408688886..92c9ac3c0 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -57,14 +57,14 @@ class Photo extends \Zotlabs\Web\Controller { $uid = $person; - $r = q("SELECT * FROM photo WHERE scale = %d AND uid = %d AND photo_usage = %d LIMIT 1", + $r = q("SELECT * FROM photo WHERE imgscale = %d AND uid = %d AND photo_usage = %d LIMIT 1", intval($resolution), intval($uid), intval(PHOTO_PROFILE) ); if(count($r)) { - $data = dbunescbin($r[0]['data']); - $mimetype = $r[0]['type']; + $data = dbunescbin($r[0]['content']); + $mimetype = $r[0]['mimetype']; } if(intval($r[0]['os_storage'])) $data = file_get_contents($data); @@ -113,7 +113,7 @@ class Photo extends \Zotlabs\Web\Controller { // If using resolution 1, make sure it exists before proceeding: if ($resolution == 1) { - $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND scale = %d LIMIT 1", + $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", dbesc($photo), intval($resolution) ); @@ -121,7 +121,7 @@ class Photo extends \Zotlabs\Web\Controller { $resolution = 2; } - $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND scale = %d LIMIT 1", + $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", dbesc($photo), intval($resolution) ); @@ -133,14 +133,14 @@ class Photo extends \Zotlabs\Web\Controller { // Now we'll see if we can access the photo - $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND scale = %d $sql_extra LIMIT 1", + $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d $sql_extra LIMIT 1", dbesc($photo), intval($resolution) ); if($r && $allowed) { - $data = dbunescbin($r[0]['data']); - $mimetype = $r[0]['type']; + $data = dbunescbin($r[0]['content']); + $mimetype = $r[0]['mimetype']; if(intval($r[0]['os_storage'])) $data = file_get_contents($data); } @@ -154,7 +154,7 @@ class Photo extends \Zotlabs\Web\Controller { // they won't have the photo link, so there's a reasonable chance that the person // might be able to obtain permission to view it. - $r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `scale` = %d LIMIT 1", + $r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `imgscale` = %d LIMIT 1", dbesc($photo), intval($resolution) ); diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 1659350a5..1bdc23897 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -1,12 +1,12 @@ <?php namespace Zotlabs\Module; + require_once('include/photo/photo_driver.php'); require_once('include/photos.php'); require_once('include/items.php'); require_once('include/acl_selectors.php'); require_once('include/bbcode.php'); require_once('include/security.php'); -require_once('include/Contact.php'); require_once('include/attach.php'); require_once('include/text.php'); require_once('include/PermissionDescription.php'); @@ -18,7 +18,7 @@ class Photos extends \Zotlabs\Web\Controller { function init() { - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { return; } @@ -255,13 +255,13 @@ class Photos extends \Zotlabs\Web\Controller { ( (intval($_POST['rotate']) == 1) || (intval($_POST['rotate']) == 2) )) { logger('rotate'); - $r = q("select * from photo where `resource_id` = '%s' and uid = %d and scale = 0 limit 1", + $r = q("select * from photo where `resource_id` = '%s' and uid = %d and imgscale = 0 limit 1", dbesc($resource_id), intval($page_owner_uid) ); if(count($r)) { - $d = (($r[0]['os_storage']) ? @file_get_contents($r[0]['data']) : dbunescbin($r[0]['data'])); - $ph = photo_factory($d, $r[0]['type']); + $d = (($r[0]['os_storage']) ? @file_get_contents($r[0]['content']) : dbunescbin($r[0]['content'])); + $ph = photo_factory($d, $r[0]['mimetype']); if($ph->is_valid()) { $rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 ); $ph->rotate($rotate_deg); @@ -270,9 +270,9 @@ class Photos extends \Zotlabs\Web\Controller { $height = $ph->getHeight(); if(intval($r[0]['os_storage'])) { - @file_put_contents($r[0]['data'],$ph->imageString()); - $data = $r[0]['data']; - $fsize = @filesize($r[0]['data']); + @file_put_contents($r[0]['content'],$ph->imageString()); + $data = $r[0]['content']; + $fsize = @filesize($r[0]['content']); q("update attach set filesize = %d where hash = '%s' and uid = %d limit 1", intval($fsize), dbesc($resource_id), @@ -284,7 +284,7 @@ class Photos extends \Zotlabs\Web\Controller { $fsize = strlen($data); } - $x = q("update photo set data = '%s', `size` = %d, height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 0", + $x = q("update photo set content = '%s', filesize = %d, height = %d, width = %d where `resource_id` = '%s' and uid = %d and imgscale = 0", dbescbin($data), intval($fsize), intval($height), @@ -299,7 +299,7 @@ class Photos extends \Zotlabs\Web\Controller { $width = $ph->getWidth(); $height = $ph->getHeight(); - $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 1", + $x = q("update photo set content = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and imgscale = 1", dbescbin($ph->imageString()), intval($height), intval($width), @@ -314,7 +314,7 @@ class Photos extends \Zotlabs\Web\Controller { $width = $ph->getWidth(); $height = $ph->getHeight(); - $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 2", + $x = q("update photo set content = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and imgscale = 2", dbescbin($ph->imageString()), intval($height), intval($width), @@ -329,7 +329,7 @@ class Photos extends \Zotlabs\Web\Controller { $width = $ph->getWidth(); $height = $ph->getHeight(); - $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 3", + $x = q("update photo set content = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and imgscale = 3", dbescbin($ph->imageString()), intval($height), intval($width), @@ -340,12 +340,12 @@ class Photos extends \Zotlabs\Web\Controller { } } - $p = q("SELECT type, is_nsfw, description, resource_id, scale, allow_cid, allow_gid, deny_cid, deny_gid FROM photo WHERE resource_id = '%s' AND uid = %d ORDER BY scale DESC", + $p = q("SELECT mimetype, is_nsfw, description, resource_id, imgscale, allow_cid, allow_gid, deny_cid, deny_gid FROM photo WHERE resource_id = '%s' AND uid = %d ORDER BY imgscale DESC", dbesc($resource_id), intval($page_owner_uid) ); if($p) { - $ext = $phototypes[$p[0]['type']]; + $ext = $phototypes[$p[0]['mimetype']]; $r = q("UPDATE `photo` SET `description` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource_id` = '%s' AND `uid` = %d", dbesc($desc), @@ -440,7 +440,7 @@ class Photos extends \Zotlabs\Web\Controller { if($success['replaced']) { $post_tags[] = array( 'uid' => $profile_uid, - 'type' => $success['termtype'], + 'ttype' => $success['termtype'], 'otype' => TERM_OBJ_POST, 'term' => $success['term'], 'url' => $success['url'] @@ -510,7 +510,7 @@ class Photos extends \Zotlabs\Web\Controller { - function get() { + function get() { // URLs: // photos/name @@ -518,7 +518,7 @@ class Photos extends \Zotlabs\Web\Controller { // photos/name/image/xxxxx - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { notice( t('Public access denied.') . EOL); return; } @@ -611,7 +611,7 @@ class Photos extends \Zotlabs\Web\Controller { /* Show space usage */ - $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(\App::$data['channel']['channel_account_id']) ); @@ -704,8 +704,8 @@ class Photos extends \Zotlabs\Web\Controller { \App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$cmd) . '" title="oembed" />' . "\r\n"; - $r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s' - AND `scale` <= 4 and photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`", + $r = q("SELECT `resource_id`, max(`imgscale`) AS `imgscale` FROM `photo` WHERE `uid` = %d AND `album` = '%s' + AND `imgscale` <= 4 and photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`", intval($owner_uid), dbesc($album), intval(PHOTO_NORMAL), @@ -725,9 +725,9 @@ class Photos extends \Zotlabs\Web\Controller { $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 ) and is_nsfw = %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 ) and is_nsfw = %d $sql_extra GROUP BY resource_id) ph + ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale) ORDER BY created $order LIMIT %d OFFSET %d", intval($owner_uid), dbesc($album), @@ -777,7 +777,7 @@ class Photos extends \Zotlabs\Web\Controller { else $twist = 'rotright'; - $ext = $phototypes[$rr['type']]; + $ext = $phototypes[$rr['mimetype']]; $imgalt_e = $rr['filename']; $desc_e = $rr['description']; @@ -790,7 +790,7 @@ class Photos extends \Zotlabs\Web\Controller { '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, @@ -852,8 +852,8 @@ class Photos extends \Zotlabs\Web\Controller { // fetch image, item containing image, then comments - $ph = q("SELECT id,aid,uid,xchan,resource_id,created,edited,title,`description`,album,filename,`type`,height,width,`size`,scale,photo_usage,is_nsfw,allow_cid,allow_gid,deny_cid,deny_gid FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' - $sql_extra ORDER BY `scale` ASC ", + $ph = q("SELECT id,aid,uid,xchan,resource_id,created,edited,title,`description`,album,filename,mimetype,height,width,filesize,imgscale,photo_usage,is_nsfw,allow_cid,allow_gid,deny_cid,deny_gid FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' + $sql_extra ORDER BY `imgscale` ASC ", intval($owner_uid), dbesc($datum) ); @@ -884,7 +884,7 @@ class Photos extends \Zotlabs\Web\Controller { $order = 'DESC'; - $prvnxt = q("SELECT `resource_id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0 + $prvnxt = q("SELECT `resource_id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `imgscale` = 0 $sql_extra ORDER BY `created` $order ", dbesc($ph[0]['album']), intval($owner_uid) @@ -911,7 +911,7 @@ class Photos extends \Zotlabs\Web\Controller { if(count($ph) == 1) $hires = $lores = $ph[0]; if(count($ph) > 1) { - if($ph[1]['scale'] == 2) { + if($ph[1]['imgscale'] == 2) { // original is 640 or less, we can display it directly $hires = $lores = $ph[0]; } @@ -949,9 +949,9 @@ class Photos extends \Zotlabs\Web\Controller { $prevlink = array($prevlink, t('Previous')); $photo = array( - 'href' => z_root() . '/photo/' . $hires['resource_id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], + 'href' => z_root() . '/photo/' . $hires['resource_id'] . '-' . $hires['imgscale'] . '.' . $phototypes[$hires['mimetype']], 'title'=> t('View Full Size'), - 'src' => z_root() . '/photo/' . $lores['resource_id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis') + 'src' => z_root() . '/photo/' . $lores['resource_id'] . '-' . $lores['imgscale'] . '.' . $phototypes[$lores['mimetype']] . '?f=&_u=' . datetime_convert('','','','ymdhis') ); if($nextlink) @@ -1277,28 +1277,25 @@ class Photos extends \Zotlabs\Web\Controller { \App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$cmd) . '" title="oembed" />' . "\r\n"; - $r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' + $r = q("SELECT `resource_id`, max(`imgscale`) AS `imgscale` FROM `photo` WHERE `uid` = %d and photo_usage in ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`", intval(\App::$data['channel']['channel_id']), - dbesc('Contact Photos'), - dbesc( t('Contact Photos')), intval(PHOTO_NORMAL), intval(PHOTO_PROFILE), intval($unsafe) ); - if(count($r)) { + if($r) { \App::set_pager_total(count($r)); \App::set_pager_itemspage(60); } - $r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.album, p.scale, p.created FROM photo p INNER JOIN - (SELECT resource_id, max(scale) scale FROM photo - WHERE uid=%d AND album != '%s' AND album != '%s' - AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra group by resource_id) ph - ON (p.resource_id = ph.resource_id and p.scale = ph.scale) ORDER by p.created DESC LIMIT %d OFFSET %d", + $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.album, p.imgscale, p.created FROM photo p + INNER JOIN ( SELECT resource_id, max(imgscale) imgscale FROM photo + WHERE uid = %d AND photo_usage IN ( %d, %d ) + AND is_nsfw = %d $sql_extra group by resource_id ) ph + ON (p.resource_id = ph.resource_id and p.imgscale = ph.imgscale) + ORDER by p.created DESC LIMIT %d OFFSET %d", intval(\App::$data['channel']['channel_id']), - dbesc('Contact Photos'), - dbesc( t('Contact Photos')), intval(PHOTO_NORMAL), intval(PHOTO_PROFILE), intval($unsafe), @@ -1309,14 +1306,14 @@ class Photos extends \Zotlabs\Web\Controller { $photos = array(); - if(count($r)) { + if($r) { $twist = 'rotright'; foreach($r as $rr) { if($twist == 'rotright') $twist = 'rotleft'; else $twist = 'rotright'; - $ext = $phototypes[$rr['type']]; + $ext = $phototypes[$rr['mimetype']]; if(\App::get_template_engine() === 'internal') { $alt_e = template_escape($rr['filename']); @@ -1332,7 +1329,7 @@ class Photos extends \Zotlabs\Web\Controller { 'twist' => ' ' . $twist . rand(2,4), 'link' => z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id'], 'title' => t('View Photo'), - 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, + 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . ((($rr['imgscale']) == 6) ? 4 : $rr['imgscale']) . '.' . $ext, 'alt' => $alt_e, 'album' => array( 'link' => z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . bin2hex($rr['album']), diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index bea4a08b7..5cbf45daa 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -1,12 +1,13 @@ <?php namespace Zotlabs\Module; + /** * @file mod/ping.php * */ require_once('include/bbcode.php'); -require_once('include/notify.php'); + /** * @brief do several updates when pinged. @@ -172,7 +173,7 @@ class Ping extends \Zotlabs\Web\Controller { ); break; case 'all_events': - $r = q("update event set `ignore` = 1 where `ignore` = 0 and uid = %d AND start < '%s' AND start > '%s' ", + $r = q("update event set `dimissed` = 1 where `dismissed` = 0 and uid = %d AND dtstart < '%s' AND dtstart > '%s' ", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) @@ -208,17 +209,17 @@ class Ping extends \Zotlabs\Web\Controller { ); if($t && intval($t[0]['total']) > 49) { $z = q("select * from notify where uid = %d - and seen = 0 order by date desc limit 50", + and seen = 0 order by created desc limit 50", intval(local_channel()) ); } else { $z1 = q("select * from notify where uid = %d - and seen = 0 order by date desc limit 50", + and seen = 0 order by created desc limit 50", intval(local_channel()) ); $z2 = q("select * from notify where uid = %d - and seen = 1 order by date desc limit %d", + and seen = 1 order by created desc limit %d", intval(local_channel()), intval(50 - intval($t[0]['total'])) ); @@ -229,10 +230,10 @@ class Ping extends \Zotlabs\Web\Controller { foreach($z as $zz) { $notifs[] = array( 'notify_link' => z_root() . '/notify/view/' . $zz['id'], - 'name' => $zz['name'], + 'name' => $zz['xname'], 'url' => $zz['url'], 'photo' => $zz['photo'], - 'when' => relative_date($zz['date']), + 'when' => relative_date($zz['created']), 'hclass' => (($zz['seen']) ? 'notify-seen' : 'notify-unseen'), 'message' => strip_tags(bbcode($zz['msg'])) ); @@ -285,7 +286,7 @@ class Ping extends \Zotlabs\Web\Controller { foreach($r as $item) { if((argv(1) === 'home') && (! intval($item['item_wall']))) continue; - $result[] = format_notification($item); + $result[] = \Zotlabs\Lib\Enotify::format($item); } } // logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA); @@ -324,9 +325,9 @@ class Ping extends \Zotlabs\Web\Controller { $result = array(); $r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash - WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0 - and type in ( 'event', 'birthday' ) - ORDER BY `start` DESC LIMIT 1000", + WHERE `event`.`uid` = %d AND dtstart < '%s' AND dtstart > '%s' and `dismissed` = 0 + and etype in ( 'event', 'birthday' ) + ORDER BY `dtstart` DESC LIMIT 1000", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) @@ -335,14 +336,14 @@ class Ping extends \Zotlabs\Web\Controller { if($r) { foreach($r as $rr) { if($rr['adjust']) - $md = datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'Y/m'); + $md = datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'Y/m'); else - $md = datetime_convert('UTC', 'UTC', $rr['start'], 'Y/m'); + $md = datetime_convert('UTC', 'UTC', $rr['dtstart'], 'Y/m'); - $strt = datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['start']); + $strt = datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart']); $today = ((substr($strt, 0, 10) === datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d')) ? true : false); - $when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); + $when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); $result[] = array( 'notify_link' => z_root() . '/events', // FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'], @@ -442,10 +443,10 @@ class Ping extends \Zotlabs\Web\Controller { $t5 = dba_timer(); if($vnotify & (VNOTIFY_EVENT|VNOTIFY_EVENTTODAY|VNOTIFY_BIRTHDAY)) { - $events = q("SELECT type, start, adjust FROM `event` - WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0 - and type in ( 'event', 'birthday' ) - ORDER BY `start` ASC ", + $events = q("SELECT etype, dtstart, adjust FROM `event` + WHERE `event`.`uid` = %d AND dtstart < '%s' AND dtstart > '%s' and `dismissed` = 0 + and etype in ( 'event', 'birthday' ) + ORDER BY `dtstart` ASC ", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) @@ -458,14 +459,14 @@ class Ping extends \Zotlabs\Web\Controller { $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d'); foreach($events as $x) { $bd = false; - if($x['type'] === 'birthday') { + if($x['etype'] === 'birthday') { $result['birthdays'] ++; $bd = true; } else { $result['events'] ++; } - if(datetime_convert('UTC', ((intval($x['adjust'])) ? date_default_timezone_get() : 'UTC'), $x['start'], 'Y-m-d') === $str_now) { + if(datetime_convert('UTC', ((intval($x['adjust'])) ? date_default_timezone_get() : 'UTC'), $x['dtstart'], 'Y-m-d') === $str_now) { $result['all_events_today'] ++; if($bd) $result['birthdays_today'] ++; diff --git a/Zotlabs/Module/Poke.php b/Zotlabs/Module/Poke.php index 123ecbc7b..cf8d83023 100644 --- a/Zotlabs/Module/Poke.php +++ b/Zotlabs/Module/Poke.php @@ -115,7 +115,7 @@ class Poke extends \Zotlabs\Web\Controller { ), ); - $arr['object'] = json_encode($obj); + $arr['obj'] = json_encode($obj); $arr['item_origin'] = 1; $arr['item_wall'] = 1; diff --git a/Zotlabs/Module/Prate.php b/Zotlabs/Module/Prate.php index 65bbcca9a..2a8539ed0 100644 --- a/Zotlabs/Module/Prate.php +++ b/Zotlabs/Module/Prate.php @@ -85,7 +85,7 @@ class Prate extends \Zotlabs\Web\Controller { $record = $z[0]['xlink_id']; } if($record) { - proc_run('php','include/ratenotif.php','rating',$record); + \Zotlabs\Daemon\Master::Summon(array('Ratenotif','rating',$record)); } json_return_and_die(array('result' => true));; diff --git a/Zotlabs/Module/Probe.php b/Zotlabs/Module/Probe.php index 79abe9819..dda792131 100644 --- a/Zotlabs/Module/Probe.php +++ b/Zotlabs/Module/Probe.php @@ -20,17 +20,17 @@ class Probe extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); $addr = trim($_GET['addr']); $do_import = ((intval($_GET['import']) && is_site_admin()) ? true : false); - $res = zot_finger($addr,$channel,false); + + $j = \Zotlabs\Zot\Finger::run($addr,$channel,false); + + // $res = zot_finger($addr,$channel,false); + $o .= '<pre>'; - if($res['success']) - $j = json_decode($res['body'],true); - else { + if(! $j['success']) { $o .= sprintf( t('Fetching URL returns error: %1$s'),$res['error'] . "\r\n\r\n"); $o .= "<strong>https connection failed. Trying again with auto failover to http.</strong>\r\n\r\n"; - $res = zot_finger($addr,$channel,true); - if($res['success']) - $j = json_decode($res['body'],true); - else + $j = \Zotlabs\Zot\Finger::run($addr,$channel,true); + if(! $j['success']) $o .= sprintf( t('Fetching URL returns error: %1$s'),$res['error'] . "\r\n\r\n"); } diff --git a/Zotlabs/Module/Profile.php b/Zotlabs/Module/Profile.php index 04a64fe76..8bf358bc8 100644 --- a/Zotlabs/Module/Profile.php +++ b/Zotlabs/Module/Profile.php @@ -55,8 +55,8 @@ class Profile extends \Zotlabs\Web\Controller { function get() { - if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) { - return login(); + if(observer_prohibited(true)) { + return login(); } $groups = array(); diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index 8f879503c..6129a7492 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -9,7 +9,7 @@ namespace Zotlabs\Module; require_once('include/photo/photo_driver.php'); require_once('include/photos.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); /* @brief Function for sync'ing permissions of profile-photos and their profile * @@ -93,7 +93,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { $srcW = $_POST['xfinal'] - $srcX; $srcH = $_POST['yfinal'] - $srcY; - $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND scale = %d LIMIT 1", + $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND imgscale = %d LIMIT 1", dbesc($image_id), dbesc(local_channel()), intval($scale)); @@ -101,9 +101,9 @@ class Profile_photo extends \Zotlabs\Web\Controller { if($r) { $base_image = $r[0]; - $base_image['data'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['data']) : dbunescbin($base_image['data'])); + $base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['content']) : dbunescbin($base_image['content'])); - $im = photo_factory($base_image['data'], $base_image['type']); + $im = photo_factory($base_image['content'], $base_image['mimetype']); if($im->is_valid()) { $im->cropImage(300,$srcX,$srcY,$srcW,$srcH); @@ -113,25 +113,25 @@ class Profile_photo extends \Zotlabs\Web\Controller { $p = array('aid' => $aid, 'uid' => local_channel(), 'resource_id' => $base_image['resource_id'], 'filename' => $base_image['filename'], 'album' => t('Profile Photos')); - $p['scale'] = 4; + $p['imgscale'] = 4; $p['photo_usage'] = (($is_default_profile) ? PHOTO_PROFILE : PHOTO_NORMAL); $r1 = $im->save($p); $im->scaleImage(80); - $p['scale'] = 5; + $p['imgscale'] = 5; $r2 = $im->save($p); $im->scaleImage(48); - $p['scale'] = 6; + $p['imgscale'] = 6; $r3 = $im->save($p); if($r1 === false || $r2 === false || $r3 === false) { // if one failed, delete them all so we can start over. notice( t('Image resize failed.') . EOL ); - $x = q("delete from photo where resource_id = '%s' and uid = %d and scale >= 4 ", + $x = q("delete from photo where resource_id = '%s' and uid = %d and imgscale >= 4 ", dbesc($base_image['resource_id']), local_channel() ); @@ -179,7 +179,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { info( t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL); // Update directory in background - proc_run('php',"include/directory.php",$channel['channel_id']); + \Zotlabs\Daemon\Master::Summon(array('Directory',$channel['channel_id'])); // Now copy profile-permissions to pictures, to prevent privacyleaks by automatically created folder 'Profile Pictures' @@ -208,7 +208,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { logger('attach_store: ' . print_r($res,true)); if($res && intval($res['data']['is_photo'])) { - $i = q("select * from photo where resource_id = '%s' and uid = %d order by scale", + $i = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale", dbesc($hash), intval(local_channel()) ); @@ -220,11 +220,11 @@ class Profile_photo extends \Zotlabs\Web\Controller { $os_storage = false; foreach($i as $ii) { - if(intval($ii['scale']) < 2) { - $smallest = intval($ii['scale']); + if(intval($ii['imgscale']) < 2) { + $smallest = intval($ii['imgscale']); $os_storage = intval($ii['os_storage']); - $imagedata = $ii['data']; - $filetype = $ii['type']; + $imagedata = $ii['content']; + $filetype = $ii['mimetype']; } } } @@ -250,7 +250,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { */ - function get() { + function get() { if(! local_channel()) { notice( t('Permission denied.') . EOL ); @@ -275,7 +275,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { $resource_id = argv(2); - $r = q("SELECT id, album, scale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY scale ASC", + $r = q("SELECT id, album, imgscale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY imgscale ASC", intval(local_channel()), dbesc($resource_id) ); @@ -285,7 +285,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { } $havescale = false; foreach($r as $rr) { - if($rr['scale'] == 5) + if($rr['imgscale'] == 5) $havescale = true; } @@ -311,11 +311,11 @@ class Profile_photo extends \Zotlabs\Web\Controller { ); profile_photo_set_profile_perms(); //Reset default photo permissions to public - proc_run('php','include/directory.php',local_channel()); + \Zotlabs\Daemon\Master::Summon(array('Directory',local_channel())); goaway(z_root() . '/profiles'); } - $r = q("SELECT `data`, `type`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", + $r = q("SELECT content, mimetype, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", intval($r[0]['id']), intval(local_channel()) @@ -326,15 +326,15 @@ class Profile_photo extends \Zotlabs\Web\Controller { } if(intval($r[0]['os_storage'])) - $data = @file_get_contents($r[0]['data']); + $data = @file_get_contents($r[0]['content']); else - $data = dbunescbin($r[0]['data']); + $data = dbunescbin($r[0]['content']); - $ph = photo_factory($data, $r[0]['type']); + $ph = photo_factory($data, $r[0]['mimetype']); $smallest = 0; if($ph->is_valid()) { // go ahead as if we have just uploaded a new photo to crop - $i = q("select resource_id, scale from photo where resource_id = '%s' and uid = %d order by scale", + $i = q("select resource_id, imgscale from photo where resource_id = '%s' and uid = %d order by imgscale", dbesc($r[0]['resource_id']), intval(local_channel()) ); @@ -342,8 +342,8 @@ class Profile_photo extends \Zotlabs\Web\Controller { if($i) { $hash = $i[0]['resource_id']; foreach($i as $ii) { - if(intval($ii['scale']) < 2) { - $smallest = intval($ii['scale']); + if(intval($ii['imgscale']) < 2) { + $smallest = intval($ii['imgscale']); } } } diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 72edf396f..06e5cfd7b 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -1,7 +1,8 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); +require_once('include/selectors.php'); class Profiles extends \Zotlabs\Web\Controller { @@ -66,16 +67,16 @@ class Profiles extends \Zotlabs\Web\Controller { $name = t('Profile-') . ($num_profiles + 1); - $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1", + $r1 = q("SELECT `fullname`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1", intval(local_channel())); - $r2 = q("INSERT INTO `profile` (`aid`, `uid` , `profile_guid`, `profile_name` , `name`, `photo`, `thumb`) + $r2 = q("INSERT INTO `profile` (`aid`, `uid` , `profile_guid`, `profile_name` , `fullname`, `photo`, `thumb`) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s' )", intval(get_account_id()), intval(local_channel()), dbesc(random_string()), dbesc($name), - dbesc($r1[0]['name']), + dbesc($r1[0]['fullname']), dbesc($r1[0]['photo']), dbesc($r1[0]['thumb']) ); @@ -276,14 +277,14 @@ class Profiles extends \Zotlabs\Web\Controller { $name = escape_tags(trim($_POST['name'])); - if($orig[0]['name'] != $name) { + if($orig[0]['fullname'] != $name) { $namechanged = true; $v = validate_channelname($name); if($v) { notice($v); $namechanged = false; - $name = $orig[0]['name']; + $name = $orig[0]['fullname']; } } @@ -349,7 +350,7 @@ class Profiles extends \Zotlabs\Web\Controller { $withchanged = false; if(strlen($with)) { - if($with != strip_tags($orig[0]['with'])) { + if($with != strip_tags($orig[0]['partner'])) { $withchanged = true; $prf = ''; $lookup = $with; @@ -381,7 +382,7 @@ class Profiles extends \Zotlabs\Web\Controller { } } else - $with = $orig[0]['with']; + $with = $orig[0]['partner']; } $profile_fields_basic = get_profile_fields_basic(); @@ -438,7 +439,7 @@ class Profiles extends \Zotlabs\Web\Controller { $changes[] = t('Dislikes'); $value = $dislikes; } - if($work != $orig[0]['work']) { + if($work != $orig[0]['employment']) { $changes[] = t('Work/Employment'); } if($religion != $orig[0]['religion']) { @@ -485,7 +486,7 @@ class Profiles extends \Zotlabs\Web\Controller { $r = q("UPDATE `profile` SET `profile_name` = '%s', - `name` = '%s', + `fullname` = '%s', `pdesc` = '%s', `gender` = '%s', `dob` = '%s', @@ -495,7 +496,7 @@ class Profiles extends \Zotlabs\Web\Controller { `postal_code` = '%s', `country_name` = '%s', `marital` = '%s', - `with` = '%s', + `partner` = '%s', `howlong` = '%s', `sexual` = '%s', `homepage` = '%s', @@ -514,7 +515,7 @@ class Profiles extends \Zotlabs\Web\Controller { `tv` = '%s', `film` = '%s', `romance` = '%s', - `work` = '%s', + `employment` = '%s', `education` = '%s', `hide_friends` = %d WHERE `id` = %d AND `uid` = %d", @@ -584,13 +585,13 @@ class Profiles extends \Zotlabs\Web\Controller { if($is_default) { // reload the info for the sidebar widget - why does this not work? profile_load($a,$channel['channel_address']); - proc_run('php','include/directory.php',local_channel()); + \Zotlabs\Daemon\Master::Summon(array('Directory',local_channel())); } } } - function get() { + function get() { $o = ''; @@ -601,7 +602,7 @@ class Profiles extends \Zotlabs\Web\Controller { return; } - require_once('include/identity.php'); + require_once('include/channel.php'); $profile_fields_basic = get_profile_fields_basic(); $profile_fields_advanced = get_profile_fields_advanced(); @@ -625,12 +626,7 @@ class Profiles extends \Zotlabs\Web\Controller { return; } - require_once('include/profile_selectors.php'); - - $editselect = 'none'; - // if(feature_enabled(local_channel(),'richtext')) - // $editselect = 'textareas'; \App::$page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( '$baseurl' => z_root(), @@ -714,7 +710,7 @@ class Profiles extends \Zotlabs\Web\Controller { '$is_default' => $is_default, '$default' => t('This is your default profile.') . EOL . translate_scope(map_scope($channel['channel_r_profile'])), '$advanced' => $advanced, - '$name' => array('name', t('Your full name'), $r[0]['name'], t('Required'), '*'), + '$name' => array('name', t('Your full name'), $r[0]['fullname'], t('Required'), '*'), '$pdesc' => array('pdesc', t('Title/Description'), $r[0]['pdesc']), '$dob' => dob($r[0]['dob']), '$hide_friends' => $hide_friends, @@ -727,7 +723,7 @@ class Profiles extends \Zotlabs\Web\Controller { '$gender_min' => gender_selector_min($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$marital_min' => marital_selector_min($r[0]['marital']), - '$with' => array('with', t("Who (if applicable)"), $r[0]['with'], t('Examples: cathy123, Cathy Williams, cathy@example.com')), + '$with' => array('with', t("Who (if applicable)"), $r[0]['partner'], t('Examples: cathy123, Cathy Williams, cathy@example.com')), '$howlong' => array('howlong', t('Since (date)'), ($r[0]['howlong'] === NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))), '$sexual' => sexpref_selector($r[0]['sexual']), '$sexual_min' => sexpref_selector_min($r[0]['sexual']), @@ -745,7 +741,7 @@ class Profiles extends \Zotlabs\Web\Controller { '$film' => array('film', t('Film/Dance/Culture/Entertainment'), $r[0]['film']), '$interest' => array('interest', t('Hobbies/Interests'), $r[0]['interest']), '$romance' => array('romance',t('Love/Romance'), $r[0]['romance']), - '$work' => array('work', t('Work/Employment'), $r[0]['work']), + '$work' => array('work', t('Work/Employment'), $r[0]['employment']), '$education' => array('education', t('School/Education'), $r[0]['education']), '$contact' => array('contact', t('Contact information and social networks'), $r[0]['contact']), '$channels' => array('channels', t('My other channels'), $r[0]['channels']), @@ -761,7 +757,7 @@ class Profiles extends \Zotlabs\Web\Controller { $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_channel()); - if(count($r)) { + if($r) { $tpl = get_markup_template('profile_entry.tpl'); foreach($r as $rr) { @@ -782,10 +778,7 @@ class Profiles extends \Zotlabs\Web\Controller { '$cr_new' => t('Create New'), '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"), '$profiles' => $profiles - )); - - - + )); } return $o; diff --git a/Zotlabs/Module/Profperm.php b/Zotlabs/Module/Profperm.php index 94267aaac..33e9d1ece 100644 --- a/Zotlabs/Module/Profperm.php +++ b/Zotlabs/Module/Profperm.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/Contact.php'); + require_once('include/photos.php'); diff --git a/Zotlabs/Module/Pubsites.php b/Zotlabs/Module/Pubsites.php index 9313a3c5a..0dda08e6d 100644 --- a/Zotlabs/Module/Pubsites.php +++ b/Zotlabs/Module/Pubsites.php @@ -28,10 +28,11 @@ class Pubsites extends \Zotlabs\Web\Controller { if($ret['success']) { $j = json_decode($ret['body'],true); if($j) { - $o .= '<table class="table table-striped table-hover"><tr><td>' . t('Hub URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td colspan="2">' . t('Ratings') . '</td></tr>'; + $o .= '<table class="table table-striped table-hover"><tr><td>' . t('Hub URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Stats') . '</td><td>' . t('Software') . '</td><td colspan="2">' . t('Ratings') . '</td></tr>'; if($j['sites']) { foreach($j['sites'] as $jj) { - if($jj['project'] !== \Zotlabs\Project\System::get_platform_name()) + $m = parse_url($jj['url']); + if(strpos($jj['project'],\Zotlabs\Lib\System::get_platform_name()) === false) continue; $host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3)); $rate_links = ((local_channel()) ? '<td><a href="rate?f=&target=' . $host . '" class="btn-btn-default"><i class="fa fa-check-square-o"></i> ' . t('Rate') . '</a></td>' : ''); @@ -43,7 +44,7 @@ class Pubsites extends \Zotlabs\Web\Controller { $location = '<br /> '; } $urltext = str_replace(array('https://'), '', $jj['url']); - $o .= '<tr><td><a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" ><i class="fa fa-link"></i> ' . $urltext . '</a>' . $location . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="fa fa-eye"></i> ' . t('View') . '</a></td>' . $rate_links . '</tr>'; + $o .= '<tr><td><a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" ><i class="fa fa-link"></i> ' . $urltext . '</a>' . $location . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . '<a target="stats" href="https://hubchart-tarine.rhcloud.com/hub.jsp?hubFqdn=' . $m['host'] . '"><i class="fa fa-area-chart"></i></a></td><td>' . ucwords($jj['project']) . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="fa fa-eye"></i> ' . t('View') . '</a></td>' . $rate_links . '</tr>'; } } diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index adc16e6e6..312be7718 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -12,7 +12,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $_SESSION['loadtime'] = datetime_convert(); - if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) { + if(observer_prohibited(true)) { return login(); } @@ -71,7 +71,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); } - require_once('include/identity.php'); + require_once('include/channel.php'); require_once('include/security.php'); if(get_config('system','site_firehose')) { diff --git a/Zotlabs/Module/Randprof.php b/Zotlabs/Module/Randprof.php index 86b25c22a..dc2e925fe 100644 --- a/Zotlabs/Module/Randprof.php +++ b/Zotlabs/Module/Randprof.php @@ -6,7 +6,6 @@ namespace Zotlabs\Module; class Randprof extends \Zotlabs\Web\Controller { function init() { - require_once('include/Contact.php'); $x = random_profile(); if($x) goaway(chanlink_url($x)); diff --git a/Zotlabs/Module/Rate.php b/Zotlabs/Module/Rate.php index e2c05b6d4..da23b840e 100644 --- a/Zotlabs/Module/Rate.php +++ b/Zotlabs/Module/Rate.php @@ -102,14 +102,12 @@ class Rate extends \Zotlabs\Web\Controller { } if($record) { - proc_run('php','include/ratenotif.php','rating',$record); + \Zotlabs\Daemon\Master::Summon(array('Ratenotif','rating',$record)); } } - - - function get() { + function get() { if(! local_channel()) { notice( t('Permission denied.') . EOL); diff --git a/Zotlabs/Module/Ratings.php b/Zotlabs/Module/Ratings.php index 802bbfec2..969fb5015 100644 --- a/Zotlabs/Module/Ratings.php +++ b/Zotlabs/Module/Ratings.php @@ -8,7 +8,7 @@ class Ratings extends \Zotlabs\Web\Controller { function init() { - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { return; } @@ -80,9 +80,9 @@ class Ratings extends \Zotlabs\Web\Controller { - function get() { + function get() { - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { notice( t('Public access denied.') . EOL); return; } diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php new file mode 100644 index 000000000..ed4f87e7e --- /dev/null +++ b/Zotlabs/Module/React.php @@ -0,0 +1,51 @@ +<?php + +namespace Zotlabs\Module; + + +class React extends \Zotlabs\Web\Controller { + + function get() { + if(! local_channel()) + return; + + $postid = $_REQUEST['postid']; + + if(! $postid) + return; + + $emoji = $_REQUEST['emoji']; + if($_REQUEST['emoji']) { + + $i = q("select * from item where id = %d and uid = %d", + intval($postid), + intval(local_channel()) + ); + + if(! $i) + return; + + $channel = \App::get_channel(); + + $n = array(); + $n['aid'] = $channel['channel_account_id']; + $n['uid'] = $channel['channel_id']; + $n['item_origin'] = true; + $n['parent'] = $postid; + $n['parent_mid'] = $i[0]['mid']; + $n['mid'] = item_message_id(); + $n['verb'] = ACTIVITY_REACT . '#' . $emoji; + $n['body'] = "\n\n[zmg=32x32]" . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]' . "\n\n"; + $n['author_xchan'] = $channel['channel_hash']; + + $x = item_store($n); + if($x['success']) { + $nid = $x['item_id']; + \Zotlabs\Daemon\Master::Summon(array('Notifier','like',$nid)); + } + + } + + } + +}
\ No newline at end of file diff --git a/Zotlabs/Module/Regdir.php b/Zotlabs/Module/Regdir.php index 65f8daf67..48a7cc16d 100644 --- a/Zotlabs/Module/Regdir.php +++ b/Zotlabs/Module/Regdir.php @@ -60,14 +60,11 @@ class Regdir extends \Zotlabs\Web\Controller { json_return_and_die($result); } - $f = zot_finger('[system]@' . $m['host']); - if($f['success']) { - $j = json_decode($f['body'],true); - if($j['success'] && $j['guid']) { - $x = import_xchan($j); - if($x['success']) { - $result['success'] = true; - } + $j = \Zotlabs\Zot\Finger::run('[system]@' . $m['host']); + if($j['success'] && $j['guid']) { + $x = import_xchan($j); + if($x['success']) { + $result['success'] = true; } } diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index ca3f33238..7cd1ee501 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); class Register extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Removeaccount.php b/Zotlabs/Module/Removeaccount.php index da496dfad..39e06bb7f 100644 --- a/Zotlabs/Module/Removeaccount.php +++ b/Zotlabs/Module/Removeaccount.php @@ -36,17 +36,12 @@ class Removeaccount extends \Zotlabs\Web\Controller { } } - require_once('include/Contact.php'); - $global_remove = intval($_POST['global']); - account_remove($account_id,true); - + account_remove($account_id, 1 - $global_remove); } - - - - function get() { + + function get() { if(! local_channel()) goaway(z_root()); diff --git a/Zotlabs/Module/Removeme.php b/Zotlabs/Module/Removeme.php index 9b634672a..e611d8112 100644 --- a/Zotlabs/Module/Removeme.php +++ b/Zotlabs/Module/Removeme.php @@ -35,8 +35,6 @@ class Removeme extends \Zotlabs\Web\Controller { } } - require_once('include/Contact.php'); - $global_remove = intval($_POST['global']); channel_remove(local_channel(),1 - $global_remove,true); @@ -44,8 +42,7 @@ class Removeme extends \Zotlabs\Web\Controller { } - - function get() { + function get() { if(! local_channel()) goaway(z_root()); diff --git a/Zotlabs/Module/Rmagic.php b/Zotlabs/Module/Rmagic.php index bcdbf6c90..26b0c46a6 100644 --- a/Zotlabs/Module/Rmagic.php +++ b/Zotlabs/Module/Rmagic.php @@ -24,7 +24,7 @@ class Rmagic extends \Zotlabs\Web\Controller { } } - function post() { + function post() { $address = trim($_REQUEST['address']); @@ -34,13 +34,13 @@ class Rmagic extends \Zotlabs\Web\Controller { try { require_once('library/openid/openid.php'); - $openid = new LightOpenID(z_root()); + $openid = new \LightOpenID(z_root()); $openid->identity = $address; $openid->returnUrl = z_root() . '/openid'; $openid->required = array('namePerson/friendly', 'namePerson'); $openid->optional = array('namePerson/first','media/image/aspect11','media/image/default'); goaway($openid->authUrl()); - } catch (Exception $e) { + } catch (\Exception $e) { notice( t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.').'<br /><br >'. t('The error message was:').' '.$e->getMessage()); } @@ -82,7 +82,7 @@ class Rmagic extends \Zotlabs\Web\Controller { } - function get() { + function get() { $o = replace_macros(get_markup_template('rmagic.tpl'),array( '$title' => t('Remote Authentication'), diff --git a/Zotlabs/Module/Rsd_xml.php b/Zotlabs/Module/Rsd_xml.php index 06af39ad1..e5059834b 100644 --- a/Zotlabs/Module/Rsd_xml.php +++ b/Zotlabs/Module/Rsd_xml.php @@ -6,7 +6,7 @@ class Rsd_xml extends \Zotlabs\Web\Controller { function init() { header ("Content-Type: text/xml"); echo replace_macros(get_markup_template('rsd.tpl'),array( - '$project' => \Zotlabs\Project\System::get_platform_name(), + '$project' => \Zotlabs\Lib\System::get_platform_name(), '$baseurl' => z_root(), '$apipath' => z_root() . '/api/' )); diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 9941ebbd2..402a27d40 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -79,7 +79,7 @@ class Search extends \Zotlabs\Web\Controller { return $o; if($tag) { - $sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type in ( %d , %d) and term = '%s') ", + $sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and ttype in ( %d , %d) and term = '%s') ", intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG), @@ -139,7 +139,7 @@ class Search extends \Zotlabs\Web\Controller { $item_normal = item_normal(); $pub_sql = public_permissions_sql($observer_hash); - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); diff --git a/Zotlabs/Module/Search_ac.php b/Zotlabs/Module/Search_ac.php index 78bcf374d..4e936d97b 100644 --- a/Zotlabs/Module/Search_ac.php +++ b/Zotlabs/Module/Search_ac.php @@ -46,7 +46,7 @@ class Search_ac extends \Zotlabs\Web\Controller { } } - $r = q("select distinct term, tid, url from term where type in ( %d, %d ) $tag_sql_extra group by term order by term asc", + $r = q("select distinct term, tid, url from term where ttype in ( %d, %d ) $tag_sql_extra group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG) ); diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php index a6293e842..875004fae 100644 --- a/Zotlabs/Module/Settings.php +++ b/Zotlabs/Module/Settings.php @@ -78,7 +78,7 @@ class Settings extends \Zotlabs\Web\Controller { $r = q("UPDATE clients SET client_id='%s', pw='%s', - name='%s', + clname='%s', redirect_uri='%s', icon='%s', uid=%d @@ -91,7 +91,7 @@ class Settings extends \Zotlabs\Web\Controller { intval(local_channel()), dbesc($key)); } else { - $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), @@ -337,7 +337,7 @@ class Settings extends \Zotlabs\Web\Controller { } $hide_presence = 1 - (intval($role_permissions['online'])); if($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(local_channel()), dbesc( t('Friends') ) ); @@ -345,7 +345,7 @@ class Settings extends \Zotlabs\Web\Controller { require_once('include/group.php'); group_add(local_channel(), t('Friends')); group_add_member(local_channel(),t('Friends'),$channel['channel_hash']); - $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(local_channel()), dbesc( t('Friends') ) ); @@ -483,7 +483,7 @@ class Settings extends \Zotlabs\Web\Controller { if($username != $channel['channel_name']) { $name_change = true; - require_once('include/identity.php'); + require_once('include/channel.php'); $err = validate_channelname($username); if($err) { notice($err); @@ -537,13 +537,13 @@ class Settings extends \Zotlabs\Web\Controller { dbesc(datetime_convert()), dbesc($channel['channel_hash']) ); - $r = q("update profile set name = '%s' where uid = %d and is_default = 1", + $r = q("update profile set fullname = '%s' where uid = %d and is_default = 1", dbesc($username), intval($channel['channel_id']) ); } - proc_run('php','include/directory.php',local_channel()); + \Zotlabs\Daemon\Master::Summon(array('Directory',local_channel())); build_sync_packet(); @@ -562,7 +562,7 @@ class Settings extends \Zotlabs\Web\Controller { - function get() { + function get() { $o = ''; nav_set_selected('settings'); @@ -615,7 +615,7 @@ class Settings extends \Zotlabs\Web\Controller { '$title' => t('Add application'), '$submit' => t('Update'), '$cancel' => t('Cancel'), - '$name' => array('name', t('Name'), $app['name'] , ''), + '$name' => array('name', t('Name'), $app['clname'] , ''), '$key' => array('key', t('Consumer Key'), $app['client_id'], ''), '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''), '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''), @@ -1047,7 +1047,7 @@ class Settings extends \Zotlabs\Web\Controller { '$h_prv' => t('Security and Privacy Settings'), '$permissions_set' => $permissions_set, - '$server_role' => \Zotlabs\Project\System::get_server_role(), + '$server_role' => \Zotlabs\Lib\System::get_server_role(), '$perms_set_msg' => t('Your permissions are already configured. Click to view/adjust'), '$hide_presence' => array('hide_presence', t('Hide my online presence'),$hide_presence, t('Prevents displaying in your profile that you are online'), $yes_no), @@ -1062,11 +1062,11 @@ class Settings extends \Zotlabs\Web\Controller { '$lbl_p2macro' => t('Advanced Privacy Settings'), - '$expire' => array('expire',t('Expire other channel content after this many days'),$expire,sprintf( t('0 or blank to use the website limit. The website expires after %d days.'),intval($sys_expire))), + '$expire' => array('expire',t('Expire other channel content after this many days'),$expire, t('0 or blank to use the website limit.') . ' ' . ((intval($sys_expire)) ? sprintf( t('This website expires after %d days.'),intval($sys_expire)) : t('This website does not expire imported content.')) . ' ' . t('The website limit takes precedence if lower than your limit.')), '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']) , t('May reduce spam activity')), - '$permissions' => t('Default Post Permissions'), + '$permissions' => t('Default Post and Publish Permissions'), '$permdesc' => t("\x28click to open/close\x29"), - '$aclselect' => populate_acl($perm_defaults, false, \PermissionDescription::fromDescription(t('Use my default audience setting for the type of post'))), + '$aclselect' => populate_acl($perm_defaults, false, \PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))), '$suggestme' => $suggestme, '$group_select' => $group_select, '$role' => array('permissions_role' , t('Channel permissions category:'), $permissions_role, '', get_roles()), diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index f8c14951b..c4878e217 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -12,7 +12,6 @@ namespace Zotlabs\Module; /** * @brief Initialisation for the setup module. * - * @param[in,out] App &$a */ class Setup extends \Zotlabs\Web\Controller { @@ -54,16 +53,15 @@ class Setup extends \Zotlabs\Web\Controller { /** * @brief Handle the actions of the different setup steps. * - * @param[in,out] App &$a */ - function post() { - global $db; + + function post() { switch($this->install_wizard_pass) { case 1: case 2: return; - break; // just in case return don't return :) + // implied break; case 3: $urlpath = \App::get_path(); $dbhost = trim($_POST['dbhost']); @@ -82,39 +80,15 @@ class Setup extends \Zotlabs\Web\Controller { $siteurl = rtrim($siteurl,'/'); require_once('include/dba/dba_driver.php'); - unset($db); - $db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true); + + $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true); - if(! $db->connected) { - echo 'Database Connect failed: ' . $db->error; + if(! \DBA::$dba->connected) { + echo 'Database Connect failed: ' . DBA::$dba->error; killme(); - \App::$data['db_conn_failed']=true; } - /*if(get_db_errno()) { - unset($db); - $db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, '', true); - - if(! get_db_errno()) { - $r = q("CREATE DATABASE '%s'", - dbesc($dbdata) - ); - if($r) { - unset($db); - $db = new dba($dbhost, $dbport, $dbuser, $dbpass, $dbdata, true); - } else { - \App::$data['db_create_failed']=true; - } - } else { - \App::$data['db_conn_failed']=true; - return; - } - }*/ - //if(get_db_errno()) { - - //} - return; - break; + // implied break; case 4: $urlpath = \App::get_path(); $dbhost = notags(trim($_POST['dbhost'])); @@ -138,10 +112,12 @@ class Setup extends \Zotlabs\Web\Controller { } } - // connect to db - $db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true); - - if(! $db->connected) { + if(! \DBA::$dba->connected) { + // connect to db + $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true); + } + + if(! \DBA::$dba->connected) { echo 'CRITICAL: DB not connected.'; killme(); } @@ -175,6 +151,8 @@ class Setup extends \Zotlabs\Web\Controller { \App::$data['db_installed'] = true; return; + // implied break; + default: break; } } @@ -191,11 +169,10 @@ class Setup extends \Zotlabs\Web\Controller { * * Depending on the state we are currently in it returns different content. * - * @param App &$a * @return string parsed HTML output */ - function get() { - global $db; + + function get() { $o = ''; $wizard_status = ''; @@ -228,7 +205,7 @@ class Setup extends \Zotlabs\Web\Controller { $txt .= "<pre>".\App::$data['db_failed'] . "</pre>". EOL ; $db_return_text .= $txt; } - if($db && $db->connected) { + if(\DBA::$dba && \DBA::$dba->connected) { $r = q("SELECT COUNT(*) as `total` FROM `account`"); if($r && count($r) && $r[0]['total']) { $tpl = get_markup_template('install.tpl'); @@ -407,8 +384,8 @@ class Setup extends \Zotlabs\Web\Controller { function check_php(&$phpath, &$checks) { $help = ''; - if(version_compare(PHP_VERSION, '5.4') < 0) { - $help .= t('PHP version 5.4 or greater is required.'); + if(version_compare(PHP_VERSION, '5.5') < 0) { + $help .= t('PHP version 5.5 or greater is required.'); $this->check_add($checks, t('PHP version'), false, false, $help); } @@ -598,7 +575,7 @@ class Setup extends \Zotlabs\Web\Controller { if(! is_writable(TEMPLATE_BUILD_PATH) ) { $status = false; $help = t('Red uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL; - $help .= sprintf( t('In order to store these compiled templates, the web server needs to have write access to the directory %s under the Red top level folder.'), TEMPLATE_BUILD_PATH) . EOL; + $help .= sprintf( t('In order to store these compiled templates, the web server needs to have write access to the directory %s under the top level web folder.'), TEMPLATE_BUILD_PATH) . EOL; $help .= t('Please ensure that the user that your web server runs as (e.g. www-data) has write access to this folder.').EOL; $help .= sprintf( t('Note: as a security measure, you should give the web server write access to %s only--not the template files (.tpl) that it contains.'), TEMPLATE_BUILD_PATH) . EOL; } @@ -698,12 +675,12 @@ class Setup extends \Zotlabs\Web\Controller { function load_database($db) { - $str = file_get_contents($db->get_install_script()); + $str = file_get_contents(\DBA::$dba->get_install_script()); $arr = explode(';',$str); $errors = false; foreach($arr as $a) { if(strlen(trim($a))) { - $r = @$db->q(trim($a)); + $r = dbq(trim($a)); if(! $r) { $errors .= t('Errors encountered creating database tables.') . $a . EOL; } @@ -734,7 +711,7 @@ class Setup extends \Zotlabs\Web\Controller { set_config('system','curl_ssl_ciphers','ALL:!eNULL'); // Create a system channel - require_once ('include/identity.php'); + require_once ('include/channel.php'); create_sys_channel(); $baseurl = z_root(); diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php index 73db01657..fcc2486ba 100644 --- a/Zotlabs/Module/Share.php +++ b/Zotlabs/Module/Share.php @@ -48,7 +48,7 @@ class Share extends \Zotlabs\Web\Controller { $is_photo = (($r[0]['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false); if($is_photo) { - $object = json_decode($r[0]['object'],true); + $object = json_decode($r[0]['obj'],true); $photo_bb = $object['body']; } diff --git a/Zotlabs/Module/Sharedwithme.php b/Zotlabs/Module/Sharedwithme.php index 8eaa47dba..25bc7dba3 100644 --- a/Zotlabs/Module/Sharedwithme.php +++ b/Zotlabs/Module/Sharedwithme.php @@ -46,7 +46,7 @@ class Sharedwithme extends \Zotlabs\Web\Controller { } //list files - $r = q("SELECT id, uid, object, item_unseen FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'", + $r = q("SELECT id, uid, obj, item_unseen FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'", dbesc(ACTIVITY_POST), dbesc(ACTIVITY_OBJ_FILE), intval(local_channel()), @@ -59,7 +59,7 @@ class Sharedwithme extends \Zotlabs\Web\Controller { if($r) { foreach($r as $rr) { - $object = json_decode($rr['object'],true); + $object = json_decode($rr['obj'],true); $item = array(); $item['id'] = $rr['id']; diff --git a/Zotlabs/Module/Siteinfo.php b/Zotlabs/Module/Siteinfo.php index c65277004..41f6e9f0b 100644 --- a/Zotlabs/Module/Siteinfo.php +++ b/Zotlabs/Module/Siteinfo.php @@ -16,10 +16,10 @@ class Siteinfo extends \Zotlabs\Web\Controller { function get() { if(! get_config('system','hidden_version_siteinfo')) { - $version = sprintf( t('Version %s'), \Zotlabs\Project\System::get_project_version()); + $version = sprintf( t('Version %s'), \Zotlabs\Lib\System::get_project_version()); if(@is_dir('.git') && function_exists('shell_exec')) { $commit = @shell_exec('git log -1 --format="%h"'); - $tag = \Zotlabs\Project\System::get_std_version(); // @shell_exec('git describe --tags --abbrev=0'); + $tag = \Zotlabs\Lib\System::get_std_version(); // @shell_exec('git describe --tags --abbrev=0'); } if(! isset($commit) || strlen($commit) > 16) $commit = ''; diff --git a/Zotlabs/Module/Subthread.php b/Zotlabs/Module/Subthread.php index 16a011a40..0226664d7 100644 --- a/Zotlabs/Module/Subthread.php +++ b/Zotlabs/Module/Subthread.php @@ -144,7 +144,7 @@ class Subthread extends \Zotlabs\Web\Controller { $arr['verb'] = $activity; $arr['obj_type'] = $objtype; - $arr['object'] = $obj; + $arr['obj'] = $obj; $arr['allow_cid'] = $item['allow_cid']; $arr['allow_gid'] = $item['allow_gid']; diff --git a/Zotlabs/Module/Tagger.php b/Zotlabs/Module/Tagger.php index 879cf3dbb..0a46cf56d 100644 --- a/Zotlabs/Module/Tagger.php +++ b/Zotlabs/Module/Tagger.php @@ -124,14 +124,14 @@ class Tagger extends \Zotlabs\Web\Controller { $arr['tgt_type'] = $targettype; $arr['target'] = $target; $arr['obj_type'] = $objtype; - $arr['object'] = $obj; + $arr['obj'] = $obj; $arr['parent_mid'] = $item['mid']; store_item_tag($item['uid'],$item['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$term,$tagid); $ret = post_activity_item($arr); if($ret['success']) - proc_run('php','include/notifier.php','tag',$ret['activity']['id']); + \Zotlabs\Daemon\Master::Summon(array('Notifier','tag',$ret['activity']['id'])); killme(); diff --git a/Zotlabs/Module/Tagrm.php b/Zotlabs/Module/Tagrm.php index 81ae30aa5..42aa6e90f 100644 --- a/Zotlabs/Module/Tagrm.php +++ b/Zotlabs/Module/Tagrm.php @@ -54,7 +54,7 @@ class Tagrm extends \Zotlabs\Web\Controller { - function get() { + function get() { if(! local_channel()) { goaway(z_root() . '/' . $_SESSION['photo_return']); diff --git a/Zotlabs/Module/Tasks.php b/Zotlabs/Module/Tasks.php index ab05f8be9..6d0a92d91 100644 --- a/Zotlabs/Module/Tasks.php +++ b/Zotlabs/Module/Tasks.php @@ -45,7 +45,7 @@ class Tasks extends \Zotlabs\Web\Controller { if((argc() > 2) && (argv(1) === 'complete') && intval(argv(2))) { $ret = array('success' => false); - $r = q("select * from event where `type` = 'task' and uid = %d and id = %d limit 1", + $r = q("select * from event where `etype` = 'task' and uid = %d and id = %d limit 1", intval(local_channel()), intval(argv(2)) ); @@ -80,9 +80,9 @@ class Tasks extends \Zotlabs\Web\Controller { $event['account'] = $channel['channel_account_id']; $event['uid'] = $channel['channel_id']; $event['event_xchan'] = $channel['channel_hash']; - $event['type'] = 'task'; + $event['etype'] = 'task'; $event['nofinish'] = true; - $event['created'] = $event['edited'] = $event['start'] = datetime_convert(); + $event['created'] = $event['edited'] = $event['dtstart'] = datetime_convert(); $event['adjust'] = 1; $event['allow_cid'] = '<' . $channel['channel_hash'] . '>'; $event['summary'] = escape_tags($_REQUEST['summary']); @@ -92,21 +92,13 @@ class Tasks extends \Zotlabs\Web\Controller { else $x = array('success' => false); json_return_and_die($x); - } - - + } } - - - - - function get() { - + function get() { if(! local_channel()) return; - - + return ''; } } diff --git a/Zotlabs/Module/Thing.php b/Zotlabs/Module/Thing.php index e95ec53f6..65fc0588e 100644 --- a/Zotlabs/Module/Thing.php +++ b/Zotlabs/Module/Thing.php @@ -7,7 +7,7 @@ namespace Zotlabs\Module; require_once('include/items.php'); require_once('include/security.php'); -require_once('include/contact_selectors.php'); +require_once('include/selectors.php'); require_once('include/acl_selectors.php'); @@ -26,7 +26,7 @@ class Thing extends \Zotlabs\Web\Controller { $verb = escape_tags($_REQUEST['verb']); $activity = intval($_REQUEST['activity']); $profile_guid = escape_tags($_REQUEST['profile_assign']); - $url = $_REQUEST['link']; + $url = $_REQUEST['url']; $photo = $_REQUEST['img']; $hash = random_string(); @@ -212,7 +212,7 @@ class Thing extends \Zotlabs\Web\Controller { $arr['verb'] = $verb; $arr['obj_type'] = $objtype; - $arr['object'] = $obj; + $arr['obj'] = $obj; if(! $profile['is_default']) { $arr['item_private'] = true; @@ -235,7 +235,7 @@ class Thing extends \Zotlabs\Web\Controller { } - function get() { + function get() { // @FIXME one problem with things is we can't share them unless we provide the channel in the url // so we can definitively lookup the owner. diff --git a/Zotlabs/Module/Uexport.php b/Zotlabs/Module/Uexport.php index ada7e0986..d48f96d76 100644 --- a/Zotlabs/Module/Uexport.php +++ b/Zotlabs/Module/Uexport.php @@ -11,7 +11,7 @@ class Uexport extends \Zotlabs\Web\Controller { if(argc() > 1) { $channel = \App::get_channel(); - require_once('include/identity.php'); + require_once('include/channel.php'); if(argc() > 1 && intval(argv(1)) > 1900) { $year = intval(argv(1)); diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index 726ef043b..ea478f92a 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -1,23 +1,22 @@ <?php namespace Zotlabs\Module; -require_once('include/contact_selectors.php'); -require_once('include/Contact.php'); +require_once('include/selectors.php'); class Viewconnections extends \Zotlabs\Web\Controller { function init() { - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { return; } if(argc() > 1) profile_load($a,argv(1)); } - function get() { + function get() { - if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + if(observer_prohibited()) { notice( t('Public access denied.') . EOL); return; } diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php index 5bdecfa75..9a1019ddb 100644 --- a/Zotlabs/Module/Wall_attach.php +++ b/Zotlabs/Module/Wall_attach.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; require_once('include/attach.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/photos.php'); diff --git a/Zotlabs/Module/Wall_upload.php b/Zotlabs/Module/Wall_upload.php index fff3ed03a..3868cb14e 100644 --- a/Zotlabs/Module/Wall_upload.php +++ b/Zotlabs/Module/Wall_upload.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; require_once('include/photo/photo_driver.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/photos.php'); diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index d8adb55b2..bb8d454c8 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); require_once('include/PermissionDescription.php'); diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php new file mode 100644 index 000000000..1e6446904 --- /dev/null +++ b/Zotlabs/Module/Wiki.php @@ -0,0 +1,424 @@ +<?php + +namespace Zotlabs\Module;/** @file */ + +class Wiki extends \Zotlabs\Web\Controller { + + function init() { + // Determine which channel's wikis to display to the observer + $nick = null; + if (argc() > 1) + $nick = argv(1); // if the channel name is in the URL, use that + if (!$nick && local_channel()) { // if no channel name was provided, assume the current logged in channel + $channel = \App::get_channel(); + if ($channel && $channel['channel_address']) { + $nick = $channel['channel_address']; + goaway(z_root() . '/wiki/' . $nick); + } + } + if (!$nick) { + notice(t('You must be logged in to see this page.') . EOL); + goaway('/login'); + } + } + + function get() { + require_once('include/wiki.php'); + require_once('include/acl_selectors.php'); + // TODO: Combine the interface configuration into a unified object + // Something like $interface = array('new_page_button' => false, 'new_wiki_button' => false, ...) + $wiki_owner = false; + $showNewWikiButton = false; + $showCommitMsg = false; + $hidePageHistory = false; + $pageHistory = array(); + $local_observer = null; + $resource_id = ''; + + // init() should have forced the URL to redirect to /wiki/channel so assume argc() > 1 + $nick = argv(1); + $channel = get_channel_by_nick($nick); // The channel who owns the wikis being viewed + if(! $channel) { + notice('Invalid channel' . EOL); + goaway('/' . argv(0)); + } + // Determine if the observer is the channel owner so the ACL dialog can be populated + if (local_channel() === intval($channel['channel_id'])) { + $local_observer = \App::get_channel(); + $wiki_owner = true; + + // Obtain the default permission settings of the channel + $channel_acl = array( + 'allow_cid' => $local_observer['channel_allow_cid'], + 'allow_gid' => $local_observer['channel_allow_gid'], + 'deny_cid' => $local_observer['channel_deny_cid'], + 'deny_gid' => $local_observer['channel_deny_gid'] + ); + // Initialize the ACL to the channel default permissions + $x = array( + 'lockstate' => (( $local_observer['channel_allow_cid'] || + $local_observer['channel_allow_gid'] || + $local_observer['channel_deny_cid'] || + $local_observer['channel_deny_gid']) + ? 'lock' : 'unlock'), + 'acl' => populate_acl($channel_acl), + 'bang' => '' + ); + } else { + // Not the channel owner + $channel_acl = $x = array(); + } + + switch (argc()) { + case 2: + // Configure page template + $wikiheader = t('Wiki Sandbox'); + $content = '"# Wiki Sandbox\n\nContent you **edit** and **preview** here *will not be saved*."'; + $hide_editor = false; + $showPageControls = false; + $showNewWikiButton = $wiki_owner; + $showNewPageButton = false; + $hidePageHistory = true; + $showCommitMsg = false; + break; + case 3: + // /wiki/channel/wiki -> No page was specified, so redirect to Home.md + $wikiUrlName = urlencode(argv(2)); + goaway('/'.argv(0).'/'.argv(1).'/'.$wikiUrlName.'/Home'); + case 4: + // GET /wiki/channel/wiki/page + // Fetch the wiki info and determine observer permissions + $wikiUrlName = urlencode(argv(2)); + $pageUrlName = urlencode(argv(3)); + $w = wiki_exists_by_name($channel['channel_id'], $wikiUrlName); + if(!$w['resource_id']) { + notice('Wiki not found' . EOL); + goaway('/'.argv(0).'/'.argv(1)); + } + $resource_id = $w['resource_id']; + + if (!$wiki_owner) { + // Check for observer permissions + $observer_hash = get_observer_hash(); + $perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash); + if(!$perms['read']) { + notice('Permission denied.' . EOL); + goaway('/'.argv(0).'/'.argv(1)); + } + if($perms['write']) { + $wiki_editor = true; + } else { + $wiki_editor = false; + } + } else { + $wiki_editor = true; + } + $wikiheader = urldecode($wikiUrlName) . ': ' . urldecode($pageUrlName); // show wiki name and page + $p = wiki_get_page_content(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); + if(!$p['success']) { + notice('Error retrieving page content' . EOL); + goaway('/'.argv(0).'/'.argv(1).'/'.$wikiUrlName); + } + $content = ($p['content'] !== '' ? $p['content'] : '"# New page\n"'); + $hide_editor = false; + $showPageControls = $wiki_editor; + $showNewWikiButton = $wiki_owner; + $showNewPageButton = $wiki_editor; + $hidePageHistory = false; + $showCommitMsg = true; + $pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); + break; + default: // Strip the extraneous URL components + goaway('/'.argv(0).'/'.argv(1).'/'.$wikiUrlName.'/'.$pageUrlName); + } + // Render the Markdown-formatted page content in HTML + require_once('library/markdown.php'); + + $o .= replace_macros(get_markup_template('wiki.tpl'),array( + '$wikiheader' => $wikiheader, + '$hideEditor' => $hide_editor, + '$showPageControls' => $showPageControls, + '$showNewWikiButton'=> $showNewWikiButton, + '$showNewPageButton'=> $showNewPageButton, + '$hidePageHistory' => $hidePageHistory, + '$showCommitMsg' => $showCommitMsg, + '$channel' => $channel['channel_address'], + '$resource_id' => $resource_id, + '$page' => $pageUrlName, + '$lockstate' => $x['lockstate'], + '$acl' => $x['acl'], + '$bang' => $x['bang'], + '$content' => $content, + '$renderedContent' => Markdown(json_decode($content)), + '$wikiName' => array('wikiName', t('Enter the name of your new wiki:'), '', ''), + '$pageName' => array('pageName', t('Enter the name of the new page:'), '', ''), + '$commitMsg' => array('commitMsg', '', '', '', '', 'placeholder="(optional) Enter a custom message when saving the page..."'), + '$pageHistory' => $pageHistory['history'] + )); + head_add_js('library/ace/ace.js'); // Ace Code Editor + return $o; + } + + function post() { + require_once('include/wiki.php'); + + // /wiki/channel/preview + // Render mardown-formatted text in HTML for preview + if((argc() > 2) && (argv(2) === 'preview')) { + $content = $_POST['content']; + require_once('library/markdown.php'); + $html = purify_html(Markdown($content)); + json_return_and_die(array('html' => $html, 'success' => true)); + } + + // Create a new wiki + // /wiki/channel/create/wiki + if ((argc() > 3) && (argv(2) === 'create') && (argv(3) === 'wiki')) { + $nick = argv(1); + $channel = get_channel_by_nick($nick); + // Determine if observer has permission to create wiki + $observer_hash = get_observer_hash(); + // Only the channel owner can create a wiki, at least until we create a + // more detail permissions framework + if (local_channel() !== intval($channel['channel_id'])) { + goaway('/'.argv(0).'/'.$nick.'/'); + } + $wiki = array(); + // Generate new wiki info from input name + $wiki['rawName'] = $_POST['wikiName']; + $wiki['htmlName'] = escape_tags($_POST['wikiName']); + $wiki['urlName'] = urlencode($_POST['wikiName']); + if($wiki['urlName'] === '') { + notice('Error creating wiki. Invalid name.'); + goaway('/wiki'); + } + // Get ACL for permissions + $acl = new \Zotlabs\Access\AccessList($channel); + $acl->set_from_array($_POST); + $r = wiki_create_wiki($channel, $observer_hash, $wiki, $acl); + if ($r['success']) { + $homePage = wiki_create_page('Home', $r['item']['resource_id']); + if(!$homePage['success']) { + notice('Wiki created, but error creating Home page.'); + goaway('/wiki/'.$nick.'/'.$wiki['urlName']); + } + goaway('/wiki/'.$nick.'/'.$wiki['urlName'].'/'.$homePage['page']['urlName']); + } else { + notice('Error creating wiki'); + goaway('/wiki'); + } + } + + // Delete a wiki + if ((argc() > 3) && (argv(2) === 'delete') && (argv(3) === 'wiki')) { + $nick = argv(1); + $channel = get_channel_by_nick($nick); + // Only the channel owner can delete a wiki, at least until we create a + // more detail permissions framework + if (local_channel() !== intval($channel['channel_id'])) { + logger('Wiki delete permission denied.' . EOL); + json_return_and_die(array('message' => 'Wiki delete permission denied.', 'success' => false)); + } else { + /* + $channel = get_channel_by_nick($nick); + $observer_hash = get_observer_hash(); + // Figure out who the page owner is. + $perms = get_all_perms(intval($channel['channel_id']), $observer_hash); + // TODO: Create a new permission setting for wiki analogous to webpages. Until + // then, use webpage permissions + if (!$perms['write_pages']) { + logger('Wiki delete permission denied.' . EOL); + json_return_and_die(array('success' => false)); + } + */ + } + $resource_id = $_POST['resource_id']; + $deleted = wiki_delete_wiki($resource_id); + if ($deleted['success']) { + json_return_and_die(array('message' => '', 'success' => true)); + } else { + logger('Error deleting wiki: ' . $resource_id); + json_return_and_die(array('message' => 'Error deleting wiki', 'success' => false)); + } + } + + // Create a page + if ((argc() === 4) && (argv(2) === 'create') && (argv(3) === 'page')) { + $nick = argv(1); + $resource_id = $_POST['resource_id']; + // Determine if observer has permission to create a page + $channel = get_channel_by_nick($nick); + if (local_channel() !== intval($channel['channel_id'])) { + $observer_hash = get_observer_hash(); + $perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash); + if(!$perms['write']) { + logger('Wiki write permission denied. ' . EOL); + json_return_and_die(array('success' => false)); + } + } + $name = $_POST['name']; //Get new page name + if(urlencode(escape_tags($_POST['name'])) === '') { + json_return_and_die(array('message' => 'Error creating page. Invalid name.', 'success' => false)); + } + $page = wiki_create_page($name, $resource_id); + if ($page['success']) { + json_return_and_die(array('url' => '/'.argv(0).'/'.argv(1).'/'.$page['wiki']['urlName'].'/'.urlencode($page['page']['urlName']), 'success' => true)); + } else { + logger('Error creating page'); + json_return_and_die(array('message' => 'Error creating page.', 'success' => false)); + } + } + + // Fetch page list for a wiki + if ((argc() === 5) && (argv(2) === 'get') && (argv(3) === 'page') && (argv(4) === 'list')) { + $resource_id = $_POST['resource_id']; // resource_id for wiki in db + $channel = get_channel_by_nick(argv(1)); + $observer_hash = get_observer_hash(); + if (local_channel() !== intval($channel['channel_id'])) { + $perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash); + if(!$perms['read']) { + logger('Wiki read permission denied.' . EOL); + json_return_and_die(array('pages' => null, 'message' => 'Permission denied.', 'success' => false)); + } + } + $page_list_html = widget_wiki_pages(array( + 'resource_id' => $resource_id, + 'refresh' => true, + 'channel' => argv(1))); + json_return_and_die(array('pages' => $page_list_html, 'message' => '', 'success' => true)); + } + + // Save a page + if ((argc() === 4) && (argv(2) === 'save') && (argv(3) === 'page')) { + + $resource_id = $_POST['resource_id']; + $pageUrlName = $_POST['name']; + $pageHtmlName = escape_tags($_POST['name']); + $content = $_POST['content']; //Get new content + $commitMsg = $_POST['commitMsg']; + if ($commitMsg === '') { + $commitMsg = 'Updated ' . $pageHtmlName; + } + $nick = argv(1); + $channel = get_channel_by_nick($nick); + // Determine if observer has permission to save content + if (local_channel() !== intval($channel['channel_id'])) { + $observer_hash = get_observer_hash(); + $perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash); + if(!$perms['write']) { + logger('Wiki write permission denied. ' . EOL); + json_return_and_die(array('success' => false)); + } + } + + $saved = wiki_save_page(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName, 'content' => $content)); + if($saved['success']) { + $ob = \App::get_observer(); + $commit = wiki_git_commit(array( + 'commit_msg' => $commitMsg, + 'resource_id' => $resource_id, + 'observer' => $ob, + 'files' => array($pageUrlName.'.md') + )); + if($commit['success']) { + json_return_and_die(array('message' => 'Wiki git repo commit made', 'success' => true)); + } else { + json_return_and_die(array('message' => 'Error making git commit','success' => false)); + } + } else { + json_return_and_die(array('message' => 'Error saving page', 'success' => false)); + } + } + + // Update page history + // /wiki/channel/history/page + if ((argc() === 4) && (argv(2) === 'history') && (argv(3) === 'page')) { + + $resource_id = $_POST['resource_id']; + $pageUrlName = $_POST['name']; + + $nick = argv(1); + $channel = get_channel_by_nick($nick); + // Determine if observer has permission to read content + if (local_channel() !== intval($channel['channel_id'])) { + $observer_hash = get_observer_hash(); + $perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash); + if(!$perms['read']) { + logger('Wiki read permission denied.' . EOL); + json_return_and_die(array('historyHTML' => '', 'message' => 'Permission denied.', 'success' => false)); + } + } + $historyHTML = widget_wiki_page_history(array( + 'resource_id' => $resource_id, + 'pageUrlName' => $pageUrlName + )); + json_return_and_die(array('historyHTML' => $historyHTML, 'message' => '', 'success' => true)); + } + + // Delete a page + if ((argc() === 4) && (argv(2) === 'delete') && (argv(3) === 'page')) { + $resource_id = $_POST['resource_id']; + $pageUrlName = $_POST['name']; + if ($pageUrlName === 'Home') { + json_return_and_die(array('message' => 'Cannot delete Home','success' => false)); + } + // Determine if observer has permission to delete pages + $nick = argv(1); + $channel = get_channel_by_nick($nick); + if (local_channel() !== intval($channel['channel_id'])) { + $observer_hash = get_observer_hash(); + $perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash); + if(!$perms['write']) { + logger('Wiki write permission denied. ' . EOL); + json_return_and_die(array('success' => false)); + } + } + $deleted = wiki_delete_page(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); + if($deleted['success']) { + $ob = \App::get_observer(); + $commit = wiki_git_commit(array( + 'commit_msg' => 'Deleted ' . $pageHtmlName, + 'resource_id' => $resource_id, + 'observer' => $ob, + 'files' => null + )); + if($commit['success']) { + json_return_and_die(array('message' => 'Wiki git repo commit made', 'success' => true)); + } else { + json_return_and_die(array('message' => 'Error making git commit','success' => false)); + } + } else { + json_return_and_die(array('message' => 'Error deleting page', 'success' => false)); + } + } + + // Revert a page + if ((argc() === 4) && (argv(2) === 'revert') && (argv(3) === 'page')) { + $resource_id = $_POST['resource_id']; + $pageUrlName = $_POST['name']; + $commitHash = $_POST['commitHash']; + // Determine if observer has permission to revert pages + $nick = argv(1); + $channel = get_channel_by_nick($nick); + if (local_channel() !== intval($channel['channel_id'])) { + $observer_hash = get_observer_hash(); + $perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash); + if(!$perms['write']) { + logger('Wiki write permission denied.' . EOL); + json_return_and_die(array('success' => false)); + } + } + $reverted = wiki_revert_page(array('commitHash' => $commitHash, 'observer' => \App::get_observer(), 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); + if($reverted['success']) { + json_return_and_die(array('content' => $reverted['content'], 'message' => '', 'success' => true)); + } else { + json_return_and_die(array('content' => '', 'message' => 'Error reverting page', 'success' => false)); + } + } + + + //notice('You must be authenticated.'); + json_return_and_die(array('message' => 'You must be authenticated.', 'success' => false)); + + } +} diff --git a/Zotlabs/Module/Zotfeed.php b/Zotlabs/Module/Zotfeed.php index 28040149f..6b505c890 100644 --- a/Zotlabs/Module/Zotfeed.php +++ b/Zotlabs/Module/Zotfeed.php @@ -15,7 +15,7 @@ class Zotfeed extends \Zotlabs\Web\Controller { if(! $mindate) $mindate = datetime_convert('UTC','UTC', 'now - 14 days'); - if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) { + if(observer_prohibited()) { $result['message'] = 'Public access denied'; json_return_and_die($result); } @@ -45,8 +45,6 @@ class Zotfeed extends \Zotlabs\Web\Controller { $result['messages'] = zot_feed($r[0]['channel_id'],$observer['xchan_hash'],array('mindate' => $mindate)); $result['success'] = true; json_return_and_die($result); - - } } |