Ejemplo n.º 1
0
 public function createAdmin(\Request $req, \Response $res)
 {
     $admin = new \Model\Admin();
     if ($req->password != $req->confirm_password || !strlen($req->password)) {
         $res->Json(array("flash" => "passwords must have a value and match!"), 500);
         return;
     }
     if (!$admin->checkUsername($req->username) || !strlen($req->username)) {
         $res->Json(array("flash" => "invalid username"), 500);
         return;
     }
     $admin->username = $req->username;
     $admin->email = $req->email;
     if (strlen($req->password)) {
         $admin->password = crypt($req->password);
     }
     $admin->write();
     $res->Json($admin->toArray(array("password")));
 }
Ejemplo n.º 2
0
<?php

$user = $argv[1];
$pass = $argv[2];
$email = $argv[3];
error_reporting(E_ALL);
ini_set("display_errors", 1);
define("APP_ROOT", __DIR__ . "/..");
require_once __DIR__ . "/../Classes/Autoloader.php";
$config = new \Config("config");
$db = new \Database($config->database);
Registry::add("config", $config);
Registry::add("db", $db);
$admin = new \Model\Admin();
$admin->username = $user;
$admin->password = crypt($pass);
$admin->email = $email;
$admin->write();