Пример #1
0
chdir("..");
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$session = new Session();
if ($session->isLoggedIn()) {
    header("Location: ../index.php");
}
$db = new Database($THINKTANK_CFG);
$conn = $db->getConnection();
$od = new OwnerDAO($db);
$user_email = mysql_real_escape_string($_POST['email']);
$s = new SmartyThinkTank();
$s->caching = false;
if ($_POST['Submit'] == 'Login') {
    $result = $od->getForLogin($user_email);
    if (!$result) {
        header("Location: login.php?emsg=Invalid+email+or+password");
    } elseif (!$session->pwdCheck($_POST['pwd'], $result['pwd'])) {
        header("Location: login.php?emsg=Incorrect+email+or+password");
    } else {
        // this sets variables in the session
        $session->completeLogin($result);
        $od->updateLastLogin($user_email);
        if (isset($_GET['ret']) && !empty($_GET['ret'])) {
            header("Location: {$_GET['ret']}");
        } else {
            header("Location: " . $THINKTANK_CFG['site_root_path']);
        }
        exit;
    }
Пример #2
0
<?php

chdir("..");
require_once "common/init.php";
$authorized = false;
if (isset($argc) && $argc > 1) {
    // check for CLI credentials
    $session = new Session();
    $username = $argv[1];
    $pw = $argv[2];
    $od = new OwnerDAO($db);
    $result = $od->getForLogin($username);
    if ($session->pwdCheck($pw, $result['pwd'])) {
        $authorized = true;
        echo "Authorized to run crawler.";
    } else {
        echo "Incorrect username and password.";
    }
} else {
    // check user is logged in on the web
    session_start();
    $session = new Session();
    if ($session->isLoggedIn()) {
        $authorized = true;
    }
}
if ($authorized) {
    $crawler->crawl();
    if (isset($conn)) {
        $db->closeConnection($conn);
        // Clean up