public function SetForm($id)
 {
     if (test_user()) {
         $db = M('ActivityFormAnswer');
         $questionList = M('ActivityForm')->where('activity_id=%d', $id)->select();
         // 检查重复提交
         if (M('ActivityFormSign')->where('activity_id=%d AND username="******"', $id, cookie('username'))->count() != 0) {
             $this->error('你已经提交过了');
             return;
         }
         $sign_data = array('username' => cookie('username'), 'activity_id' => $id);
         $sign_id = M('ActivityFormSign')->add($sign_data);
         if ($sign_id <= 0) {
             $this->error('系统异常,提交失败');
             return;
         }
         // 合成数据
         foreach ($questionList as $value) {
             if (count(I($value['id'])) == 0) {
                 $this->error('存在未填项');
                 return;
             }
             $data[] = array('question_id' => $value['id'], 'answer' => I($value['id']), 'sign_id' => $sign_id);
         }
         if ($db->addAll($data) > 0) {
             $this->success('提交成功', 'detail.html?id=' . $id);
         } else {
             M('ActivityFormSign')->where('id=%d', $sign_id)->delete();
             $this->error('系统异常,提交失败');
         }
     } else {
         $this->error('用户验证失败');
     }
 }
Beispiel #2
0
 function testSend()
 {
     $client = new DemocracyInAction_Client();
     list($status, $data) = $client->send(authentication_url(), array('email' => test_user(), 'password' => test_pass()), 'post');
     $this->assertWantedPattern('/Successful Login/', $data);
     $url = 'https://' . test_node() . '/api/getObjects.sjs';
     list($status, $data) = $client->send($url, array('object' => 'supporter', 'limit' => 1));
     $this->assertWantedPattern('/organization_KEY="1"/', $data);
 }
Beispiel #3
0
 function testValidCredentials()
 {
     list($status, $data) = post(authentication_url(), array('email' => test_user(), 'password' => test_pass()));
     #has an interesting status code
     $this->assertEqual($status, 200);
     #has interesting success message
     $this->assertWantedPattern('/Successful Login/', $data);
     #looks like we expect
     $expected = file_get_contents(dirname(__FILE__) . '/../fixtures/auth/valid.xml');
     $this->assertEqual($data, $expected);
 }
Beispiel #4
0
function IsAdmin()
{
    if (test_user()) {
        if (M('User')->where('username="******"', cookie('username'))->getField('admin')) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Beispiel #5
0
function authenticated_curl_handle()
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
    $temp_file = tempnam(sys_get_temp_dir(), 'DIA');
    curl_setopt($ch, CURLOPT_COOKIEFILE, $temp_file);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $temp_file);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, authentication_url());
    curl_setopt($ch, CURLOPT_POSTFIELDS, "email=" . test_user() . "&password=" . test_pass());
    $data = curl_exec($ch);
    return $ch;
}
 public function DelCookie($id)
 {
     if (!test_user()) {
         echo json_encode(array('error' => '删除失败', 'status' => false));
         return;
     }
     if (M('Cookie')->where('id=%d', $id)->delete()) {
         M('SignList')->where('cookieid=%d', $id)->delete();
         $kv = new \SaeKV();
         $kv->init();
         $kv->delete('Cookie' . $id);
         echo json_encode(array('info' => '删除成功', 'status' => true));
     } else {
         echo json_encode(array('error' => '删除失败', 'status' => false));
     }
 }
 public function AddProcess($pid, $content)
 {
     $resJson = array('status' => false);
     // 检测用户状态
     $ProCreater = M('Project')->where('id=%d', $pid)->getField('username');
     if (test_user() && $ProCreater == cookie('username')) {
         $data = array('project_id' => $pid, 'content' => htmlspecialchars($content));
         if (M('ProjectProcess')->add($data)) {
             $resJson['status'] = true;
             $resJson['info'] = '更新成功';
         } else {
             $resJson['error'] = '添加失败,系统异常';
         }
     } else {
         $resJson['error'] = '账号异常';
     }
     echo json_encode($resJson);
 }
