/**
* Checks which files of a directory are missing in a SQLite3 database and returns a list of them.
*
* @arg dir The directory for which to check
* @arg dbfile The file containing the database
* @arg table The table name of the database
* @arg col The column containing the filenames
* @arg enckey The encryption key used for the database
* @returns A list of files missing from the database, or an empty list
*/
function missing_files_from_directory($dir, $dbfile, $table, $col, $enckey = NULL)
{
    $missing = array();
    $dirscan = scandir($dir, SCANDIR_SORT_ASCENDING);
    if ($dirscan == false) {
        // Either $dir is not a directory or scandir had no success
        return $missing;
    }
    try {
        if (is_string($enckey)) {
            $db = new SQLite3($dbfile, SQLITE3_OPEN_READONLY, $enckey);
        } else {
            $db = new SQLite3($dbfile, SQLITE3_OPEN_READONLY);
        }
    } catch (Exception $e) {
        // Database could not be opened; return empty array
        return $missing;
    }
    foreach ($dirscan as $file) {
        if (is_dir($file) || is_link($file)) {
            // Filtering out directories (. and ..) and links {
            continue;
        }
        if ($db->querySingle("SELECT EXISTS(SELECT * FROM " . $table . " WHERE " . $col . " = '" . SQLite3::escapeString($file) . "');")) {
            // if an entry exists, returns TRUE, otherwise FALSE; invalid or failing queries return FALSE
            continue;
        }
        // entry does not exist; add to array
        $missing[] = $file;
    }
    $db->close();
    sort($missing, SORT_LOCALE_STRING | SORT_FLAG_CASE);
    return $missing;
    // sort based on the locale, case-insensitive
}
function acctstart($input)
{
    require_once "settings.php";
    $input = $input;
    $delimiter1 = "The new session";
    $delimiter2 = "has been created";
    $pos1 = strpos($input, $delimiter1) + strlen($delimiter1) + 2;
    $pos2 = strpos($input, $delimiter2) - 2;
    $sstrlen = $pos2 - $pos1;
    $sessid = substr($input, $pos1, $sstrlen);
    exec($vpncmd . " " . $softetherip . " /SERVER /HUB:" . $hubname . " /PASSWORD:"******" /CSV /CMD SessionGet " . $sessid, $SessionGet);
    if (strpos($SessionGet[0], "rror occurred") != FALSE) {
        die("Error - SessionGet resulted in error");
    }
    foreach ($SessionGet as $line) {
        list($key, $val) = explode(",", $line, 2);
        $result[$key] = $val;
    }
    $recheck = 0;
    dhcptest:
    sleep(2);
    exec($vpncmd . " " . $softetherip . " /SERVER /HUB:" . $hubname . " /PASSWORD:"******" /CSV /CMD IpTable", $IpTable);
    $ok = 0;
    foreach ($IpTable as $line) {
        if (strpos($line, $sessid)) {
            if (strpos($line, "DHCP")) {
                list(, $key, $val) = explode(",", $line);
                list($framedip) = explode(" ", $val);
                #$result2[$key] = $val;
                $ok = 1;
            }
        }
    }
    if ($ok == 0) {
        if ($recheck == 4) {
            die("Error - could not find session in retrived IpTable data");
        }
        sleep(2);
        $recheck = $recheck + 1;
        goto dhcptest;
    }
    $db = new SQLite3($database);
    $db->exec('CREATE TABLE IF NOT EXISTS sessions (sessionid varchar(255), username varchar (255), clientip varchar (255), inputoctets varchar (255), ' . 'outputoctets varchar (255), framedip varchar (255), nasip varchar (255), nasport varchar (255), acctstarttime varchar (255), ' . 'acctsessiontime varchar (255), PRIMARY KEY(sessionid))');
    $query = $db->escapeString('INSERT OR REPLACE INTO sessions (sessionid, username, clientip, inputoctets, outputoctets, framedip, nasip, nasport, acctstarttime, acctsessiontime) VALUES ("' . $sessid . '","' . $result["User Name (Authentication)"] . '","' . $result["Client IP Address"] . '",NULL,NULL,"' . $framedip . '","' . $result["Server IP Address (Reported)"] . '","' . $result["Server Port (Reported)"] . '","' . $result["Connection Started at"] . '",NULL)');
    $db->exec($query);
    $sessid = $db->escapeString($sessid);
    $results = $db->querySingle("SELECT * FROM sessions WHERE sessionid = '" . $sessid . "'", true);
    $tmpfname = tempnam($tmpdir, "acctstarttmp_");
    $handle = fopen($tmpfname, "w");
    $packet = "Service-Type = Framed-User" . "\n" . "Framed-Protocol = PPP" . "\n" . "NAS-Port = " . $results['nasport'] . "\n" . "NAS-Port-Type = Async" . "\n" . "User-Name = '" . $results['username'] . "'" . "\n" . "Calling-Station-Id = '" . $results['clientip'] . "'" . "\n" . "Called-Station-Id = '" . $results['nasip'] . "'" . "\n" . "Acct-Session-Id = '" . $sessid . "'" . "\n" . "Framed-IP-Address = " . $results['framedip'] . "\n" . "Acct-Authentic = RADIUS" . "\n" . "Event-Timestamp = " . time() . "\n" . "Acct-Status-Type = Start" . "\n" . "NAS-Identifier = '" . $results['nasip'] . "'" . "\n" . "Acct-Delay-Time = 0" . "\n" . "NAS-IP-Address = " . $results['nasip'] . "\n";
    fwrite($handle, $packet);
    fclose($handle);
    exec("radclient " . $radiussrv . ":" . $radiusport . " acct " . $radiuspass . " -f " . $tmpfname);
    unlink($tmpfname);
    $db->close();
}
Exemple #3
0
function getAPIs()
{
    $apis = array();
    $db = new SQLite3('./urls/urls.db');
    #Grab most recent VirusTotal API
    $vtresult = $db->querySingle('SELECT key FROM apis WHERE site = "vt" ORDER BY id DESC');
    $apis['vt'] = $vtresult;
    $wotresult = $db->querySingle('SELECT key FROM apis WHERE site = "wot" ORDER BY id DESC');
    $apis['wot'] = $wotresult;
    $googresult = $db->querySingle('SELECT key FROM apis WHERE site = "goog" ORDER BY id DESC');
    $apis['goog'] = $googresult;
    foreach ($apis as $id => $val) {
        if ($val == '') {
            exit("Error retrieving API key for ({$id}). Check the urls.db database.");
        }
    }
    #print_r($apis);
    return $apis;
}
function init_db()
{
    global $sqlite_database;
    $db = new SQLite3($sqlite_database);
    $test_query = "select count(*) from sqlite_master where name = 'credentials'";
    if ($db->querySingle($test_query) == 0) {
        $create_table = "create table credentials (userid text not null unique, " . "credentials text not null);";
        $db->exec($create_table);
    }
    return $db;
}
Exemple #5
0
    function author_save($keyword = false, $session = false)
    {
        $db = new SQLite3('author.db') or die('Unable to open database');
        $query = <<<EOD
CREATE TABLE IF NOT EXISTS authors (
  author STRING PRIMARY KEY,
  session STRING )
EOD;
        $db->exec($query) or die('Create db failed');
        $count = $db->querySingle("SELECT count(*) as count FROM authors WHERE author='{$keyword}'");
        if ($count < 1) {
            $query = <<<EOD
INSERT INTO authors VALUES ( '{$keyword}','{$session}' )
EOD;
            $db->exec($query) or die("Unable to add author {$keyword}");
        }
        return;
    }
