示例#1
0
文件: FbAuth.php 项目: soychicka/tg
 static function requireAuthenticate($is_ajax = true, $extra_secure = true, &$realUser = null)
 {
     global $api_key, $api_key_secret, $adminUserIDs;
     $u = MyAuth::checkAuthentication($extra_secure);
     if (!$u) {
         if ($is_ajax) {
             return 0;
         }
         $facebook = new Facebook($api_key, $api_key_secret);
         $user = $facebook->require_login();
         if ($user) {
             MyAuth::setLoginAuthenticate($user);
         }
         $u = $user;
     }
     if (isset($realUser)) {
         $realUser = $u;
     }
     //Return the mock_user if the real user is an administrator and mockuser is set
     $mu = GetAdminDebug('mock_user');
     if ($mu != 'NONE' && in_array(intval($u), $adminUserIDs)) {
         return $mu;
     } else {
         return $u;
     }
 }
示例#2
0
        $fp->log($u);
        if ($u) {
            MyAuth::setLoginAuthenticate($u['uid']);
            header("Location: {$appAfterLoginUrl}");
            die;
        } else {
            echo '<span class="error_message">Login not valid!</span>';
        }
    } else {
        //signup
        $fp->log("Signup!");
        if (!User::RegisterUser($_REQUEST['first_name'], $_REQUEST['last_name'], $_REQUEST['email'], $_REQUEST['password'], $_REQUEST['gender'])) {
            echo '<span class="error_message">Probaly the email has been already used! Plase try wih a different one</span>';
        } else {
            $u = User::getByEmail($_REQUEST['email']);
            MyAuth::setLoginAuthenticate($u['uid']);
            header("Location: {$appAfterLoginUrl}");
            die;
        }
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="Content-Style-Type" content="text/css">
        <meta http-equiv="Content-Script-Type" content="text/javascript">

        <link rel="stylesheet" type="text/css" href="static/css/main.css<?php 
echo cache_burner();
示例#3
0
//I create timer object and start it (TRUE)
$timer = new Benchmark_Timer();
$timer->start();

//Establish connection
try {
 DB::get()->connect();
} catch (Exception $e) {
 print_r($e); //### It must be handle better: writing in the log file (that must be set) and 
} 
*/
function aq($val)
{
    return trim($val, "\"'");
}
$u = MyAuth::checkAuthentication(false);
//### This must change later to true and take vcare to pass the cookie
$fp->log($u);
if (!$u) {
    error('Not logged in');
}
//In order to debug XML add "?T3ST=1" in the URL
if (isset($_REQUEST[$debug_parameter])) {
    $XML_debug = true;
}
if (isset($_REQUEST['action'])) {
    if ($_REQUEST['action'] == "createevent") {
        $fp->log("createevent");
        $name = aq($_REQUEST['name']);
        $description = aq($_REQUEST['description']);
        $time = aq($_REQUEST['time']);
示例#4
0
文件: MyAuth.php 项目: soychicka/tg
            echo '<pre>';
            print_r($_COOKIE);
            if (isset($_COOKIE['tjc_lo'])) {
                $a = explode(',', $_COOKIE['tjc_lo']);
                $t = $a[1];
                $curr_t = time();
                $exp_time = $curr_t - $t;
                echo "\nCookie 'lo' was set at ", date('l jS \\of F Y h:i:s A', $t), ' (', intval($exp_time / 60), ' min and ', $exp_time % 60, ' sec  ago)';
            }
            echo '</pre>';
        } else {
            if ($c == 2) {
                //Auth as user 10101010
                $u = '10101010';
                MyAuth::setLoginAuthenticate($u);
                echo "MyAuth::setLoginAuthenticate({$u}) executed";
            } else {
                if ($c == 3) {
                    //perform the check auth
                    $n = MyAuth::checkAuthentication(false);
                    $e = MyAuth::checkAuthentication();
                    echo '<pre>';
                    print_r($_COOKIE);
                    echo "Auth (normal) user is {$n}\n";
                    echo "Auth (extra secure) user is {$e}";
                    echo '</pre>';
                }
            }
        }
    }
}
示例#5
0
文件: admin.php 项目: soychicka/tg
$NameParts = explode('/', $_SERVER["SCRIPT_NAME"]);
$page = $NameParts[count($NameParts) - 1];
require_once 'include/basic.php';
require_once 'include/MyAuth.php';
$fp->log($_GET, '_GET');
$fp->log($_COOKIE, '_COOKIE');
/*
$fp->group('_COOKIE[]:');
ob_start();
print_r( $_COOKIE );
$out = ob_get_clean();
TRACE(TRACE_DEBUG, $out);
$fp->groupEnd();
*/
$user = MyAuth::requireAuthentication($appLoginUrl, false, false);
if (!in_array($user, $adminUserIDs)) {
    echo '<h1>You are not the admin!</h1>';
    die;
}
if (isset($_GET['obstart_debug'])) {
    if ($_GET['admin_obstart'] == '1') {
        SetAdminDebug('obstart', '1');
    } else {
        SetAdminDebug('obstart', '0');
    }
    header("Refresh: 0;url=admin.php");
    echo 'You\'ll be redirected in about 1 sec. If not, click <a href="admin.php">here</a>.';
    die;
}
if (isset($_GET['mock_user_debug'])) {