Пример #1
0
 public function index()
 {
     //$admins = array('math001','duodaamaster');
     //echo $this->username;
     $au = isset($_POST['add_username']) ? $_POST['add_username'] : '';
     $al = isset($_POST['add_userlevel']) ? $_POST['add_userlevel'] : '';
     $au = trim($au);
     $al = trim($al);
     echo '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>' . "\n";
     if ($au != '' && $al != '') {
         $uids = qa_handles_to_userids(array($au), true);
         $uid = $uids[$au];
         if ($uid != null) {
             if ($this->user_model->get_user_config($au) !== null or $this->user_model->get_user_level($au) !== null) {
                 echo '已经建立过此用户,或者出现其它错误';
                 exit;
             }
             $blogsetting = array('username' => $au, 'blogtitle' => $au . '的空间', 'blogsubtitle' => $au . '于哆嗒数学网撰写文章的空间', 'articlesshow' => 10);
             $userlevel = array('username' => $au, 'level' => 0 + $al);
             $this->db->insert('userconfig', $blogsetting);
             $this->db->insert('userlevel', $userlevel);
             echo $au . '创建成功!';
             exit;
         } else {
             echo '用户名不存在';
             exit;
         }
     } else {
         echo '<form action="/blog/index.php/admin/" method="post">' . "\n";
         echo '添加用户:<input name="add_username" id="add_username" style="width:100px" /> 权限:<input name="add_userlevel" id="add_userlevel" style="width:20px" value = "0" />' . "\n";
         echo '<input type="submit" value="确定" />' . "\n";
         echo '</form>' . "\n";
     }
 }
Пример #2
0
 function get_qa_avartar_html($user, $size = 200)
 {
     $userid_array = qa_handles_to_userids(array($user));
     $userid = $userid_array[$user];
     $useraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true));
     $avartahtml = qa_get_user_avatar_html($useraccount['flags'], $useraccount['email'], $useraccount['handle'], $useraccount['avatarblobid'], $useraccount['avatarwidth'], $useraccount['avatarheight'], qa_opt('avatar_profile_size'));
     $avartahtml = strtolower($avartahtml);
     if ($avartahtml != null) {
         $avartahtml = strtolower($avartahtml);
         $avartahtml = str_replace('?', '\\?', $avartahtml);
         //生成avarta的html串,从站点的根目录引用
     } else {
         $avartahtml = '<a href="' . $this->config->item('qaroot_src') . '?qa=user/' . $user . '" class="qa-user-link">';
         $avartahtml .= '<img src="' . base_url($this->config->item('app_src')) . '/views/theme/' . $this->config->item('theme') . '/img/default_avatar.jpg' . '"/>';
         $avartahtml .= '</a>';
     }
     return $avartahtml;
 }
Пример #3
0
function cs_user_badge($handle)
{
    if (qa_opt('badge_active')) {
        $userids = qa_handles_to_userids(array($handle));
        $userid = $userids[$handle];
        // displays small badge widget, suitable for meta
        $result = qa_db_read_all_values(qa_db_query_sub('SELECT badge_slug FROM ^userbadges WHERE user_id=#', $userid));
        if (count($result) == 0) {
            return;
        }
        $badges = qa_get_badge_list();
        foreach ($result as $slug) {
            $bcount[$badges[$slug]['type']] = isset($bcount[$badges[$slug]['type']]) ? $bcount[$badges[$slug]['type']] + 1 : 1;
        }
        $output = '<ul class="user-badge clearfix">';
        for ($x = 2; $x >= 0; $x--) {
            if (!isset($bcount[$x])) {
                continue;
            }
            $count = $bcount[$x];
            if ($count == 0) {
                continue;
            }
            $type = qa_get_badge_type($x);
            $types = $type['slug'];
            $typed = $type['name'];
            $output .= '<li class="badge-medal ' . $types . '"><i class="icon-badge" title="' . $count . ' ' . $typed . '"></i><span class="badge-pointer badge-' . $types . '-count" title="' . $count . ' ' . $typed . '"> ' . $count . '</span></li>';
        }
        $output = substr($output, 0, -1);
        // lazy remove space
        $output .= '</ul>';
        return $output;
    }
}