Пример #1
0
 public function execute(array $command)
 {
     $cwd = getcwd();
     chdir(info()->rootDir());
     $this->instance()->run(new ArrayInput($command), new NullOutput());
     chdir($cwd);
 }
Пример #2
0
 /**
  * Page uri : lang/slug.
  *
  * @return \Illuminate\Http\Response | \Illuminate\Http\RedirectResponse
  */
 public function uri($page = null)
 {
     $app = app();
     if ($app->make('request')->path() != $page->uri() && !$page->is_home) {
         return redirect($page->uri());
     }
     $app->instance('currentPage', $page);
     if (!$page) {
         abort('404');
     }
     if ($page->private && !Auth::check()) {
         return redirect()->guest(route(config('app.locale') . '.login'));
     }
     if ($page->redirect) {
         $childUri = $page->children->first()->uri();
         return redirect($childUri);
     }
     // get submenu
     $children = $this->repository->getSubMenu($page->uri);
     $templateDir = 'pages::' . config('typicms.template_dir', 'public') . '.';
     $template = $page->template ?: 'default';
     if (!view()->exists($templateDir . $template)) {
         info('Template ' . $template . ' not found, switching to default template.');
         $template = 'default';
     }
     return response()->view($templateDir . $template, compact('children', 'page'));
 }
Пример #3
0
function tagrm_post(&$a)
{
    if (!local_user()) {
        goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
    }
    if (x($_POST, 'submit') && $_POST['submit'] === t('Cancel')) {
        goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
    }
    $tag = x($_POST, 'tag') ? hex2bin(notags(trim($_POST['tag']))) : '';
    $item = x($_POST, 'item') ? intval($_POST['item']) : 0;
    $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_user()));
    if (!count($r)) {
        goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
    }
    $arr = explode(',', $r[0]['tag']);
    for ($x = 0; $x < count($arr); $x++) {
        if ($arr[$x] === $tag) {
            unset($arr[$x]);
            break;
        }
    }
    $tag_str = implode(',', $arr);
    q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($tag_str), intval($item), intval(local_user()));
    info(t('Tag removed') . EOL);
    goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
    // NOTREACHED
}
Пример #4
0
function follow_post(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        goaway($_SESSION['return_url']);
        // NOTREACHED
    }
    if ($_REQUEST['cancel']) {
        goaway($_SESSION['return_url']);
    }
    $uid = local_user();
    $url = notags(trim($_REQUEST['url']));
    $return_url = $_SESSION['return_url'];
    // Makes the connection request for friendica contacts easier
    // This is just a precaution if maybe this page is called somewhere directly via POST
    $_SESSION["fastlane"] = $url;
    $result = new_contact($uid, $url, true);
    if ($result['success'] == false) {
        if ($result['message']) {
            notice($result['message']);
        }
        goaway($return_url);
    } elseif ($result['cid']) {
        goaway($a->get_baseurl() . '/contacts/' . $result['cid']);
    }
    info(t('Contact added') . EOL);
    if (strstr($return_url, 'contacts')) {
        goaway($a->get_baseurl() . '/contacts/' . $contact_id);
    }
    goaway($return_url);
    // NOTREACHED
}
Пример #5
0
function lostpass_content(&$a)
{
    if (x($_GET, 'verify')) {
        $verify = $_GET['verify'];
        $hash = hash('whirlpool', $verify);
        $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1", dbesc($hash));
        if (!count($r)) {
            notice(t("Request could not be verified. (You may have previously submitted it.) Password reset failed.") . EOL);
            goaway(z_root());
            return;
        }
        $uid = $r[0]['uid'];
        $username = $r[0]['username'];
        $email = $r[0]['email'];
        $new_password = autoname(6) . mt_rand(100, 9999);
        $new_password_encoded = hash('whirlpool', $new_password);
        $r = q("UPDATE `user` SET `password` = '%s', `pwdreset` = ''  WHERE `uid` = %d LIMIT 1", dbesc($new_password_encoded), intval($uid));
        if ($r) {
            $tpl = get_markup_template('pwdreset.tpl');
            $o .= replace_macros($tpl, array('$lbl1' => t('Password Reset'), '$lbl2' => t('Your password has been reset as requested.'), '$lbl3' => t('Your new password is'), '$lbl4' => t('Save or copy your new password - and then'), '$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.', '$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'), '$newpass' => $new_password, '$baseurl' => $a->get_baseurl()));
            info("Your password has been reset." . EOL);
            $email_tpl = get_intltext_template("passchanged_eml.tpl");
            $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $username, '$email' => $email, '$new_password' => $new_password, '$uid' => $newuid));
            $res = mail($email, "Your password has changed at {$a->config['sitename']}", $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
            return $o;
        }
    } else {
        $tpl = get_markup_template('lostpass.tpl');
        $o .= replace_macros($tpl, array('$title' => t('Forgot your Password?'), '$desc' => t('Enter your email address and submit to have your password reset. Then check your email for further instructions.'), '$name' => t('Nickname or Email: '), '$submit' => t('Reset')));
        return $o;
    }
}
Пример #6
0
 function get()
 {
     if (!local_channel()) {
         goaway(z_root() . '/' . $_SESSION['photo_return']);
         // NOTREACHED
     }
     // remove tag on the fly if item and tag are provided
     if (argc() == 4 && argv(1) === 'drop' && intval(argv(2))) {
         $item = intval(argv(2));
         $tag = argv(3);
         $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_channel()));
         if (!$r) {
             goaway(z_root() . '/' . $_SESSION['photo_return']);
         }
         $r = fetch_post_tags($r, true);
         $item = $r[0];
         $new_tags = array();
         if ($item['term']) {
             for ($x = 0; $x < count($item['term']); $x++) {
                 if ($item['term'][$x]['term'] !== hex2bin($tag)) {
                     $new_tags[] = $item['term'][$x];
                 }
             }
         }
         if ($new_tags) {
             $item['term'] = $new_tags;
         } else {
             unset($item['term']);
         }
         item_store_update($item);
         info(t('Tag removed') . EOL);
         goaway(z_root() . '/' . $_SESSION['photo_return']);
     }
     //if we got only the item print a list of tags to select
     if (argc() == 3 && argv(1) === 'drop' && intval(argv(2))) {
         $o = '';
         $item = intval(argv(2));
         $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_channel()));
         if (!$r) {
             goaway(z_root() . '/' . $_SESSION['photo_return']);
         }
         $r = fetch_post_tags($r, true);
         if (!count($r[0]['term'])) {
             goaway(z_root() . '/' . $_SESSION['photo_return']);
         }
         $o .= '<h3>' . t('Remove Item Tag') . '</h3>';
         $o .= '<p id="tag-remove-desc">' . t('Select a tag to remove: ') . '</p>';
         $o .= '<form id="tagrm" action="tagrm" method="post" >';
         $o .= '<input type="hidden" name="item" value="' . $item . '" />';
         $o .= '<ul>';
         foreach ($r[0]['term'] as $x) {
             $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x['term']) . '" >' . bbcode($x['term']) . '</input></li>';
         }
         $o .= '</ul>';
         $o .= '<input id="tagrm-submit" type="submit" name="submit" value="' . t('Remove') . '" />';
         $o .= '<input id="tagrm-cancel" type="submit" name="submit" value="' . t('Cancel') . '" />';
         $o .= '</form>';
         return $o;
     }
 }
