Example #1
0
<?php

include '../inc/globals.inc';
extract($_POST);
$data = file_get_contents(CONFIG_FILE);
$json = json_decode($data, true);
header("Content-type: text/plain");
#var_dump($user);
#var_dump($json);
if ($json[finduser($username, $json)]['password'] == ccrypt($password)) {
    $loc = '../../app/';
    setcookie('x-codeita-user', ccrypt($json[finduser($username, $json)]['id']), null, '/');
} else {
    $loc = '../../index?login=false&badpass=true';
}
header("Location: {$loc}");
//return json_encode($out);
function finduser($username, $array)
{
    $i = 0;
    foreach ($array as $item) {
        if ($item["username"] == $username) {
            return $i;
        }
        $i++;
    }
    return false;
}
Example #2
0
<?php

include '../inc/globals.inc';
$us = $_POST['users'];
$out = array();
while ($item = current($us)) {
    $it = array('id' => generateUID(), 'username' => key($us), 'password' => ccrypt($item));
    array_push($out, $it);
    //echo key($us).'-'.$item;
    next($us);
}
if (!is_dir(CONFIG_PATH)) {
    mkdir(CONFIG_PATH, 0755);
}
if (is_file(CONFIG_FILE)) {
    unlink(CONFIG_FILE);
}
if (file_put_contents(CONFIG_FILE, json_encode($out))) {
    if (!is_dir(FILES_PATH)) {
        mkdir(FILES_PATH, 0755);
        recurse_copy('starter-site/', FILES_PATH);
    }
    echo 1;
} else {
    echo 0;
}
function generateUID()
{
    return '_' . uniqid();
}
function recurse_copy($src, $dst)