Beispiel #8
0
        $ok = $requete->execute(array($id, $nom));
    }
    // Et on envoie ce résultat au programme qui l'a demandé : le controller
}
/*FACEBOOK CONNECT*/
$appId = '898558203596431';
$appSecret = '16f33b4c7bca662b5b6d286fe9a2642d';
FacebookSession::setDefaultApplication($appId, $appSecret);
$helper = new FacebookRedirectLoginHelper(route(''));
if (isset($_SESSION) && isset($_SESSION['fb_token'])) {
    $session = new FacebookSession($_SESSION['fb_token']);
} else {
    $session = $helper->getSessionFromRedirect();
}
if ($session) {
    try {
        $_SESSION['fb_token'] = $session->getToken();
        $request = new FacebookRequest($session, 'GET', '/me');
        $profile = $request->execute()->getGraphObject();
        $_SESSION['fbName'] = $profile->getProperty('name');
        $_SESSION['fbId'] = $profile->getProperty('id');
        test_user($_SESSION['fbName'], $_SESSION['fbId']);
        $request2 = new FacebookRequest($session, 'GET', '/me/picture?type=large&redirect=false');
        $picture = $request2->execute();
        $img = $picture->getGraphObject()->asArray();
        $_SESSION['fbImg'] = $img;
    } catch (Exception $e) {
        $_SESSION = null;
        session_destroy();
    }
}
<?php

if (!defined('THINK_PATH')) {
    exit;
}
?>
<!DOCTYPE HTML>
<?php 
$auto_login = new \User\Api\UserApi();
$auto_login->autologin();
if (!test_user()) {
    header("Location: /User/Login?from=" . $_SERVER['PHP_SELF'] . $_SERVER["QUERY_STRING"]);
    exit;
}
?>
<html class="no-js">
<head>
	  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

  <!-- Set render engine for 360 browser -->
  <meta name="renderer" content="webkit">

  <!-- No Baidu Siteapp-->
  <meta http-equiv="Cache-Control" content="no-siteapp"/>

  <link rel="icon" type="image/png" href="/Public/assets/i/favicon.png">
Beispiel #10
0
function test_collection($collection_url)
{
    $collection = new Collection($collection_url);
    // 获取收藏夹名称
    $title = $collection->get_title();
    var_dump($title);
    // 获取收藏夹简介
    $description = $collection->get_description();
    var_dump($description);
    // 获取收藏夹建立者
    $author = $collection->get_author();
    var_dump($author);
    $answer_list = $collection->get_answers();
    foreach ($answer_list as $answer) {
        var_dump($answer);
    }
}
$time = new Time();
$time->star();
$user_url = 'https://www.zhihu.com/people/zhang-jia-wei';
$question_url = 'https://www.zhihu.com/question/38813693';
$answer_url = 'https://www.zhihu.com/question/23841579/answer/79001713';
$topics_url = 'https://www.zhihu.com/topic/19606711';
$collection_url = 'https://www.zhihu.com/collection/19650606';
test_user($user_url);
// test_question($question_url);
// test_answer($answer_url);
// test_topics($topics_url);
// test_collection($collection_url);
$time->stop();
echo $time->spent();
Beispiel #11
0
 public function ChangePassword($old, $new)
 {
     $resultArr = array('status' => false);
     if (!test_user()) {
         $resultArr['error'] = '登录已失效';
         return $resultArr;
     }
     $userinfo = $this->where('username="******"', cookie('username'))->find();
     if ($userinfo['password'] != login_en_code($old)) {
         $resultArr['error'] = '旧密码不对啦~';
         return $resultArr;
     }
     if (!preg_match('/[\\S]{6,128}/', $new)) {
         return $jsonResult = array('status' => false, 'error' => '密码不符合条件<br/>请输入6-128位密码');
     }
     $data = array('password' => login_en_code($new));
     trace($data, 'debug');
     if ($this->where('username="******"', cookie('username'))->save($data)) {
         $resultArr['status'] = true;
         $resultArr['info'] = '修改密码成功';
     } else {
         $resultArr['error'] = '修改密码失败,密码未变动或系统错误';
     }
     return $resultArr;
 }