Пример #7
0
function regmod_content(&$a)
{
    global $lang;
    $_SESSION['return_url'] = App::$cmd;
    if (!local_channel()) {
        info(t('Please login.') . EOL);
        $o .= '<br /><br />' . login(App::$config['system']['register_policy'] == REGISTER_CLOSED ? 0 : 1);
        return $o;
    }
    if (!is_site_admin()) {
        notice(t('Permission denied.') . EOL);
        return '';
    }
    if (argc() != 3) {
        killme();
    }
    $cmd = argv(1);
    $hash = argv(2);
    if ($cmd === 'deny') {
        if (!account_deny($hash)) {
            killme();
        }
    }
    if ($cmd === 'allow') {
        if (!account_allow($hash)) {
            killme();
        }
    }
}
function candidatesArePeopleToo()
{
    global $FLAG_CAN_CHANGE_DB;
    $s = mysql_query("\n    SELECT q.id, q.name, count(*) as num\n    FROM news_qualifiers AS q\n    WHERE idperson=0\n    GROUP BY name\n    ORDER BY num DESC");
    while ($r = mysql_fetch_array($s)) {
        $name = $r['name'];
        // Get the party
        $idString = 'none now';
        $persons = getPersonsByName($name, $idString, infoFunction);
        // If I reached this point, I know for sure I either have one
        // or zero matches, there are no ambiguities.
        if (count($persons) == 0) {
            $person = addPersonToDatabase($name, $r['name']);
        } else {
            $person = $persons[0];
            mysql_query("UPDATE news_qualifiers " . "SET idperson={$person->id} " . "WHERE name='" . $r['name'] . "'");
        }
        info('<a href="/politica/api/add_person_update_qualifier.php?name=' . $r['name'] . '" target="_blank">add</a>');
        // Locate these people and update them in several tables now.
        // We're mainly interested in updating the ID to the new ID that
        // will be in the People database, from the previous ID that was
        // the senator's ID in the senators table.
        if ($FLAG_CAN_CHANGE_DB) {
            mysql_query("UPDATE news_qualifiers " . "SET idperson={$person->id} " . "WHERE name='" . $r['name'] . "'");
        }
    }
    printJsCommitCookieScript();
}
Пример #9
0
 function post()
 {
     if (!local_channel()) {
         return;
     }
     if ($_POST['url']) {
         $arr = array('uid' => intval($_REQUEST['uid']), 'url' => escape_tags($_REQUEST['url']), 'guid' => escape_tags($_REQUEST['guid']), 'author' => escape_tags($_REQUEST['author']), 'addr' => escape_tags($_REQUEST['addr']), 'name' => escape_tags($_REQUEST['name']), 'desc' => escape_tags($_REQUEST['desc']), 'photo' => escape_tags($_REQUEST['photo']), 'version' => escape_tags($_REQUEST['version']), 'price' => escape_tags($_REQUEST['price']), 'requires' => escape_tags($_REQUEST['requires']), 'system' => intval($_REQUEST['system']), 'sig' => escape_tags($_REQUEST['sig']), 'categories' => escape_tags($_REQUEST['categories']));
         $_REQUEST['appid'] = Zlib\Apps::app_install(local_channel(), $arr);
         if (Zlib\Apps::app_installed(local_channel(), $arr)) {
             info(t('App installed.') . EOL);
         }
         return;
     }
     $papp = Zlib\Apps::app_decode($_POST['papp']);
     if (!is_array($papp)) {
         notice(t('Malformed app.') . EOL);
         return;
     }
     if ($_POST['install']) {
         Zlib\Apps::app_install(local_channel(), $papp);
         if (Zlib\Apps::app_installed(local_channel(), $papp)) {
             info(t('App installed.') . EOL);
         }
     }
     if ($_POST['delete']) {
         Zlib\Apps::app_destroy(local_channel(), $papp);
     }
     if ($_POST['edit']) {
         return;
     }
     if ($_SESSION['return_url']) {
         goaway(z_root() . '/' . $_SESSION['return_url']);
     }
     goaway(z_root() . '/apps');
 }
