Exemplo n.º 1
0
function favorite_list($vars = null)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
    $where_sql = "WHERE 1=1 ";
    isset($vars['userid']) && ($where_sql .= " AND `uid`='" . (int) $vars['userid'] . "' ");
    isset($vars['fid']) && ($where_sql .= " AND `fid`='" . (int) $vars['fid'] . "' ");
    isset($vars['mode']) && ($where_sql .= " AND `mode`='" . (int) $vars['mode'] . "'");
    isset($vars['appid']) && ($where_sql .= " AND `appid`='" . (int) $vars['appid'] . "' ");
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case 'hot':
            $order_sql = " ORDER BY `count` {$by}";
            break;
        default:
            $order_sql = " ORDER BY `id` {$by}";
    }
    $md5 = md5($where_sql . $order_sql);
    $offset = 0;
    if ($vars['page']) {
        $total = iPHP::total($md5, "SELECT count(*) FROM `#iCMS@__favorite` {$where_sql} ");
        iPHP::assign("fav_total", $total);
        $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/favorite/' . $md5 . "/" . (int) $GLOBALS['page'];
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $rs = iDB::all("SELECT * FROM `#iCMS@__favorite` {$where_sql} {$order_sql} LIMIT {$offset},{$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        $resource = array();
        $vars['user'] && iPHP::app('user.class', 'static');
        if ($rs) {
            foreach ($rs as $key => $value) {
                $value['url'] = iPHP::router(array('/favorite/{id}/', $value['id']), iPHP_ROUTER_REWRITE);
                $vars['user'] && ($value['user'] = user::info($value['uid'], $value['nickname']));
                if (isset($vars['loop'])) {
                    $resource[$key] = $value;
                } else {
                    $resource[$value['id']] = $value;
                }
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemplo n.º 2
0
 function confirmRequest($salt)
 {
     if (!$this->find($salt)) {
         return PEAR::raiseError('cannot find request');
     }
     // activate the handle and grant karma
     // implicitly without human intervention
     // copied from the user class and Damblan_Karma
     include_once 'pear-database-user.php';
     $user = user::info($this->handle, null, 0);
     if (!isset($user['registered'])) {
         return PEAR::raiseError('Error - user request was deleted, please try again');
     }
     include_once 'pear-database-note.php';
     note::removeAll($this->handle);
     $data = array();
     $data['handle'] = $user['handle'];
     $data['registered'] = 1;
     $data['created'] = gmdate('Y-m-d');
     $data['createdby'] = SITE . 'web';
     $e = user::update($data, true);
     if (PEAR::isError($e) || !$e) {
         return $e;
     }
     $query = 'INSERT INTO karma VALUES (?, ?, ?, ?, NOW())';
     $id = $this->dbh->nextId('karma');
     $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.voter', SITE . 'web'));
     $id = $this->dbh->nextId('karma');
     $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', SITE . 'web'));
     if (!DB::isError($sth)) {
         note::add($this->handle, 'Account opened', SITE . 'web');
         $msg = "Your PEAR voter account has been opened.\n" . "You can now participate in the elections  by going to\n" . "    http://" . PEAR_CHANNELNAME . "/election/";
         $xhdr = "From: " . PEAR_WEBMASTER_EMAIL;
         if (!DEVBOX) {
             mail($user['email'], "Your PEAR Account Request", $msg, $xhdr, "-f " . PEAR_BOUNCE_EMAIL);
         }
         $this->deleteRequest();
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
    /**
     * Mark a user for password resetting
     *
     * @param string $user
     * @param string $pass1
     * @param string $pass2
     * @return array
     */
    function resetPassword($user, $pass1, $pass2)
    {
        require_once 'Damblan/Mailer.php';
        $errors = array();
        $salt = md5(mt_rand(4, 13) . $user . time() . $pass1);
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
        $this->_dbh->query('DELETE FROM lostpassword WHERE handle=?', array($user));
        $e = $this->_dbh->query('INSERT INTO lostpassword
            (handle, newpassword, salt, requested)
            VALUES(?,?,?,NOW())', array($user, md5($pass1), $salt));
        PEAR::staticPopErrorHandling();
        if (PEAR::isError($e)) {
            $errors[] = 'Could not change password: '******'pear-database-user.php';
            $info = user::info($user);
            $this->_mailer = Damblan_mailer::create(array('To' => array($info['name'] . ' <' . $info['email'] . '>'), 'Reply-To' => array('PEAR QA <' . PEAR_QA_EMAIL . '>'), 'Subject' => '[PEAR-ACCOUNT-PASSWORD] Your password reset request : %username%', 'Body' => 'A request has been made to reset your password for %username%
at pear.php.net.

If you intended to reset the password, please navigate to this page:
  https://' . PEAR_CHANNELNAME . '/account/password-confirm-change.php
and follow the instructions.  Your password reset code is:

%salt%

If you have received this email by mistake or did not request a
password change, no further action is necessary.  Your password
will NOT change until you confirm the change, and it cannot be changed
without the password reset code.  Password change requests are automatically
purged after 24 hours.

PEAR Quality Assurance.'), array('username' => $user, 'salt' => $salt));
            $this->_mailer->send();
        }
        return $errors;
    }
Exemplo n.º 4
0
 /**
  * Get maintainers
  *
  * Get maintainers to inform of a trackback (the
  * lead maintainers of a package).
  *
  * @since
  * @access public
  * @param  boolean $activeOnly  To get only active leads
  *                 is set to false by default so there's
  *                 no bc problems.
  *
  * @return array(string) The list of maintainer emails.
  */
 function getMaintainers($id, $leadOnly = false, $activeOnly = true)
 {
     include_once 'pear-database-maintainer.php';
     $maintainers = maintainer::get($id, $leadOnly, $activeOnly);
     $res = array();
     include_once 'pear-database-user.php';
     foreach ($maintainers as $maintainer => $data) {
         $tmpUser = user::info($maintainer, 'email');
         if (!is_array($tmpUser) || !isset($tmpUser['email'])) {
             continue;
         }
         $res[] = $tmpUser['email'];
     }
     return $res;
 }
Exemplo n.º 5
0
require_once 'HTTP.php';
require 'bugs/pear-bugs.php';
include_once 'pear-database-user.php';
$bugs = new PEAR_Bugs();
$site = new Damblan_URL();
$karma = new Damblan_Karma($dbh);
$params = array('handle' => '', 'action' => '');
$site->getElements($params);
$handle = htmlspecialchars(strtolower($params['handle']));
// Redirect to the accounts list if no handle was specified
if (empty($handle)) {
    localRedirect('/accounts.php');
}
$dbh->setFetchmode(DB_FETCHMODE_ASSOC);
$permissions = $karma->get($handle);
$row = user::info($handle);
if ($row === null) {
    error_handler($handle . ' is not a valid account name.', 'Invalid Account');
}
switch ($params['action']) {
    case 'wishlist':
        if (!empty($row['wishlist'])) {
            HTTP::redirect($row['wishlist']);
        } else {
            PEAR::raiseError(htmlspecialchars($row['name']) . ' has not registered a wishlist');
        }
        break;
    case 'bugs':
        HTTP::redirect('/bugs/search.php?handle=' . $handle . '&cmd=display');
        break;
    case 'rss':
Exemplo n.º 6
0
 echo '  </select>';
 echo '  </td>';
 echo '  <td>';
 echo '  <input type="button" onClick="addMaintainer(); return false" name="add" value="Add as" />';
 echo '  <select name="role" size="1">';
 echo '    <option value="lead">lead</option>';
 echo '    <option value="developer">developer</option>';
 echo '    <option value="helper">helper</option>';
 echo '  </select><br /><br />';
 echo '  <input type="button" onClick="removeMaintainer(); return false" name="remove" value="Remove" />';
 echo '  </td>';
 echo '  <td>';
 echo '  <select multiple="yes" name="maintainers[]" onChange="activateRemove();" size="10">';
 $maintainers = maintainer::get($id);
 foreach ($maintainers as $handle => $role) {
     $info = user::info($handle, "name");
     // XXX: This sucks
     printf('<option value="%s||%s">%s (%s, %s)</option>', $handle, $role['role'], $info['name'], $handle, $role['role']);
 }
 echo '  </select>';
 echo '  </td>';
 echo '</tr>';
 echo '<tr>';
 echo '  <td colspan="3"><input type="submit" /></td>';
 echo '</tr>';
 echo '</table>';
 echo '</form>';
 echo '<script language="JavaScript" type="text/javascript">';
 echo 'document.form.remove.disabled = true;';
 echo 'document.form.add.disabled = true;';
 echo 'document.form.role.disabled = true;';
Exemplo n.º 7
0
    function email($election, $votes, $salt)
    {
        include_once 'pear-database-user.php';
        $info = user::info($this->user);
        $email = '"' . $info['name'] . '" <' . $info['email'] . '>';
        $headers = "From: bounce-no-user@php.net\n";
        $headers .= "X-Mailer: PEAR election voting interface\n";
        $headers .= "X-PEAR-Election: " . $election['id'] . "\n";
        $subject = '[PEAR-ELECTION] Your vote in election ' . $election['purpose'];
        if ($votes) {
            $votes = $this->prettifyVotes($election, $votes);
            $text = 'Your vote for the election: ' . $election['purpose'] . "\n" . 'has been registered.  You voted for:
';
            $text .= $votes . "\n";
            $text .= 'Your vote salt is ' . $salt . "\n";
            $text .= 'this is your only record of the vote salt, without it your vote ' . 'cannot be retrieved.  Thank you for voting';
        } else {
            $text = 'Your abstaining vote for the election: ' . $election['purpose'] . "\n" . 'has been registered.' . "\n";
            $text .= 'Your vote salt is ' . $salt . "\n";
            $text .= 'this is your only record of the vote salt, without it your vote ' . 'cannot be retrieved.  Thank you for voting';
        }
        $text .= "\nVisit http://pear.php.net/election/ to retrieve your vote";
        $res = mail($email, $subject, $text, $headers, '-f bounce-no-user@php.net');
        return $res;
    }
Exemplo n.º 8
0
 function confirmRequest($handle, $password, $name)
 {
     $sql = 'SELECT handle FROM users WHERE handle = ?';
     if ($handle == $this->dbh->getOne($sql, array($handle))) {
         $id = $this->dbh->nextId("karma");
         $query = 'INSERT INTO karma VALUES (?, ?, ?, ?, NOW())';
         $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', 'pearweb'));
         return true;
     }
     list($firstname, $lastname) = explode(' ', $name, 2);
     $data = array('handle' => $handle, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $this->email, 'purpose' => 'bug tracker', 'password' => $password, 'password2' => $password, 'purpose' => 'Open/Comment on bugs', 'moreinfo' => 'Automatic Account Request', 'homepage' => '');
     include_once 'pear-database-user.php';
     $useradd = user::add($data, true, true);
     if ($useradd !== true) {
         return $useradd;
     }
     $sql = 'SELECT handle from bug_account_request WHERE salt = ?';
     $temphandle = $this->dbh->getOne($sql, array($this->salt));
     // update all relevant records to the new handle
     $this->dbh->query('UPDATE bugdb_comments set reporter_name = ? WHERE handle = ?', array($name, $temphandle));
     $this->dbh->query('UPDATE bugdb set reporter_name = ? WHERE handle = ?', array($name, $temphandle));
     $this->dbh->query('UPDATE users set handle = ? WHERE handle = ?', array($handle, $temphandle));
     $this->dbh->query('UPDATE bugdb set registered = 1, handle = ? WHERE handle = ?', array($handle, $temphandle));
     $this->dbh->query('UPDATE bugdb_comments set handle = ? WHERE handle = ?', array($handle, $temphandle));
     $this->dbh->query('UPDATE bugdb_patchtracker set developer = ? WHERE developer = ?', array($handle, $temphandle));
     $this->handle = $handle;
     // activate the handle and grant karma
     // implicitly without human intervention
     // copied from the user class and Damblan_Karma
     include_once 'pear-database-user.php';
     $user = user::info($handle, null, 0);
     if (!isset($user['registered'])) {
         return false;
     }
     @($arr = unserialize($user['userinfo']));
     include_once 'pear-database-note.php';
     note::removeAll($handle);
     $data = array();
     $data['registered'] = 1;
     $data['password'] = $password;
     $data['name'] = $name;
     if (is_array($arr)) {
         $data['userinfo'] = $arr[1];
     }
     $data['create'] = gmdate('Y-m-d');
     $data['createBy'] = SITE . 'web';
     $data['handle'] = $handle;
     user::update($data, true);
     $query = 'INSERT INTO karma VALUES (?, ?, ?, ?, NOW())';
     $id = $this->dbh->nextId('karma');
     $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', SITE . 'web'));
     $id = $this->dbh->nextId('karma');
     $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.voter', SITE . 'web'));
     if (!DB::isError($sth)) {
         require_once 'bugs/pear-bugs-utils.php';
         $pbu = new PEAR_Bugs_Utils();
         note::add($this->handle, 'Account opened', SITE . 'web');
         $bugs = $this->dbh->getAll('SELECT * FROM bugdb WHERE handle = ?', array($this->handle), DB_FETCHMODE_ASSOC);
         foreach ($bugs as $bug) {
             $this->sendBugEmail($bug);
         }
         $patches = $this->dbh->getAll('SELECT bugdb.package_name, bugdb_patchtracker.*
             FROM bugdb_patchtracker, bugdb
             WHERE bugdb_patchtracker.developer = ?
                 AND bugdb.id = bugdb_patchtracker.bugdb_id', array($this->handle), DB_FETCHMODE_ASSOC);
         foreach ($patches as $patch) {
             $pbu->sendPatchEmail($patch);
         }
         $bugs = $this->dbh->getAll('SELECT bugdb_comments.email,bugdb_comments.comment,
                 bugdb_comments.reporter_name, bugdb.id,
                 bugdb.bug_type,bugdb.package_name,bugdb.sdesc,
                 bugdb.ldesc,bugdb.php_version, bugdb.php_os,bugdb.status,
                 bugdb.assign,bugdb.package_version
              FROM bugdb_comments, bugdb
              WHERE bugdb.id = bugdb_comments.bug AND
              bugdb_comments.handle = ?', array($this->handle), DB_FETCHMODE_ASSOC);
         foreach ($bugs as $bug) {
             $this->sendBugCommentEmail($bug);
         }
         $msg = "Your PEAR bug tracker account has been opened.\n" . "Bugs you have opened will now be displayed, and you can\n" . "add new comments to existing bugs";
         $xhdr = "From: " . PEAR_WEBMASTER_EMAIL;
         if (!DEVBOX) {
             mail($user['email'], "Your PEAR Bug Tracker Account Request", $msg, $xhdr, "-f " . PEAR_BOUNCE_EMAIL);
         }
         $this->deleteRequest();
         return true;
     }
     return false;
 }
Exemplo n.º 9
0
/**
 * setup the $auth_user object
 */
function init_auth_user()
{
    global $auth_user, $dbh;
    if (empty($_COOKIE['PEAR_USER']) || empty($_COOKIE['PEAR_PW'])) {
        $auth_user = null;
        return false;
    }
    if (!empty($auth_user)) {
        return true;
    }
    require_once 'pear-database-user.php';
    $data = user::info($_COOKIE['PEAR_USER'], null, true, false);
    $auth_user = new PEAR_Auth();
    $auth_user->data($data);
    if (md5($_COOKIE['PEAR_PW']) == @$auth_user->password) {
        return true;
    }
    $auth_user = null;
    return false;
}
Exemplo n.º 10
0
 public function value($article, $art_data = "", $vars = array(), $page = 1, $tpl = false)
 {
     $article['appid'] = iCMS_APP_ARTICLE;
     $categoryApp = iPHP::app("category");
     $category = $categoryApp->category($article['cid'], false);
     if ($tpl) {
         $category or iPHP::throw404('运行出错!找不到该文章的栏目缓存<b>cid:' . $article['cid'] . '</b> 请更新栏目缓存或者确认栏目是否存在', 10002);
     } else {
         if (empty($category)) {
             return false;
         }
     }
     if ($category['status'] == 0) {
         return false;
     }
     if (iPHP::$iTPL_MODE == "html" && $tpl && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || $category['mode'] == "0")) {
         return false;
     }
     $_iurlArray = array($article, $category);
     $article['iurl'] = iURL::get('article', $_iurlArray, $page);
     $article['url'] = $article['iurl']->href;
     $article['link'] = "<a href='{$article['url']}'>{$article['title']}</a>";
     $tpl && $category['mode'] == '1' && iCMS::gotohtml($article['iurl']->path, $article['iurl']->href);
     if ($vars['category_lite']) {
         $article['category'] = $categoryApp->get_lite($category);
     } else {
         $article['category'] = $category;
     }
     $this->taoke = false;
     if ($art_data) {
         $pkey = intval($page - 1);
         $pageurl = $article['iurl']->pageurl;
         if ($article['chapter']) {
             $chapterArray = $art_data;
             $count = count($chapterArray);
             $adid = $chapterArray[$pkey]['id'];
             $art_data = iDB::row("SELECT body,subtitle FROM `#iCMS@__article_data` WHERE aid='" . (int) $article['id'] . "' AND id='" . (int) $adid . "' LIMIT 1;", ARRAY_A);
         }
         $art_data['body'] = $this->ubb($art_data['body']);
         preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $art_data['body'], $pic_array);
         $p_array = array_unique($pic_array[1]);
         if ($p_array) {
             foreach ($p_array as $key => $_pic) {
                 $article['pics'][$key] = trim($_pic);
             }
         }
         if (substr($art_data['body'], 0, 19) == '#--iCMS.Markdown--#') {
             // $art_data['body']    = iPHP::Markdown($art_data['body']);
             $art_data['body'] = substr($art_data['body'], 19);
             $article['markdown'] = ture;
         }
         if ($article['chapter']) {
             $article['body'] = $art_data['body'];
         } else {
             $body = explode('#--iCMS.PageBreak--#', $art_data['body']);
             $count = count($body);
             $article['body'] = $body[$pkey];
         }
         $total = $count + intval(iCMS::$config['article']['pageno_incr']);
         $article['body'] = $this->keywords($article['body']);
         $article['body'] = $this->taoke($article['body']);
         $article['taoke'] = $this->taoke;
         $article['subtitle'] = $art_data['subtitle'];
         unset($body, $art_data);
         $pageArray = array();
         if ($total > 1) {
             iPHP::loadClass("Pages");
             $_GLOBALS_iPage = $GLOBALS['iPage'];
             $category['mode'] && iCMS::set_html_url($article['iurl']);
             $pageconf = array('page_name' => 'p', 'url' => $pageurl, 'total' => $total, 'perpage' => 1, 'nowindex' => (int) $_GET['p'], 'lang' => iPHP::lang(iPHP_APP . ':page'));
             if ($article['chapter']) {
                 foreach ((array) $chapterArray as $key => $value) {
                     $pageconf['titles'][$key + 1] = $value['subtitle'];
                 }
             }
             $iPages = new iPages($pageconf);
             unset($GLOBALS['iPage']);
             $GLOBALS['iPage'] = $_GLOBALS_iPage;
             unset($_GLOBALS_iPage);
             $pageArray['list'] = $iPages->list_page();
             $pageArray['index'] = $iPages->first_page('array');
             $pageArray['prev'] = $iPages->prev_page('array');
             $pageArray['next'] = $iPages->next_page('array');
             $pageArray['endof'] = $iPages->last_page('array');
             $pagenav = $iPages->show(0);
             $pagetext = $iPages->show(10);
         }
         $article['page'] = array('pn' => $page, 'total' => $total, 'count' => $count, 'current' => $page, 'nav' => $pagenav, 'pageurl' => $pageurl, 'text' => $pagetext, 'PAGES' => $iPages, 'args' => iS::escapeStr($_GET['pageargs']), 'first' => $page == "1" ? true : false, 'last' => $page == $count ? true : false, 'end' => $page == $total ? true : false) + $pageArray;
         $next_url = $pageArray['next']['url'];
         unset($pagenav, $pagetext, $iPages, $pageArray);
         if ($pic_array[0]) {
             $img_array = array_unique($pic_array[0]);
             foreach ($img_array as $key => $img) {
                 $img = str_replace('<img', '<img title="' . $article['title'] . '" alt="' . $article['title'] . '"', $img);
                 if (iCMS::$config['article']['pic_center']) {
                     $img_replace[$key] = '<p align="center">' . $img . '</p>';
                 } else {
                     $img_replace[$key] = $img;
                 }
                 if (iCMS::$config['article']['pic_next'] && $count > 1) {
                     $clicknext = '<a href="' . $next_url . '"><b>' . iPHP::lang('iCMS:article:clicknext') . '</b></a>';
                     $clickimg = '<a href="' . $next_url . '" title="' . $article['title'] . '" class="img">' . $img . '</a>';
                     if (iCMS::$config['article']['pic_center']) {
                         $img_replace[$key] = '<p align="center">' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p align="center">' . $clickimg . '</p>';
                     } else {
                         $img_replace[$key] = '<p>' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p>' . $clickimg . '</p>';
                     }
                 }
             }
             $article['body'] = str_replace($img_array, $img_replace, $article['body']);
         }
     }
     if ($vars['tags']) {
         $article['tags_fname'] = $category['name'];
         if ($article['tags']) {
             $tagApp = iPHP::app("tag");
             $tagArray = $tagApp->get_array($article['tags']);
             $article['tag_array'] = array();
             foreach ((array) $tagArray as $tk => $tag) {
                 $article['tag_array'][$tk] = $tag;
                 $article['tags_link'] .= $tag['link'];
                 $tag_name_array[] = $tag['name'];
             }
             $tag_name_array && ($article['tags_fname'] = $tag_name_array[0]);
             unset($tagApp, $tagArray, $tag_name_array);
         }
     }
     if ($vars['meta']) {
         if ($article['metadata']) {
             $article['meta'] = unserialize($article['metadata']);
             unset($article['metadata']);
         }
     }
     if ($vars['user']) {
         iPHP::app('user.class', 'static');
         if ($article['postype']) {
             $article['user'] = user::empty_info($article['userid'], '#' . $article['editor']);
         } else {
             $article['user'] = user::info($article['userid'], $article['author']);
         }
     }
     if (strstr($article['source'], '||')) {
         list($s_name, $s_url) = explode('||', $article['source']);
         $article['source'] = '<a href="' . $s_url . '" target="_blank">' . $s_name . '</a>';
     }
     if (strstr($article['author'], '||')) {
         list($a_name, $a_url) = explode('||', $article['author']);
         $article['author'] = '<a href="' . $a_url . '" target="_blank">' . $a_name . '</a>';
     }
     $article['hits'] = array('script' => iCMS_API . '?app=article&do=hits&cid=' . $article['cid'] . '&id=' . $article['id'], 'count' => $article['hits'], 'today' => $article['hits_today'], 'yday' => $article['hits_yday'], 'week' => $article['hits_week'], 'month' => $article['hits_month']);
     $article['comment'] = array('url' => iCMS_API . "?app=article&do=comment&appid={$article['appid']}&iid={$article['id']}&cid={$article['cid']}", 'count' => $article['comments']);
     if ($article['picdata']) {
         $picdata = unserialize($article['picdata']);
     }
     unset($article['picdata']);
     $article['pic'] = get_pic($article['pic'], $picdata['b'], get_twh($vars['btw'], $vars['bth']));
     $article['mpic'] = get_pic($article['mpic'], $picdata['m'], get_twh($vars['mtw'], $vars['mth']));
     $article['spic'] = get_pic($article['spic'], $picdata['s'], get_twh($vars['stw'], $vars['sth']));
     $article['param'] = array("appid" => $article['appid'], "iid" => $article['id'], "cid" => $article['cid'], "suid" => $article['userid'], "title" => $article['title'], "url" => $article['url']);
     return $article;
 }
Exemplo n.º 11
0
     echo '  <td class="textcell" valign="top">';
     echo 'Voting has not started yet.';
     break;
 default:
     $proposal->getVotes($dbh);
     if (count($proposal->votes) == 0) {
         echo '  <td class="textcell" valign="top">';
         echo 'No votes have been cast yet.';
     } else {
         $users = array();
         $head = true;
         echo '  <td class="ulcell" valign="top">' . "\n<ul>\n";
         include_once 'pear-database-user.php';
         foreach ($proposal->votes as $vote) {
             if (!isset($users[$vote->user_handle])) {
                 $users[$vote->user_handle] =& user::info($vote->user_handle);
             }
             if ($vote->value > 0) {
                 $vote->value = '+' . $vote->value;
             }
             echo ' <li><strong>';
             echo make_link('pepr-vote-show.php?id=' . $proposal->id . '&amp;handle=' . htmlspecialchars($vote->user_handle), $vote->value);
             echo '</strong>';
             if ($vote->is_conditional) {
                 echo '^';
             } elseif (!empty($vote->comment)) {
                 echo '*';
             }
             echo ' &nbsp;(';
             echo make_link('/user/' . htmlspecialchars($vote->user_handle), htmlspecialchars($users[$vote->user_handle]['name']));
             echo ')&nbsp; ' . format_date($vote->timestamp);
Exemplo n.º 12
0
    include_once 'pear-database-user.php';
    $result = user::update($user_post);
    if (DB::isError($result)) {
        PEAR::raiseError('Could not update the user profile, please notify ' . PEAR_WEBMASTER_EMAIL);
        break;
    }
    report_success('Your information was successfully updated.');
}
if ($command == 'change_password') {
    if (!validate_csrf_token($csrf_token_name)) {
        report_error('Invalid token.');
        response_footer();
        exit;
    }
    include_once 'pear-database-user.php';
    $user = user::info($handle, 'password', true, false);
    // If it's an admin we can change ones password without knowing {{{
    // it's old password.
    if (!$auth_user->isAdmin()) {
        if (empty($_POST['password_old']) || empty($_POST['password']) || empty($_POST['password2'])) {
            PEAR::raiseError('Please fill out all password fields.');
            break;
        }
        if ($user['password'] != md5($_POST['password_old'])) {
            PEAR::raiseError('You provided a wrong old password.');
            break;
        }
    }
    if ($_POST['password'] != $_POST['password2']) {
        PEAR::raiseError('The new passwords do not match.');
        break;
Exemplo n.º 13
0
if (empty($selectStatus)) {
    echo "<p>";
    echo "PEPr is PEAR's system for managing the process of submitting ";
    echo "new packages. If you would like to submit your own package, ";
    echo "please have a look at the <a href=\"/manual/en/developers-newmaint.php\">New Maintainers' Guide</a>.";
    echo "</p>";
    echo "<p>";
    echo "<a href=\"/feeds/pepr{$searchPostfix}.rss\"><img src=\"/gifs/feed.png\" width=\"16\" height=\"16\" alt=\"Aggregate this\" border=\"0\" /></a>";
    echo "</p>";
}
display_overview_nav();
$users = array();
foreach ($proposals as $proposal) {
    include_once 'pear-database-user.php';
    if (!isset($users[$proposal->user_handle])) {
        $users[$proposal->user_handle] = user::info($proposal->user_handle);
    }
}
$statuses = $proposalStatiMap;
$proposals_by_status = array();
foreach ($statuses as $status => $status_description) {
    $proposals_by_status[$status] = array();
}
foreach ($proposals as $proposal) {
    //Only show 10 finished proposals unless we're specifically looking at everything
    if ($selectStatus != 'finished' && $proposal->getStatus() == 'finished' && count($proposals_by_status[$proposal->getStatus()]) >= 10) {
        continue;
    }
    $proposals_by_status[$proposal->getStatus()][] = $proposal;
}
foreach ($statuses as $status => $status_description) {
Exemplo n.º 14
0
 /**
  * Update user information
  *
  * @access public
  * @param  array User information
  * @return object|boolean DB error object on failure, true on success
  */
 static function update($data, $admin = false)
 {
     global $dbh;
     if (!isset($data['handle'])) {
         return false;
     }
     $fields = array('name', 'email', 'homepage', 'showemail', 'userinfo', 'pgpkeyid', 'wishlist', 'latitude', 'longitude', 'active', 'password', 'from_site');
     if ($admin) {
         $fields[] = 'registered';
         $fields[] = 'created';
         $fields[] = 'createdby';
     }
     $info = user::info($data['handle'], null, 'any');
     // In case a active value isn't passed in
     $active = isset($info['active']) ? $info['active'] : true;
     $change_k = $change_v = array();
     foreach ($data as $key => $value) {
         if (!in_array($key, $fields)) {
             continue;
         }
         $change_k[] = $key;
         $change_v[] = $value;
     }
     $sql = 'UPDATE users SET ' . "\n";
     foreach ($change_k as $k) {
         $sql .= $k . ' = ?,' . "\n";
     }
     $sql = substr($sql, 0, -2);
     $sql .= ' WHERE handle = ?';
     $change_v[] = $data['handle'];
     $err = $dbh->query($sql, $change_v);
     if (DB::isError($err)) {
         return $err;
     }
     if (isset($data['active']) && $data['active'] === 0 && $active) {
         // this user is completely inactive, so mark all maintains as not active.
         $dbh->query('UPDATE maintains SET active = 0 WHERE handle = ?', array($info['handle']));
     }
     return true;
 }
Exemplo n.º 15
0
    echo 'Voting Extended: ' . format_date($proposal->longened_date, 'Y-m-d');
    echo "</li>\n";
}
?>

   </ul>
  </td>
  <td class="ulcell" valign="top">

<?php 
if ($changelog = @ppComment::getAll($proposal->id, 'package_proposal_changelog')) {
    echo "<ul>\n";
    include_once 'pear-database-user.php';
    foreach ($changelog as $comment) {
        if (!isset($userinfos[$comment->user_handle])) {
            $userinfo[$comment->user_handle] = user::info($comment->user_handle);
        }
        echo '<li><p style="margin: 0em 0em 0.3em 0em; font-size: 90%;">';
        echo htmlspecialchars($userinfo[$comment->user_handle]['name']);
        echo '<br />[' . format_date($comment->timestamp) . ']</p>';
        switch ($proposal->markup) {
            case 'wiki':
                require_once 'Text/Wiki.php';
                $wiki =& new Text_Wiki();
                $wiki->disableRule('wikilink');
                echo $wiki->transform($comment->comment);
                break;
            case 'bbcode':
            default:
                require_once 'HTML/BBCodeParser.php';
                $bbparser = new HTML_BBCodeParser(array('filters' => 'Basic,Images,Links,Lists,Extended'));
Exemplo n.º 16
0
         $items[$i]['releasenotes'] = 'Downloads per day: ' . number_format($item['releasenotes'], 2);
     }
     $channel_title = 'PEAR: Popular releases';
     $channel_description = 'The most popular releases in PEAR.';
     break;
 case 'bug':
     $_REQUEST = array('id' => $argument, 'format' => 'rss');
     include dirname(dirname(__FILE__)) . '/bugs/rss/bug.php';
     exit;
 case 'user':
     $user = $argument;
     include_once 'pear-database-user.php';
     if (!user::exists($user)) {
         rss_bailout();
     }
     $name = user::info($user, "name");
     $channel_title = "PEAR: Latest releases for " . $user;
     $channel_description = "The latest releases for the PEAR developer " . $user . " (" . $name['name'] . ")";
     $items = user::getRecentReleases($user);
     break;
 case 'pkg':
     $package = $argument;
     include_once 'pear-database-package.php';
     if (package::isValid($package) == false) {
         rss_bailout();
         return PEAR::raiseError("The requested URL " . $_SERVER['REQUEST_URI'] . " was not found on this server.");
     }
     $channel_title = "Latest releases of " . $package;
     $channel_description = "The latest releases for the package " . $package;
     $items = package::getRecent(10, $package);
     break;
Exemplo n.º 17
0
 <tr>
  <th class="headrow" style="width: 100%">&raquo; Comments</th>
 </tr>
 <tr>

<?php 
$comments = ppComment::getAll($id, 'package_proposal_comments');
$userInfos = array();
if (is_array($comments) && count($comments) > 0) {
    echo '  <td class="ulcell" valign="top">' . "\n";
    echo '   <ul class="spaced">' . "\n";
    include_once 'pear-database-user.php';
    foreach ($comments as $comment) {
        if (empty($userInfos[$comment->user_handle])) {
            $userInfos[$comment->user_handle] = user::info($comment->user_handle);
        }
        echo '<li><p style="margin: 0em 0em 0.3em 0em;">';
        echo user_link($comment->user_handle, true);
        echo ' [' . format_date($comment->timestamp) . ']</p>';
        echo nl2br(htmlentities(trim($comment->comment))) . "\n</li>";
    }
    echo "   </ul>\n";
} else {
    echo '  <td class="textcell" valign="top">';
    echo 'There are no comments.';
}
?>

  </td>
 </tr>
Exemplo n.º 18
0
    if (!isset($_POST['handle']) || empty($_POST['handle'])) {
        $errors[] = 'Please enter your username';
    }
    if (!isset($_POST['password']) || empty($_POST['password'])) {
        $errors[] = 'Please enter your new password';
    }
    if (!isset($_POST['password2']) || empty($_POST['password2'])) {
        $errors[] = 'Please confirm your new password';
    }
    if (isset($_POST['password']) && isset($_POST['password2'])) {
        if ($_POST['password'] !== $_POST['password2']) {
            $errors[] = 'Passwords do not match';
        }
    }
    include_once 'pear-database-user.php';
    if (array('handle' => $_POST['handle']) != user::info($_POST['handle'], 'handle')) {
        $errors[] = 'Unknown user "' . $_POST['handle'] . '"';
        $_POST['handle'] = '';
    }
    if (!count($errors)) {
        require 'users/passwordmanage.php';
        $manager = new Users_PasswordManage();
        $errors = $manager->resetPassword($_POST['handle'], $_POST['password'], $_POST['password2']);
        if (!count($errors)) {
            $user = $_POST['handle'];
            require PEARWEB_TEMPLATEDIR . '/users/passwordreset.php';
            exit;
        }
    }
}
response_header("PEAR :: Forgot your password?");
Exemplo n.º 19
0
function comment_list($vars)
{
    if ($vars['display'] && empty($vars['loop'])) {
        if (empty($vars['_display'])) {
            $_vars = iCMS::app_ref(true);
            $vars = array_merge($vars, $_vars);
        }
        return comment_list_display($vars);
    }
    $where_sql = " `status`='1'";
    if (isset($vars['appid'])) {
        $appid = (int) $vars['appid'];
        $where_sql .= " AND `appid`='{$appid}'";
    }
    if (isset($vars['cid!'])) {
        $ncids = explode(',', $vars['cid!']);
        $vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true));
        $where_sql .= iPHP::where($ncids, 'cid', 'not');
    }
    if (isset($vars['cid'])) {
        $cid = explode(',', $vars['cid']);
        $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
        $where_sql .= iPHP::where($cid, 'cid');
    }
    isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'");
    $vars['pid'] && ($where_sql .= " AND `pid`='" . (int) $vars['pid'] . "'");
    $vars['iid'] && ($where_sql .= " AND `iid`='" . (int) $vars['iid'] . "'");
    $vars['id'] && ($where_sql .= " AND `id`='" . (int) $vars['id'] . "'");
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    $by = $vars['by'] == 'ASC' ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        default:
            $order_sql = " ORDER BY `id` {$by}";
    }
    $md5 = md5($where_sql . $order_sql);
    $offset = 0;
    $limit = "LIMIT {$maxperpage}";
    if ($vars['page']) {
        isset($vars['total_cache']) && ($_GET['total_cahce'] = true);
        $total = iPHP::total($md5, "SELECT count(*) FROM `#iCMS@__comment` WHERE {$where_sql} limit 1");
        $pgconf = array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:comment'), 'ajax' => $vars['page_ajax'] ? 'iCMS.comment.page' : FALSE, 'nowindex' => $GLOBALS['page']);
        if ($vars['display'] == 'iframe' || $vars['page_ajax']) {
            iS::gp('pn', 'GP', 2);
            $pgconf['page_name'] = 'pn';
            $pgconf['nowindex'] = $GLOBALS['pn'];
        }
        isset($vars['total_cache']) && ($pgconf['total_type'] = $vars['total_cache']);
        $multi = iCMS::page($pgconf);
        $offset = $multi->offset;
        $limit = "LIMIT {$offset},{$maxperpage}";
        // if($offset>1000){
        //$where_sql.=" AND `id` >= (SELECT `id` FROM `#iCMS@__comment` WHERE {$where_sql} {$order_sql} LIMIT {$offset},1)";
        //$limit  = "LIMIT {$maxperpage}";
        // }
        iPHP::assign("comment_total", $total);
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/comment/' . $md5 . "/" . (int) $offset;
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__comment` WHERE {$where_sql} {$order_sql} {$limit}");
        //iDB::debug(1);
        $ln = $GLOBALS['page'] - 1 < 0 ? 0 : $GLOBALS['page'] - 1;
        if ($resource) {
            foreach ($resource as $key => $value) {
                if ($vars['date_format']) {
                    $value['addtime'] = get_date($value['addtime'], $vars['date_format']);
                }
                $value['url'] = iCMS_API . '?app=comment&do=goto&iid=' . $value['iid'] . '&appid=' . $value['appid'] . '&cid=' . $value['cid'];
                $value['lou'] = $total - ($i + $ln * $maxperpage);
                $value['content'] = nl2br($value['content']);
                $value['user'] = user::info($value['userid'], $value['username'], $vars['facesize']);
                $value['reply_uid'] && ($value['reply'] = user::info($value['reply_uid'], $value['reply_name'], $vars['facesize']));
                $value['total'] = $total;
                if ($vars['page']) {
                    $value['page'] = array('total' => $multi->totalpage, 'perpage' => $multi->perpage);
                }
                $value['param'] = array("appid" => iCMS_APP_COMMENT, "id" => $value['id'], "userid" => $value['userid'], "name" => $value['username']);
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemplo n.º 20
0
 function sendActionEmail($event, $userType, $user_handle = null, $comment = '')
 {
     global $dbh, $karma, $auth_user;
     if (empty($karma)) {
         $karma = new Damblan_Karma($dbh);
     }
     require 'pepr/pepr-emails.php';
     $email = $proposalEmailTexts[$event];
     if (empty($email)) {
         return PEAR::raiseError("Email template for {$event} not found");
     }
     switch ($userType) {
         case 'admin':
             $prefix = "[ADMIN]";
             break;
         case 'mixed':
             if ($karma->has($user_handle, "pear.pepr.admin") && $this->user_handle != $user_handle) {
                 $prefix = "[ADMIN]";
             } else {
                 $prefix = "";
             }
             break;
         default:
             $prefix = "";
     }
     $prefix = PROPOSAL_EMAIL_PREFIX . $prefix . " ";
     include_once 'pear-database-user.php';
     $actorinfo = user::info($user_handle);
     $ownerinfo = user::info($this->user_handle);
     $this->getVotes($dbh);
     $vote = @$this->votes[$user_handle];
     if (isset($vote)) {
         $vote->value = $vote->value > 0 ? "+" . $vote->value : $vote->value;
         if ($vote->is_conditional) {
             $vote_conditional = "\n\nThis vote is conditional. The condition is:\n\n" . $vote->comment;
         } elseif ($vote->comment) {
             $comment = "\n\nComment:\n\n" . $vote->comment;
         }
         $vote_url = "http://" . PEAR_CHANNELNAME . "/pepr/pepr-vote-show.php?id=" . $this->id . "&handle=" . $user_handle;
     }
     if ($event == 'change_status_finished') {
         $proposalVotesSum = ppVote::getSum($dbh, $this->id);
         $vote_result = 'Sum of Votes: ' . $proposalVotesSum['all'];
         $vote_result .= ' (' . $proposalVotesSum['conditional'] . ' conditional)';
         if ($proposalVotesSum['all'] >= 5) {
             $vote_result .= "\nResult:       This proposal was accepted";
         } else {
             $vote_result .= "\nResult:       This proposal was rejected";
         }
     }
     $proposal_url = "http://" . PEAR_CHANNELNAME . "/pepr/pepr-proposal-show.php?id=" . $this->id;
     $end_voting_time = @$this->longened_date > 0 ? $this->longened_date + PROPOSAL_STATUS_VOTE_TIMELINE : @$this->vote_date + PROPOSAL_STATUS_VOTE_TIMELINE;
     if ($event == 'proposal_comment' && $user_handle == $this->user_handle) {
         $email['to'] = $email['to']['owner'];
     } else {
         if (!isset($user_handle)) {
             $email['to'] = $email['to']['pearweb'];
         } else {
             if ($karma->has($user_handle, "pear.pepr.admin")) {
                 $email['to'] = $email['to']['admin'];
             } else {
                 $email['to'] = $email['to']['user'];
             }
         }
     }
     $email['subject'] = $prefix . $email['subject'];
     $replace = array("/\\{pkg_category\\}/", "/\\{pkg_name\\}/", "/\\{owner_name\\}/", "/\\{owner_email\\}/", "/\\{owner_link\\}/", "/\\{actor_name\\}/", "/\\{actor_email\\}/", "/\\{actor_link\\}/", "/\\{proposal_url\\}/", "/\\{end_voting_time\\}/", "/\\{vote_value\\}/", "/\\{vote_url\\}/", "/\\{email_pear_dev\\}/", "/\\{email_pear_group\\}/", "/\\{comment\\}/", "/\\{vote_result\\}/", "/\\{vote_conditional\\}/");
     $replacements = array($this->pkg_category, $this->pkg_name, isset($ownerinfo['name']) ? $ownerinfo['name'] : "", isset($ownerinfo['email']) ? "<{$ownerinfo['email']}>" : '', isset($ownerinfo['handle']) ? user_link($ownerinfo['handle'], true) : "", isset($actorinfo['name']) ? $actorinfo['name'] : "", isset($actorinfo['email']) ? $actorinfo['email'] : "", isset($actorinfo['handle']) ? "http://" . PEAR_CHANNELNAME . "/user/" . $actorinfo['handle'] : "", $proposal_url, format_date($end_voting_time), isset($vote) ? $vote->value : 0, isset($vote) ? $vote_url : "", PROPOSAL_MAIL_PEAR_DEV, PROPOSAL_MAIL_PEAR_GROUP, isset($comment) ? wordwrap($comment) : '', isset($vote_result) ? $vote_result : '', isset($vote_conditional) ? $vote_conditional : "");
     $email = preg_replace($replace, $replacements, $email);
     $email['text'] .= PROPOSAL_EMAIL_POSTFIX;
     if (is_object($auth_user)) {
         $from = '"' . $auth_user->name . '" <' . $auth_user->email . '>';
     } else {
         $from = PROPOSAL_MAIL_FROM;
     }
     $to = explode(", ", $email['to']);
     $email['to'] = array_shift($to);
     $headers = "CC: " . implode(", ", $to) . "\n";
     $headers .= "From: " . $from . "\n";
     $headers .= "X-Mailer: " . "PEPr, PEAR Proposal System" . "\n";
     $headers .= "X-PEAR-Category: " . $this->pkg_category . "\n";
     $headers .= "X-PEAR-Package: " . $this->pkg_name . "\n";
     $headers .= "X-PEPr-Status: " . $this->getStatus() . "\n";
     if ($event == "change_status_proposal") {
         $headers .= "Message-ID: <proposal-" . $this->id . "@" . PEAR_CHANNELNAME . ">\n";
     } else {
         $headers .= "In-Reply-To: <proposal-" . $this->id . "@" . PEAR_CHANNELNAME . ">\n";
     }
     if (!DEVBOX) {
         $res = mail($email['to'], $email['subject'], $email['text'], $headers, '-f ' . PEAR_BOUNCE_EMAIL);
     } else {
         $res = true;
     }
     if (!$res) {
         return PEAR::raiseError('Could not send notification email.');
     }
     return true;
 }
Exemplo n.º 21
0
    </div>
    <div class="widget-content nopadding">
      <form action="<?php 
echo APP_FURI;
?>
&do=batch" method="post" class="form-inline" id="<?php 
echo APP_FORMID;
?>
" target="iPHP_FRAME">
        <ul class="recent-comments">
          <?php 
if ($rs) {
    foreach ($rs as $key => $value) {
        $C = $this->category[$value['cid']];
        $url = iCMS_API . '?app=comment&do=goto&iid=' . $value['iid'] . '&appid=' . $value['appid'] . '&cid=' . $value['cid'];
        $user = user::info($value['userid'], $value['username']);
        $app_label = app::get_label($value['appid'], 'title');
        ?>
          <li id="id-<?php 
        echo $value['id'];
        ?>
">
            <div class="user-thumb">
              <a href="<?php 
        echo $user['url'];
        ?>
" target="_blank" class="avatar">
              <img width="50" height="50" alt="<?php 
        echo $user['name'];
        ?>
" src="<?php 
Exemplo n.º 22
0
function user_inbox($vars = null)
{
    $maxperpage = 30;
    $where_sql = "WHERE `status` ='1'";
    if ($_GET['user']) {
        if ($_GET['user'] == "10000") {
            $where_sql .= " AND `userid`='10000' AND `friend` IN ('" . user::$userid . "','0')";
        } else {
            $friend = (int) $_GET['user'];
            $where_sql .= " AND `userid`='" . user::$userid . "' AND `friend`='" . $friend . "'";
        }
        $group_sql = '';
        $p_fields = 'COUNT(*)';
        $s_fields = '*';
        iPHP::assign("msg_count", false);
    } else {
        //	 	$where_sql.= " AND (`userid`='".user::$userid."' OR (`userid`='10000' AND `friend`='0'))";
        $where_sql .= " AND `userid`='" . user::$userid . "'";
        $group_sql = ' GROUP BY `friend` DESC';
        $p_fields = 'COUNT(DISTINCT id)';
        $s_fields = 'max(id) AS id ,COUNT(id) AS msg_count,`userid`, `friend`, `send_uid`, `send_name`, `receiv_uid`, `receiv_name`, `content`, `type`, `sendtime`, `readtime`';
        iPHP::assign("msg_count", true);
    }
    $offset = 0;
    $total = iPHP::total($md5, "SELECT {$p_fields} FROM `#iCMS@__message` {$where_sql} {$group_sql}", 'nocache');
    iPHP::assign("msgs_total", $total);
    $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
    $offset = $multi->offset;
    $resource = iDB::all("SELECT {$s_fields} FROM `#iCMS@__message` {$where_sql} {$group_sql} ORDER BY `id` DESC LIMIT {$offset},{$maxperpage}");
    iPHP_SQL_DEBUG && iDB::debug(1);
    $msg_type_map = array('0' => '系统信息', '1' => '私信', '2' => '提醒', '3' => '留言');
    if ($resource) {
        foreach ($resource as $key => $value) {
            $value['sender'] = user::info($value['send_uid'], $value['send_name']);
            $value['receiver'] = user::info($value['receiv_uid'], $value['receiv_name']);
            $value['label'] = $msg_type_map[$value['type']];
            if ($value['userid'] == $value['send_uid']) {
                $value['is_sender'] = true;
                $value['user'] = $value['receiver'];
            }
            if ($value['userid'] == $value['receiv_uid']) {
                $value['is_sender'] = false;
                $value['user'] = $value['sender'];
            }
            $value['url'] = iPHP::router(array('/user/inbox/{uid}', $value['user']['uid']), iPHP_ROUTER_REWRITE);
            $resource[$key] = $value;
        }
    }
    return $resource;
}
Exemplo n.º 23
0
 public function value($article, $art_data = "", $vars = array(), $page = 1, $tpl = false)
 {
     $article['appid'] = iCMS_APP_ARTICLE;
     $categoryApp = iPHP::app("category");
     $category = $categoryApp->category($article['cid'], false);
     if ($tpl) {
         $category or iPHP::throw404('运行出错!找不到该文章的栏目缓存<b>cid:' . $article['cid'] . '</b> 请更新栏目缓存或者确认栏目是否存在', 10002);
     } else {
         if (empty($category)) {
             return false;
         }
     }
     if ($category['status'] == 0) {
         return false;
     }
     if (iPHP::$iTPL_MODE == "html" && $tpl && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || $category['mode'] == "0")) {
         return false;
     }
     $_iurlArray = array($article, $category);
     $article['iurl'] = iURL::get('article', $_iurlArray, $page);
     $article['url'] = $article['iurl']->href;
     $article['link'] = "<a href='{$article['url']}'>{$article['title']}</a>";
     $tpl && $category['mode'] == '1' && iCMS::gotohtml($article['iurl']->path, $article['iurl']->href);
     if ($vars['category_lite']) {
         $article['category'] = $categoryApp->get_lite($category);
     } else {
         $article['category'] = $category;
     }
     $this->taoke = false;
     if ($art_data) {
         $pageurl = $article['iurl']->pageurl;
         // if(strpos($art_data['body'], '#--iCMS.ArticleData--#')!==false){
         //     iPHP::app('article.table');
         //     $art_data['body'] = articleTable::get_text($article['id']);
         // }
         $art_data['body'] = $this->ubb($art_data['body']);
         preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $art_data['body'], $pic_array);
         $p_array = array_unique($pic_array[1]);
         if ($p_array) {
             foreach ($p_array as $key => $_pic) {
                 $article['pics'][$key] = trim($_pic);
             }
         }
         if (strpos($art_data['body'], '#--iCMS.Markdown--#') !== false) {
             $art_data['body'] = iPHP::Markdown($art_data['body']);
         }
         $body = explode('#--iCMS.PageBreak--#', $art_data['body']);
         $count = count($body);
         $total = $count + intval(iCMS::$config['article']['pageno_incr']);
         $article['body'] = $this->keywords($body[intval($page - 1)]);
         $article['body'] = $this->taoke($article['body']);
         $article['subtitle'] = $art_data['subtitle'];
         $article['taoke'] = $this->taoke;
         unset($art_data);
         if ($total > 1) {
             $flag = 0;
             $num_nav = '';
             for ($i = $page - 3; $i <= $page - 1; $i++) {
                 if ($i < 1) {
                     continue;
                 }
                 $num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
                 $flag++;
             }
             $num_nav .= '<span class="current">' . $page . '</span>';
             for ($i = $page + 1; $i <= $total; $i++) {
                 $num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
                 $flag++;
                 if ($flag == 6) {
                     break;
                 }
             }
             $index_nav = '<a href="' . $article['url'] . '" class="first" target="_self">' . iPHP::lang('iCMS:page:index') . '</a>';
             $prev_url = iPHP::p2num($pageurl, $page - 1 > 1 ? $page - 1 : 1);
             $prev_nav = '<a href="' . $prev_url . '" class="prev" target="_self">' . iPHP::lang('iCMS:page:prev') . '</a>';
             $next_url = iPHP::p2num($pageurl, $total - $page > 0 ? $page + 1 : $page);
             $next_nav = '<a href="' . $next_url . '" class="next" target="_self">' . iPHP::lang('iCMS:page:next') . '</a>';
             $end_nav = '<a href="' . iPHP::p2num($pageurl, $total) . '" class="end" target="_self">共' . $total . '页</a>';
             $text_nav = $index_nav . $prev_nav . '<span class="current">第' . $page . '页</span>' . $next_nav . $end_nav;
             $pagenav = $index_nav . $prev_nav . $num_nav . $next_nav . $end_nav;
         }
         $article['page'] = array('total' => $total, 'count' => $count, 'current' => $page, 'num' => $num_nav, 'text' => $text_nav, 'nav' => $pagenav, 'prev' => $prev_url, 'next' => $next_url, 'pageurl' => $pageurl, 'last' => $page == $count ? true : false, 'end' => $page == $total ? true : false);
         unset($index_nav, $prev_nav, $num_nav, $next_nav, $end_nav, $pagenav);
         //var_dump($page,$total,$count);
         if ($pic_array[0]) {
             $img_array = array_unique($pic_array[0]);
             foreach ($img_array as $key => $img) {
                 $img = str_replace('<img', '<img title="' . $article['title'] . '" alt="' . $article['title'] . '"', $img);
                 if (iCMS::$config['article']['pic_center']) {
                     $img_replace[$key] = '<p align="center">' . $img . '</p>';
                 } else {
                     $img_replace[$key] = $img;
                 }
                 if (iCMS::$config['article']['pic_next'] && $count > 1) {
                     $clicknext = '<a href="' . $next_url . '"><b>' . iPHP::lang('iCMS:article:clicknext') . '</b></a>';
                     $clickimg = '<a href="' . $next_url . '" title="' . $article['title'] . '" class="img">' . $img . '</a>';
                     if (iCMS::$config['article']['pic_center']) {
                         $img_replace[$key] = '<p align="center">' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p align="center">' . $clickimg . '</p>';
                     } else {
                         $img_replace[$key] = '<p>' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p>' . $clickimg . '</p>';
                     }
                 }
             }
             $article['body'] = str_replace($img_array, $img_replace, $article['body']);
         }
     }
     if ($vars['prev_next'] && iCMS::$config['article']['prev_next']) {
         //上一篇
         $prev_cache = iPHP_DEVICE . '/article/' . $article['id'] . '/prev';
         $prev_array = iCache::get($prev_cache);
         if (empty($prev_array)) {
             $prev_array = array('empty' => true, 'title' => iPHP::lang('iCMS:article:first'), 'pic' => array(), 'url' => 'javascript:;');
             $prevrs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `id` < '{$article['id']}' AND `cid`='{$article['cid']}' AND `status`='1' order by id DESC LIMIT 1;");
             if ($prevrs) {
                 $prev_array = array('empty' => false, 'title' => $prevrs->title, 'pic' => get_pic($prevrs->pic), 'url' => iURL::get('article', array((array) $prevrs, $category))->href);
             }
             iCache::set($prev_cache, $prev_array);
         }
         $article['prev'] = $prev_array;
         //下一篇
         $next_cache = iPHP_DEVICE . '/article/' . $article['id'] . '/next';
         $next_array = iCache::get($next_cache);
         if (empty($next_array)) {
             $next_array = array('empty' => true, 'title' => iPHP::lang('iCMS:article:last'), 'pic' => array(), 'url' => 'javascript:;');
             $nextrs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `id` > '{$article['id']}'  and `cid`='{$article['cid']}' AND `status`='1' order by id ASC LIMIT 1;");
             if ($nextrs) {
                 $next_array = array('empty' => false, 'title' => $nextrs->title, 'pic' => get_pic($nextrs->pic), 'url' => iURL::get('article', array((array) $nextrs, $category))->href);
             }
             iCache::set($next_cache, $next_array);
         }
         $article['next'] = $next_array;
     }
     if ($vars['tags']) {
         $article['tags_fname'] = $category['name'];
         if ($article['tags']) {
             $tagApp = iPHP::app("tag");
             $tagArray = $tagApp->get_array($article['tags']);
             $article['tag_array'] = array();
             foreach ((array) $tagArray as $tk => $tag) {
                 $article['tag_array'][$tk]['name'] = $tag['name'];
                 $article['tag_array'][$tk]['url'] = $tag['url'];
                 $article['tag_array'][$tk]['link'] = $tag['link'];
                 $article['tags_link'] .= $tag['link'];
                 $tag_name_array[] = $tag['name'];
             }
             $tag_name_array && ($article['tags_fname'] = $tag_name_array[0]);
             unset($tagApp, $tagArray, $tag_name_array);
         }
     }
     if ($vars['meta']) {
         if ($article['metadata']) {
             $article['meta'] = unserialize($article['metadata']);
             unset($article['metadata']);
         }
     }
     if ($vars['user']) {
         iPHP::app('user.class', 'static');
         if ($article['postype']) {
             $article['user'] = user::empty_info($article['userid'], '#' . $article['editor']);
         } else {
             $article['user'] = user::info($article['userid'], $article['author']);
         }
     }
     if (strstr($article['source'], '||')) {
         list($s_name, $s_url) = explode('||', $article['source']);
         $article['source'] = '<a href="' . $s_url . '" target="_blank">' . $s_name . '</a>';
     }
     if (strstr($article['author'], '||')) {
         list($a_name, $a_url) = explode('||', $article['author']);
         $article['author'] = '<a href="' . $a_url . '" target="_blank">' . $a_name . '</a>';
     }
     $article['hits'] = array('script' => iCMS_API . '?app=article&do=hits&cid=' . $article['cid'] . '&id=' . $article['id'], 'count' => $article['hits'], 'today' => $article['hits_today'], 'yday' => $article['hits_yday'], 'week' => $article['hits_week'], 'month' => $article['hits_month']);
     $article['comment'] = array('url' => iCMS_API . "?app=article&do=comment&appid={$article['appid']}&iid={$article['id']}&cid={$article['cid']}", 'count' => $article['comments']);
     if ($article['picdata']) {
         $picdata = unserialize($article['picdata']);
     }
     unset($article['picdata']);
     $article['pic'] = get_pic($article['pic'], $picdata['b'], get_twh($vars['btw'], $vars['bth']));
     $article['mpic'] = get_pic($article['mpic'], $picdata['m'], get_twh($vars['mtw'], $vars['mth']));
     $article['spic'] = get_pic($article['spic'], $picdata['s'], get_twh($vars['stw'], $vars['sth']));
     $article['param'] = array("appid" => $article['appid'], "iid" => $article['id'], "cid" => $article['cid'], "suid" => $article['userid'], "title" => $article['title'], "url" => $article['url']);
     return $article;
 }
Exemplo n.º 24
0
 /**
  * Get maintainers to inform of a trackback (the lead maintainers of a package).
  *
  *
  * @since
  * @access public
  * @param  boolean $activeOnly  To get only active leads
  *                 is set to false by default so there's
  *                 no bc problems.
  *
  * @return array(string) The list of maintainer emails.
  */
 function getMaintainers($activeOnly = true)
 {
     include_once 'pear-database-maintainer.php';
     $maintainers = maintainer::get($this->get('id'), true, $activeOnly);
     $res = array();
     include_once 'pear-database-user.php';
     foreach ($maintainers as $maintainer => $data) {
         $tmpUser = user::info($maintainer, 'email');
         if (empty($tmpUser['email'])) {
             continue;
         }
         $res[] = $tmpUser['email'];
     }
     return $res;
 }
Exemplo n.º 25
0
    if (selectObj.selectedIndex != 0) {
        document.forms['account_form'].reason.value = selectObj.options[selectObj.selectedIndex].value;
    }
    selectObj.selectedIndex = 0;
}
// -->
</script>
<?php 
// }}}
$self = htmlspecialchars($_SERVER['PHP_SELF']);
$acreq = isset($_GET['acreq']) ? strip_tags(htmlspecialchars($_GET['acreq'])) : '';
do {
    // {{{ "approve account request" form
    if (!empty($acreq)) {
        include_once 'pear-database-user.php';
        $requser = user::info($acreq, null, false);
        if (empty($requser['name']) || $requser['from_site'] == 'pecl') {
            break;
        }
        list($purpose, $moreinfo) = @unserialize($requser['userinfo']);
        $bb = new BorderBox('Account request from ' . $requser['name'] . ' &lt;' . $requser['email'] . '&gt;', "100%", '', 2, true);
        $bb->horizHeadRow("Requested username:"******"Realname:", $requser['name']);
        $bb->horizHeadRow("Email address:", '<a href="mailto:' . $requser['email'] . '">' . $requser['email'] . "</a>");
        $bb->horizHeadRow("Purpose of account:", $purpose);
        $bb->horizHeadRow("More information:", $moreinfo);
        $bb->end();
        $i = "      ";
        print "<br />\n";
        print "{$i}<form action=\"{$self}\" method=\"POST\">\n";
        print $i . '   <input type="hidden" name="id" value="' . $requser['handle'] . "\" />\n";