Example #1
0
 /**
  * Set up this new Controller object for an app with render data
  *
  * @param App $app the application
  * @param Object $render the render data
  */
 public function setup_for_app($app, $render)
 {
     $this->view = $app->get_file();
     // "faq" from "www.yawf.org/project/faq"
     $this->path = $app->get_path();
     // e.g. "project/faq"
     $this->render = $render;
     // data to be rendered in views
     $this->setup_request($app);
     // inherited from Request class
     $this->flash = $this->flash_object();
     // uses a request session
 }
Example #2
0
 function get()
 {
     require_once 'include/acl_selectors.php';
     require_once 'include/permissions.php';
     $yes_no = array(t('No'), t('Yes'));
     $p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_channel()));
     if (count($p)) {
         $profile = $p[0];
     }
     load_pconfig(local_channel(), 'expire');
     $channel = \App::get_channel();
     $global_perms = \Zotlabs\Access\Permissions::Perms();
     $permiss = array();
     $perm_opts = array(array(t('Nobody except yourself'), 0), array(t('Only those you specifically allow'), PERMS_SPECIFIC), array(t('Approved connections'), PERMS_CONTACTS), array(t('Any connections'), PERMS_PENDING), array(t('Anybody on this website'), PERMS_SITE), array(t('Anybody in this network'), PERMS_NETWORK), array(t('Anybody authenticated'), PERMS_AUTHED), array(t('Anybody on the internet'), PERMS_PUBLIC));
     $limits = \Zotlabs\Access\PermissionLimits::Get(local_channel());
     foreach ($global_perms as $k => $perm) {
         $options = array();
         foreach ($perm_opts as $opt) {
             if (!strstr($k, 'view') && $opt[1] == PERMS_PUBLIC) {
                 continue;
             }
             $options[$opt[1]] = $opt[0];
         }
         $permiss[] = array($k, $perm, $limits[$k], '', $options);
     }
     $username = $channel['channel_name'];
     $nickname = $channel['channel_address'];
     $timezone = $channel['channel_timezone'];
     $notify = $channel['channel_notifyflags'];
     $defloc = $channel['channel_location'];
     $maxreq = $channel['channel_max_friend_req'];
     $expire = $channel['channel_expire_days'];
     $adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT);
     $sys_expire = get_config('system', 'default_expire_days');
     //		$unkmail    = \App::$user['unkmail'];
     //		$cntunkmail = \App::$user['cntunkmail'];
     $hide_presence = intval(get_pconfig(local_channel(), 'system', 'hide_online_status'));
     $expire_items = get_pconfig(local_channel(), 'expire', 'items');
     $expire_items = $expire_items === false ? '1' : $expire_items;
     // default if not set: 1
     $expire_notes = get_pconfig(local_channel(), 'expire', 'notes');
     $expire_notes = $expire_notes === false ? '1' : $expire_notes;
     // default if not set: 1
     $expire_starred = get_pconfig(local_channel(), 'expire', 'starred');
     $expire_starred = $expire_starred === false ? '1' : $expire_starred;
     // default if not set: 1
     $expire_photos = get_pconfig(local_channel(), 'expire', 'photos');
     $expire_photos = $expire_photos === false ? '0' : $expire_photos;
     // default if not set: 0
     $expire_network_only = get_pconfig(local_channel(), 'expire', 'network_only');
     $expire_network_only = $expire_network_only === false ? '0' : $expire_network_only;
     // default if not set: 0
     $suggestme = get_pconfig(local_channel(), 'system', 'suggestme');
     $suggestme = $suggestme === false ? '0' : $suggestme;
     // default if not set: 0
     $post_newfriend = get_pconfig(local_channel(), 'system', 'post_newfriend');
     $post_newfriend = $post_newfriend === false ? '0' : $post_newfriend;
     // default if not set: 0
     $post_joingroup = get_pconfig(local_channel(), 'system', 'post_joingroup');
     $post_joingroup = $post_joingroup === false ? '0' : $post_joingroup;
     // default if not set: 0
     $post_profilechange = get_pconfig(local_channel(), 'system', 'post_profilechange');
     $post_profilechange = $post_profilechange === false ? '0' : $post_profilechange;
     // default if not set: 0
     $blocktags = get_pconfig(local_channel(), 'system', 'blocktags');
     $blocktags = $blocktags === false ? '0' : $blocktags;
     $timezone = date_default_timezone_get();
     $opt_tpl = get_markup_template("field_checkbox.tpl");
     if (get_config('system', 'publish_all')) {
         $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
     } else {
         $profile_in_dir = replace_macros($opt_tpl, array('$field' => array('profile_in_directory', t('Publish your default profile in the network directory'), $profile['publish'], '', $yes_no)));
     }
     $suggestme = replace_macros($opt_tpl, array('$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', $yes_no)));
     $subdir = strlen(\App::get_path()) ? '<br />' . t('or') . ' ' . z_root() . '/channel/' . $nickname : '';
     $tpl_addr = get_markup_template("settings_nick_set.tpl");
     $prof_addr = replace_macros($tpl_addr, array('$desc' => t('Your channel address is'), '$nickname' => $nickname, '$subdir' => $subdir, '$basepath' => \App::get_hostname()));
     $stpl = get_markup_template('settings.tpl');
     $acl = new \Zotlabs\Access\AccessList($channel);
     $perm_defaults = $acl->get();
     require_once 'include/group.php';
     $group_select = mini_group_select(local_channel(), $channel['channel_default_group']);
     require_once 'include/menu.php';
     $m1 = menu_list(local_channel());
     $menu = false;
     if ($m1) {
         $menu = array();
         $current = get_pconfig(local_channel(), 'system', 'channel_menu');
         $menu[] = array('name' => '', 'selected' => !$current ? true : false);
         foreach ($m1 as $m) {
             $menu[] = array('name' => htmlspecialchars($m['menu_name'], ENT_COMPAT, 'UTF-8'), 'selected' => $m['menu_name'] === $current ? ' selected="selected" ' : false);
         }
     }
     $evdays = get_pconfig(local_channel(), 'system', 'evdays');
     if (!$evdays) {
         $evdays = 3;
     }
     $permissions_role = get_pconfig(local_channel(), 'system', 'permissions_role');
     if (!$permissions_role) {
         $permissions_role = 'custom';
     }
     $permissions_set = $permissions_role != 'custom' ? true : false;
     $perm_roles = \Zotlabs\Access\PermissionRoles::roles();
     if (get_account_techlevel() < 4 && $permissions_role !== 'custom') {
         unset($perm_roles[t('Other')]);
     }
     $vnotify = get_pconfig(local_channel(), 'system', 'vnotify');
     $always_show_in_notices = get_pconfig(local_channel(), 'system', 'always_show_in_notices');
     if ($vnotify === false) {
         $vnotify = -1;
     }
     $o .= replace_macros($stpl, array('$ptitle' => t('Channel Settings'), '$submit' => t('Submit'), '$baseurl' => z_root(), '$uid' => local_channel(), '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, '$h_basic' => t('Basic Settings'), '$username' => array('username', t('Full Name:'), $username, ''), '$email' => array('email', t('Email Address:'), $email, ''), '$timezone' => array('timezone_select', t('Your Timezone:'), $timezone, '', get_timezones()), '$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')), '$allowloc' => array('allow_location', t('Use Browser Location:'), get_pconfig(local_channel(), 'system', 'use_browser_location') ? 1 : '', '', $yes_no), '$adult' => array('adult', t('Adult Content'), $adult_flag, t('This channel frequently or regularly publishes adult content. (Please tag any adult material and/or nudity with #NSFW)'), $yes_no), '$h_prv' => t('Security and Privacy Settings'), '$permissions_set' => $permissions_set, '$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), '$lbl_pmacro' => t('Simple Privacy Settings:'), '$pmacro3' => t('Very Public - <em>extremely permissive (should be used with caution)</em>'), '$pmacro2' => t('Typical - <em>default public, privacy when desired (similar to social network permissions but with improved privacy)</em>'), '$pmacro1' => t('Private - <em>default private, never open or public</em>'), '$pmacro0' => t('Blocked - <em>default blocked to/from everybody</em>'), '$permiss_arr' => $permiss, '$blocktags' => array('blocktags', t('Allow others to tag your posts'), 1 - $blocktags, t('Often used by the community to retro-actively flag inappropriate content'), $yes_no), '$lbl_p2macro' => t('Channel Permission Limits'), '$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 Access Control List (ACL)'), '$permdesc' => t("(click to open/close)"), '$aclselect' => populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))), '$allow_cid' => acl2json($perm_defaults['allow_cid']), '$allow_gid' => acl2json($perm_defaults['allow_gid']), '$deny_cid' => acl2json($perm_defaults['deny_cid']), '$deny_gid' => acl2json($perm_defaults['deny_gid']), '$suggestme' => $suggestme, '$group_select' => $group_select, '$role' => array('permissions_role', t('Channel permissions category:'), $permissions_role, '', $perm_roles), '$profile_in_dir' => $profile_in_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, '$unkmail' => $unkmail, '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), intval($channel['channel_max_anon_mail']), t("Useful to reduce spamming")), '$h_not' => t('Notification Settings'), '$activity_options' => t('By default post a status message when:'), '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no), '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, '', $yes_no), '$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, '', $yes_no), '$lbl_not' => t('Send a notification email when:'), '$notify1' => array('notify1', t('You receive a connection request'), $notify & NOTIFY_INTRO, NOTIFY_INTRO, '', $yes_no), '$notify2' => array('notify2', t('Your connections are confirmed'), $notify & NOTIFY_CONFIRM, NOTIFY_CONFIRM, '', $yes_no), '$notify3' => array('notify3', t('Someone writes on your profile wall'), $notify & NOTIFY_WALL, NOTIFY_WALL, '', $yes_no), '$notify4' => array('notify4', t('Someone writes a followup comment'), $notify & NOTIFY_COMMENT, NOTIFY_COMMENT, '', $yes_no), '$notify5' => array('notify5', t('You receive a private message'), $notify & NOTIFY_MAIL, NOTIFY_MAIL, '', $yes_no), '$notify6' => array('notify6', t('You receive a friend suggestion'), $notify & NOTIFY_SUGGEST, NOTIFY_SUGGEST, '', $yes_no), '$notify7' => array('notify7', t('You are tagged in a post'), $notify & NOTIFY_TAGSELF, NOTIFY_TAGSELF, '', $yes_no), '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), $notify & NOTIFY_POKE, NOTIFY_POKE, '', $yes_no), '$lbl_vnot' => t('Show visual notifications including:'), '$vnotify1' => array('vnotify1', t('Unseen grid activity'), $vnotify & VNOTIFY_NETWORK, VNOTIFY_NETWORK, '', $yes_no), '$vnotify2' => array('vnotify2', t('Unseen channel activity'), $vnotify & VNOTIFY_CHANNEL, VNOTIFY_CHANNEL, '', $yes_no), '$vnotify3' => array('vnotify3', t('Unseen private messages'), $vnotify & VNOTIFY_MAIL, VNOTIFY_MAIL, t('Recommended'), $yes_no), '$vnotify4' => array('vnotify4', t('Upcoming events'), $vnotify & VNOTIFY_EVENT, VNOTIFY_EVENT, '', $yes_no), '$vnotify5' => array('vnotify5', t('Events today'), $vnotify & VNOTIFY_EVENTTODAY, VNOTIFY_EVENTTODAY, '', $yes_no), '$vnotify6' => array('vnotify6', t('Upcoming birthdays'), $vnotify & VNOTIFY_BIRTHDAY, VNOTIFY_BIRTHDAY, t('Not available in all themes'), $yes_no), '$vnotify7' => array('vnotify7', t('System (personal) notifications'), $vnotify & VNOTIFY_SYSTEM, VNOTIFY_SYSTEM, '', $yes_no), '$vnotify8' => array('vnotify8', t('System info messages'), $vnotify & VNOTIFY_INFO, VNOTIFY_INFO, t('Recommended'), $yes_no), '$vnotify9' => array('vnotify9', t('System critical alerts'), $vnotify & VNOTIFY_ALERT, VNOTIFY_ALERT, t('Recommended'), $yes_no), '$vnotify10' => array('vnotify10', t('New connections'), $vnotify & VNOTIFY_INTRO, VNOTIFY_INTRO, t('Recommended'), $yes_no), '$vnotify11' => array('vnotify11', t('System Registrations'), $vnotify & VNOTIFY_REGISTER, VNOTIFY_REGISTER, '', $yes_no), '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')), '$h_advn' => t('Advanced Account/Page Type Settings'), '$h_descadvn' => t('Change the behaviour of this account for special situations'), '$pagetype' => $pagetype, '$lbl_misc' => t('Miscellaneous Settings'), '$photo_path' => array('photo_path', t('Default photo upload folder'), get_pconfig(local_channel(), 'system', 'photo_path'), t('%Y - current year, %m -  current month')), '$attach_path' => array('attach_path', t('Default file upload folder'), get_pconfig(local_channel(), 'system', 'attach_path'), t('%Y - current year, %m -  current month')), '$menus' => $menu, '$menu_desc' => t('Personal menu to display in your channel pages'), '$removeme' => t('Remove Channel'), '$removechannel' => t('Remove this channel.'), '$firefoxshare' => t('Firefox Share $Projectname provider'), '$cal_first_day' => array('first_day', t('Start calendar week on monday'), get_pconfig(local_channel(), 'system', 'cal_first_day') ? 1 : '', '', $yes_no)));
     call_hooks('settings_form', $o);
     //$o .= '</form>' . "\r\n";
     return $o;
 }
Example #3
0
 /**
  * @brief Handle the actions of the different setup steps.
  *
  */
 function post()
 {
     switch ($this->install_wizard_pass) {
         case 1:
         case 2:
             return;
             // implied break;
         // implied break;
         case 3:
             $urlpath = \App::get_path();
             $dbhost = trim($_POST['dbhost']);
             $dbport = intval(trim($_POST['dbport']));
             $dbuser = trim($_POST['dbuser']);
             $dbpass = trim($_POST['dbpass']);
             $dbdata = trim($_POST['dbdata']);
             $dbtype = intval(trim($_POST['dbtype']));
             $phpath = trim($_POST['phpath']);
             $adminmail = trim($_POST['adminmail']);
             $siteurl = trim($_POST['siteurl']);
             $advanced = intval($_POST['advanced']) ? 1 : 0;
             // $siteurl should not have a trailing slash
             $siteurl = rtrim($siteurl, '/');
             require_once 'include/dba/dba_driver.php';
             $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
             if (!\DBA::$dba->connected) {
                 echo 'Database Connect failed: ' . DBA::$dba->error;
                 killme();
             }
             return;
             // implied break;
         // implied break;
         case 4:
             $urlpath = \App::get_path();
             $dbhost = notags(trim($_POST['dbhost']));
             $dbport = intval(notags(trim($_POST['dbport'])));
             $dbuser = notags(trim($_POST['dbuser']));
             $dbpass = notags(trim($_POST['dbpass']));
             $dbdata = notags(trim($_POST['dbdata']));
             $dbtype = intval(notags(trim($_POST['dbtype'])));
             $phpath = notags(trim($_POST['phpath']));
             $timezone = notags(trim($_POST['timezone']));
             $adminmail = notags(trim($_POST['adminmail']));
             $siteurl = notags(trim($_POST['siteurl']));
             $advanced = intval($_POST['advanced']) ? 1 : 0;
             if ($siteurl != z_root()) {
                 $test = z_fetch_url($siteurl . "/setup/testrewrite");
                 if (!$test['success'] || $test['body'] != 'ok') {
                     \App::$data['url_fail'] = true;
                     \App::$data['url_error'] = $test['error'];
                     return;
                 }
             }
             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();
             }
             $tpl = get_intltext_template('htconfig.tpl');
             $txt = replace_macros($tpl, array('$dbhost' => $dbhost, '$dbport' => $dbport, '$dbuser' => $dbuser, '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$dbtype' => $dbtype, '$uno' => 1 - $advanced, '$timezone' => $timezone, '$siteurl' => $siteurl, '$site_id' => random_string(), '$phpath' => $phpath, '$adminmail' => $adminmail));
             $result = file_put_contents('.htconfig.php', $txt);
             if (!$result) {
                 \App::$data['txt'] = $txt;
             }
             $errors = $this->load_database($db);
             if ($errors) {
                 \App::$data['db_failed'] = $errors;
             } else {
                 \App::$data['db_installed'] = true;
             }
             return;
             // implied break;
         // implied break;
         default:
             break;
     }
 }
Example #4
0
 function get()
 {
     $o = '';
     nav_set_selected('settings');
     if (!local_channel() || $_SESSION['delegate']) {
         notice(t('Permission denied.') . EOL);
         return login();
     }
     $channel = \App::get_channel();
     if ($channel) {
         head_set_icon($channel['xchan_photo_s']);
     }
     $yes_no = array(t('No'), t('Yes'));
     if (argc() > 1 && argv(1) === 'oauth') {
         if (argc() > 2 && argv(2) === 'add') {
             $tpl = get_markup_template("settings_oauth_edit.tpl");
             $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Submit'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), '', t('Name of application')), '$key' => array('key', t('Consumer Key'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$secret' => array('secret', t('Consumer Secret'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$redirect' => array('redirect', t('Redirect'), '', t('Redirect URI - leave blank unless your application specifically requires this')), '$icon' => array('icon', t('Icon url'), '', t('Optional'))));
             return $o;
         }
         if (argc() > 3 && argv(2) === 'edit') {
             $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel());
             if (!count($r)) {
                 notice(t('Application not found.'));
                 return;
             }
             $app = $r[0];
             $tpl = get_markup_template("settings_oauth_edit.tpl");
             $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Update'), '$cancel' => t('Cancel'), '$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'], ''), '$icon' => array('icon', t('Icon url'), $app['icon'], '')));
             return $o;
         }
         if (argc() > 3 && argv(2) === 'delete') {
             check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
             $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel());
             goaway(z_root() . "/settings/oauth/");
             return;
         }
         $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my \n\t\t\t\t\tFROM clients\n\t\t\t\t\tLEFT JOIN tokens ON clients.client_id=tokens.client_id\n\t\t\t\t\tWHERE clients.uid IN (%d,0)", local_channel(), local_channel());
         $tpl = get_markup_template("settings_oauth.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$baseurl' => z_root(), '$title' => t('Connected Apps'), '$add' => t('Add application'), '$edit' => t('Edit'), '$delete' => t('Delete'), '$consumerkey' => t('Client key starts with'), '$noname' => t('No name'), '$remove' => t('Remove authorization'), '$apps' => $r));
         return $o;
     }
     if (argc() > 1 && argv(1) === 'featured') {
         $settings_addons = "";
         $o = '';
         $r = q("SELECT * FROM `hook` WHERE `hook` = 'feature_settings' ");
         if (!$r) {
             $settings_addons = t('No feature settings configured');
         }
         call_hooks('feature_settings', $settings_addons);
         $tpl = get_markup_template("settings_addons.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_featured"), '$title' => t('Feature/Addon Settings'), '$settings_addons' => $settings_addons));
         return $o;
     }
     /*
      * ACCOUNT SETTINGS
      */
     if (argc() > 1 && argv(1) === 'account') {
         $account_settings = "";
         call_hooks('account_settings', $account_settings);
         $email = \App::$account['account_email'];
         $tpl = get_markup_template("settings_account.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_account"), '$title' => t('Account Settings'), '$origpass' => array('origpass', t('Current Password'), ' ', ''), '$password1' => array('npassword', t('Enter New Password'), '', ''), '$password2' => array('confirm', t('Confirm New Password'), '', t('Leave password fields blank unless changing')), '$submit' => t('Submit'), '$email' => array('email', t('Email Address:'), $email, ''), '$removeme' => t('Remove Account'), '$removeaccount' => t('Remove this account including all its channels'), '$account_settings' => $account_settings));
         return $o;
     }
     if (argc() > 1 && argv(1) === 'tokens') {
         $atoken = null;
         if (argc() > 2) {
             $id = argv(2);
             $atoken = q("select * from atoken where atoken_id = %d and atoken_uid = %d", intval($id), intval(local_channel()));
             if ($atoken) {
                 $atoken = $atoken[0];
             }
             if ($atoken && argc() > 3 && argv(3) === 'drop') {
                 $r = q("delete from atoken where atoken_id = %d", intval($id));
             }
         }
         $t = q("select * from atoken where atoken_uid = %d", intval(local_channel()));
         $desc = t('Use this form to create temporary access identifiers to share things with non-members. These identities may be used in Access Control Lists and visitors may login using these credentials to access the private content.');
         $desc2 = t('You may also provide <em>dropbox</em> style access links to friends and associates by adding the Login Password to any specific site URL as shown. Examples:');
         $tpl = get_markup_template("settings_tokens.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_tokens"), '$title' => t('Guest Access Tokens'), '$desc' => $desc, '$desc2' => $desc2, '$tokens' => $t, '$atoken' => $atoken, '$url1' => z_root() . '/channel/' . $channel['channel_address'], '$url2' => z_root() . '/photos/' . $channel['channel_address'], '$name' => array('name', t('Login Name') . ' <span class="required">*</span>', $atoken ? $atoken['atoken_name'] : '', ''), '$token' => array('token', t('Login Password') . ' <span class="required">*</span>', $atoken ? $atoken['atoken_token'] : autoname(8), ''), '$expires' => array('expires', t('Expires (yyyy-mm-dd)'), $atoken['atoken_expires'] && $atoken['atoken_expires'] != NULL_DATE ? datetime_convert('UTC', date_default_timezone_get(), $atoken['atoken_expires']) : '', ''), '$submit' => t('Submit')));
         return $o;
     }
     if (argc() > 1 && argv(1) === 'features') {
         $arr = array();
         $features = get_features();
         foreach ($features as $fname => $fdata) {
             $arr[$fname] = array();
             $arr[$fname][0] = $fdata[0];
             foreach (array_slice($fdata, 1) as $f) {
                 $arr[$fname][1][] = array('feature_' . $f[0], $f[1], intval(feature_enabled(local_channel(), $f[0])) ? "1" : '', $f[2], array(t('Off'), t('On')));
             }
         }
         $tpl = get_markup_template("settings_features.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_features"), '$title' => t('Additional Features'), '$features' => $arr, '$submit' => t('Submit')));
         return $o;
     }
     if (argc() > 1 && argv(1) === 'connectors') {
         $settings_connectors = "";
         call_hooks('connector_settings', $settings_connectors);
         $r = null;
         $tpl = get_markup_template("settings_connectors.tpl");
         $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_connectors"), '$title' => t('Connector Settings'), '$submit' => t('Submit'), '$settings_connectors' => $settings_connectors));
         call_hooks('display_settings', $o);
         return $o;
     }
     /*
      * DISPLAY SETTINGS
      */
     if (argc() > 1 && argv(1) === 'display') {
         $default_theme = get_config('system', 'theme');
         if (!$default_theme) {
             $default_theme = 'default';
         }
         $default_mobile_theme = get_config('system', 'mobile_theme');
         if (!$mobile_default_theme) {
             $mobile_default_theme = 'none';
         }
         $allowed_themes_str = get_config('system', 'allowed_themes');
         $allowed_themes_raw = explode(',', $allowed_themes_str);
         $allowed_themes = array();
         if (count($allowed_themes_raw)) {
             foreach ($allowed_themes_raw as $x) {
                 if (strlen(trim($x)) && is_dir("view/theme/{$x}")) {
                     $allowed_themes[] = trim($x);
                 }
             }
         }
         $themes = array();
         $files = glob('view/theme/*');
         if ($allowed_themes) {
             foreach ($allowed_themes as $th) {
                 $f = $th;
                 $is_experimental = file_exists('view/theme/' . $th . '/experimental');
                 $unsupported = file_exists('view/theme/' . $th . '/unsupported');
                 $is_mobile = file_exists('view/theme/' . $th . '/mobile');
                 $is_library = file_exists('view/theme/' . $th . '/library');
                 $mobile_themes["---"] = t("No special theme for mobile devices");
                 if (!$is_experimental or $is_experimental && (get_config('experimentals', 'exp_themes') == 1 or get_config('experimentals', 'exp_themes') === false)) {
                     $theme_name = $is_experimental ? sprintf(t('%s - (Experimental)'), $f) : $f;
                     if (!$is_library) {
                         if ($is_mobile) {
                             $mobile_themes[$f] = $themes[$f] = $theme_name . ' (' . t('mobile') . ')';
                         } else {
                             $mobile_themes[$f] = $themes[$f] = $theme_name;
                         }
                     }
                 }
             }
         }
         $theme_selected = !x($_SESSION, 'theme') ? $default_theme : $_SESSION['theme'];
         $mobile_theme_selected = !x($_SESSION, 'mobile_theme') ? $default_mobile_theme : $_SESSION['mobile_theme'];
         $preload_images = get_pconfig(local_channel(), 'system', 'preload_images');
         $preload_images = $preload_images === false ? '0' : $preload_images;
         // default if not set: 0
         $user_scalable = get_pconfig(local_channel(), 'system', 'user_scalable');
         $user_scalable = $user_scalable === false ? '1' : $user_scalable;
         // default if not set: 1
         $browser_update = intval(get_pconfig(local_channel(), 'system', 'update_interval'));
         $browser_update = $browser_update == 0 ? 80 : $browser_update / 1000;
         // default if not set: 40 seconds
         $itemspage = intval(get_pconfig(local_channel(), 'system', 'itemspage'));
         $itemspage = $itemspage > 0 && $itemspage < 101 ? $itemspage : 20;
         // default if not set: 20 items
         $nosmile = get_pconfig(local_channel(), 'system', 'no_smilies');
         $nosmile = $nosmile === false ? '0' : $nosmile;
         // default if not set: 0
         $title_tosource = get_pconfig(local_channel(), 'system', 'title_tosource');
         $title_tosource = $title_tosource === false ? '0' : $title_tosource;
         // default if not set: 0
         $theme_config = "";
         if (($themeconfigfile = $this->get_theme_config_file($theme_selected)) != null) {
             require_once $themeconfigfile;
             $theme_config = theme_content($a);
         }
         $tpl = get_markup_template("settings_display.tpl");
         $o = replace_macros($tpl, array('$ptitle' => t('Display Settings'), '$d_tset' => t('Theme Settings'), '$d_ctset' => t('Custom Theme Settings'), '$d_cset' => t('Content Settings'), '$form_security_token' => get_form_security_token("settings_display"), '$submit' => t('Submit'), '$baseurl' => z_root(), '$uid' => local_channel(), '$theme' => $themes ? array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview') : false, '$mobile_theme' => $mobile_themes ? array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, '') : false, '$preload_images' => array('preload_images', t("Preload images before rendering the page"), $preload_images, t("The subjective page load time will be longer but the page will be ready when displayed"), $yes_no), '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Show emoticons (smilies) as images"), 1 - intval($nosmile), '', $yes_no), '$title_tosource' => array('title_tosource', t("Link post titles to source"), $title_tosource, '', $yes_no), '$layout_editor' => t('System Page Layout Editor - (advanced)'), '$theme_config' => $theme_config, '$expert' => feature_enabled(local_channel(), 'expert'), '$channel_list_mode' => array('channel_list_mode', t('Use blog/list mode on channel page'), get_pconfig(local_channel(), 'system', 'channel_list_mode'), t('(comments displayed separately)'), $yes_no), '$network_list_mode' => array('network_list_mode', t('Use blog/list mode on grid page'), get_pconfig(local_channel(), 'system', 'network_list_mode'), t('(comments displayed separately)'), $yes_no), '$channel_divmore_height' => array('channel_divmore_height', t('Channel page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'channel_divmore_height') ? get_pconfig(local_channel(), 'system', 'channel_divmore_height') : 400, t('click to expand content exceeding this height')), '$network_divmore_height' => array('network_divmore_height', t('Grid page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'network_divmore_height') ? get_pconfig(local_channel(), 'system', 'network_divmore_height') : 400, t('click to expand content exceeding this height'))));
         return $o;
     }
     if (argv(1) === 'channel') {
         require_once 'include/acl_selectors.php';
         require_once 'include/permissions.php';
         $p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_channel()));
         if (count($p)) {
             $profile = $p[0];
         }
         load_pconfig(local_channel(), 'expire');
         $channel = \App::get_channel();
         $global_perms = get_perms();
         $permiss = array();
         $perm_opts = array(array(t('Nobody except yourself'), 0), array(t('Only those you specifically allow'), PERMS_SPECIFIC), array(t('Approved connections'), PERMS_CONTACTS), array(t('Any connections'), PERMS_PENDING), array(t('Anybody on this website'), PERMS_SITE), array(t('Anybody in this network'), PERMS_NETWORK), array(t('Anybody authenticated'), PERMS_AUTHED), array(t('Anybody on the internet'), PERMS_PUBLIC));
         foreach ($global_perms as $k => $perm) {
             $options = array();
             foreach ($perm_opts as $opt) {
                 if (!$perm[2] && $opt[1] == PERMS_PUBLIC) {
                     continue;
                 }
                 $options[$opt[1]] = $opt[0];
             }
             $permiss[] = array($k, $perm[3], $channel[$perm[0]], $perm[4], $options);
         }
         //		logger('permiss: ' . print_r($permiss,true));
         $username = $channel['channel_name'];
         $nickname = $channel['channel_address'];
         $timezone = $channel['channel_timezone'];
         $notify = $channel['channel_notifyflags'];
         $defloc = $channel['channel_location'];
         $maxreq = $channel['channel_max_friend_req'];
         $expire = $channel['channel_expire_days'];
         $adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT);
         $sys_expire = get_config('system', 'default_expire_days');
         //		$unkmail    = \App::$user['unkmail'];
         //		$cntunkmail = \App::$user['cntunkmail'];
         $hide_presence = intval(get_pconfig(local_channel(), 'system', 'hide_online_status'));
         $expire_items = get_pconfig(local_channel(), 'expire', 'items');
         $expire_items = $expire_items === false ? '1' : $expire_items;
         // default if not set: 1
         $expire_notes = get_pconfig(local_channel(), 'expire', 'notes');
         $expire_notes = $expire_notes === false ? '1' : $expire_notes;
         // default if not set: 1
         $expire_starred = get_pconfig(local_channel(), 'expire', 'starred');
         $expire_starred = $expire_starred === false ? '1' : $expire_starred;
         // default if not set: 1
         $expire_photos = get_pconfig(local_channel(), 'expire', 'photos');
         $expire_photos = $expire_photos === false ? '0' : $expire_photos;
         // default if not set: 0
         $expire_network_only = get_pconfig(local_channel(), 'expire', 'network_only');
         $expire_network_only = $expire_network_only === false ? '0' : $expire_network_only;
         // default if not set: 0
         $suggestme = get_pconfig(local_channel(), 'system', 'suggestme');
         $suggestme = $suggestme === false ? '0' : $suggestme;
         // default if not set: 0
         $post_newfriend = get_pconfig(local_channel(), 'system', 'post_newfriend');
         $post_newfriend = $post_newfriend === false ? '0' : $post_newfriend;
         // default if not set: 0
         $post_joingroup = get_pconfig(local_channel(), 'system', 'post_joingroup');
         $post_joingroup = $post_joingroup === false ? '0' : $post_joingroup;
         // default if not set: 0
         $post_profilechange = get_pconfig(local_channel(), 'system', 'post_profilechange');
         $post_profilechange = $post_profilechange === false ? '0' : $post_profilechange;
         // default if not set: 0
         $blocktags = get_pconfig(local_channel(), 'system', 'blocktags');
         $blocktags = $blocktags === false ? '0' : $blocktags;
         $timezone = date_default_timezone_get();
         $opt_tpl = get_markup_template("field_checkbox.tpl");
         if (get_config('system', 'publish_all')) {
             $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
         } else {
             $profile_in_dir = replace_macros($opt_tpl, array('$field' => array('profile_in_directory', t('Publish your default profile in the network directory'), $profile['publish'], '', $yes_no)));
         }
         $suggestme = replace_macros($opt_tpl, array('$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', $yes_no)));
         $subdir = strlen(\App::get_path()) ? '<br />' . t('or') . ' ' . z_root() . '/channel/' . $nickname : '';
         $tpl_addr = get_markup_template("settings_nick_set.tpl");
         $prof_addr = replace_macros($tpl_addr, array('$desc' => t('Your channel address is'), '$nickname' => $nickname, '$subdir' => $subdir, '$basepath' => \App::get_hostname()));
         $stpl = get_markup_template('settings.tpl');
         $acl = new \Zotlabs\Access\AccessList($channel);
         $perm_defaults = $acl->get();
         require_once 'include/group.php';
         $group_select = mini_group_select(local_channel(), $channel['channel_default_group']);
         require_once 'include/menu.php';
         $m1 = menu_list(local_channel());
         $menu = false;
         if ($m1) {
             $menu = array();
             $current = get_pconfig(local_channel(), 'system', 'channel_menu');
             $menu[] = array('name' => '', 'selected' => !$current ? true : false);
             foreach ($m1 as $m) {
                 $menu[] = array('name' => htmlspecialchars($m['menu_name'], ENT_COMPAT, 'UTF-8'), 'selected' => $m['menu_name'] === $current ? ' selected="selected" ' : false);
             }
         }
         $evdays = get_pconfig(local_channel(), 'system', 'evdays');
         if (!$evdays) {
             $evdays = 3;
         }
         $permissions_role = get_pconfig(local_channel(), 'system', 'permissions_role');
         if (!$permissions_role) {
             $permissions_role = 'custom';
         }
         $permissions_set = $permissions_role != 'custom' ? true : false;
         $vnotify = get_pconfig(local_channel(), 'system', 'vnotify');
         $always_show_in_notices = get_pconfig(local_channel(), 'system', 'always_show_in_notices');
         if ($vnotify === false) {
             $vnotify = -1;
         }
         $o .= replace_macros($stpl, array('$ptitle' => t('Channel Settings'), '$submit' => t('Submit'), '$baseurl' => z_root(), '$uid' => local_channel(), '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, '$h_basic' => t('Basic Settings'), '$username' => array('username', t('Full Name:'), $username, ''), '$email' => array('email', t('Email Address:'), $email, ''), '$timezone' => array('timezone_select', t('Your Timezone:'), $timezone, '', get_timezones()), '$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')), '$allowloc' => array('allow_location', t('Use Browser Location:'), get_pconfig(local_channel(), 'system', 'use_browser_location') ? 1 : '', '', $yes_no), '$adult' => array('adult', t('Adult Content'), $adult_flag, t('This channel frequently or regularly publishes adult content. (Please tag any adult material and/or nudity with #NSFW)'), $yes_no), '$h_prv' => t('Security and Privacy Settings'), '$permissions_set' => $permissions_set, '$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), '$lbl_pmacro' => t('Simple Privacy Settings:'), '$pmacro3' => t('Very Public - <em>extremely permissive (should be used with caution)</em>'), '$pmacro2' => t('Typical - <em>default public, privacy when desired (similar to social network permissions but with improved privacy)</em>'), '$pmacro1' => t('Private - <em>default private, never open or public</em>'), '$pmacro0' => t('Blocked - <em>default blocked to/from everybody</em>'), '$permiss_arr' => $permiss, '$blocktags' => array('blocktags', t('Allow others to tag your posts'), 1 - $blocktags, t('Often used by the community to retro-actively flag inappropriate content'), $yes_no), '$lbl_p2macro' => t('Advanced Privacy Settings'), '$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 and Publish Permissions'), '$permdesc' => t("(click to open/close)"), '$aclselect' => populate_acl($perm_defaults, false, \Zotlabs\Lib\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()), '$profile_in_dir' => $profile_in_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, '$unkmail' => $unkmail, '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), intval($channel['channel_max_anon_mail']), t("Useful to reduce spamming")), '$h_not' => t('Notification Settings'), '$activity_options' => t('By default post a status message when:'), '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no), '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, '', $yes_no), '$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, '', $yes_no), '$lbl_not' => t('Send a notification email when:'), '$notify1' => array('notify1', t('You receive a connection request'), $notify & NOTIFY_INTRO, NOTIFY_INTRO, '', $yes_no), '$notify2' => array('notify2', t('Your connections are confirmed'), $notify & NOTIFY_CONFIRM, NOTIFY_CONFIRM, '', $yes_no), '$notify3' => array('notify3', t('Someone writes on your profile wall'), $notify & NOTIFY_WALL, NOTIFY_WALL, '', $yes_no), '$notify4' => array('notify4', t('Someone writes a followup comment'), $notify & NOTIFY_COMMENT, NOTIFY_COMMENT, '', $yes_no), '$notify5' => array('notify5', t('You receive a private message'), $notify & NOTIFY_MAIL, NOTIFY_MAIL, '', $yes_no), '$notify6' => array('notify6', t('You receive a friend suggestion'), $notify & NOTIFY_SUGGEST, NOTIFY_SUGGEST, '', $yes_no), '$notify7' => array('notify7', t('You are tagged in a post'), $notify & NOTIFY_TAGSELF, NOTIFY_TAGSELF, '', $yes_no), '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), $notify & NOTIFY_POKE, NOTIFY_POKE, '', $yes_no), '$lbl_vnot' => t('Show visual notifications including:'), '$vnotify1' => array('vnotify1', t('Unseen grid activity'), $vnotify & VNOTIFY_NETWORK, VNOTIFY_NETWORK, '', $yes_no), '$vnotify2' => array('vnotify2', t('Unseen channel activity'), $vnotify & VNOTIFY_CHANNEL, VNOTIFY_CHANNEL, '', $yes_no), '$vnotify3' => array('vnotify3', t('Unseen private messages'), $vnotify & VNOTIFY_MAIL, VNOTIFY_MAIL, t('Recommended'), $yes_no), '$vnotify4' => array('vnotify4', t('Upcoming events'), $vnotify & VNOTIFY_EVENT, VNOTIFY_EVENT, '', $yes_no), '$vnotify5' => array('vnotify5', t('Events today'), $vnotify & VNOTIFY_EVENTTODAY, VNOTIFY_EVENTTODAY, '', $yes_no), '$vnotify6' => array('vnotify6', t('Upcoming birthdays'), $vnotify & VNOTIFY_BIRTHDAY, VNOTIFY_BIRTHDAY, t('Not available in all themes'), $yes_no), '$vnotify7' => array('vnotify7', t('System (personal) notifications'), $vnotify & VNOTIFY_SYSTEM, VNOTIFY_SYSTEM, '', $yes_no), '$vnotify8' => array('vnotify8', t('System info messages'), $vnotify & VNOTIFY_INFO, VNOTIFY_INFO, t('Recommended'), $yes_no), '$vnotify9' => array('vnotify9', t('System critical alerts'), $vnotify & VNOTIFY_ALERT, VNOTIFY_ALERT, t('Recommended'), $yes_no), '$vnotify10' => array('vnotify10', t('New connections'), $vnotify & VNOTIFY_INTRO, VNOTIFY_INTRO, t('Recommended'), $yes_no), '$vnotify11' => array('vnotify11', t('System Registrations'), $vnotify & VNOTIFY_REGISTER, VNOTIFY_REGISTER, '', $yes_no), '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')), '$h_advn' => t('Advanced Account/Page Type Settings'), '$h_descadvn' => t('Change the behaviour of this account for special situations'), '$pagetype' => $pagetype, '$expert' => feature_enabled(local_channel(), 'expert'), '$hint' => t('Please enable expert mode (in <a href="settings/features">Settings > Additional features</a>) to adjust!'), '$lbl_misc' => t('Miscellaneous Settings'), '$photo_path' => array('photo_path', t('Default photo upload folder'), get_pconfig(local_channel(), 'system', 'photo_path'), t('%Y - current year, %m -  current month')), '$attach_path' => array('attach_path', t('Default file upload folder'), get_pconfig(local_channel(), 'system', 'attach_path'), t('%Y - current year, %m -  current month')), '$menus' => $menu, '$menu_desc' => t('Personal menu to display in your channel pages'), '$removeme' => t('Remove Channel'), '$removechannel' => t('Remove this channel.'), '$firefoxshare' => t('Firefox Share $Projectname provider'), '$cal_first_day' => array('first_day', t('Start calendar week on monday'), get_pconfig(local_channel(), 'system', 'cal_first_day') ? 1 : '', '', $yes_no)));
         call_hooks('settings_form', $o);
         $o .= '</form>' . "\r\n";
         return $o;
     }
 }
Example #5
0
/**
 * @brief Handle the actions of the different setup steps.
 *
 * @param[in,out] App &$a
 */
function setup_post(&$a)
{
    global $install_wizard_pass, $db;
    switch ($install_wizard_pass) {
        case 1:
        case 2:
            return;
            break;
            // just in case return don't return :)
        // just in case return don't return :)
        case 3:
            $urlpath = App::get_path();
            $dbhost = trim($_POST['dbhost']);
            $dbport = intval(trim($_POST['dbport']));
            $dbuser = trim($_POST['dbuser']);
            $dbpass = trim($_POST['dbpass']);
            $dbdata = trim($_POST['dbdata']);
            $dbtype = intval(trim($_POST['dbtype']));
            $phpath = trim($_POST['phpath']);
            $adminmail = trim($_POST['adminmail']);
            $siteurl = trim($_POST['siteurl']);
            $advanced = intval($_POST['advanced']) ? 1 : 0;
            // $siteurl should not have a trailing slash
            $siteurl = rtrim($siteurl, '/');
            require_once 'include/dba/dba_driver.php';
            unset($db);
            $db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
            if (!$db->connected) {
                echo 'Database Connect failed: ' . $db->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;
        case 4:
            $urlpath = App::get_path();
            $dbhost = notags(trim($_POST['dbhost']));
            $dbport = intval(notags(trim($_POST['dbport'])));
            $dbuser = notags(trim($_POST['dbuser']));
            $dbpass = notags(trim($_POST['dbpass']));
            $dbdata = notags(trim($_POST['dbdata']));
            $dbtype = intval(notags(trim($_POST['dbtype'])));
            $phpath = notags(trim($_POST['phpath']));
            $timezone = notags(trim($_POST['timezone']));
            $adminmail = notags(trim($_POST['adminmail']));
            $siteurl = notags(trim($_POST['siteurl']));
            $advanced = intval($_POST['advanced']) ? 1 : 0;
            if ($siteurl != z_root()) {
                $test = z_fetch_url($siteurl . "/setup/testrewrite");
                if (!$test['success'] || $test['body'] != 'ok') {
                    App::$data['url_fail'] = true;
                    App::$data['url_error'] = $test['error'];
                    return;
                }
            }
            // connect to db
            $db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
            if (!$db->connected) {
                echo 'CRITICAL: DB not connected.';
                killme();
            }
            $tpl = get_intltext_template('htconfig.tpl');
            $txt = replace_macros($tpl, array('$dbhost' => $dbhost, '$dbport' => $dbport, '$dbuser' => $dbuser, '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$dbtype' => $dbtype, '$uno' => 1 - $advanced, '$timezone' => $timezone, '$siteurl' => $siteurl, '$site_id' => random_string(), '$phpath' => $phpath, '$adminmail' => $adminmail));
            $result = file_put_contents('.htconfig.php', $txt);
            if (!$result) {
                App::$data['txt'] = $txt;
            }
            $errors = load_database($db);
            if ($errors) {
                App::$data['db_failed'] = $errors;
            } else {
                App::$data['db_installed'] = true;
            }
            return;
            break;
    }
}
Example #6
0
/**
 * @param  App $a
 * @return string
 */
function admin_page_site(&$a)
{
    /* Installed langs */
    $lang_choices = get_avaiable_languages();
    if (strlen(get_config('system', 'directory_submit_url')) and !strlen(get_config('system', 'directory'))) {
        set_config('system', 'directory', dirname(get_config('system', 'directory_submit_url')));
        del_config('system', 'directory_submit_url');
    }
    /* Installed themes */
    $theme_choices = array();
    $theme_choices_mobile = array();
    $theme_choices_mobile["---"] = t("No special theme for mobile devices");
    $files = glob('view/theme/*');
    /**/
    if ($files) {
        foreach ($files as $file) {
            if (intval(file_exists($file . '/unsupported'))) {
                continue;
            }
            $f = basename($file);
            $theme_name = file_exists($file . '/experimental') ? sprintf("%s - (Experimental)", $f) : $f;
            if (file_exists($file . '/mobile')) {
                $theme_choices_mobile[$f] = $theme_name;
            } else {
                $theme_choices[$f] = $theme_name;
            }
        }
    }
    /* Community page style */
    $community_page_style_choices = array(CP_NO_COMMUNITY_PAGE => t("No community page"), CP_USERS_ON_SERVER => t("Public postings from users of this site"), CP_GLOBAL_COMMUNITY => t("Global community page"));
    /* OStatus conversation poll choices */
    $ostatus_poll_choices = array("-2" => t("Never"), "-1" => t("At post arrival"), "0" => t("Frequently"), "60" => t("Hourly"), "720" => t("Twice daily"), "1440" => t("Daily"));
    $poco_discovery_choices = array("0" => t("Disabled"), "1" => t("Users"), "2" => t("Users, Global Contacts"), "3" => t("Users, Global Contacts/fallback"));
    $poco_discovery_since_choices = array("30" => t("One month"), "91" => t("Three months"), "182" => t("Half a year"), "365" => t("One year"));
    /* get user names to make the install a personal install of X */
    $user_names = array();
    $user_names['---'] = t('Multi user instance');
    $users = q("SELECT username, nickname FROM `user`");
    foreach ($users as $user) {
        $user_names[$user['nickname']] = $user['username'];
    }
    /* Banner */
    $banner = get_config('system', 'banner');
    if ($banner == false) {
        $banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
    }
    $banner = htmlspecialchars($banner);
    $info = get_config('config', 'info');
    $info = htmlspecialchars($info);
    // Automatically create temporary paths
    get_temppath();
    get_lockpath();
    get_itemcachepath();
    //echo "<pre>"; var_dump($lang_choices); die("</pre>");
    /* Register policy */
    $register_choices = array(REGISTER_CLOSED => t("Closed"), REGISTER_APPROVE => t("Requires approval"), REGISTER_OPEN => t("Open"));
    $ssl_choices = array(SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"), SSL_POLICY_FULL => t("Force all links to use SSL"), SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)"));
    if ($a->config['hostname'] == "") {
        $a->config['hostname'] = $a->get_hostname();
    }
    $diaspora_able = $a->get_path() == "";
    $t = get_markup_template("admin_site.tpl");
    return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Site'), '$submit' => t('Save Settings'), '$registration' => t('Registration'), '$upload' => t('File upload'), '$corporate' => t('Policies'), '$advanced' => t('Advanced'), '$portable_contacts' => t('Auto Discovered Contact Directory'), '$performance' => t('Performance'), '$relocate' => t('Relocate - WARNING: advanced function. Could make this server unreachable.'), '$baseurl' => $a->get_baseurl(true), '$sitename' => array('sitename', t("Site name"), $a->config['sitename'], ''), '$hostname' => array('hostname', t("Host name"), $a->config['hostname'], ""), '$sender_email' => array('sender_email', t("Sender Email"), $a->config['sender_email'], t("The email address your server shall use to send notification emails from."), "", "", "email"), '$banner' => array('banner', t("Banner/Logo"), $banner, ""), '$shortcut_icon' => array('shortcut_icon', t("Shortcut icon"), get_config('system', 'shortcut_icon'), t("Link to an icon that will be used for browsers.")), '$touch_icon' => array('touch_icon', t("Touch icon"), get_config('system', 'touch_icon'), t("Link to an icon that will be used for tablets and mobiles.")), '$info' => array('info', t('Additional Info'), $info, sprintf(t('For public servers: you can add additional information here that will be listed at %s/siteinfo.'), get_server())), '$language' => array('language', t("System language"), get_config('system', 'language'), "", $lang_choices), '$theme' => array('theme', t("System theme"), get_config('system', 'theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices), '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system', 'mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile), '$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system', 'ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices), '$force_ssl' => array('force_ssl', t("Force SSL"), get_config('system', 'force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")), '$old_share' => array('old_share', t("Old style 'Share'"), get_config('system', 'old_share'), t("Deactivates the bbcode element 'share' for repeating items.")), '$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), get_config('system', 'hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")), '$singleuser' => array('singleuser', t("Single user instance"), get_config('system', 'singleuser'), t("Make this instance multi-user or single-user for the named user"), $user_names), '$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system', 'maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")), '$maximagelength' => array('maximagelength', t("Maximum image length"), get_config('system', 'max_image_length'), t("Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.")), '$jpegimagequality' => array('jpegimagequality', t("JPEG image quality"), get_config('system', 'jpeg_quality'), t("Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.")), '$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices), '$daily_registrations' => array('max_daily_registrations', t("Maximum Daily Registrations"), get_config('system', 'max_daily_registrations'), t("If registration is permitted above, this sets the maximum number of new user registrations to accept per day.  If register is set to closed, this setting has no effect.")), '$register_text' => array('register_text', t("Register text"), $a->config['register_text'], t("Will be displayed prominently on the registration page.")), '$abandon_days' => array('abandon_days', t('Accounts abandoned after x days'), get_config('system', 'account_abandon_days'), t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')), '$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system', 'allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")), '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system', 'allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")), '$block_public' => array('block_public', t("Block public"), get_config('system', 'block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.")), '$force_publish' => array('publish_all', t("Force publish"), get_config('system', 'publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")), '$global_directory' => array('directory', t("Global directory URL"), get_config('system', 'directory'), t("URL to the global directory. If this is not set, the global directory is completely unavailable to the application.")), '$thread_allow' => array('thread_allow', t("Allow threaded items"), get_config('system', 'thread_allow'), t("Allow infinite level threading for items on this site.")), '$newuser_private' => array('newuser_private', t("Private posts by default for new users"), get_config('system', 'newuser_private'), t("Set default post permissions for all new members to the default privacy group rather than public.")), '$enotify_no_content' => array('enotify_no_content', t("Don't include post content in email notifications"), get_config('system', 'enotify_no_content'), t("Don't include the content of a post/comment/private message/etc. in the email notifications that are sent out from this site, as a privacy measure.")), '$private_addons' => array('private_addons', t("Disallow public access to addons listed in the apps menu."), get_config('config', 'private_addons'), t("Checking this box will restrict addons listed in the apps menu to members only.")), '$disable_embedded' => array('disable_embedded', t("Don't embed private images in posts"), get_config('system', 'disable_embedded'), t("Don't replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos will have to authenticate and load each image, which may take a while.")), '$allow_users_remote_self' => array('allow_users_remote_self', t('Allow Users to set remote_self'), get_config('system', 'allow_users_remote_self'), t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')), '$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system', 'block_extended_register'), t("Disallow users to register additional accounts for use as pages.")), '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system', 'no_openid'), t("OpenID support for registration and logins.")), '$no_regfullname' => array('no_regfullname', t("Fullname check"), !get_config('system', 'no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")), '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system', 'no_utf'), t("Use PHP UTF8 regular expressions")), '$community_page_style' => array('community_page_style', t("Community Page Style"), get_config('system', 'community_page_style'), t("Type of community page to show. 'Global community' shows every public posting from an open distributed network that arrived on this server."), $community_page_style_choices), '$max_author_posts_community_page' => array('max_author_posts_community_page', t("Posts per user on community page"), get_config('system', 'max_author_posts_community_page'), t("The maximum number of posts per user on the community page. (Not valid for 'Global Community')")), '$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system', 'ostatus_disabled'), t("Provide built-in OStatus (StatusNet, GNU Social etc.) compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")), '$ostatus_poll_interval' => array('ostatus_poll_interval', t("OStatus conversation completion interval"), (string) intval(get_config('system', 'ostatus_poll_interval')), t("How often shall the poller check for new entries in OStatus conversations? This can be a very ressource task."), $ostatus_poll_choices), '$ostatus_not_able' => t("OStatus support can only be enabled if threading is enabled."), '$diaspora_able' => $diaspora_able, '$diaspora_not_able' => t("Diaspora support can't be enabled because Friendica was installed into a sub directory."), '$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system', 'diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")), '$dfrn_only' => array('dfrn_only', t('Only allow Friendica contacts'), get_config('system', 'dfrn_only'), t("All contacts must use Friendica protocols. All other built-in communication protocols disabled.")), '$verifyssl' => array('verifyssl', t("Verify SSL"), get_config('system', 'verifyssl'), t("If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.")), '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system', 'proxyuser'), ""), '$proxy' => array('proxy', t("Proxy URL"), get_config('system', 'proxy'), ""), '$timeout' => array('timeout', t("Network timeout"), x(get_config('system', 'curl_timeout')) ? get_config('system', 'curl_timeout') : 60, t("Value is in seconds. Set to 0 for unlimited (not recommended).")), '$delivery_interval' => array('delivery_interval', t("Delivery interval"), x(get_config('system', 'delivery_interval')) ? get_config('system', 'delivery_interval') : 2, t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")), '$poll_interval' => array('poll_interval', t("Poll interval"), x(get_config('system', 'poll_interval')) ? get_config('system', 'poll_interval') : 2, t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), intval(get_config('system', 'maxloadavg')) > 0 ? get_config('system', 'maxloadavg') : 50, t("Maximum system load before delivery and poll processes are deferred - default 50.")), '$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), intval(get_config('system', 'maxloadavg_frontend')) > 0 ? get_config('system', 'maxloadavg_frontend') : 50, t("Maximum system load before the frontend quits service - default 50.")), '$optimize_max_tablesize' => array('optimize_max_tablesize', t("Maximum table size for optimization"), intval(get_config('system', 'optimize_max_tablesize')) > 0 ? get_config('system', 'optimize_max_tablesize') : 100, t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")), '$optimize_fragmentation' => array('optimize_fragmentation', t("Minimum level of fragmentation"), intval(get_config('system', 'optimize_fragmentation')) > 0 ? get_config('system', 'optimize_fragmentation') : 30, t("Minimum fragmenation level to start the automatic optimization - default value is 30%.")), '$poco_completion' => array('poco_completion', t("Periodical check of global contacts"), get_config('system', 'poco_completion'), t("If enabled, the global contacts are checked periodically for missing or outdated data and the vitality of the contacts and servers.")), '$poco_requery_days' => array('poco_requery_days', t("Days between requery"), get_config('system', 'poco_requery_days'), t("Number of days after which a server is requeried for his contacts.")), '$poco_discovery' => array('poco_discovery', t("Discover contacts from other servers"), (string) intval(get_config('system', 'poco_discovery')), t("Periodically query other servers for contacts. You can choose between 'users': the users on the remote system, 'Global Contacts': active contacts that are known on the system. The fallback is meant for Redmatrix servers and older friendica servers, where global contacts weren't available. The fallback increases the server load, so the recommened setting is 'Users, Global Contacts'."), $poco_discovery_choices), '$poco_discovery_since' => array('poco_discovery_since', t("Timeframe for fetching global contacts"), (string) intval(get_config('system', 'poco_discovery_since')), t("When the discovery is activated, this value defines the timeframe for the activity of the global contacts that are fetched from other servers."), $poco_discovery_since_choices), '$poco_local_search' => array('poco_local_search', t("Search the local directory"), get_config('system', 'poco_local_search'), t("Search the local directory instead of the global directory. When searching locally, every search will be executed on the global directory in the background. This improves the search results when the search is repeated.")), '$nodeinfo' => array('nodeinfo', t("Publish server information"), get_config('system', 'nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")), '$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system', 'use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")), '$suppress_language' => array('suppress_language', t("Suppress Language"), get_config('system', 'suppress_language'), t("Suppress language information in meta information about a posting.")), '$suppress_tags' => array('suppress_tags', t("Suppress Tags"), get_config('system', 'suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")), '$itemcache' => array('itemcache', t("Path to item cache"), get_config('system', 'itemcache'), t("The item caches buffers generated bbcode and external images.")), '$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system', 'itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")), '$max_comments' => array('max_comments', t("Maximum numbers of comments per post"), get_config('system', 'max_comments'), t("How much comments should be shown for each post? Default value is 100.")), '$lockpath' => array('lockpath', t("Path for lock file"), get_config('system', 'lockpath'), t("The lock file is used to avoid multiple pollers at one time. Only define a folder here.")), '$temppath' => array('temppath', t("Temp path"), get_config('system', 'temppath'), t("If you have a restricted system where the webserver can't access the system temp path, enter another path here.")), '$basepath' => array('basepath', t("Base path to installation"), get_config('system', 'basepath'), t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot.")), '$proxy_disabled' => array('proxy_disabled', t("Disable picture proxy"), get_config('system', 'proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")), '$old_pager' => array('old_pager', t("Enable old style pager"), get_config('system', 'old_pager'), t("The old style pager has page numbers but slows down massively the page speed.")), '$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system', 'only_tag_search'), t("On large systems the text search can slow down the system extremely.")), '$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")), '$rino' => array('rino', t("RINO Encryption"), intval(get_config('system', 'rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")), '$embedly' => array('embedly', t("Embedly API key"), get_config('system', 'embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")), '$form_security_token' => get_form_security_token("admin_site")));
}