Пример #10
0
function redred_settings_post($a, $post)
{
    if (!local_channel()) {
        return;
    }
    // don't check redred settings if redred submit button is not clicked
    if (!x($_POST, 'redred-submit')) {
        return;
    }
    $channel = App::get_channel();
    // Don't let somebody post to their self channel. Since we aren't passing message-id this would be very very bad.
    if (!trim($_POST['redred_channel'])) {
        notice(t('Channel is required.') . EOL);
        return;
    }
    if ($channel['channel_address'] === trim($_POST['redred_channel'])) {
        notice(t('Invalid channel.') . EOL);
        return;
    }
    set_pconfig(local_channel(), 'redred', 'baseapi', trim($_POST['redred_baseapi']));
    set_pconfig(local_channel(), 'redred', 'username', trim($_POST['redred_username']));
    set_pconfig(local_channel(), 'redred', 'password', z_obscure(trim($_POST['redred_password'])));
    set_pconfig(local_channel(), 'redred', 'channel', trim($_POST['redred_channel']));
    set_pconfig(local_channel(), 'redred', 'post', intval($_POST['redred_enable']));
    set_pconfig(local_channel(), 'redred', 'post_by_default', intval($_POST['redred_default']));
    info(t('redred Settings saved.') . EOL);
}
Пример #11
0
function crepair_post(&$a)
{
    if (!local_user()) {
        return;
    }
    $cid = $a->argc > 1 ? intval($a->argv[1]) : 0;
    if ($cid) {
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user()));
    }
    if (!count($r)) {
        return;
    }
    $contact = $r[0];
    $nick = x($_POST, 'nick') ? $_POST['nick'] : '';
    $url = x($_POST, 'url') ? $_POST['url'] : '';
    $request = x($_POST, 'request') ? $_POST['request'] : '';
    $confirm = x($_POST, 'confirm') ? $_POST['confirm'] : '';
    $notify = x($_POST, 'notify') ? $_POST['notify'] : '';
    $poll = x($_POST, 'poll') ? $_POST['poll'] : '';
    $attag = x($_POST, 'attag') ? $_POST['attag'] : '';
    $photo = x($_POST, 'photo') ? $_POST['photo'] : '';
    $r = q("UPDATE `contact` SET `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s' \n\t\tWHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($nick), dbesc($url), dbesc($request), dbesc($confirm), dbesc($notify), dbesc($poll), dbesc($attag), intval($contact['id']), local_user());
    if ($photo) {
        logger('mod-crepair: updating photo from ' . $photo);
        require_once "Photo.php";
        $photos = import_profile_photo($photo, local_user(), $contact['id']);
        $x = q("UPDATE `contact` SET `photo` = '%s',\n\t\t\t`thumb` = '%s',\n\t\t\t`micro` = '%s',\n\t\t\t`name-date` = '%s',\n\t\t\t`uri-date` = '%s',\n\t\t\t`avatar-date` = '%s'\n\t\t\tWHERE `id` = %d LIMIT 1\n\t\t\t", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact['id']));
    }
    if ($r) {
        info(t('Contact settings applied.') . EOL);
    } else {
        notice(t('Contact update failed.') . EOL);
    }
    return;
}
function importFile($file_name, $college_letter_code)
{
    global $startWith;
    $data = file_get_contents($file_name);
    $json = json_decode($data, true);
    info("[---------------- starting with {$startWith} ----------------]");
    for ($i = $startWith; $i < count($json); $i++) {
        $college = $json[$i];
        $num = (double) $college["coldep"] > 0 ? (double) $college["coldep"] : (double) $college["colsen"];
        $college_name = ucwords(strtolower("{$college_letter_code}{$num} {$college["jud_lbl"]}"));
        info("[---------------------------------------------------]");
        info("[{$i}. {$college_name}]");
        $parts = extractNameAndParty($college["USL"]);
        addCandidateToCollege($college_name, $parts[0], $parts[1]);
        $parts = extractNameAndParty($college["ARD"]);
        addCandidateToCollege($college_name, $parts[0], $parts[1]);
        addCandidateToCollege($college_name, $college["PP_DD"], "PP_DD");
        addCandidateToCollege($college_name, $college["UDMR"], "UDMR");
        if ($college_letter_code == "D") {
            $others = explode(", ", $college["Alti_Candi"]);
        } else {
            $others = explode(", ", $college["Alti_candi"]);
        }
        foreach ($others as $other_candidate) {
            $other_candidate = trim($other_candidate);
            if ($other_candidate == "") {
                continue;
            }
            $parts = extractNameAndParty($other_candidate);
            addCandidateToCollege($college_name, $parts[0], $parts[1]);
        }
        $startWith = $i;
    }
}
Пример #13
0
function regmod_content(&$a)
{
    global $lang;
    $_SESSION['return_url'] = $a->cmd;
    if (!local_user()) {
        info(t('Please login.') . EOL);
        $o .= '<br /><br />' . login($a->config['system']['register_policy'] == REGISTER_CLOSED ? 0 : 1);
        return $o;
    }
    if (!is_site_admin() || x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
        notice(t('Permission denied.') . EOL);
        return '';
    }
    if (argc() != 3) {
        killme();
    }
    $cmd = argv(1);
    $hash = argv(2);
    if ($cmd === 'deny') {
        if (!user_deny($hash)) {
            killme();
        }
    }
    if ($cmd === 'allow') {
        if (!user_allow($hash)) {
            killme();
        }
    }
}
Пример #14
0
function info($data, $top)
{
    global $protocols;
    echo ' ', ip($data, 12), ' > ', ip($data, 16), ' protocol=';
    if (!isset($protocols[$data[9]])) {
        echo 'unknown(', $data[9], ')';
        return;
    }
    echo $protocols[$data[9]];
    if ($data[9] == 1) {
        // ICMP
        info_icmp(array_slice($data, 20));
        if ($data[9] == 1 && $data[20] == 3) {
            // ICMP Destination Unreachable
            echo "\n\tdata: ";
            // Print into on the contained packet
            info(array_slice($data, 28), false);
        }
    } else {
        if ($data[9] == 6) {
            // TCP
            info_tcp(array_slice($data, 20));
        } else {
            if ($data[9] == 17) {
                // UDP
                info_udp(array_slice($data, 20));
            }
        }
    }
}
Пример #15
0
function oexchange_content(&$a)
{
    if (!local_user()) {
        $o = login(false);
        return $o;
    }
    if ($a->argc > 1 && $a->argv[1] === 'done') {
        info(t('Post successful.') . EOL);
        return;
    }
    $url = x($_GET, 'url') && strlen($_GET['url']) ? urlencode(notags(trim($_GET['url']))) : '';
    $title = x($_GET, 'title') && strlen($_GET['title']) ? '&title=' . urlencode(notags(trim($_GET['title']))) : '';
    $description = x($_GET, 'description') && strlen($_GET['description']) ? '&description=' . urlencode(notags(trim($_GET['description']))) : '';
    $tags = x($_GET, 'tags') && strlen($_GET['tags']) ? '&tags=' . urlencode(notags(trim($_GET['tags']))) : '';
    $s = fetch_url($a->get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
    if (!strlen($s)) {
        return;
    }
    require_once 'include/html2bbcode.php';
    $post = array();
    $post['profile_uid'] = local_user();
    $post['return'] = '/oexchange/done';
    $post['body'] = html2bbcode($s);
    $post['type'] = 'wall';
    $_POST = $post;
    require_once 'mod/item.php';
    item_post($a);
}
Пример #16
0
function lostpass_content(&$a)
{
    if (x($_GET, 'verify')) {
        $verify = $_GET['verify'];
        $r = q("SELECT * FROM account WHERE account_reset = '%s' LIMIT 1", dbesc($verify));
        if (!$r) {
            notice(t("Request could not be verified. (You may have previously submitted it.) Password reset failed.") . EOL);
            goaway(z_root());
            return;
        }
        $aid = $r[0]['account_id'];
        $email = $r[0]['account_email'];
        $new_password = autoname(6) . mt_rand(100, 9999);
        $salt = random_string(32);
        $password_encoded = hash('whirlpool', $salt . $new_password);
        $r = q("UPDATE account SET account_salt = '%s', account_password = '******', account_reset = '', account_flags = (account_flags & ~%d) where account_id = %d", dbesc($salt), dbesc($password_encoded), intval(ACCOUNT_UNVERIFIED), intval($aid));
        if ($r) {
            $tpl = get_markup_template('pwdreset.tpl');
            $o .= replace_macros($tpl, array('$lbl1' => t('Password Reset'), '$lbl2' => t('Your password has been reset as requested.'), '$lbl3' => t('Your new password is'), '$lbl4' => t('Save or copy your new password - and then'), '$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.', '$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'), '$newpass' => $new_password, '$baseurl' => $a->get_baseurl()));
            info("Your password has been reset." . EOL);
            $email_tpl = get_intltext_template("passchanged_eml.tpl");
            $message = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => sprintf(t('Site Member (%s)'), $email), '$email' => $email, '$new_password' => $new_password, '$uid' => $newuid));
            $subject = email_header_encode(sprintf(t('Your password has changed at %s'), get_config('system', 'sitename')), 'UTF-8');
            $res = mail($email, $subject, $message, 'From: ' . 'Administrator@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
            return $o;
        }
    } else {
        $tpl = get_markup_template('lostpass.tpl');
        $o .= replace_macros($tpl, array('$title' => t('Forgot your Password?'), '$desc' => t('Enter your email address and submit to have your password reset. Then check your email for further instructions.'), '$name' => t('Email Address'), '$submit' => t('Reset')));
        return $o;
    }
}
Пример #17
0
function afficher_liste_articles($tableau)
{
    if (!empty($tableau)) {
        mb_internal_encoding('UTF-8');
        $i = 0;
        $out = '<ul id="billets">' . "\n";
        foreach ($tableau as $article) {
            // ICONE SELON STATUT
            $out .= "\t" . '<li>' . "\n";
            // TITRE
            $out .= "\t\t" . '<span class="' . ($article['bt_statut'] == '1' ? 'on' : 'off') . '">' . '<a href="ecrire.php?post_id=' . $article['bt_id'] . '" title="' . htmlspecialchars(trim(mb_substr(strip_tags($article['bt_abstract']), 0, 249)), ENT_QUOTES) . '">' . $article['bt_title'] . '</a>' . '</span>' . "\n";
            // DATE
            $out .= "\t\t" . '<span><a href="' . basename($_SERVER['PHP_SELF']) . '?filtre=' . substr($article['bt_date'], 0, 8) . '">' . date_formate($article['bt_date']) . '</a> @ ' . heure_formate($article['bt_date']) . '</span>' . "\n";
            // NOMBRE COMMENTS
            $texte = $article['bt_nb_comments'];
            $out .= "\t\t" . '<span><a href="commentaires.php?post_id=' . $article['bt_id'] . '">' . $texte . '</a></span>' . "\n";
            // STATUT
            if ($article['bt_statut'] == '1') {
                $out .= "\t\t" . '<span><a href="' . $article['bt_link'] . '">' . $GLOBALS['lang']['lien_article'] . '</a></span>' . "\n";
            } else {
                $out .= "\t\t" . '<span><a href="' . $article['bt_link'] . '">' . $GLOBALS['lang']['preview'] . '</a></span>' . "\n";
            }
            $out .= "\t" . '</li>' . "\n";
            $i++;
        }
        $out .= '</ul>' . "\n\n";
        echo $out;
    } else {
        echo info($GLOBALS['lang']['note_no_article']);
    }
}
Пример #18
0
function regmod_content(&$a)
{
    global $lang;
    $_SESSION['return_url'] = $a->cmd;
    if (!local_user()) {
        info(t('Please login.') . EOL);
        $o .= '<br /><br />' . login($a->config['register_policy'] == REGISTER_CLOSED ? 0 : 1);
        return $o;
    }
    if (!is_site_admin() || x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
        notice(t('Permission denied.') . EOL);
        return '';
    }
    if ($a->argc != 3) {
        killme();
    }
    $cmd = $a->argv[1];
    $hash = $a->argv[2];
    if ($cmd === 'deny') {
        user_deny($hash);
        goaway($a->get_baseurl() . "/admin/users/");
        killme();
    }
    if ($cmd === 'allow') {
        user_allow($hash);
        goaway($a->get_baseurl() . "/admin/users/");
        killme();
    }
}
Пример #19
0
function regmod_content(&$a)
{
    global $lang;
    $_SESSION['return_url'] = $a->cmd;
    if (!local_user()) {
        info(t('Please login.') . EOL);
        $o .= '<br /><br />' . login($a->config['register_policy'] == REGISTER_CLOSED ? 0 : 1);
        return $o;
    }
    if (!is_site_admin()) {
        notice(t('Permission denied.') . EOL);
        return '';
    }
    if ($a->argc != 3) {
        killme();
    }
    $cmd = $a->argv[1];
    $hash = $a->argv[2];
    if ($cmd === 'deny') {
        if (!user_deny($hash)) {
            killme();
        }
    }
    if ($cmd === 'allow') {
        if (!user_allow($hash)) {
            killme();
        }
    }
}
Пример #20
0
function dirfind_content(&$a)
{
    $search = notags(trim($_REQUEST['search']));
    if (strpos($search, '@') === 0) {
        $search = substr($search, 1);
    }
    $o = '';
    $o .= '<h2>' . t('People Search') . ' - ' . $search . '</h2>';
    if ($search) {
        $p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : '';
        if (strlen(get_config('system', 'directory_submit_url'))) {
            $x = fetch_url('http://dir.friendica.com/lsearch?f=' . $p . '&search=' . urlencode($search));
        }
        //TODO fallback local search if global dir not available.
        //		else
        //			$x = post_url($a->get_baseurl() . '/lsearch', $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) {
                $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => $jj->photo, '$tags' => $jj->tags));
            }
        } else {
            info(t('No matches') . EOL);
        }
    }
    $o .= '<div class="clear"></div>';
    $o .= paginate($a);
    return $o;
}
Пример #21
0
function ldapauth_hook_authenticate($a, &$b)
{
    $mail = '';
    if (ldapauth_authenticate($b['username'], $b['password'], $mail)) {
        $results = q("SELECT * FROM account where account_email = '%s' OR account_email = '%s'  AND account_flags in (0,1) limit 1", dbesc($b['username']), dbesc($mail));
        if (!$results && $mail && intval(get_config('ldapauth', 'create_account')) == 1) {
            require_once 'include/account.php';
            $acct = create_account(array('email' => $mail, 'password' => random_string()));
            if ($acct['success']) {
                logger('ldapauth: Created account for ' . $b['username'] . ' using ' . $mail);
                info(t('An account has been created for you.'));
                $b['user_record'] = $acct['account'];
                $b['authenticated'] = 1;
            }
        } elseif (intval(get_config('ldapauth', 'create_account')) != 1 && !$results) {
            logger('ldapauth: User ' . $b['username'] . ' authenticated but no db-record and. Rejecting auth.');
            notice(t('Authentication successful but rejected: account creation is disabled.'));
            return;
        }
        if ($results) {
            logger('ldapauth: Login success for ' . $b['username']);
            $b['user_record'] = $results[0];
            $b['authenticated'] = 1;
        }
    }
    return;
}
Пример #22
0
function appman_post(&$a)
{
    if (!local_user()) {
        return;
    }
    if ($_POST['url']) {
        $arr = array('uid' => intval($_REQUEST['uid']), 'url' => escape_tags($_REQUEST['url']), 'guid' => escape_tags($_REQUEST['guid']), 'author' => escape_tags($_REQUEST['author']), 'addr' => escape_tags($_REQUEST['addr']), 'name' => escape_tags($_REQUEST['name']), 'desc' => escape_tags($_REQUEST['desc']), 'photo' => escape_tags($_REQUEST['photo']), 'version' => escape_tags($_REQUEST['version']), 'price' => escape_tags($_REQUEST['price']), 'sig' => escape_tags($_REQUEST['sig']));
        $_REQUEST['appid'] = app_install(local_user(), $arr);
        if (app_installed(local_user(), $arr)) {
            info(t('App installed.') . EOL);
        }
        return;
    }
    $papp = app_decode($_POST['papp']);
    if (!is_array($papp)) {
        notice(t('Malformed app.') . EOL);
        return;
    }
    if ($_POST['install']) {
        app_install(local_user(), $papp);
        if (app_installed(local_user(), $papp)) {
            info(t('App installed.') . EOL);
        }
    }
    if ($_POST['delete']) {
        app_destroy(local_user(), $papp);
    }
    if ($_POST['edit']) {
        return;
    }
    if ($_SESSION['return_url']) {
        goaway(z_root() . '/' . $_SESSION['return_url']);
    }
    goaway(z_root() . '/apps/personal');
}
Пример #23
0
function langfilter_addon_settings_post(&$a, &$b)
{
    if (!local_user()) {
        return;
    }
    if ($_POST['langfilter-settings-submit']) {
        set_pconfig(local_user(), 'langfilter', 'languages', trim($_POST['langfilter_languages']));
        $enable = x($_POST, 'langfilter_enable') ? intval($_POST['langfilter_enable']) : 0;
        $disable = 1 - $enable;
        set_pconfig(local_user(), 'langfilter', 'disable', $disable);
        $minconfidence = 0 + $_POST['langfilter_minconfidence'];
        if (!$minconfidence) {
            $minconfidence = 0;
        } else {
            if ($minconfidence < 0) {
                $minconfidence = 0;
            } else {
                if ($minconfidence > 100) {
                    $minconfidence = 100;
                }
            }
        }
        set_pconfig(local_user(), 'langfilter', 'minconfidence', $minconfidence / 100.0);
        info(t('Language Filter Settings saved.') . EOL);
    }
}
Пример #24
0
 function post()
 {
     if (!local_channel()) {
         return;
     }
     if (\App::$argc != 2) {
         return;
     }
     $contact_id = intval(\App::$argv[1]);
     $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_channel()));
     if (!count($r)) {
         notice(t('Contact not found.') . EOL);
         return;
     }
     $contact = $r[0];
     $new_contact = intval($_POST['suggest']);
     $hash = random_string();
     $note = escape_tags(trim($_POST['note']));
     if ($new_contact) {
         $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($new_contact), intval(local_channel()));
         if (count($r)) {
             $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)\n\t\t\t\t\tVALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')", intval(local_channel()), intval($contact_id), dbesc($r[0]['name']), dbesc($r[0]['url']), dbesc($r[0]['request']), dbesc($r[0]['photo']), dbesc($hash), dbesc(datetime_convert()));
             $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1", dbesc($hash), intval(local_channel()));
             if (count($r)) {
                 $fsuggest_id = $r[0]['id'];
                 q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($note), intval($fsuggest_id), intval(local_channel()));
                 proc_run('php', 'include/notifier.php', 'suggest', $fsuggest_id);
             }
             info(t('Friend suggestion sent.') . EOL);
         }
     }
 }
