Пример #1
0
/**
 * Redirects to the URL given in $location where $type is the HTTP status code
 * and $search is a string which contains keywords that will be sent in
 * $_GET['s'].
 *
 * This function always ends the execution of the current script.
 *
 * @param int $type HTTP status code
 * @param string $location URL that will be redirected to
 * @param string $search string with keywords. Slashes and '%20' serve as
 *     seperators.
 */
function redirect($type, $location, $search = FALSE, $abs = FALSE)
{
    switch ($type) {
        case 301:
            header('HTTP/1.1 301 Moved Permanently');
            break;
        case 307:
            header('HTTP/1.1 307 Temporary Redirect');
            break;
        case 403:
            header('HTTP/1.1 403 Forbidden');
            break;
        case 404:
            header('HTTP/1.1 404 Not Found');
            break;
    }
    // Determine the protocol, domain and (optionally) port of the server.
    $server = get_server();
    if (!$abs) {
        header('Location: ' . $server . '/' . $location . ($search != FALSE ? '?s=' . trim(strtr($search, array('/' => '+', '%20' => '+')), '+') : ''));
    } else {
        header('Location: ' . $location);
    }
    exit;
}
Пример #2
0
/**
 * @brief Controller for /match.
 *
 * It takes keywords from your profile and queries the directory server for
 * matching keywords from other profiles.
 *
 * @param App &$a
 * @return void|string
 */
function match_content(&$a)
{
    $o = '';
    if (!local_user()) {
        return;
    }
    $a->page['aside'] .= findpeople_widget();
    $a->page['aside'] .= follow_widget();
    $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
    $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
    if (!count($r)) {
        return;
    }
    if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) {
        notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
        return;
    }
    $params = array();
    $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
    if ($tags) {
        $params['s'] = $tags;
        if ($a->pager['page'] != 1) {
            $params['p'] = $a->pager['page'];
        }
        if (strlen(get_config('system', 'directory'))) {
            $x = post_url(get_server() . '/msearch', $params);
        } else {
            $x = post_url($a->get_baseurl() . '/msearch', $params);
        }
        $j = json_decode($x);
        if ($j->total) {
            $a->set_pager_total($j->total);
            $a->set_pager_itemspage($j->items_page);
        }
        if (count($j->results)) {
            $id = 0;
            foreach ($j->results as $jj) {
                $match_nurl = normalise_link($jj->url);
                $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl));
                if (!count($match)) {
                    $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo);
                    $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
                    $photo_menu = array(array(t("View Profile"), zrl($jj->url)));
                    $photo_menu[] = array(t("Connect/Follow"), $connlnk);
                    $contact_details = get_contact_details_by_url($jj->url, local_user());
                    $entry = array('url' => zrl($jj->url), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $jj->url, 'name' => $jj->name, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'inttxt' => ' ' . t('is interested in:'), 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'img_hover' => $jj->tags, 'photo_menu' => $photo_menu, 'id' => ++$id);
                    $entries[] = $entry;
                }
            }
            $tpl = get_markup_template('viewcontact_template.tpl');
            $o .= replace_macros($tpl, array('$title' => t('Profile Match'), '$contacts' => $entries, '$paginate' => paginate($a)));
        } else {
            info(t('No matches') . EOL);
        }
    }
    return $o;
}
Пример #3
0
function testdrive_enotify(&$a, &$b)
{
    if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM && x($b['params'], 'system_type') && $b['params']['system_type'] === 'testdrive_expire') {
        $b['itemlink'] = $a->get_baseurl();
        $b['epreamble'] = $b['preamble'] = sprintf(t('Your account on %s will expire in a few days.'), get_config('system', 'sitename'));
        $b['subject'] = t('Your Friendica test account is about to expire.');
        $b['body'] = sprintf(t("Hi %1\$s,\n\nYour test account on %2\$s will expire in less than five days. We hope you enjoyed this test drive and use this opportunity to find a permanent Friendica website for your integrated social communications. A list of public sites is available at %s/siteinfo - and for more information on setting up your own Friendica server please see the Friendica project website at http://friendica.com."), $b['params']['to_name'], "[url=" . $app->config["system"]["url"] . "]" . $app->config["sitename"] . "[/url]", get_server());
    }
}
Пример #4
0
function match_content(&$a)
{
    $o = '';
    if (!local_user()) {
        return;
    }
    $a->page['aside'] .= follow_widget();
    $a->page['aside'] .= findpeople_widget();
    $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
    $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Profile Match')));
    $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
    if (!count($r)) {
        return;
    }
    if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) {
        notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
        return;
    }
    $params = array();
    $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
    if ($tags) {
        $params['s'] = $tags;
        if ($a->pager['page'] != 1) {
            $params['p'] = $a->pager['page'];
        }
        if (strlen(get_config('system', 'directory'))) {
            $x = post_url(get_server() . '/msearch', $params);
        } else {
            $x = post_url($a->get_baseurl() . '/msearch', $params);
        }
        $j = json_decode($x);
        if ($j->total) {
            $a->set_pager_total($j->total);
            $a->set_pager_itemspage($j->items_page);
        }
        if (count($j->results)) {
            $tpl = get_markup_template('match.tpl');
            foreach ($j->results as $jj) {
                $match_nurl = normalise_link($jj->url);
                $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl));
                if (!count($match)) {
                    $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo);
                    $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
                    $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => proxy_url($jj->photo), '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags));
                }
            }
        } else {
            info(t('No matches') . EOL);
        }
    }
    $o .= cleardiv();
    $o .= paginate($a);
    return $o;
}
Пример #5
0
<link rel="stylesheet" type="text/css" href="<?php 
echo base_url();
?>
assets/css/style.pete.css">
<link href="assets/js/plugin/datepicker/css/datepicker.css" rel="stylesheet">	
<script src="assets/js/plugin/datepicker/bootstrap-datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="assets/js/plugin/responsive-table/responsive-table.css">
<script src="assets/js/plugin/responsive-table/responsive-table.js"></script>
<script>
	var api_server="<?php 
