Example #1
0
 public function testServices()
 {
     $ins = getAuth();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Auth\IAuth::class, $ins);
     $ins = getView();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\View\IView::class, $ins);
     $ins = getLog();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Log\ILog::class, $ins);
     //        $ins = getDB();
     //        $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Database\MedooDB::class, $ins);
     //        $ins = getRedis();
     //        $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Database\PRedis::class, $ins);
     //        $ins = getDataPool();
     //        $this->assertInstanceOf(\Wwtg99\DataPool\Common\IDataPool::class, $ins);
     $ins = getCache();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\Cache::class, $ins);
     $ins = getSession();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\SessionUtil::class, $ins);
     $ins = getCookie();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\CookieUtil::class, $ins);
     $ins = getOValue();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\OldValue::class, $ins);
     $ins = getAssets();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\View\AssetsManager::class, $ins);
     $ins = getMailer();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Utils\Mail::class, $ins);
     $ins = Flight::Express();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Utils\Express::class, $ins);
     $ins = getPlugin('php');
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Plugin\IPlugin::class, $ins);
 }
Example #2
0
 function setAuthVars()
 {
     /*	set authenticated user variables in smarty variable
      */
     $auth = getAuth();
     $this->assign("auth_type", $auth->getAuthType());
     $this->assign("auth_name", $auth->getAuthUsername());
 }
Example #3
0
 function __addAuthParams(&$params_arr)
 {
     $auth_obj = getAuth();
     list($auth_name, $auth_pass, $auth_type) = $auth_obj->getAuthParams();
     $params_arr["auth_name"] = $auth_name;
     $params_arr["auth_pass"] = $auth_pass;
     $params_arr["auth_type"] = $auth_type;
     $params_arr["auth_remoteaddr"] = getClientIPAddress();
 }
Example #4
0
function cc_get_uid()
{
    $auth = getAuth();
    if ($auth) {
        $auth->respondWithUserID();
    } else {
        CCAuth::logout();
    }
    die;
}
Example #5
0
function sendRoomNotification($room, $msg)
{
    LogMe("Sending message to room {$room}: {$msg}");
    $auth = new GorkaLaucirica\HipchatAPIv2Client\Auth\OAuth2(getAuth($room));
    $browserclient = new Buzz\Client\Curl();
    $browserclient->setVerifyPeer(false);
    $browser = new Buzz\Browser($browserclient);
    $client = new GorkaLaucirica\HipchatAPIv2Client\Client($auth, $browser);
    $message = new \GorkaLaucirica\HipchatAPIv2Client\Model\Message();
    $message->setMessage($msg['msg']);
    $message->setMessageFormat('text');
    if (isset($msg['color'])) {
        $message->setColor($msg['color']);
    }
    $x = new GorkaLaucirica\HipchatAPIv2Client\API\RoomAPI($client);
    $ret = $x->sendRoomNotification($room, $message);
    LogMe(print_r($ret, true));
}
Example #6
0
    	<form method="post" action="admin.php" id="form1">
		   <p>email</p>
		   <p><input type="text" name="email" /></p>
		   <p>mot de passe</p>
		   <p><input type="text" name="mdp" /></p>

		<button type="submit" form="form1" value="Submit">Connexion</button>
		</form>


		<?php 