Exemple #6
0
function acctstop($input)
{
    require_once "settings.php";
    $delimiter1 = "Session";
    $delimiter2 = ": The session has been terminated.";
    $pos1 = strpos($input, $delimiter1) + strlen($delimiter1) + 2;
    $pos2 = strpos($input, $delimiter2) - 1;
    $sstrlen = $pos2 - $pos1;
    $sessid = substr($input, $pos1, $sstrlen);
    $delimiter1 = "outgoing data size:";
    $delimiter2 = "bytes,";
    $pos1 = strpos($input, $delimiter1) + strlen($delimiter1) + 1;
    $pos2 = strpos($input, $delimiter2) - 1;
    $sstrlen = $pos2 - $pos1;
    $outdata = substr($input, $pos1, $sstrlen);
    $delimiter1 = "incoming data size:";
    $delimiter2 = "bytes.";
    $pos1 = strpos($input, $delimiter1) + strlen($delimiter1) + 1;
    $pos2 = strpos($input, $delimiter2) - 1;
    $sstrlen = $pos2 - $pos1;
    $indata = substr($input, $pos1, $sstrlen);
    $db = new SQLite3($database);
    $sessid = $db->escapeString($sessid);
    $results = $db->querySingle("SELECT * FROM sessions WHERE sessionid = '" . $sessid . "'", true);
    if ($results == FALSE) {
        die("Error - could not find sessionid");
    }
    list($time1, , $time2) = explode(" ", $results['acctstarttime']);
    $sessiontime = time() - strtotime($time1 . " " . $time2);
    $tmpfname = tempnam($tmpdir, "acctstoptmp_");
    $handle = fopen($tmpfname, "w");
    $packet = "Service-Type = Framed-User" . "\n" . "Framed-Protocol = PPP" . "\n" . "NAS-Port = " . $results['nasport'] . "\n" . "NAS-Port-Type = Async" . "\n" . "User-Name = '" . $results['username'] . "'" . "\n" . "Calling-Station-Id = '" . $results['clientip'] . "'" . "\n" . "Called-Station-Id = '" . $results['nasip'] . "'" . "\n" . "Acct-Session-Id = '" . $sessid . "'" . "\n" . "Framed-IP-Address = " . $results['framedip'] . "\n" . "Acct-Authentic = RADIUS" . "\n" . "Event-Timestamp = " . time() . "\n" . "Acct-Session-Time = " . $sessiontime . "\n" . "Acct-Input-Octets = " . $indata . "\n" . "Acct-Output-Octets = " . $outdata . "\n" . "Acct-Status-Type = Stop" . "\n" . "NAS-Identifier = '" . $results['nasip'] . "'" . "\n" . "Acct-Delay-Time = 0" . "\n" . "NAS-IP-Address = " . $results['nasip'] . "\n";
    fwrite($handle, $packet);
    fclose($handle);
    exec("radclient " . $radiussrv . ":" . $radiusport . " acct " . $radiuspass . " -f " . $tmpfname);
    unlink($tmpfname);
    $db->exec("DELETE FROM sessions WHERE sessionid = '" . $sessid . "' LIMIT 1");
    $db->close();
}
Exemple #7
0
if (!isset($_GET['act'])) {
    $_GET['act'] = "calendar";
}
if ($_GET['act'] != "view" && $_GET['act'] != "games" && $_GET['act'] != "stats" && $_GET['act'] != "calendar") {
    $_GET['act'] = "calendar";
}
if (file_exists("./echl15-16.db3")) {
    $sqldb = new SQLite3("./echl15-16.db3");
} else {
    $sqldb = new SQLite3("../hockey15-16.db3");
}
$sqldb->exec("PRAGMA encoding = \"UTF-8\";");
$sqldb->exec("PRAGMA auto_vacuum = 1;");
$sqldb->exec("PRAGMA foreign_keys = 1;");
$sqlite_games_string = "";
$firstgamedate = $sqldb->querySingle("SELECT Date FROM " . $leaguename . "Games WHERE id=1");
$lastgamedate = $sqldb->querySingle("SELECT Date FROM " . $leaguename . "Games WHERE id=(SELECT MAX(id) FROM " . $leaguename . "Games)");
if ($lastgamedate < gmdate("Y") . gmdate("m") . gmdate("d")) {
    $lastgamedate = gmdate("Y") . gmdate("m") . gmdate("d");
}
if ($_GET['act'] == "calendar") {
    if (isset($_GET['date']) && strlen($_GET['date']) == 8) {
        if (!isset($_GET['month']) || !is_numeric($_GET['month'])) {
            $_GET['month'] = substr($_GET['date'], 4, 2);
        }
        if (!isset($_GET['year']) || !is_numeric($_GET['year'])) {
            $_GET['year'] = substr($_GET['date'], 0, 4);
        }
    }
    if (isset($_GET['date']) && strlen($_GET['date']) == 6) {
        if (!isset($_GET['month']) || !is_numeric($_GET['month'])) {
Exemple #8
0
            $handle->exec("update ZTFCSTATIONMODEL set ZAPIKEY = 'gva', ZAPIID = '" . $stop['stopCode'] . "' where ZID = '" . $row['ZID'] . "'");
        }
        if ($distance < 250) {
            if ($row['ZNAME'] == $stop['stopName']) {
                $handle->exec("update ZTFCSTATIONMODEL set ZAPIKEY = 'gva', ZAPIID = '" . $stop['stopCode'] . "' where ZID = '" . $row['ZID'] . "'");
            } else {
                $parts = explode(",", $row['ZNAME']);
                if (isset($parts[1])) {
                    if (trim($parts[1]) == $stop['stopName']) {
                        $handle->exec("update ZTFCSTATIONMODEL set ZAPIKEY = 'gva', ZAPIID = '" . $stop['stopCode'] . "' where ZID = '" . $row['ZID'] . "'");
                        print $parts[1] . ' == ' . $stop['stopName'] . "\n";
                    }
                } else {
                    print "Distance ({$distance}) too long for " . $row['ZNAME'] . "\n";
                }
            }
        } else {
            print "Distance ({$distance}) too long for " . $row['ZNAME'] . "\n";
        }
    } else {
        print "nothing found for " . $row['ZNAME'] . "< {$url} >\n";
    }
}
$result = $handle->querySingle("select count(*) from ZTFCSTATIONMODEL where ZCOUNTY = 'Geneva' AND ZDEPARTURESURL ISNULL  ");
print $result . " are still without an URL\n";
function getFirst($url)
{
    $result = file_get_contents("http://www.timeforcoffee.ch/api/" . $url);
    $r = json_decode($result, true);
    return $r['departures'];
}
Exemple #9
0
<?php