echo get_server();
?>
";
</script>





function set_footer()
{
    $footer = null;
    global $options;
    $server = get_server();
    // jQuery
    if ($options['general']['enable_sort'] || $options['general']['enable_viewer']) {
        $footer .= "  <script type=\"text/javascript\" src=\"" . $server . $options['assets']['jquery_js'] . "\"></script>" . PHP_EOL;
    }
    // Dropbox Dropins
    if ($options['general']['enable_viewer'] && $options['general']['share_button'] && $options['keys']['dropbox'] !== null) {
        $footer .= "  <script type=\"text/javascript\" src=\"https://www.dropbox.com/static/api/2/dropins.js\" id=\"dropboxjs\" data-app-key=\"" . $options['keys']['dropbox'] . "\"></script>" . PHP_EOL;
    }
    $protocol = get_protocol();
    if ($options['general']['concat_assets'] === true) {
        if ($options['general']['enable_viewer'] === true) {
            $footer .= "  <script type=\"text/javascript\" src=\"" . $server . $options['assets']['bootstrap_js'] . "\"></script>" . PHP_EOL;
        }
        $footer .= "  <script type=\"text/javascript\" src=\"" . $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . "/assets/js/listr.pack.js\"></script>" . PHP_EOL;
    } else {
        // Stupid Table
        if ($options['general']['enable_sort'] === true && $options['assets']['stupid_table']) {
            $footer .= "  <script type=\"text/javascript\" src=\"" . $server . $options['assets']['stupid_table'] . "\"></script>" . PHP_EOL;
        }
        // jQuery Searcher
        if ($options['general']['enable_search'] === true && $options['assets']['jquery_searcher']) {
            $footer .= "  <script type=\"text/javascript\" src=\"" . $server . $options['assets']['jquery_searcher'] . "\"></script>" . PHP_EOL;
        }
        // Modal Viewer
        if ($options['general']['enable_viewer'] === true) {
            $footer .= "  <script type=\"text/javascript\" src=\"" . $server . $options['assets']['bootstrap_js'] . "\"></script>" . PHP_EOL;
            // Highlighter.js
            if ($options['general']['enable_highlight'] === true && $options['assets']['highlight_css'] && $options['assets']['highlight_js']) {
                $footer .= "  <script type=\"text/javascript\" src=\"" . $server . $options['assets']['highlight_js'] . "\"></script>" . PHP_EOL;
            }
        }
        $footer .= "  <script type=\"text/javascript\" src=\"" . $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . "/assets/js/listr.min.js\"></script>" . PHP_EOL;
    }
    // Append JS
    foreach ($options['assets']['append_js'] as $append_js) {
        if (is_array($append_js)) {
            $footer .= "  <script type=\"text/javascript\" src=\"" . $append_js[0] . "\" " . $append_js[1] . "></script>" . PHP_EOL;
        } else {
            if ($append_js !== null) {
                $footer .= "  <script type=\"text/javascript\" src=\"{$append_js}\"></script>" . PHP_EOL;
            }
        }
    }
    // Bootlint
    if ($options['debug']['bootlint'] === true) {
        $footer .= "  <script type=\"text/javascript\" src=\"" . $server . $options['assets']['bootlint'] . "\"></script>" . PHP_EOL;
    }
    return $footer;
}
Пример #7
0
/**
 * @param  App $a
 * @return string
 */
function admin_page_site(&$a)
{
    /* Installed langs */
    $lang_choices = array();
    $langs = glob('view/*/strings.php');
    /**/
    if (is_array($langs) && count($langs)) {
        if (!in_array('view/en/strings.php', $langs)) {
            $langs[] = 'view/en/';
        }
        asort($langs);
        foreach ($langs as $l) {
            $t = explode("/", $l);
            $lang_choices[$t[1]] = $t[1];
        }
    }
    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) {
            $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();
    }
    $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), '$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.")), '$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")));
}
Пример #8
0
function discover_directory($search)
{
    $data = Cache::get("dirsearch:" . $search);
    if (!is_null($data)) {
        // Only search for the same item every 24 hours
        if (time() < $data + 60 * 60 * 24) {
            logger("Already searched for " . $search . " in the last 24 hours", LOGGER_DEBUG);
            return;
        }
    }
    $x = fetch_url(get_server() . "/lsearch?p=1&n=500&search=" . urlencode($search));
    $j = json_decode($x);
    if (count($j->results)) {
        foreach ($j->results as $jj) {
            // Check if the contact already exists
            $exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
            if ($exists) {
                logger("Profile " . $jj->url . " already exists (" . $search . ")", LOGGER_DEBUG);
                if ($exists[0]["last_contact"] < $exists[0]["last_failure"] and $exists[0]["updated"] < $exists[0]["last_failure"]) {
                    continue;
                }
                // Update the contact
                poco_last_updated($jj->url);
                continue;
            }
            // Harcoded paths aren't so good. But in this case it is okay.
            // First: We only will get Friendica contacts (which always are using this url schema)
            // Second: There will be no further problems if we are doing a mistake
            $server_url = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "\$1\$2", $jj->url);
            if ($server_url != $jj->url) {
                if (!poco_check_server($server_url)) {
                    logger("Friendica server " . $server_url . " doesn't answer.", LOGGER_DEBUG);
                    continue;
                }
            }
            logger("Friendica server " . $server_url . " seems to be okay.", LOGGER_DEBUG);
            logger("Check if profile " . $jj->url . " is reachable (" . $search . ")", LOGGER_DEBUG);
            $data = probe_url($jj->url);
            if ($data["network"] == NETWORK_DFRN) {
                logger("Add profile " . $jj->url . " to local directory (" . $search . ")", LOGGER_DEBUG);
                poco_check($data["url"], $data["name"], $data["network"], $data["photo"], "", "", "", $jj->tags, $data["addr"], "", 0);
            }
        }
    }
    Cache::set("dirsearch:" . $search, time(), CACHE_DAY);
}
Пример #9
0
<?php

