コード例 #1
0
 /**
  * 判断未登录,则跳转到登陆页
  */
 public static function RequireLogin()
 {
     if (!Passport::IsLogin()) {
         redirect('login.php?return_url=' . urlencode($_SERVER['REQUEST_URI']));
         exit('尚未登录,<a href="login.php?return_url=' . urlencode($_SERVER['REQUEST_URI']) . '">请登录</a>!');
     }
 }
コード例 #2
0
<div class="well">
    <?php 
echo $form->textFieldRow($passport, "[{$i}]firstName");
?>
    <?php 
echo $form->textFieldRow($passport, "[{$i}]lastName");
?>
    <?php 
echo $form->textFieldRow($passport, "[{$i}]birthday");
?>
    <?php 
echo $form->radioButtonListInlineRow($passport, "[{$i}]genderId", Passport::getPossibleGenders());
?>
    <?php 
echo $form->dropDownListRow($passport, "[{$i}]countryId", Country::getPossibleCountries());
?>
    <?php 
echo $form->dropDownListRow($passport, "[{$i}]documentTypeId", Passport::getPossibleTypes());
?>
    <?php 
echo $form->textFieldRow($passport, "[{$i}]series");
?>
    <?php 
echo $form->textFieldRow($passport, "[{$i}]number");
?>
</div>
コード例 #3
0
ファイル: blog.php プロジェクト: z445056647/phx-svns
                $third = $thirdAccount->getByType($type_arr[0], $type_arr[1]);
                $api = Factory::CreateAPI2($type_arr[0], $type_arr[1], $third);
                $ret = $api->publish($_POST['title'], $content);
                if ($ret !== true && str_contains($ret, '已过期')) {
                    $thirdAccount->fail($third, $ret);
                }
                $TEMPLATE['report'][$type] = array('status' => $ret === true, 'msg' => $ret === true ? '发送成功!' . ($third['url'] ? '<a href="' . $third['url'] . '" target="_blank">查看</a>' : '') : '发送失败:' . $ret . ' <a href="list_err.php">重新发送</a>');
                $task->AddTask($type, $content, time(), NULL, $ret === true ? Task::OK : Task::ERROR, $ret, 'blog', $_POST['title']);
            }
            $watch->Stop();
            $TEMPLATE['report']['watch'] = array('status' => true, 'msg' => "总耗时:{$watch->getElapsedSeconds()} 秒");
        }
    }
}
$TEMPLATE['title'] = '发博客';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['blog'] = 'current';
$TEMPLATE['target_list'] = $wt_open->getBlogList();
$TEMPLATE['platform_list'] = $wt_open->getPlatformList();
foreach ($TEMPLATE['platform_list'] as &$item) {
    $item['list'] = $wt_open->getBlogList($item['id']);
    unset($item);
}
$smarty = new Template();
echo $smarty->r('blog');
function validate()
{
    global $TEMPLATE;
    $check = true;
    if (strlen($_POST['title']) == 0 || strlen($_POST['content']) == 0) {
        $TEMPLATE['report']['check_cont'] = array('status' => false, 'msg' => '标题和内容均不能为空!');
コード例 #4
0
ファイル: Task.class.php プロジェクト: z445056647/phx-svns
 /**
  * 按状态和分页获取任务列表
  * @param int $status
  * @param string $limit
  */
 public function GetList($status, $limit = NULL)
 {
     $cond = array('status' => $status);
     if (!Passport::IsAdmin()) {
         $user = new User();
         $perms = $user->getPerms(Passport::GetLoginUid());
         if (count($perms) > 0) {
             $cond['pid'] = array_keys($perms);
         } else {
             $cond['uid'] = Passport::GetLoginUid();
         }
     }
     $list = $this->findBy($cond, $this->primary_key, $limit, null, 'send_time desc, id desc');
     // 查询 username 字段
     $uids = array();
     foreach ($list as $item) {
         $uids[] = $item['uid'];
     }
     $uids = array_unique($uids);
     $user = new User();
     $user_list = $user->gets($uids);
     foreach ($list as &$item) {
         $item['username'] = if_null($user_list[$item['uid']]['username'], 'uid: ' . $item['uid']);
         unset($item);
     }
     return $list;
 }
コード例 #5
0
ファイル: upload.php プロジェクト: a195474368/ejw
 */
//载入全局配置和函数包
require dirname(__FILE__) . "/../../app.php";
//////////////////////////////
//注册会话
$session = getgpc('session');
//用户体系
$sid = '';
//系统管理员
if ($_G['manager']['id']) {
    $sid = 'manager';
}
//普通用户
if (!$_G['manager']['id'] && $session) {
    Module::loader('passport', 'function');
    $hash = Passport::session_decode($session);
    if ($hash['id']) {
        $sid = 'member';
    }
}
//会话域
if (!$sid) {
    alert(1, '您当前不在登录状态(' . $sid . ')');
} elseif (empty($_FILES) === FALSE) {
    //连接数据库
    System::connect();
    $res = Attach::savefile(array('field' => 'imgFile', 'filetype' => 'image', 'account' => $sid, 'absolute' => TRUE));
    //关闭数据库
    System::connect();
    if ($res) {
        alert(0, NULL, $res);
コード例 #6
0
ファイル: bind.php プロジェクト: z445056647/phx-svns
    case 'qzone':
        $code_key = 'oauth_vericode';
        break;
    case 'renren':
    case 'sina':
        $code_key = 'code';
        break;
    default:
        $code_key = 'oauth_verifier';
        break;
}
$token = $api->getAccessToken($_GET[$code_key], $_GET['oauth_token']);
if ($token['oauth_token']) {
    $api->openid = $token['openid'];
    $thirdAccount = new ThirdAccount();
    $tableInfo = array('uid' => Passport::GetLoginUid(), 'pid' => $pid, 'type' => $api->type, 'token' => $token['oauth_token'], 'token_secret' => $token['oauth_token_secret'], 'openid' => $token['openid'], 'nick' => $api->getNick(), 'url' => $api->getUrl(), 'valid' => 1);
    Log::customLog('token_expires_error.txt', "绑定 Token,信息:" . print_r($tableInfo, true));
    $user = new User();
    $users = $user->getsAll();
    foreach ($users as $uid => $item) {
        $tableInfo['uid'] = $uid;
        $thirdAccount->replace($tableInfo);
    }
    redirect($_GET['redir']);
    echo <<<HTML
<script>
opener.location=opener.location;
window.close();
</script>
HTML;
} else {
コード例 #7
0
ファイル: register.php プロジェクト: z445056647/phx-svns
if (Passport::IsLogin()) {
    redirect('index.php');
}
if (Request::IsPost()) {
    $fields = $_POST['f'];
    if (validate($fields)) {
        $user = new User();
        $ret = $user->getByName($fields['username']);
        $TEMPLATE['error'] = array();
        if ($ret) {
            $TEMPLATE['error']['username'] = '******';
        } else {
            $tableInfo = array('username' => $fields['username'], 'password' => md5($fields['password']), 'type' => $user->totals() == 0 ? 1 : 0, 'reg_date' => time(), 'last_login' => time());
            $newid = $user->insertIgnore($tableInfo);
            if ($newid) {
                $ret = Passport::WriteCookie($newid, $tableInfo['username'], $tableInfo['type']);
                $return_url = get_returnurl('index.php');
                $wt_open = new WTOpen();
                $cbs = $wt_open->getCallbackList();
                $scripts = '';
                if (count($cbs) > 0) {
                    $token = http_build_query($ret);
                    foreach ($cbs as $value) {
                        $url = get_absolute_url("login_api.php?{$token}", $value);
                        $scripts .= "<script src=\"{$url}\"></script>\n";
                    }
                }
                echo <<<HTML
{$scripts}
<script>
location.replace('{$return_url}');
コード例 #8
0
ファイル: init.php プロジェクト: z445056647/phx-svns
include_once ROOT_DIR . '_CLASS' . DS . 'FX' . DS . 'function.inc.php';
include_once ROOT_DIR . '_CLASS' . DS . 'function.inc.php';
function autoload($class_name)
{
    $file = ROOT_DIR . '_CLASS' . DS . 'FX' . DS . $class_name . '.class.php';
    if (file_exists($file)) {
        include_once $file;
    } else {
        $file = ROOT_DIR . '_CLASS' . DS . $class_name . '.class.php';
        if (file_exists($file)) {
            include_once $file;
        }
    }
}
spl_autoload_register('autoload');
/*---Debug Begin---*/
if (defined('DEBUG') && DEBUG == true || $_REQUEST['debug'] == 1) {
    //Debug模式将错误打开
    ini_set('display_errors', true);
    //设置错误级别
    error_reporting(ERROR_LEVEL);
    //开启ob函数
    ob_start();
    //Debug开关打开
    Debug::start();
    //注册shutdown函数用来Debug显示
    register_shutdown_function(array('Debug', 'show'));
}
/*---Debug End---*/
$TEMPLATE['is_admin'] = Passport::IsAdmin();
コード例 #9
0
ファイル: upload.php プロジェクト: z445056647/phx-svns
<?php

include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../../../init.php';
Passport::RequireLogin();
if ($_FILES) {
    $ret = array();
    foreach ($_FILES as $file) {
        $success = false;
        $errReason = "";
        if ($file['size'] == 0) {
            $errReason = "文件大小为 0 字节。";
        } else {
            @mkdir(UPLOAD_PATH, 0777, true);
            $new_filename = microtime(true) . '_' . Pinyin::get(str_replace(' ', '-', $file['name']));
            $upload_file = UPLOAD_PATH . $new_filename;
            if (move_uploaded_file($file['tmp_name'], $upload_file)) {
                $success = true;
            }
        }
        $ret[] = array('Success' => $success, 'ErrReason' => $errReason, 'NewFileName' => UPLOAD_PATH_WWW . $new_filename);
    }
    echo json_encode($ret);
    exit;
}
?>
<form enctype="multipart/form-data" method="post">
  <input type="file" name="file1">
  <input type="submit" value="上传">
</form>
コード例 #10
0
ファイル: login_api.php プロジェクト: z445056647/phx-svns
<?php

/**
 * 登录接口,多域名同步登录使用
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
Passport::WriteCookie($_GET['uid'], $_GET['id'], $_GET['type'], $_GET['sign']);
echo '//ok';
コード例 #11
0
ファイル: login.php プロジェクト: z445056647/phx-svns
 * 登录页面
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
if ($_GET['action'] == 'logoff') {
    Passport::LogOff();
    redirect('login.php');
}
if (Passport::IsLogin()) {
    redirect('index.php');
}
if (Request::IsPost()) {
    $fields = $_POST['f'];
    if (validate($fields)) {
        $ret = Passport::Login($fields['username'], $fields['password']);
        if (is_array($ret)) {
            $return_url = get_returnurl('index.php');
            $wt_open = new WTOpen();
            $cbs = $wt_open->getCallbackList();
            $scripts = '';
            if (count($cbs) > 0) {
                $token = http_build_query($ret);
                foreach ($cbs as $value) {
                    $url = get_absolute_url("login_api.php?{$token}", $value);
                    $scripts .= "<script src=\"{$url}\"></script>\n";
                }
            }
            echo <<<HTML
{$scripts}
<script>
コード例 #12
0
ファイル: Session.class.php プロジェクト: z445056647/phx-svns
 /**
  * 获取Session物理文件名
  */
 private static function getSessionFile()
 {
     return LOG_PATH . Passport::GetLoginUid() . '.session';
 }
コード例 #13
0
ファイル: WTOpen.class.php プロジェクト: z445056647/phx-svns
 /**
  * 按平台和权限获取博客列表
  * @param int $pid
  * @param bool $perm
  */
 public function getBlogList($pid = 0, $perm = TRUE)
 {
     if ($pid == 0) {
         return array();
     }
     if ($perm) {
         $user = new User();
         $perms = $user->getPerms(Passport::GetLoginUid());
         if (!array_key_exists($pid, $perms)) {
             return array();
         }
     }
     $list = Config::blog_list();
     if ($pid > 0) {
         $set_list = $this->findBy(array('status' => 1, 'pid' => $pid), 'name');
         $new_list = array();
         foreach ($list as $key => $value) {
             if (array_key_exists($key, $set_list) || array_key_exists($key, Config::simula_list())) {
                 $new_list[$key] = $list[$key];
             }
         }
         $list = $new_list;
     } else {
         foreach ($list as $key => $value) {
             if ($key == 'qzone_simula') {
                 //	只要设定任何一个 qzone APPKEY,qzone模拟登录就关闭
                 if ($this->fetchOne(array('status' => 1, 'name' => 'qzone'))) {
                     unset($list[$key]);
                     continue;
                 }
             }
             if (array_key_exists($key, Config::open_list())) {
                 unset($list[$key]);
             }
         }
     }
     return $list;
 }
コード例 #14
0
 /**
  * 获取登录账户绑定信息
  * @param string $type	第三方平台类型
  * @param int $pid		自建平台ID
  */
 public function getByType($type, $pid = 0, $uid = NULL)
 {
     $uid = if_null($uid, Passport::GetLoginUid());
     return $this->getThird($uid, $type, $pid);
 }