$query = "UPDATE prestiolus SET datereturn = datetime() WHERE id = '" . $_GET['id'] . "';";
//update prestiolus set datereturn = datetime() where id = '4';
$db = new SQLite3('prestiolus.db');
$db->querySingle($query);
header('Location: index.php');
Exemple #10
0
<?php

session_start();
if (empty($_SESSION['user_name']) || !empty($_SESSION['role']) && $_SESSION['role'] != "admin") {
    header('Location: login.php');
}
include "config.inc";
$list_db = new SQLite3("lists.db");
$where = "";
$total_pages = $list_db->querySingle('SELECT COUNT(*) FROM lists' . $where);
$limit = 20;
$page = empty($_GET["page"]) ? 1 : $_GET["page"];
if ($page > 1) {
    $start = ($page - 1) * $limit;
} else {
    $start = 0;
}
$results = $list_db->query("SELECT * FROM lists ORDER BY evt_updatetime DESC LIMIT {$start}, {$limit}");
$arrs = array();
while ($row = $results->fetchArray()) {
    $id = $row["evt_id"];
    $outPath = dirname(__FILE__) . '/content/' . $id . "/avatar.jpg";
    //echo filesize($outPath);
    if (file_exists($outPath) && filesize($outPath) > 1024) {
        continue;
    } else {
        array_push($arrs, $id);
    }
}
?>
<div id="msg"></div>
Exemple #11
0
                 $update->execute();
             }
             $res->finalize();
         }
         ++$count;
         $merge->bindValue('id', $count);
         $merge->execute();
         $res = $tdb->query("SELECT ID FROM poly WHERE type = 1");
         $diff->bindValue('outer', $count);
         while ($row = $res->fetchArray(SQLITE3_NUM)) {
             echo "Diffing " . $row[0] . "\n";
             $diff->bindValue('inner', $row[0]);
             $diff->execute();
         }
         $res->finalize();
         $endpoly = $tdb->querySingle("SELECT AsText(polygon) FROM poly WHERE id = " . (int) $count);
         echo $endpoly . "\n";
         if (!empty($insert_final) && !empty($endpoly)) {
             $insert_final->bindValue('id', $p->zone, SQLITE3_INTEGER);
             $insert_final->bindValue('name', $p->name);
             $insert_final->bindValue('region', $p->region);
             $insert_final->bindValue('realm', $p->realm);
             $insert_final->bindValue('geom', $endpoly);
             $insert_final->execute();
         }
     }
     break;
 case 'exportsql':
     if (empty($args->command->options['spatialite'])) {
         throw new Exception("Must specify spatialite DB");
     }
Exemple #12
0
<?php