require_once 'base.php';
if (!defined('IS_PRODUCTION')) {
    die('undefine IS_PRODUCTION');
}
$server = get_server(CURRENT_PLATFORM);
$server->setProduction(IS_PRODUCTION);
$server->addDirectory(CONTROLLER_ROOT);
echo $server->handle();
Пример #10
0
function magic_input($controller, $id, $pref_text, $pref_input, $value, $table, $field, $id_name)
{
    ?>
        <span style="min-width: 20px !important;min-height: 10px !important;" id="<?php 
    echo $pref_text . "_" . $id;
    ?>
" 
              onclick="$(this).hide();$('#<?php 
    echo $pref_input . "_" . $id;
    ?>
').show().focus();">
            &nbsp;<?php 
    echo $value;
    ?>
        </span>
        <input class="magic_input" size="<?php 
    echo strlen($value) - 3;
    ?>
" 
               onBlur="
                   $(this).hide();
                   $('#<?php 
    echo $pref_text . "_" . $id;
    ?>
').show().text($(this).val());
                   $.post('<?php 
    echo get_server() . base_url() . $controller;
    ?>
',
                   {
                       'table':'<?php 
    echo $table;
    ?>
',
                       'field':'<?php 
    echo $field;
    ?>
',
                       'update_value':$('input[name=<?php 
    echo $pref_input . "_" . $id;
    ?>
]').val(),
                       'id_name':'<?php 
    echo $id_name;
    ?>
',
                       'id':'<?php 
    echo $id;
    ?>
'
                   },function(data){
                       
                   });
               " 
               id="<?php 
    echo $pref_input . "_" . $id;
    ?>
"  
               type="text" name="<?php 
    echo $pref_input . "_" . $id;
    ?>
" 
               value="<?php 
    echo $value;
    ?>
" />
   <?php 
}
Пример #11
0
     log_conversion($config['LOG_DIR'] . '/' . $vid . '.log', 'Invalid meta tool..must be yamdi or flvtool2');
 }
 exec($cmd, $output);
 log_conversion($config['LOG_DIR'] . '/' . $vid . '.log', implode("\n", $output));
 //change permissions to 666 for lighty
 @chmod($config['FLVDO_DIR'] . '/' . $vid . '.flv', 0666);
 // delete temporary flv file
 @unlink($config['FLVDO_DIR'] . '/' . $vid . 'x.flv');
 //extract video thumbs
 extract_video_thumbs($video_path, $vid);
 //activate video
 if (file_exists($config['FLVDO_DIR'] . '/' . $vid . '.flv') && filesize($config['FLVDO_DIR'] . '/' . $vid . '.flv') > 10) {
     $add = NULL;
     if ($config['multi_server'] == '1') {
         require $config['BASE_DIR'] . '/include/function_server.php';
         $server = get_server();
         update_server_used($server);
         upload_video($config['FLVDO_DIR'] . '/' . $vid . '.flv', $server['server_ip'], $server['ftp_username'], $server['ftp_password'], $server['ftp_root']);
         update_server($server);
         $add = ", server = '" . mysql_real_escape_string($server['url']) . "'";
     }
     $active = $config['approve'] == '1' ? '0' : '1';
     $sql = "UPDATE video SET active = '" . $active . "'" . $add . " WHERE VID = " . intval($vid) . " LIMIT 1";
     $conn->execute($sql);
     @unlink($config['TMP_DIR'] . '/logs/' . $vid . '.log');
 }
 //delete original video
 if ($config['del_original_video'] == '1') {
     if (filesize($config['FLVDO_DIR'] . '/' . $vid . '.flv') > 100 && file_exists($config['FLVDO_DIR'] . '/' . $vid . '.flv')) {
         chmod($video_path, 0777);
         unlink($video_path);
Пример #12
0
function dirfind_content(&$a, $prefix = "")
{
    $community = false;
    $local = get_config('system', 'poco_local_search');
    $search = $prefix . notags(trim($_REQUEST['search']));
    if (strpos($search, '@') === 0) {
        $search = substr($search, 1);
    }
    if (strpos($search, '!') === 0) {
        $search = substr($search, 1);
        $community = true;
    }
    $o = '';
    $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('People Search - %s'), $search)));
    if ($search) {
        if ($local) {
            if ($community) {
                $extra_sql = " AND `community`";
            } else {
                $extra_sql = "";
            }
            $perpage = 80;
            $startrec = $a->pager['page'] * $perpage - $perpage;
            $count = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t(`url` REGEXP '%s' OR `name` REGEXP '%s' OR `location` REGEXP '%s' OR\n\t\t\t\t\t\t`about` REGEXP '%s' OR `keywords` REGEXP '%s')" . $extra_sql, dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)));
            $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`keywords`\n\t\t\t\t\tFROM `gcontact`\n\t\t\t\t\tLEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`\n\t\t\t\t\t\tAND `contact`.`uid` = %d AND NOT `contact`.`blocked`\n\t\t\t\t\t\tAND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')\n\t\t\t\t\tWHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND\n\t\t\t\t\t(`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR\n\t\t\t\t\t\t`gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s') {$extra_sql}\n\t\t\t\t\t\tGROUP BY `gcontact`.`nurl`\n\t\t\t\t\t\tORDER BY `gcontact`.`updated` DESC LIMIT %d, %d", intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND), dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), intval($startrec), intval($perpage));
            $j = new stdClass();
            $j->total = $count[0]["total"];
            $j->items_page = $perpage;
            $j->page = $a->pager['page'];
            foreach ($results as $result) {
                if (poco_alternate_ostatus_url($result["url"])) {
                    continue;
                }
                if ($result["name"] == "") {
                    $urlparts = parse_url($result["url"]);
                    $result["name"] = end(explode("/", $urlparts["path"]));
                }
                $objresult = new stdClass();
                $objresult->cid = $result["cid"];
                $objresult->name = $result["name"];
                $objresult->url = $result["url"];
                $objresult->photo = $result["photo"];
                $objresult->tags = $result["keywords"];
                $j->results[] = $objresult;
            }
            // Add found profiles from the global directory to the local directory
            proc_run('php', 'include/discover_poco.php', "dirsearch", urlencode($search));
        } else {
            $p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : '';
            if (strlen(get_config('system', 'directory'))) {
                $x = fetch_url(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
            }
            $j = json_decode($x);
        }
        if ($j->total) {
            $a->set_pager_total($j->total);
            $a->set_pager_itemspage($j->items_page);
        }
        if (count($j->results)) {
            $tpl = get_markup_template('match.tpl');
            foreach ($j->results as $jj) {
                // If We already know this contact then don't show the "connect" button
                if ($jj->cid > 0) {
                    $connlnk = "";
                    $conntxt = "";
                } else {
                    $connlnk = $a->get_baseurl() . '/follow/?url=' . ($jj->connect ? $jj->connect : $jj->url);
                    $conntxt = t('Connect');
                }
                $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo);
                $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => proxy_url($jj->photo), '$tags' => $jj->tags, '$conntxt' => $conntxt, '$connlnk' => $connlnk));
            }
        } else {
            info(t('No matches') . EOL);
        }
    }
    $o .= '<div class="clear"></div>';
    $o .= paginate($a);
    return $o;
}
Пример #13
0
function vier_community_info()
{
    $a = get_app();
    $show_pages = get_vier_config("show_pages", 1);
    $show_profiles = get_vier_config("show_profiles", 1);
    $show_helpers = get_vier_config("show_helpers", 1);
    $show_services = get_vier_config("show_services", 1);
    $show_friends = get_vier_config("show_friends", 1);
    $show_lastusers = get_vier_config("show_lastusers", 1);
    //get_baseurl
    $url = $a->get_baseurl($ssl_state);
    $aside['$url'] = $url;
    // comunity_profiles
    if ($show_profiles) {
        $r = suggestion_query(local_user(), 0, 9);
        $tpl = get_markup_template('ch_directory_item.tpl');
        if (count($r)) {
            $aside['$comunity_profiles_title'] = t('Community Profiles');
            $aside['$comunity_profiles_items'] = array();
            foreach ($r as $rr) {
                $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $a->get_baseurl() . '/follow/?url=' . urlencode($rr['url']), '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO), '$alt_text' => $rr['name']));
                $aside['$comunity_profiles_items'][] = $entry;
            }
        }
    }
    // last 9 users
    if ($show_lastusers) {
        $publish = get_config('system', 'publish_all') ? '' : " AND `publish` = 1 ";
        $order = " ORDER BY `register_date` DESC ";
        $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`\n\t\t\t\tFROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`\n\t\t\t\tWHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$order} LIMIT %d , %d ", 0, 9);
        $tpl = get_markup_template('ch_directory_item.tpl');
        if (count($r)) {
            $aside['$lastusers_title'] = t('Last users');
            $aside['$lastusers_items'] = array();
            foreach ($r as $rr) {
                $profile_link = $a->get_baseurl() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']);
                $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $profile_link, '$photo' => $a->get_cached_avatar_image($rr['thumb']), '$alt_text' => $rr['name']));
                $aside['$lastusers_items'][] = $entry;
            }
        }
    }
    //right_aside FIND FRIENDS
    if ($show_friends and local_user()) {
        $nv = array();
        $nv['title'] = array("", t('Find Friends'), "", "");
        $nv['directory'] = array('directory', t('Local Directory'), "", "");
        $nv['global_directory'] = array(get_server(), t('Global Directory'), "", "");
        $nv['match'] = array('match', t('Similar Interests'), "", "");
        $nv['suggest'] = array('suggest', t('Friend Suggestions'), "", "");
        $nv['invite'] = array('invite', t('Invite Friends'), "", "");
        $nv['search'] = '<form name="simple_bar" method="get" action="' . $a->get_baseurl() . '/dirfind">
						<span class="sbox_l"></span>
						<span class="sbox">
						<input type="text" name="search" size="13" maxlength="50">
						</span>
						<span class="sbox_r" id="srch_clear"></span>';
        $aside['$nv'] = $nv;
    }
    //Community_Pages at right_aside
    if ($show_pages and local_user()) {
        require_once 'include/forums.php';
        if (x($_GET['cid']) && intval($_GET['cid']) != 0) {
            $cid = $_GET['cid'];
        }
        //sort by last updated item
        $lastitem = true;
        $contacts = get_forumlist($a->user['uid'], true, $lastitem, true);
        $total = count($contacts);
        $visible_forums = 10;
        if (count($contacts)) {
            $id = 0;
            foreach ($contacts as $contact) {
                $selected = $cid == $contact['id'] ? ' forum-selected' : '';
                $entry = array('url' => z_root() . '/network?f=&cid=' . $contact['id'], 'external_url' => z_root() . '/redir/' . $contact['id'], 'name' => $contact['name'], 'cid' => $contact['id'], 'selected' => $selected, 'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO), 'id' => ++$id);
                $entries[] = $entry;
            }
            $tpl = get_markup_template('widget_forumlist_right.tpl');
            $page .= replace_macros($tpl, array('$title' => t('Forums'), '$forums' => $entries, '$link_desc' => t('External link to forum'), '$total' => $total, '$visible_forums' => $visible_forums, '$showmore' => t('show more')));
            $aside['$page'] = $page;
        }
    }
    //END Community Page
    //helpers
    if ($show_helpers) {
        $r = array();
        $helperlist = get_config("vier", "helperlist");
        $helpers = explode(",", $helperlist);
        if ($helpers) {
            $query = "";
            foreach ($helpers as $index => $helper) {
                if ($query != "") {
                    $query .= ",";
                }
                $query .= "'" . dbesc(normalise_link(trim($helper))) . "'";
            }
            $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
        }
        foreach ($r as $index => $helper) {
            $r[$index]["url"] = zrl($helper["url"]);
        }
        $r[] = array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
        $tpl = get_markup_template('ch_helpers.tpl');
        if ($r) {
            $helpers = array();
            $helpers['title'] = array("", t('Help'), "", "");
            $aside['$helpers_items'] = array();
            foreach ($r as $rr) {
                $entry = replace_macros($tpl, array('$url' => $rr['url'], '$title' => $rr['name']));
                $aside['$helpers_items'][] = $entry;
            }
            $aside['$helpers'] = $helpers;
        }
    }
    //end helpers
    //connectable services
    if ($show_services) {
        $r = array();
        if (plugin_enabled("appnet")) {
            $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
        }
        if (plugin_enabled("buffer")) {
            $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
        }
        if (plugin_enabled("blogger")) {
            $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
        }
        if (plugin_enabled("dwpost")) {
            $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
        }
        if (plugin_enabled("fbpost")) {
            $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
        }
        if (plugin_enabled("ifttt")) {
            $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
        }
        if (plugin_enabled("statusnet")) {
            $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
        }
        if (plugin_enabled("gpluspost")) {
            $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
        }
        //if (plugin_enabled("ijpost"))
        //	$r[] = array("photo" => "images/", "name" => "");
        if (plugin_enabled("libertree")) {
            $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
        }
        //if (plugin_enabled("ljpost"))
        //	$r[] = array("photo" => "images/", "name" => "");
        if (plugin_enabled("pumpio")) {
            $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
        }
        if (plugin_enabled("tumblr")) {
            $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
        }
        if (plugin_enabled("twitter")) {
            $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
        }
        if (plugin_enabled("wppost")) {
            $r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress");
        }
        if (function_exists("imap_open") and !get_config("system", "imap_disabled") and !get_config("system", "dfrn_only")) {
            $r[] = array("photo" => "images/mail.png", "name" => "E-Mail");
        }
        $tpl = get_markup_template('ch_connectors.tpl');
        if (count($r)) {
            $con_services = array();
            $con_services['title'] = array("", t('Connect Services'), "", "");
            $aside['$con_services'] = $con_services;
            foreach ($r as $rr) {
                $entry = replace_macros($tpl, array('$url' => $url, '$photo' => $rr['photo'], '$alt_text' => $rr['name']));
                $aside['$connector_items'][] = $entry;
            }
        }
    }
    //end connectable services
    //print right_aside
    $tpl = get_markup_template('communityhome.tpl');
    $a->page['right_aside'] = replace_macros($tpl, $aside);
}
Пример #14
0
function server_switch_stat($id)
{
    global $db;
    $db->setMode(0);
    $aktiv = $db->result(DB_PRE . 'ecp_server', 'stat', 'serverID = ' . $id);
    if ($aktiv == 0) {
        $aktiv = 1;
    } else {
        $aktiv = 0;
    }
    if ($db->query('UPDATE ' . DB_PRE . 'ecp_server SET stat = ' . $aktiv . ' WHERE serverID = ' . $id)) {
        $_GET['ajax'] = 1;
        get_server();
    }
}
Пример #15
0
 function dfrn_request_content(&$a)
 {
     if ($a->argc != 2 || !count($a->profile)) {
         return "";
     }
     // "Homecoming". Make sure we're logged in to this site as the correct user. Then offer a confirm button
     // to send us to the post section to record the introduction.
     if (x($_GET, 'dfrn_url')) {
         if (!local_user()) {
             info(t("Please login to confirm introduction.") . EOL);
             /* setup the return URL to come back to this page if they use openid */
             $_SESSION['return_url'] = $a->query_string;
             return login();
         }
         // Edge case, but can easily happen in the wild. This person is authenticated,
         // but not as the person who needs to deal with this request.
         if ($a->user['nickname'] != $a->argv[1]) {
             notice(t("Incorrect identity currently logged in. Please login to <strong>this</strong> profile.") . EOL);
             return login();
         }
         $dfrn_url = notags(trim(hex2bin($_GET['dfrn_url'])));
         $aes_allow = x($_GET, 'aes_allow') && $_GET['aes_allow'] == 1 ? 1 : 0;
         $confirm_key = x($_GET, 'confirm_key') ? $_GET['confirm_key'] : "";
         // Checking fastlane for validity
         if (x($_SESSION, "fastlane") and normalise_link($_SESSION["fastlane"]) == normalise_link($dfrn_url)) {
             $_POST["dfrn_url"] = $dfrn_url;
             $_POST["confirm_key"] = $confirm_key;
             $_POST["localconfirm"] = 1;
             $_POST["hidden-contact"] = 0;
             $_POST["submit"] = t('Confirm');
             dfrn_request_post($a);
             killme();
             return;
             // NOTREACHED
         }
         $tpl = get_markup_template("dfrn_req_confirm.tpl");
         $o = replace_macros($tpl, array('$dfrn_url' => $dfrn_url, '$aes_allow' => $aes_allow ? '<input type="hidden" name="aes_allow" value="1" />' : "", '$hidethem' => t('Hide this contact'), '$hidechecked' => '', '$confirm_key' => $confirm_key, '$welcome' => sprintf(t('Welcome home %s.'), $a->user['username']), '$please' => sprintf(t('Please confirm your introduction/connection request to %s.'), $dfrn_url), '$submit' => t('Confirm'), '$uid' => $_SESSION['uid'], '$nickname' => $a->user['nickname'], 'dfrn_rawurl' => $_GET['dfrn_url']));
         return $o;
     } elseif (x($_GET, 'confirm_key') && strlen($_GET['confirm_key'])) {
         // we are the requestee and it is now safe to send our user their introduction,
         // We could just unblock it, but first we have to jump through a few hoops to
         // send an email, or even to find out if we need to send an email.
         $intro = q("SELECT * FROM `intro` WHERE `hash` = '%s' LIMIT 1", dbesc($_GET['confirm_key']));
         if (count($intro)) {
             $r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\t\t\tWHERE `contact`.`id` = %d LIMIT 1", intval($intro[0]['contact-id']));
             $auto_confirm = false;
             if (count($r)) {
                 if ($r[0]['page-flags'] != PAGE_NORMAL && $r[0]['page-flags'] != PAGE_PRVGROUP) {
                     $auto_confirm = true;
                 }
                 if (!$auto_confirm) {
                     notification(array('type' => NOTIFY_INTRO, 'notify_flags' => $r[0]['notify-flags'], 'language' => $r[0]['language'], 'to_name' => $r[0]['username'], 'to_email' => $r[0]['email'], 'uid' => $r[0]['uid'], 'link' => $a->get_baseurl() . '/notifications/intros', 'source_name' => strlen(stripslashes($r[0]['name'])) ? stripslashes($r[0]['name']) : t('[Name Withheld]'), 'source_link' => $r[0]['url'], 'source_photo' => $r[0]['photo'], 'verb' => ACTIVITY_REQ_FRIEND, 'otype' => 'intro'));
                 }
                 if ($auto_confirm) {
                     require_once 'mod/dfrn_confirm.php';
                     $handsfree = array('uid' => $r[0]['uid'], 'node' => $r[0]['nickname'], 'dfrn_id' => $r[0]['issued-id'], 'intro_id' => $intro[0]['id'], 'duplex' => $r[0]['page-flags'] == PAGE_FREELOVE ? 1 : 0, 'activity' => intval(get_pconfig($r[0]['uid'], 'system', 'post_newfriend')));
                     dfrn_confirm_post($a, $handsfree);
                 }
             }
             if (!$auto_confirm) {
                 // If we are auto_confirming, this record will have already been nuked
                 // in dfrn_confirm_post()
                 $r = q("UPDATE `intro` SET `blocked` = 0 WHERE `hash` = '%s'", dbesc($_GET['confirm_key']));
             }
         }
         killme();
         return;
         // NOTREACHED
     } else {
         /**
          * Normal web request. Display our user's introduction form.
          */
         if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
             if (!get_config('system', 'local_block')) {
                 notice(t('Public access denied.') . EOL);
                 return;
             }
         }
         /**
          * Try to auto-fill the profile address
          */
         // At first look if an address was provided
         // Otherwise take the local address
         if (x($_GET, 'addr') and $_GET['addr'] != "") {
             $myaddr = hex2bin($_GET['addr']);
         } elseif (x($_GET, 'address') and $_GET['address'] != "") {
             $myaddr = $_GET['address'];
         } elseif (local_user()) {
             if (strlen($a->path)) {
                 $myaddr = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
             } else {
                 $myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(), '://') + 3);
             }
         } else {
             // last, try a zrl
             $myaddr = get_my_url();
         }
         $target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(), '://') + 3);
         /**
          *
          * The auto_request form only has the profile address
          * because nobody is going to read the comments and
          * it doesn't matter if they know you or not.
          *
          */
         if ($a->profile['page-flags'] == PAGE_NORMAL) {
             $tpl = get_markup_template('dfrn_request.tpl');
         } else {
             $tpl = get_markup_template('auto_request.tpl');
         }
         $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:");
         // see if we are allowed to have NETWORK_MAIL2 contacts
         $mail_disabled = function_exists('imap_open') && !get_config('system', 'imap_disabled') ? 0 : 1;
         if (get_config('system', 'dfrn_only')) {
             $mail_disabled = 1;
         }
         if (!$mail_disabled) {
             $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval($a->profile['uid']));
             if (!count($r)) {
                 $mail_disabled = 1;
             }
         }
         // "coming soon" is disabled for now
         //$emailnet = (($mail_disabled) ? '' : t("<strike>Connect as an email follower</strike> \x28Coming soon\x29"));
         $emailnet = "";
         $invite_desc = sprintf(t('If you are not yet a member of the free social web, <a href="%s/siteinfo">follow this link to find a public Friendica site and join us today</a>.'), get_server());
         $o .= replace_macros($tpl, array('$header' => t('Friend/Connection Request'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), '$pls_answer' => t('Please answer the following:'), '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'), $a->profile['name']), false, '', array(t('No'), t('Yes'))), '$add_note' => t('Add a personal note:'), '$page_desc' => $page_desc, '$friendica' => t('Friendica'), '$statusnet' => t('StatusNet/Federated Social Web'), '$diaspora' => t('Diaspora'), '$diasnote' => sprintf(t(' - please do not use this form.  Instead, enter %s into your Diaspora search bar.'), $target_addr), '$your_address' => t('Your Identity Address:'), '$invite_desc' => $invite_desc, '$emailnet' => $emailnet, '$submit' => t('Submit Request'), '$cancel' => t('Cancel'), '$nickname' => $a->argv[1], '$name' => $a->profile['name'], '$myaddr' => $myaddr));
         return $o;
     }
     return;
     // Somebody is fishing.
 }
Пример #16
0
function pasteEnvStatus($group_id)
{
    echo "<table border=1 cellpadding=2 cellspacing=2 bordercolor=white bgclor=#EFF1C9><tr>";
    mysql_connect("localhost", "root", "testme");
    @mysql_select_db("emc_v2") or die("Unable to select database");
    $query = "SELECT * FROM server_mapping where group_id=" . $group_id . " order by server_id";
    $result = mysql_query($query);
    $num = mysql_numrows($result);
    $i = 0;
    while ($i < $num) {
        $server_id = mysql_result($result, $i, "server_id");
        $server_name = get_server($server_id, "server_name");
        $server_host = get_server($server_id, "server_host");
        $ip = gethostbyname($server_host);
        echo "<td width=350 bordercolor=silver><font size=2>{$server_host} ({$ip})</td><td bordercolor=white><font size=1>";
        global $srv_cnt;
        $srv_cnt++;
        // Start Here - Connect to database
        mysql_connect("localhost", "root", "testme");
        @mysql_select_db("emc_v2") or die("Unable to select database");
        $queryt = "SELECT * FROM type_mapping where server_id={$server_id} order by type_id ASC";
        $resultt = mysql_query($queryt);
        $numt = mysql_numrows($resultt);
        $t = 0;
        while ($t < $numt) {
            $type_id = mysql_result($resultt, $t, "type_id");
            echo $type;
            // Get port information
            $type_port = get_type($type_id, "type_port");
            $type_name = get_type($type_id, "type_name");
            $port_res = piclive($server_host . ":" . $type_port);
            if ("{$type_port}" == "443") {
                echo "<a HREF=javascript:void(0) onclick=window.open('simple_view.php?host={$server_host}&port={$type_port}','welcome','resizable=yes,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes')><img width=15 height=15 {$port_res} border=0 title='{$server_host}:{$type_port}' /></a>";
            }
            if ("{$type_port}" == "22") {
                echo "<a HREF=javascript:void(0) onclick=window.open('goto.php?host={$server_host}','welcome','resizable=yes,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes')><img width=15 height=15 {$port_res} border=0 title='{$server_host}:{$type_port}' /></a>";
            } else {
                echo "<img width=15 height=15 {$port_res} border=0 title={$server_host}:{$type_port}>";
            }
            if ($t < $numt - 1) {
                echo "";
            }
            $t++;
        }
        //echo "<br><br>";
        echo "</td></tr>";
        $i++;
    }
    echo "</table>";
}
Пример #17
0
function dirfind_content(&$a, $prefix = "")
{
    $community = false;
    $discover_user = false;
    $local = get_config('system', 'poco_local_search');
    $search = $prefix . notags(trim($_REQUEST['search']));
    if (strpos($search, '@') === 0) {
        $search = substr($search, 1);
        if (valid_email($search) and validate_email($search) or substr(normalise_link($search), 0, 7) == "http://") {
            $user_data = probe_url($search);
            $discover_user = in_array($user_data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA));
        }
    }
    if (strpos($search, '!') === 0) {
        $search = substr($search, 1);
        $community = true;
    }
    $o = '';
    if ($search) {
        if ($discover_user) {
            $j = new stdClass();
            $j->total = 1;
            $j->items_page = 1;
            $j->page = $a->pager['page'];
            $objresult = new stdClass();
            $objresult->cid = 0;
            $objresult->name = $user_data["name"];
            $objresult->addr = $user_data["addr"];
            $objresult->url = $user_data["url"];
            $objresult->photo = $user_data["photo"];
            $objresult->tags = "";
            $objresult->network = $user_data["network"];
            $contact = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", dbesc(normalise_link($user_data["url"])), intval(local_user()));
            if ($contact) {
                $objresult->cid = $contact[0]["id"];
            }
            $j->results[] = $objresult;
            poco_check($user_data["url"], $user_data["name"], $user_data["network"], $user_data["photo"], "", "", "", "", "", datetime_convert(), 0);
        } elseif ($local) {
            if ($community) {
                $extra_sql = " AND `community`";
            } else {
                $extra_sql = "";
            }
            $perpage = 80;
            $startrec = $a->pager['page'] * $perpage - $perpage;
            if (get_config('system', 'diaspora_enabled')) {
                $diaspora = NETWORK_DIASPORA;
            } else {
                $diaspora = NETWORK_DFRN;
            }
            if (!get_config('system', 'ostatus_disabled')) {
                $ostatus = NETWORK_OSTATUS;
            } else {
                $ostatus = NETWORK_DFRN;
            }
            $count = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t(`url` REGEXP '%s' OR `name` REGEXP '%s' OR `location` REGEXP '%s' OR\n\t\t\t\t\t\t`about` REGEXP '%s' OR `keywords` REGEXP '%s')" . $extra_sql, dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)));
            $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`\n\t\t\t\t\tFROM `gcontact`\n\t\t\t\t\tLEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`\n\t\t\t\t\t\tAND `contact`.`uid` = %d AND NOT `contact`.`blocked`\n\t\t\t\t\t\tAND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')\n\t\t\t\t\tWHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND\n\t\t\t\t\t(`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR\n\t\t\t\t\t\t`gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s') {$extra_sql}\n\t\t\t\t\t\tGROUP BY `gcontact`.`nurl`\n\t\t\t\t\t\tORDER BY `gcontact`.`updated` DESC LIMIT %d, %d", intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND), dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), intval($startrec), intval($perpage));
            $j = new stdClass();
            $j->total = $count[0]["total"];
            $j->items_page = $perpage;
            $j->page = $a->pager['page'];
            foreach ($results as $result) {
                if (poco_alternate_ostatus_url($result["url"])) {
                    continue;
                }
                if ($result["name"] == "") {
                    $urlparts = parse_url($result["url"]);
                    $result["name"] = end(explode("/", $urlparts["path"]));
                }
                $objresult = new stdClass();
                $objresult->cid = $result["cid"];
                $objresult->name = $result["name"];
                $objresult->addr = $result["addr"];
                $objresult->url = $result["url"];
                $objresult->photo = $result["photo"];
                $objresult->tags = $result["keywords"];
                $objresult->network = $result["network"];
                $j->results[] = $objresult;
            }
            // Add found profiles from the global directory to the local directory
            proc_run('php', 'include/discover_poco.php', "dirsearch", urlencode($search));
        } else {
            $p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : '';
            if (strlen(get_config('system', 'directory'))) {
                $x = fetch_url(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
            }
            $j = json_decode($x);
        }
        if ($j->total) {
            $a->set_pager_total($j->total);
            $a->set_pager_itemspage($j->items_page);
        }
        if (count($j->results)) {
            $id = 0;
            foreach ($j->results as $jj) {
                $alt_text = "";
                $contact_details = get_contact_details_by_url($jj->url, local_user());
                $itemurl = $contact_details["addr"] != "" ? $contact_details["addr"] : $jj->url;
                // If We already know this contact then don't show the "connect" button
                if ($jj->cid > 0) {
                    $connlnk = "";
                    $conntxt = "";
                    $contact = q("SELECT * FROM `contact` WHERE `id` = %d", intval($jj->cid));
                    if ($contact) {
                        $photo_menu = contact_photo_menu($contact[0]);
                        $details = _contact_detail_for_template($contact[0]);
                        $alt_text = $details['alt_text'];
                    } else {
                        $photo_menu = array();
                    }
                } else {
                    $connlnk = $a->get_baseurl() . '/follow/?url=' . ($jj->connect ? $jj->connect : $jj->url);
                    $conntxt = t('Connect');
                    $photo_menu = array(array(t("View Profile"), zrl($jj->url)));
                    $photo_menu[] = array(t("Connect/Follow"), $connlnk);
                }
                $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo);
                $entry = array('alt_text' => $alt_text, 'url' => zrl($jj->url), 'itemurl' => $itemurl, 'name' => htmlentities($jj->name), 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'img_hover' => $jj->tags, 'conntxt' => $conntxt, 'connlnk' => $connlnk, 'photo_menu' => $photo_menu, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($jj->network, $jj->url), 'id' => ++$id);
                $entries[] = $entry;
            }
            $tpl = get_markup_template('viewcontact_template.tpl');
            $o .= replace_macros($tpl, array('title' => sprintf(t('People Search - %s'), $search), '$contacts' => $entries, '$paginate' => paginate($a)));
        } else {
            info(t('No matches') . EOL);
        }
    }
    return $o;
}
Пример #18
0
    }
    $host = $_SERVER['HTTP_HOST'];
    $baseUrl = $protocol . '://' . $host;
    if (substr($baseUrl, -1) == '/') {
        $baseUrl = substr($baseUrl, 0, strlen($baseUrl) - 1);
    }
    return $baseUrl;
}
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
// Set properties
$objPHPExcel->getProperties()->setCreator("LogZilla, LLC.");
$objPHPExcel->getProperties()->setLastModifiedBy($_SESSION['username']);
$objPHPExcel->getProperties()->setTitle("LogZilla Syslog Report");
$objPHPExcel->getProperties()->setSubject("Syslog Report for {$date} {$time}");
$objPHPExcel->getProperties()->setDescription("Generated by " . get_server() . $_SESSION['PROGNAME']);
$query = "SELECT * FROM " . $_SESSION['viewname'];
$results = perform_query($query, $dbLink);
$n = 0;
// die($query);
while ($row = fetch_array($results)) {
    $result_array[$n] = $row;
    $n++;
}
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue('A1', 'EID');
// $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Sequence');
$objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Host');
$objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Facility');
$objPHPExcel->getActiveSheet()->SetCellValue('D1', 'Severity');
$objPHPExcel->getActiveSheet()->SetCellValue('E1', 'Program');
Пример #19
0
function update_suggestions()
{
    $a = get_app();
    $done = array();
    // To-Do: Check if it is really neccessary to poll the own server
    poco_load(0, 0, 0, $a->get_baseurl() . '/poco');
    $done[] = $a->get_baseurl() . '/poco';
    if (strlen(get_config('system', 'directory'))) {
        $x = fetch_url(get_server() . "/pubsites");
        if ($x) {
            $j = json_decode($x);
            if ($j->entries) {
                foreach ($j->entries as $entry) {
                    poco_check_server($entry->url);
                    $url = $entry->url . '/poco';
                    if (!in_array($url, $done)) {
                        poco_load(0, 0, 0, $entry->url . '/poco');
                    }
                }
            }
        }
    }
    // Query your contacts from Friendica and Redmatrix/Hubzilla for their contacts
    $r = q("SELECT DISTINCT(`poco`) AS `poco` FROM `contact` WHERE `network` IN ('%s', '%s')", dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA));
    if (count($r)) {
        foreach ($r as $rr) {
            $base = substr($rr['poco'], 0, strrpos($rr['poco'], '/'));
            if (!in_array($base, $done)) {
                poco_load(0, 0, 0, $base);
            }
        }
    }
}
Пример #20
0
}
if (!isset($_SESSION['rights']['admin']['clankasse']) and !isset($_SESSION['rights']['superadmin'])) {
    table(ERROR, NO_ADMIN_RIGHTS);
} else {
    if (isset($_GET['func'])) {
        switch ($_GET['func']) {
            case 'add':
                admin_server_add();
                break;
            case 'edit':
                admin_server_edit((int) $_GET['id']);
                break;
            case 'del':
                admin_server_del((int) $_GET['id']);
                break;
            case 'get_server':
                get_server();
                break;
            case 'switch_aktiv':
                server_switch_aktiv((int) $_GET['id']);
                break;
            case 'switch_display':
                server_switch_display((int) $_GET['id']);
                break;
            default:
                admin_server();
        }
    } else {
        admin_server();
    }
}