if (isset($_POST["email"])) {
    ?>

			<?php 
    if (getAuth($_POST["email"], $_POST["mdp"])) {
        ?>

				<?php 
        $_SESSION['auth'] = "true";
        header('Location: ActionAdmin.php');
        ?>
			<?php 
    } else {
        ?>
				 <?php 
        header('Location: admin.php');
        ?>
 
				 
Example #7
0
        print '<div rel="wot:assurance" href="http://' . $_SERVER["SERVER_NAME"] . '/' . $_SERVER["SCRIPT_NAME"] . '.htm.asc"></div>' . "\n";
        print '</div>' . "\n";
    } else {
        main();
    }
}
$authreqissuer = isset($_POST['authreqissuer']) ? $_POST['authreqissuer'] : NULL;
$authreqissuer = isset($_GET['authreqissuer']) ? $_GET['authreqissuer'] : $authreqissuer;
$action = isset($_POST['action']) ? $_POST['action'] : NULL;
$action = isset($_GET['action']) ? $_GET['action'] : $action;
$webid = isset($_GET['webid']) ? $_GET['webid'] : NULL;
$realm = "FOAF Password";
if (isset($authreqissuer) && !isset($action)) {
    $action = "login";
}
$auth = getAuth();
/*
print "<pre>";
print_r($_SERVER);
print "</pre>";
*/
if (isset($auth['isAuthenticated']) && $auth['isAuthenticated'] == 1) {
    //    print $action . "<br/>";
    switch ($action) {
        case "account":
            account_maintenance($config, $auth['agent']['webid'], $authreqissuer);
            break;
        case "store":
            store($config, $auth['agent']['webid'], $_POST['mbox'], $_POST['password'], $_POST['active'], $_POST['mbox_sha1sum'], $authreqissuer);
            break;
        case "reminder":
 public function test_getAuth()
 {
     $object = getAuth('sql');
     $this->assertInstanceOf('w2p_Authenticators_SQL', $object);
     $object = getAuth('ldap');
     $this->assertInstanceOf('w2p_Authenticators_LDAP', $object);
     $object = getAuth('something else');
     $this->assertInstanceOf('w2p_Authenticators_SQL', $object);
 }
Example #9
0
function doAuth($info, $trusted = null, $fail_cancels = false, $idpSelect = null)
{
    if (!$info) {
        // There is no authentication information, so bail
        return authCancel(null);
    }
    $auth = getAuth();
    $cert_webid_23 = str_replace('#', '%23', $auth['agent']['webid']);
    $cert_webid = str_replace('http://', '', $cert_webid_23);
    //	$cert_webid = urlencode($auth['agent']['webid']);
    if ($_SERVER['HTTPS']) {
        $host = "https://openid4.me/";
    } else {
        $host = "http://openid4.me/";
    }
    $normalized_webid = $host . $cert_webid;
    if ($info->idSelect()) {
        //        if ($idpSelect) {
        //            $req_url = idURL($idpSelect);
        if ($auth[isAuthenticated]) {
            $req_url = $normalized_webid;
        } else {
            $trusted = false;
        }
        //        } else {
        //            $trusted = false;
        //        }
    } else {
        $req_url = $info->identity;
        if ($req_url != $normalized_webid) {
            //Get link header
            $link_webid = fetch_foaf_profile($req_url);
            if ($cert_webid == $link_webid) {
                $trusted = true;
            } else {
                $agent = get_agent(urldecode($link_webid));
                /*
                					print "<pre>";
                					print_r($agent);
                					print "</pre>";
                */
                $link_webid = isset($agent['agent']['webid']) ? str_replace('#', '%23', $agent['agent']['webid']) : '';
                if ($cert_webid_23 == $link_webid) {
                    $trusted = true;
                } else {
                    $trusted = false;
                }
            }
        } else {
            $trusted = true;
        }
    }
    $user = getLoggedInUser();
    setRequestInfo($info);
    /*
        if ((!$info->idSelect()) && ($req_url != idURL($user))) {
            return login_render(array(), $req_url, $req_url);
        }
    */
    $trust_root = $info->trust_root;
    if ($trusted) {
        setRequestInfo();
        $server =& getServer();
        $response =& $info->answer(true, null, $req_url);
        // Answer with some sample Simple Registration data.
        $agent = get_agent($auth['agent']['webid']);
        $sreg_data = array();
        if ($fullname = $agent['agent']['name']) {
            $sreg_data = array_merge($sreg_data, array('fullname' => $fullname));
        }
        if ($nickname = $agent['agent']['nick'][0]) {
            $sreg_data = array_merge($sreg_data, array('nickname' => $nickname));
        }
        if ($mbox = $agent['agent']['mbox'][0]) {
            $mbox = str_replace('mailto:', '', $mbox);
            $sreg_data = array_merge($sreg_data, array('email' => $mbox));
        }
        // Add the simple registration response values to the OpenID
        // response message.
        $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
        $sreg_response = Auth_OpenID_SRegResponse::extractResponse($sreg_request, $sreg_data);
        $sreg_response->toMessage($response->fields);
        // Generate a response to send to the user agent.
        $webresponse =& $server->encodeResponse($response);
        $new_headers = array();
        foreach ($webresponse->headers as $k => $v) {
            $new_headers[] = $k . ": " . $v;
        }
        return array($new_headers, $webresponse->body);
    } elseif ($fail_cancels) {
        return authCancel($info);
    } else {
        return trust_render($info);
    }
}
                 }
             } else {
                 json_return(401, "Unauthorized Request", NULL);
             }
         }
     } elseif ($task == "edit_user") {
         $email = trim($_POST['email']);
         $pass = trim($_POST['pass']);
         $user_id = trim($_POST['user_id']);
         $level = trim($_POST['level']);
         if (strlen($email) <= 0 || strlen($user_id) <= 0) {
             json_return(400, "Bad Request", NULL);
         } else {
             //$headers = apache_request_headers();
             if (trim(getAuth()) != "") {
                 $auth_array = split(":", getAuth());
                 if (trim($auth_array[0]) == session_id() && trim($auth_array[1]) == $_SESSION['api_key']) {
                     $main = new Main();
                     $main->editUser($email, $pass, $user_id, $level);
                 } else {
                     json_return(401, "Unauthorized Request", NULL);
                 }
             } else {
                 json_return(401, "Unauthorized Request", NULL);
             }
         }
     } else {
         json_return(404, "Not Found", NULL);
     }
     break;
 default:
Example #11
0
 /**
  * Add twig extended functions
  */
 protected function addFunctions()
 {
     // isDebug
     $func = new \Twig_SimpleFunction('isDebug', function () {
         return isDebug();
     });
     $this->twig->addFunction($func);
     // debugbarHead
     $func = new \Twig_SimpleFunction('debugbarHead', function () {
         $debugbar = \Flight::get('debugbar');
         if ($debugbar) {
             $debugRender = $debugbar->getJavascriptRenderer();
             $debugRender->setBaseUrl(U('assets/debugbar'));
             return $debugRender->renderHead();
         }
         return '';
     }, ['is_safe' => ['html']]);
     $this->twig->addFunction($func);
     // renderDubugbar
     $func = new \Twig_SimpleFunction('renderDebugbar', function () {
         $debugbar = \Flight::get('debugbar');
         if ($debugbar) {
             $debugRender = $debugbar->getJavascriptRenderer();
             return $debugRender->render();
         }
         return '';
     }, ['is_safe' => ['html']]);
     $this->twig->addFunction($func);
     // renderAssets
     $func = new \Twig_SimpleFunction('renderAssets', function ($addlib = []) {
         $ass = getAssets();
         if ($addlib) {
             $ass->addLibrary($addlib);
         }
         return $ass->renderCss() . $ass->renderJs();
     }, ['is_safe' => ['html']]);
     $this->twig->addFunction($func);
     // get resource
     $func = new \Twig_SimpleFunction('resource', function ($name, $prefix = '') {
         return getAssets()->getResource($name, $prefix);
     });
     $this->twig->addFunction($func);
     // isLogin
     $func = new \Twig_SimpleFunction('isLogin', function () {
         return getAuth()->isLogin();
     });
     $this->twig->addFunction($func);
     // isSuperuser
     $func = new \Twig_SimpleFunction('isSuperuser', function () {
         return getAuth()->isSuperuser();
     });
     $this->twig->addFunction($func);
     // hasRole
     $func = new \Twig_SimpleFunction('hasRole', function ($role) {
         return getAuth()->hasRole($role);
     });
     $this->twig->addFunction($func);
     // getConfig
     $func = new \Twig_SimpleFunction('getConfig', function ($name) {
         return \Flight::get('config')->get($name);
     });
     $this->twig->addFunction($func);
     // getUser
     $func = new \Twig_SimpleFunction('getUser', function () {
         return getAuth()->getUser();
     });
     $this->twig->addFunction($func);
     // old value
     $func = new \Twig_SimpleFunction('old', function ($name, $def = '') {
         return getOld($name, $def);
     });
     $this->twig->addFunction($func);
     // log
     $func = new \Twig_SimpleFunction('log', function ($level, $msg, $context = []) {
         return getLog()->log($level, $msg, $context);
     });
     $this->twig->addFunction($func);
 }
Example #12
0
 /**
 * Login function
 *
 * A number of things are done in this method to prevent illegal entry:
 * <ul>
 * <li>The username and password are trimmed and escaped to prevent malicious
 *     SQL being executed
 * </ul>
 * The schema previously used the MySQL PASSWORD function for encryption.  This
 * Method has been deprecated in favour of PHP's MD5() function for database independance.
 * The check_legacy_password option is no longer valid
 *
 * Upon a successful username and password match, several fields from the user
 * table are loaded in this object for convenient reference.  The style, localces
 * and preferences are also loaded at this time.
 *
 * @param string The user login name
 * @param string The user password
 * @return boolean True if successful, false if not
 */
 function login($username, $password, $redirect)
 {
     require_once DP_BASE_DIR . "/classes/authenticator.class.php";
     require_once "{$baseDir}/classes/authenticator.class.php";
     $auth_method = isset($dPconfig['auth_method']) ? $dPconfig['auth_method'] : 'sql';
     /*
     		if (@$_POST['login'] != 'login' && @$_POST['login'] != $this->_('login', UI_OUTPUT_RAW) && $_REQUEST['login'] != $auth_method) {
     			die("You have chosen to log in using an unsupported or disabled login method");
     		}
     */
     $auth =& getAuth($auth_method);
     $username = trim(db_escape($username));
     $password = trim(db_escape($password));
     if (!$auth->authenticate($username, $password, $redirect)) {
         if ($auth->fallback) {
             $auth =& getAuth("default");
             if (!$auth->authenticate($username, $password, $redirect)) {
                 return false;
             }
         }
     }
     $user_id = $auth->userId($username);
     $username = $auth->username;
     // Some authentication schemes may collect username in various ways.
     // Now that the password has been checked, see if they are allowed to
     // access the system
     if (!isset($GLOBALS['acl'])) {
         $GLOBALS['acl'] =& new dPacl();
     }
     if (!$GLOBALS['acl']->checkLogin($user_id)) {
         dprint(__FILE__, __LINE__, 1, "Permission check failed");
         return false;
     }
     $q = new DBQuery();
     $q->addTable('users');
     $q->addQuery('user_id, contact_first_name as user_first_name, contact_last_name as user_last_name, contact_company as user_company, contact_department as user_department, contact_email as user_email, user_type');
     $q->addJoin('contacts', 'con', 'contact_id = user_contact');
     $q->addWhere("user_id = {$user_id} AND user_username = '******'");
     $sql = $q->prepare();
     $q->clear();
     dprint(__FILE__, __LINE__, 7, "Login SQL: {$sql}");
     if (!db_loadObject($sql, $this)) {
         dprint(__FILE__, __LINE__, 1, "Failed to load user information");
         return false;
     }
     // load the user preferences
     $this->loadPrefs($this->user_id);
     $this->setUserLocale();
     $this->checkStyle();
     return true;
 }