Пример #25
0
function follow_init(&$a)
{
    if (!local_channel()) {
        return;
    }
    $uid = local_channel();
    $url = notags(trim($_REQUEST['url']));
    $return_url = $_SESSION['return_url'];
    $confirm = intval($_REQUEST['confirm']);
    $result = new_contact($uid, $url, $a->get_channel(), true, $confirm);
    if ($result['success'] == false) {
        if ($result['message']) {
            notice($result['message']);
        }
        goaway($return_url);
    }
    info(t('Channel added.') . EOL);
    $clone = array();
    foreach ($result['abook'] as $k => $v) {
        if (strpos($k, 'abook_') === 0) {
            $clone[$k] = $v;
        }
    }
    unset($clone['abook_id']);
    unset($clone['abook_account']);
    unset($clone['abook_channel']);
    build_sync_packet(0, array('abook' => array($clone)));
    // If we can view their stream, pull in some posts
    if ($result['abook']['abook_their_perms'] & PERMS_R_STREAM || $result['abook']['xchan_network'] === 'rss') {
        proc_run('php', 'include/onepoll.php', $result['abook']['abook_id']);
    }
    goaway(z_root() . '/connedit/' . $result['abook']['abook_id'] . '?f=&follow=1');
}
function candidatesArePeopleToo()
{
    $s = mysql_query("SELECT * FROM candidates");
    while ($r = mysql_fetch_array($s)) {
        $name = $r['name_cleaned'];
        $sid = $r['id'];
        if (strpos($r['url'], "http://") === 0) {
            $url = $r['url'];
        } else {
            $url = 'http://www.alegeri-2008.ro' . $r['url'];
        }
        $idString = '<a href=' . $url . '>alegeri2008</a>';
        $persons = getPersonsByName($name, $idString);
        // If I reached this point, I know for sure I either have one
        // or zero matches, there are no ambiguities.
        if (count($persons) == 0) {
            $person = addPersonToDatabase($name, $r['name_cleaned']);
        } else {
            $person = $persons[0];
            info("Found      {" . $name . "}");
        }
        // First and foremost, attempt to add this to the person's history.
        addPersonHistory($person->id, "alegeri/2008", $url);
        // Locate these people and update them in several tables now.
        // We're mainly interested in updating the ID to the new ID that
        // will be in the People database, from the previous ID that was
        // the senator's ID in the senators table.
        mysql_query("UPDATE candidates " . "SET idperson={$person->id} " . "WHERE id=" . $r['id']);
    }
}
Пример #27
0
function bookmarks_init(&$a)
{
    if (!local_user()) {
        return;
    }
    $item_id = intval($_REQUEST['item']);
    if (!$item_id) {
        return;
    }
    $u = $a->get_channel();
    $i = q("select * from item where id = %d and uid = %d limit 1", intval($item_id), intval(local_user()));
    if (!$i) {
        return;
    }
    $i = fetch_post_tags($i);
    $item = $i[0];
    $terms = get_terms_oftype($item['term'], TERM_BOOKMARK);
    if ($terms && !$item['item_restrict']) {
        require_once 'include/bookmarks.php';
        $s = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item['author_xchan']));
        if (!$s) {
            logger('mod_bookmarks: author lookup failed.');
            killme();
        }
        foreach ($terms as $t) {
            bookmark_add($u, $s[0], $t, $item['item_private']);
            info(t('Bookmark added') . EOL);
        }
    }
    killme();
}
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (info()->installMode()) {
         die('Opis Colibri is not installed' . PHP_EOL);
     }
     $output->getFormatter()->setStyle('b-error', new OutputFormatterStyle('white', 'red', array('bold')));
     $output->getFormatter()->setStyle('warning', new OutputFormatterStyle('yellow'));
     $output->getFormatter()->setStyle('b-warning', new OutputFormatterStyle('yellow', null, array('bold')));
     $output->getFormatter()->setStyle('b-info', new OutputFormatterStyle('green', null, array('bold')));
     $modules = $input->getArgument('module');
     foreach ($modules as $moduleName) {
         $module = module($moduleName);
         if (!$module->exists()) {
             $output->writeln('<error>Module <b-error>' . $moduleName . '</b-error> doesn\'t exist.</error>');
             continue;
         }
         if (!$module->isInstalled()) {
             $output->writeln('<warning>Module <b-warning>' . $moduleName . '</b-warning> is already uninstaled.</warning>');
             continue;
         }
         if ($module->isHidden()) {
             $output->writeln('<error>Module <b-error>' . $moduleName . '</b-error> is hidden and can\'t be uninstalled.');
             continue;
         }
         if ($module->uninstall()) {
             $output->writeln('<info>Module <b-info>' . $moduleName . '</b-info> was uninstalled.</info>');
         } else {
             $output->writeln('<error>Module <b-error>' . $moduleName . '</b-error> could not be uninstalled.</error>');
         }
     }
 }