header("X-XSS-Protection: 0");
if (empty($_GET["id"])) {
    die("活动ID 不能为空");
}
$usert = "";
$id = $_GET["id"];
$path = dirname(__FILE__) . '/content/' . $id;
$list_db = new SQLite3("lists.db");
$r = $list_db->querySingle('SELECT * FROM lists WHERE evt_id = "' . $id . '"', true);
if (!empty($r)) {
    if (!empty($usert) && $usert != $r["evt_author"]) {
        die("<meta charset='utf-8'>权限不足,无法查看");
    }
    $evt_name = $r["evt_name"];
    $evt_desc = $r["evt_desc"];
    $tpl_file = $path . "/template.html";
    $tplFileHandle = fopen($tpl_file, 'rb') or die("can't open file");
    $tpl_html = fread($tplFileHandle, filesize($tpl_file));
    fclose($tplFileHandle);
    $pubLayoutFile = dirname(__FILE__) . "/tpl/layout.html";
    $fp = fopen($pubLayoutFile, 'rb');
    $pubLayout = fread($fp, filesize($pubLayoutFile));
    fclose($fp);
    //由于活动平台限制,转换编码为 gbk
    $evt_name = iconv("utf-8", "gbk", $evt_name);
    $evt_desc = iconv("utf-8", "gbk", $evt_desc);
    $tpl_html = iconv("utf-8", "gbk", $tpl_html);
    $pubLayout = str_replace("[TITLE]", $evt_name, $pubLayout);
    $pubLayout = str_replace("[CONTENT]", $tpl_html, $pubLayout);
Exemple #13
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
$email = $_POST["email"];
$password = $_POST["password"];
$hashAndSalt = password_hash($password, PASSWORD_BCRYPT);
$db = new SQLite3('../user.db');
$db->query('create table if not exists user(email varchar(255), password varchar(255), primary key(email))');
$queryResult = $db->querySingle("select * from user where email='{$email}';");
if ($queryResult) {
    printf("failure-registered");
} else {
    $db->query("insert into user(email, password) values('{$email}', '{$hashAndSalt}');");
    printf("success", $email);
}
$db->close();
?>

/* Retrieving Champion Ladder Information */
$sort_field = $_GET["sort_field"];
$sort_type = $_GET["sort_type"];
$ladderscount = $_GET["count"];
$db = new SQLite3("../pokemon");
$xml = new DomDocument();
$xml->load("../tiers.xml");
$tiers = $xml->getElementsByTagName("tier");
$ladderchamps = array();
$standings = "";
$rowcount = 0;
foreach ($tiers as $tier) {
    $tiername = $tier->getAttribute("name");
    $tablename = $tier->getAttribute("tableName");
    $result = $db->querySingle("SELECT COUNT(*) FROM " . $tablename);
    if ($result) {
        $results = $db->query("SELECT * FROM " . $tablename . " WHERE displayed_rating = (SELECT MAX(displayed_rating) FROM " . $tablename . ")");
        while ($row = $results->fetchArray()) {
            if (isset($ladderchamps[$row['name']]) == false) {
                $ladderchamps[$row['name']] = array();
                $ladderchamps[$row['name']]['ladders'] = array();
                $ladderchamps[$row['name']]['count'] = 0;
                $ladderchamps[$row['name']]['displayed_rating'] = 0;
                $ladderchamps[$row['name']]['rating'] = 0;
            }
            $ladderchamps[$row['name']]['count']++;
            array_push($ladderchamps[$row['name']]['ladders'], $tiername);
            $ladderchamps[$row['name']]['displayed_rating'] += $row['displayed_rating'];
            $ladderchamps[$row['name']]['rating'] += $row['rating'];
        }
Exemple #15
0
<?php

$dbfile = getenv("DATA") . "library.db";
$db = new SQLite3($dbfile);
$root = $db->querySingle("SELECT value FROM config WHERE key = 'root'");
if (array_key_exists("id", $_GET)) {
    $id = $_GET["id"];
    $stmt = $db->prepare("SELECT EXISTS(SELECT 1 FROM songs WHERE id = ?)");
    $stmt->bindValue(1, $id, SQLITE3_INTEGER);
    if (!$stmt->execute()->fetchArray()[0]) {
        http_response_code(404);
        die;
    }
    $path = $root . "/" . $db->querySingle("SELECT path FROM songs WHERE id = {$id}");
    if (!is_readable($path)) {
        http_response_code(403);
        die;
    }
    $fhandle = fopen($path, "rb");
    if (!$fhandle) {
        http_response_code(403);
        die;
    }
    $finfo = finfo_open();
    $expires = 60 * 60 * 24 * 365;
    header("Pragma: public");
    header("Cache-Control: maxage=" . $expires);
    header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expires) . " UTC");
    header("Content-Type: " . finfo_file($finfo, $path, FILEINFO_MIME));
    finfo_close($finfo);
    while (!feof($fhandle)) {
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
$userEmailAddress = $_POST['email'];
$uploadFileName = $_POST['fileName'];
/* Create entry in db. */
$db = new SQLite3('../file.db');
$db->query('create table if not exists file(email varchar(255), fileName varchar(255), primary key(email, fileName))');
$queryResult = $db->querySingle("insert into file(email, fileName) values('{$userEmailAddress}', '{$uploadFileName}');");
$db->close();
/* Save string as file to disk. */
if (is_dir("../userdata/{$userEmailAddress}") === false) {
    mkdir("../userdata/{$userEmailAddress}");
}
file_put_contents("../userdata/{$userEmailAddress}/{$uploadFileName}", $_POST['fileContents']);
?>

 public function render_judge($data)
 {
     global $conf, $USERINFO;
     $html = '';
     /**
      * Show plugin to logged in user
      */
     if ($_SERVER['REMOTE_USER']) {
         /**
          * Show plugin if problem_name page exists
          */
         if (page_exists($data['problem_name'])) {
             $page_answer_exist = page_exists($data['judge']);
             $media_files = array_filter(glob($conf['mediadir'] . "/" . str_replace("%3A", "/", urlencode($data['judge'])) . "/" . "*"));
             $media_answer_exist = !empty($media_files);
             if (($page_answer_exist || $media_answer_exist) && in_array("user", $USERINFO['grps'])) {
                 $html .= '
                 <div class="judge">
                     <p onclick="jQuery(this).next().slideToggle();">' . $this->getLang('btn_submit_answer') . '</p>
                     <div>
             <form onsubmit="return false;" name="judge-submit-' . $data['problem_name'] . '" method="post">';
                 if ($data['type'] === "output-only") {
                     $html .= '
                     <div>
                         <label class="block">
                             <input type="text" style="margin-left: 2px;" id="user-output-' . $data['problem_name'] . '" size="25" tabindex="1" value="">';
                     $html .= '
                             <input class="button" type="submit" onclick="submitKey(' . "'" . $data['problem_name'] . "','" . $_SERVER['REMOTE_USER'] . "','" . $data['language'] . "','" . $data['type'] . "','" . $data['runtime'] . "','" . "','" . $this->getConf('upload_path') . "'" . '); return false;" value="' . $this->getLang('btn_submit') . '" />
                         </label>
                     </div>
                     </form>
                 ';
                 } elseif ($data['type'] === "test-case") {
                     $html .= '
                     <label class="block">
                         <input id="code-file-' . $data['problem_name'] . '"' . ' onclick="inputFileKey(' . "'" . $data['problem_name'] . "'" . '); return false;">
                         <input class="button"  onclick="inputFileKey(' . "'" . $data['problem_name'] . "'" . '); return false;" type="reset" value="' . $this->getLang('btn_choose_file') . '">
                         <input onchange="changeFilePath(' . "'" . $data['problem_name'] . "'" . ');" style="display: none;" name="code-' . $data['problem_name'] . '" id="code-' . $data['problem_name'] . '" type=file>
                 ';
                     if ($data['language'] === "all") {
                         $html .= '
                         </label>
                         <label class="block" style="margin-top: 5px;">
                             <span>' . $this->getLang('choose_language') . '</span>
                                 <select style="width: auto;" id="language-' . $data['problem_name'] . '">
                                     <option value="Java">Java</option>
                                     <option value="Python 2">Python 2</option>
                                     <option value="Python 3">Python 3</option>
                                     <option value="C++">C++</option>
                                     <option value="C">C</option>
                                 </select>
                     ';
                     }
                     $html .= '
                     <input class="button" type="submit" onclick="submitKey(' . "'" . $data['problem_name'] . "','" . $_SERVER['REMOTE_USER'] . "','" . $data['language'] . "','" . $data['type'] . "','" . $data['runtime'] . "','" . $this->getConf('upload_path') . "'" . '); return false;" value="' . $this->getLang('btn_submit') . '" tabindex="4" />
                     </label>
                     </form>
                 ';
                 }
                 $html .= '
                     <div>
                         <label class="block">
                             <span id="result-label-' . $data['problem_name'] . '"></span>
                             <span id="result-' . $data['problem_name'] . '"></span>
                         </label>
                     </div>
                 ';
                 $html .= '
                 </div></div>
             ';
                 define('DBFILE', dirname(__FILE__) . '/submissions.sqlite');
                 date_default_timezone_set('Asia/Tehran');
                 $db = new SQLite3(DBFILE);
                 $submissions = $db->querySingle('SELECT COUNT(*) FROM submissions WHERE problem_name = "' . $data['problem_name'] . '"AND username="******";');
                 if (!empty($submissions)) {
                     $html .= '
                     <div class="judge" id="previous_submissions-' . $data['problem_name'] . '">
                 ';
                 } else {
                     $html .= '
                     <div class="judge" style="display: none;" id="previous_submissions-' . $data['problem_name'] . '">
                 ';
                 }
                 $html .= '
                     <p onclick="jQuery(this).next().slideToggle();">' . $this->getLang('btn_previous_submissions') . '</p>
                         <div style="display: none;" id="previous_submissions-table-' . $data['problem_name'] . '">
                             <div class="table sectionedit1">
                                 <table class="inline">
                 ';
                 $crud = plugin_load('helper', 'judge_crud', true);
                 if ($data['type'] === "test-case") {
                     $html .= '
                         <thead>
                             <tr class="row0">
                                 <th class="col0">' . $this->getLang('count_number') . '</th><th class="col1">' . $this->getLang('timestamp') . '</th><th class="col2">' . $this->getLang('language') . '</th><th class="col3">' . $this->getLang('status') . '</th>
                             </tr>
                         </thead>
                         <tbody  id="result-row-' . $data['problem_name'] . '">';
                     $html .= $crud->tableRender(array('problem_name' => $data["problem_name"], 'type' => $data["type"], 'user' => $_SERVER['REMOTE_USER']), "html", 1, "timestamp")["submissions_table"];
                     $html .= '</tbody>';
                 } else {
                     $html .= '
                         <thead>
                             <tr class="row0">
                                 <th class="col0">' . $this->getLang('count_number') . '</th><th class="col1">' . $this->getLang('timestamp') . '</th><th class="col2">' . $this->getLang('status') . '</th>
                             </tr>
                         </thead>
                         <tbody  id="result-row-' . $data['problem_name'] . '">
                     ';
                     /**
                      * get output-only submissions
                      */
                     $html .= $crud->tableRender(array('problem_name' => $data["problem_name"], 'type' => $data["type"], 'user' => $_SERVER['REMOTE_USER']), "html", 1, "timestamp")["submissions_table"];
                     $html .= '</tbody>';
                 }
                 $html .= '
                                 </table>
                             </div>
                             <input class="button" type="submit" onclick="resultRefresh(' . "'" . $data['problem_name'] . "','" . $data['type'] . "','" . $_SERVER['REMOTE_USER'] . "'" . '); return false;" value="' . $this->getLang('table_update') . '" tabindex="4" />
                         </div>
                     </div>
                 ';
             }
         }
         if (in_array($this->getConf('editors_group'), $USERINFO['grps']) || in_array("admin", $USERINFO['grps'])) {
             if (page_exists($data['problem_name'])) {
                 if (auth_quickaclcheck($data['judge']) >= AUTH_EDIT) {
                     if ($data['type'] === "test-case") {
                         if ($media_answer_exist) {
                             $html .= '<div class="judge"><p><a target="_blank" href="?tab_files=files&do=media&ns=' . $data['judge'] . '">' . $this->getLang('btn_edit_testcase_long') . '</a></p></div>';
                         } elseif ($page_answer_exist) {
                             $html .= '<div class="judge"><p><a target="_blank" href="' . DOKU_URL . $data['judge'] . '">' . $this->getLang('btn_edit_testcase_short') . '</a></p></div>';
                         } else {
                             $html .= '<div class="judge"><p>' . $this->getLang('btn_submit_testcase') . ' (<a target="_blank" href="' . DOKU_URL . $data['judge'] . '?do=edit">' . $this->getLang('btn_submit_testcase_short') . '</a> - <a target="_blank" href="?tab_files=upload&do=media&ns=' . $data['judge'] . '">' . $this->getLang('btn_submit_testcase_long') . '</a>)</p></div>';
                         }
                     } else {
                         if ($page_answer_exist) {
                             $html .= '<div class="judge"><p><a target="_blank" href="' . DOKU_URL . $data['judge'] . '">' . $this->getLang('btn_edit_correct_answer') . '</a></p></div>';
                         } else {
                             $html .= '<div class="judge"><p><a target="_blank" href="' . DOKU_URL . $data['judge'] . "?do=edit" . '">' . $this->getLang('btn_submit_correct_answer') . '</a></p></div>';
                         }
                     }
                 }
             } else {
                 $html .= '<div class="judge"><p><a target="_blank" href="' . DOKU_URL . $data['problem_name'] . "?do=edit" . '">' . $this->getLang('btn_create_question_page') . '</a></p></div>';
             }
         }
     }
     return $html;
 }
Exemple #18
0
#Testing Update comment
echo '<div id="footcontent">';
echo "<div id='collapseBtn'>Hide/Show Footer</div>";
echo '<div id="left">';
echo '<p class="one"><a href="./">WIPSTER v0.2 Beta</a> (C) Nick Driver (<a href="https://www.twitter.com/TheDr1ver">@TheDr1ver</a>) - ' . date("Y") . '</p>';
echo '<p class="two">Operating on <a href="http://zeltser.com/remnux/">REMNUX 5</a>, running Apache with PHP version ' . phpversion() . '.</p>';
echo '</div>';
echo '<div id="center">';
include './twitter.php';
echo '</div>';
echo '<div id="right">';
#Check for autoPasteBin checker results from today
$today = getdate();
$today = $today['year'] . '-' . $today['mon'] . '-' . $today['mday'];
$db = new SQLite3('./autopb/autopb.db');
$result = $db->querySingle('SELECT date FROM results ORDER BY id DESC');
if ($result == $today) {
    echo '<p><a href="./autoPastebin.php"><span style="color:red;font-weight:bold;">NOTICE:</span> New ' . $gcseQuery . ' data found today on a PasteBin site.</a></p>';
}
echo '<p><a href="./mastiffResults.php">WIPSTER Analysis</a> | <a href="./urlResearch.php">URL Research</a> | <a href="./convert.php">Text Conversion</a> | <a href="./pastebinsearch.php">Pastebin Search</a></p>';
echo '</div>';
echo '</div>';
echo '</div>';
?>

<script src="./scripts/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function(){
	if($(window).width()<1080){
		$("#footcontent").animate({
			height:'30px'
Exemple #19
0
<?php

require "../includes/include.php";
if (!empty($_POST["url"]) && is_numeric($_POST["section"]) && intval($_POST["section"]) > 0) {
    $sqlite = new SQLite3($db_str, SQLITE3_OPEN_READWRITE);
    $url = $_POST["url"];
    $comment = $_POST["comment"];
    $section = is_numeric($_POST["section"]) && intval($_POST["section"]) > 0 ? intval($_POST["section"]) : null;
    if (sectionExists($section)) {
        $insert = $sqlite->prepare("insert into links (l_url,l_comment,l_section) values (:url,:comment,:section)");
        $insert->bindValue("url", $url, SQLITE3_TEXT);
        $insert->bindValue("comment", $comment, SQLITE3_TEXT);
        $insert->bindValue("section", $section, SQLITE3_INTEGER);
        if ($insert->execute() !== false) {
            $id = $sqlite->querySingle("select l_id from links where rowid=" . $sqlite->lastInsertRowId());
            $result = ["insert" => findLinkById($id), "success" => true, "message" => date("Y-m-d H:i:s"), "anchor" => "s{$section}"];
        } else {
            $result = ["insert" => ["url" => $url, "comment" => $comment, "section" => $section], "success" => false, "message" => "Unable to execute query", "anchor" => "s{$section}"];
        }
        $insert->close();
    } else {
        $result = ["insert" => ["url" => $url, "comment" => $comment, "section" => $section], "success" => false, "message" => "Section {$section} not found"];
    }
    $sqlite->close();
} else {
    $result = ["insert" => $_POST, "success" => false, "message" => "Bad request"];
}
print json_encode($result);
Exemple #20
0


<?php 
include 'unregisteredNav.php';
$name = test_input($_REQUEST['name']);
$email = test_input($_REQUEST['email']);
$password = md5($_REQUEST['password']);
$db = new SQLite3('../database/data');
function test_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return SQLite3::escapeString($data);
}
$admin = $db->querySingle("SELECT * FROM users WHERE name='{$name}'", true);
if ($admin == true) {
    header("Refresh:3; url=register.php");
    die("<h2>Name : {$name} is already exist please type another name</h2>");
} else {
    session_start();
    $_SESSION['name'] = $name;
    $db->exec("INSERT INTO users (name , email, password) VALUES ('{$name}', '{$email}','{$password}')");
    echo "<h1>You have been successfully registered!</h1>";
    header("Refresh:3; url=client.php");
}
        if (empty($sessid)) {
            exit;
        }
        $result = getsessiondata($sessid);
        // get session details from HUB
        $framedip = getdhcpip($sessid);
        // get DHCP assigned IP from HUB
        if ($framedip === FALSE) {
            // if user could not get ip with dhcp, disconnect it
            disconnectsession($sessid);
            exit;
        }
        $db = new SQLite3($database);
        $db->busyTimeout(5000);
        $db->exec('CREATE TABLE IF NOT EXISTS sessions (sessionid varchar(255), username varchar (255), clientip varchar (255), inputoctets varchar (255), ' . 'outputoctets varchar (255), framedip varchar (255), nasip varchar (255), nasport varchar (255), acctstarttime varchar (255), ' . 'acctsessiontime varchar (255), PRIMARY KEY(sessionid))');
        $query = $db->escapeString('INSERT OR REPLACE INTO sessions (sessionid, username, clientip, inputoctets, outputoctets, framedip, nasip, nasport, acctstarttime, acctsessiontime) VALUES ("' . $sessid . '","' . $result["User Name (Authentication)"] . '","' . $result["Client IP Address"] . '",NULL,NULL,"' . $framedip . '","' . $result["Server IP Address (Reported)"] . '","' . $result["Server Port (Reported)"] . '","' . $result["Connection Started at"] . '",NULL)');
        $db->exec($query);
        $sessid = $db->escapeString($sessid);
        $results = $db->querySingle("SELECT * FROM sessions WHERE sessionid = '" . $sessid . "'", true);
        $acctsessionid = md5($sessid . $results['acctstarttime']);
        $tmpfname = tempnam($tmpdir, "acctstarttmp_");
        $handle = fopen($tmpfname, "w");
        $packet = "Service-Type = Framed-User" . "\n" . "Framed-Protocol = PPP" . "\n" . "NAS-Port = " . $results['nasport'] . "\n" . "NAS-Port-Type = Async" . "\n" . "User-Name = '" . $results['username'] . "'" . "\n" . "Calling-Station-Id = '" . $results['clientip'] . "'" . "\n" . "Called-Station-Id = '" . $results['nasip'] . "'" . "\n" . "Acct-Session-Id = '" . $acctsessionid . "'" . "\n" . "Framed-IP-Address = " . $results['framedip'] . "\n" . "Acct-Authentic = RADIUS" . "\n" . "Event-Timestamp = " . time() . "\n" . "Acct-Status-Type = Start" . "\n" . "NAS-Identifier = '" . $results['nasip'] . "'" . "\n" . "Acct-Delay-Time = 0" . "\n" . "NAS-IP-Address = " . $results['nasip'] . "\n";
        fwrite($handle, $packet);
        fclose($handle);
        exec("radclient " . $radiussrv . ":" . $radiusport . " acct " . $radiuspass . " -f " . $tmpfname);
        unlink($tmpfname);
        $db->close();
        exit(0);
    }
}
Exemple #22
0
<!DOCTYPE html>
<html>
<head>
	<title>YouJay</title>
	<link href="style.css" rel="stylesheet" type="text/css">
	<meta http-equiv ="refresh" content="5; url=index.php">
</head>

<body>
<?php 
$db = new SQLite3('youjay.db');
$queryn = "SELECT COUNT(id) FROM playlist WHERE videoid = '" . $_GET["id"] . "'";
$row = $db->querySingle($queryn);
if ($row == 0) {
    $query = "INSERT INTO playlist (videoid, title, play, download) VALUES (\"" . $_GET["id"] . "\", \"" . str_ireplace("\"", "", $_GET["title"]) . "\", \"FALSE\", \"FALSE\");";
    $results = $db->query($query);
    ?>
	Traccia aggiunta alla playlist.<br />
	<?php 
} elseif ($row > 0) {
    echo "Il brano è già presente nella playlist<br />";
}
?>

<a href="index.php">Torna alla ricerca</a>
</body>
</html>
}
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg") {
    echo "Sorry, only JPG, JPEG & PNG files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["new_status_logo"]["tmp_name"], $target_file)) {
        echo "The file " . basename($_FILES["new_status_logo"]["name"]) . " has been uploaded.";
        header('Location: ../Input.php');
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
//   add information to db about new status
//establishing link to database
$db = new SQLite3('info.db') or die('Unable to open database');
//determining id of new status, depending on how many statuses there already are
$id = $db->querySingle("SELECT COUNT(*) FROM statuses");
$id = $id + 1;
$link_to_new_file = "logos/" . $new_status . '.' . $imageFileType;
$link_to_new_file = str_replace(' ', '', $link_to_new_file);
if (isset($_POST['new_status_name']) && !empty($_POST['new_status_name'])) {
    $sql = "INSERT INTO statuses (id, name, link) VALUES ('{$id}', '{$new_status}', '{$link_to_new_file}')";
    $db->exec($sql);
}
header('Location: ../Input.php');
 /**
  * Retrieves catalogue details, array($cat_id, $variant, $count).
  *
  * @param string $catalogue catalogue
  * @return array catalogue details, array($cat_id, $variant, $count).
  */
 protected function getCatalogueDetails($catalogue = 'messages')
 {
     if (empty($catalogue)) {
         $catalogue = 'messages';
     }
     $variant = $catalogue . '.' . $this->culture;
     $db = new SQLite3($this->source, SQLITE3_OPEN_READWRITE);
     $name = $db->escapeString($this->getSource($variant));
     $rs = $db->query("SELECT cat_id FROM catalogue WHERE name = '{$name}'");
     $i = 0;
     while ($row = $rs->fetchArray(SQLITE3_NUM)) {
         if (0 == $i) {
             $cat_id = intval($row[0]);
         }
         if (1 == $i) {
             return false;
         }
         ++$i;
     }
     // first get the catalogue ID
     $rs = $db->querySingle("SELECT count(msg_id) FROM trans_unit WHERE cat_id = {$cat_id}");
     $count = intval($rs);
     $db->close();
     return array($cat_id, $variant, $count);
 }
Exemple #25
0
        $species = $cmd['s'];
        $file = $cmd['datafile'];
        // create table if not exists
        $db = new \SQLite3(__DIR__ . "/constants/msig/msig.sqlite", SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
        $db->exec("CREATE TABLE IF NOT EXISTS {$species} (id CHAR(100) PRIMARY KEY COLLATE NOCASE, genes CHAR(20000) COLLATE NOCASE, type CHAR(20) COLLATE NOCASE)");
        $db->exec("CREATE INDEX IF NOT EXISTS index_msig_type ON {$species}(type COLLATE NOCASE)");
        $f = fopen($file, "r");
        $insert = 0;
        $update = 0;
        while (!feof($f)) {
            $line = trim(fgets($f));
            if (!$line) {
                continue;
            }
            list($id, , $genes) = explode("\t", $line, 3);
            $test = $db->querySingle("SELECT id FROM {$species} WHERE id = '{$id}' AND type = '{$type}'");
            if (empty($test)) {
                $db->exec("INSERT INTO {$species} (id, genes, type) VALUES('{$id}', '{$genes}', '{$type}')");
                $insert++;
            } else {
                $db->exec("UPDATE {$species} SET genes = '{$genes}' WHERE id = '{$id}' AND type = '{$type}'");
                $update++;
            }
        }
        fclose($f);
        echo "{$insert} records inserted!\n{$update} record may be updated!\n";
        break;
    default:
        error("Error: unknown subcommand: {$subcommand}", true);
        break;
}
Exemple #26
0
<?php

$name = $_POST['name'];
$pwd = $_POST['pwd'];
$db = new SQLite3('Test.db');
$q = $db->querySingle('select * from users where name="' . $name . '";');
if ($q != NULL) {
    die('0');
}
$db->exec("insert into users values('" . $name . "','" . $pwd . "');");
echo '1';
<?php

/*
** Скрипт возвращает последние записи в гостевой книге
*/
require_once 'gbookrecord.class.php';
define('MAX_RECORDS', 10);
$db = new SQLite3('gbook.db');
$res = $db->query('SELECT * FROM gbook ORDER BY date DESC');
$lastMod = $db->querySingle('SELECT MAX(date) AS max_date FROM gbook');
$records = array();
$recordCount = 0;
while ($row = $res->fetchArray(SQLITE3_ASSOC)) {
    $records[] = new GBookRecord($row['id'], $row['author'], $row['email'], $row['message'], $row['date']);
    $recordCount++;
    if ($recordCount >= MAX_RECORDS) {
        break;
    }
}
// Передаем заголовки и JSON пакет данных
header('Content-type: text/plain; charset=utf-8');
header('Cache-Control: no-store, no-cache');
header('Expires: ' . date('r'));
header('Last-Modified: ' . date('r', $lastMod));
echo json_encode($records);
Exemple #28
0
<?php

header("Cache-Control: no-cache, no-store, must-revalidate");
sleep(1);
print "<pre style=\"white-space: pre-wrap; word-wrap: break-word;\">";
$db = new SQLite3('/opt/Responder/Responder.db');
//$res = $db->querySingle("SELECT *, group_concat(fullhash, x'0a') as ghash," .
// "group_concat(cleartext, '; ') as gclear, COUNT(*) as hashcount FROM responder WHERE client='" .
// $_SERVER['REMOTE_ADDR'] .
$res = $db->querySingle("SELECT *, group_concat(fullhash, x'0a') as ghash," . "group_concat(cleartext, '; ') as gclear, COUNT(*) as hashcount FROM responder WHERE client='" . $_SERVER['REMOTE_ADDR'] . "' AND timestamp > datetime('now', '-2 minute')", true);
if ($res['hashcount']) {
    print "NTLM hash is leaked on " . $res['timestamp'] . " (UTC)" . PHP_EOL;
    print "You're " . $res['user'] . PHP_EOL;
    if ($res['cleartext'] == '') {
        print "Trying to crack the hash, please wait for a while…" . PHP_EOL;
        //print("Hash bruteforcing is temporary disabled." . PHP_EOL);
    } else {
        if ($res['cleartext'] == '!!NOTFOUND!!') {
            print "Plaintext password not found in our small dictionary." . PHP_EOL;
        } else {
            print "<b>Password found!</b> Your password is: " . $res['gclear'] . PHP_EOL;
            print "Unique hashes from your IP: " . $res['hashcount'] . PHP_EOL;
        }
    }
    print PHP_EOL;
    print $res['ghash'];
} else {
    print "No NTLM hash is leaked. Try to manually copy&paste file://witch.valdikss.org.ru/a to the address bar." . PHP_EOL;
    print "(Works only on Windows with IE/Edge/Chrome)";
}
print "</pre>";
Exemple #29
0
/**
* See if we are requiring key validation and if so, enforce the restrictions
*
* @param mixed $test
* @param mixed $error
*/
function ValidateKey(&$test, &$error, $key = null)
{
    global $admin;
    // load the secret key (if there is one)
    $secret = '';
    $keys = parse_ini_file('./settings/keys.ini', true);
    if ($keys && isset($keys['server']) && isset($keys['server']['secret'])) {
        $secret = trim($keys['server']['secret']);
    }
    if (strlen($secret)) {
        // ok, we require key validation, see if they have an hmac (user with form)
        // or API key
        if (!isset($key) && isset($test['vh']) && strlen($test['vh'])) {
            // validate the hash
            $hashStr = $secret;
            $hashStr .= $_SERVER['HTTP_USER_AGENT'];
            $hashStr .= $test['owner'];
            $hashStr .= $test['vd'];
            $hmac = sha1($hashStr);
            // check the elapsed time since the hmac was issued
            $now = time();
            $origTime = strtotime($test['vd']);
            $elapsed = abs($now - $origTime);
            if ($hmac != $test['vh'] || $elapsed > 86400) {
                $error = 'Your test request could not be validated (this can happen if you leave the browser window open for over a day before submitting a test).  Please try submitting it again.';
            }
        } elseif (isset($key) || isset($test['key']) && strlen($test['key'])) {
            if (isset($test['key']) && strlen($test['key']) && !isset($key)) {
                $key = $test['key'];
            }
            // see if it was an auto-provisioned key
            if (preg_match('/^(?P<prefix>[0-9A-Za-z]+)\\.(?P<key>[0-9A-Za-z]+)$/', $key, $matches)) {
                $prefix = $matches['prefix'];
                $db = new SQLite3(__DIR__ . "/dat/{$prefix}_api_keys.db");
                $k = $db->escapeString($matches['key']);
                $info = $db->querySingle("SELECT key_limit FROM keys WHERE key='{$k}'", true);
                $db->close();
                if (isset($info) && is_array($info) && isset($info['key_limit'])) {
                    $keys[$key] = array('limit' => $info['key_limit']);
                }
            }
            // validate their API key and enforce any rate limits
            if (array_key_exists($key, $keys)) {
                if (array_key_exists('default location', $keys[$key]) && strlen($keys[$key]['default location']) && !strlen($test['location'])) {
                    $test['location'] = $keys[$key]['default location'];
                }
                if (isset($keys[$key]['priority'])) {
                    $test['priority'] = $keys[$key]['priority'];
                }
                if (isset($keys[$key]['limit'])) {
                    $limit = (int) $keys[$key]['limit'];
                    // update the number of tests they have submitted today
                    if (!is_dir('./dat')) {
                        mkdir('./dat', 0777, true);
                    }
                    $lock = Lock("API Keys");
                    if (isset($lock)) {
                        $keyfile = './dat/keys_' . gmdate('Ymd') . '.dat';
                        $usage = null;
                        if (is_file($keyfile)) {
                            $usage = json_decode(file_get_contents($keyfile), true);
                        }
                        if (!isset($usage)) {
                            $usage = array();
                        }
                        if (isset($usage[$key])) {
                            $used = (int) $usage[$key];
                        } else {
                            $used = 0;
                        }
                        $runcount = max(1, $test['runs']);
                        if (!$test['fvonly']) {
                            $runcount *= 2;
                        }
                        if ($limit > 0) {
                            if ($used + $runcount <= $limit) {
                                $used += $runcount;
                                $usage[$key] = $used;
                            } else {
                                $error = 'The test request will exceed the daily test limit for the given API key';
                            }
                        } else {
                            $used += $runcount;
                            $usage[$key] = $used;
                        }
                        if (!strlen($error)) {
                            file_put_contents($keyfile, json_encode($usage));
                        }
                        Unlock($lock);
                    }
                }
                // check to see if we need to limit queue lengths from this API key
                if ($keys[$key]['queue_limit']) {
                    $test['queue_limit'] = $keys[$key]['queue_limit'];
                }
            } else {
                $error = 'Invalid API Key';
            }
            if (!strlen($error) && $key != $keys['server']['key']) {
                global $usingAPI;
                $usingAPI = true;
            }
            // Make sure API keys don't exceed the max configured priority
            $maxApiPriority = GetSetting('maxApiPriority');
            if ($maxApiPriority) {
                $test['priority'] = max($test['priority'], $maxApiPriority);
            }
        } elseif (!isset($admin) || !$admin) {
            $error = 'An error occurred processing your request (missing API key).';
            if (GetSetting('allow_getkeys')) {
                $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
                $url = "{$protocol}://{$_SERVER['HTTP_HOST']}/getkey.php";
                $error .= "  If you do not have an API key assigned you can request one at {$url}";
            }
        }
    }
}
Exemple #30
0
			<div class="alert alert-danger" role="alert" id="spam" style="display:none">Your message is a spam!</div>
			<div class="alert alert-success" role="alert" id="ham" style="display:none">Your message is not a spam!</div>
			<div id="response" style="display:none">
				<hr>
				<ul> <dl class="dl-horizontal">
					<dt>Is it correct: </dt>
					<dd><input type="radio" name="user_response" value="yes"  onclick="learn()"/> Yes</dd>
					<dd><input type="radio" name="user_response" value="no" onclick="learn()" /> No</dd>
				</dl> </ul>
			</div>
			<div class="alert alert-success" role="alert" id="thanks" style="display:none">
				<p> Thanks for your response, it helps to improve the quality of the detection </p>
			</div>
		</form>
	</div>
	<div class = "container well">
		<?php 
$db = new SQLite3('../spam_db');
echo "The number of spam analyzed is <strong>";
echo $db->querySingle('SELECT value FROM stat WHERE name = "nbr_mails_spam"');
echo "</strong><br>";
echo "The number of ham analyzed is <strong>";
echo $db->querySingle('SELECT value FROM stat WHERE name = "nbr_mails_ham"');
echo "</strong>";
?>
	</div>
	<div id="property" style="text-align:center">
		<p>Guillaume Dhainaut - All rigths reserved</p>
	</div>
</body>
</html>