Example #13
0
function needAuthType($auth_type)
{
    $auth_obj = getAuth();
    $auth_obj->needAuthType($auth_type);
}
Example #14
0
<?php

session_start();
if (!isset($_SESSION['imgur_state'])) {
    $_SESSION['imgur_state'] = sha1(microtime());
}
$state = $_SESSION['imgur_state'];
$authUrl = getAuthUrl($client_id, null, $state);
if (!isset($_SESSION['access_token'])) {
    getAuth($client_id, $state, $authUrl, $client_secret);
}
$token = $_SESSION['access_token'];
$images = getImages($token);
if (isset($images['data']['error'])) {
    if ($images['data']['error'] == 'The access token provided is invalid.') {
        getAuth($client_id, $state, $authUrl, $client_secret);
        $images = getImages($token);
    }
}
//$images = getImages($token);
//print_r();
foreach ($images['data'] as $key => $val) {
    $image = getImage($val);
}
class ImgurAPI
{
    private $env;
    private $clientId;
    // = '61cf321962377a9';
    private $clientSecret;
    // = ''
Example #15
0
 function is_auth()
 {
     require_once dirname(__FILE__) . '/../foaf-ssl/libAuthentication.php';
     // need cookies here
     global $foaf_ssl;
     if ($foaf_ssl) {
         session_start();
         if ($_COOKIE['auth'] == 1) {
             return true;
         }
         $auth = getAuth();
         $do_auth = $auth['certRSAKey'];
         $is_auth = $auth['isAuthenticated'];
         $auth_uri = $auth['subjectAltName'];
         if ($is_auth == 1) {
             setcookie("uri", "{$auth_uri}");
             setcookie("auth", "1");
             if ($auth_uri == FOAF_URI) {
                 return true;
             }
         }
     }
     return false;
 }
Example #16
0
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, True);
        curl_setopt($ch, CURLOPT_AUTOREFERER, True);
        $ret = curl_exec($ch);
        $code = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        if ($code == 200) {
            file_put_contents($fname, $ret);
        } else {
            die("code for {$url} is {$code}\n");
        }
    } else {
        $ret = file_get_contents($fname);
    }
    return $ret;
}
$callist = getAuth("http://www.google.com/calendar/feeds/default/allcalendars/full");
$doc = new DOMDocument();
$doc->loadXML($callist);
#$sels = $doc->getElementsByTagName("gCal:selected");
$sels = $doc->getElementsByTagName("entry");
print_r($sels->item(0));
die;
foreach ($doc->getElementsByTagName("gCal:selected") as $sel) {
    print_r($sel);
}
print_r($doc->saveXML());
$allcals = simplexml_import_dom($doc);
#$allcals = new SimpleXMLElement($callist);
foreach ($allcals->entry as $entry) {
    print_r($entry);
    if ((string) $entry->{'gCal:selected'}['value'] == 'true') {
Example #17
0
<?php

session_start();
include "configuration.php";
include "function.php";
$conn = open_db();
if ($kell_login) {
    if (isset($_SESSION["user"]) && isset($_SESSION["auth"])) {
        $user = $_SESSION["user"];
        $auth = $_SESSION["auth"];
    } else {
        header("Location: login.php");
    }
} else {
    $user = "******";
    $auth = getAuth(1);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon">
<link rel="stylesheet" type="text/css" href="giro.css">
<title><?php 
echo $oldalnev;
?>
</title>
</head>
<body>
<div class="menu">