Пример #29
0
function hubwall_post(&$a)
{
    if (!is_site_admin()) {
        return;
    }
    $text = trim($_REQUEST['text']);
    if (!$text) {
        return;
    }
    $sender_name = sprintf(t('$1%s Administrator'), \Zotlabs\Lib\System::get_site_name());
    $sender_email = $_REQUEST['sender'];
    $subject = $_REQUEST['subject'];
    $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r", "\\n"), array("", "\n"), $text))), ENT_QUOTES, 'UTF-8'));
    $htmlversion = bbcode(stripslashes(str_replace(array("\\r", "\\n"), array("", "<br />\n"), $text)));
    $sql_extra = intval($_REQUEST['test']) ? sprintf(" and account_email = '%s' ", get_config('system', 'admin_email')) : '';
    $recips = q("select account_email from account where account_flags = %d {$sql_extra}", intval(ACCOUNT_OK));
    if (!$recips) {
        notice(t('No recipients found.') . EOL);
        return;
    }
    $total_recips = count($recips);
    $total_delivered = 0;
    foreach ($recips as $recip) {
        $x = \Zotlabs\Lib\Enotify::send(array('fromName' => $sender_name, 'fromEmail' => $sender_email, 'replyTo' => $sender_email, 'toEmail' => $recip['account_email'], 'messageSubject' => $subject, 'htmlVersion' => $htmlversion, 'textVersion' => $textversion));
        if ($x) {
            $total_delivered++;
        }
    }
    info(sprintf(t('%1$d of %2$d messages sent.'), $total_delivered, $total_recips) . EOL);
}
Пример #30
0
function snautofollow_settings_post($a, $post)
{
    if (!local_user() || !x($_POST, 'snautofollow-submit')) {
        return;
    }
    set_pconfig(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow']));
    info(t('StatusNet AutoFollow settings updated.') . EOL);
}