예제 #1
0
 public function edit($options = array())
 {
     if (!\Utils::isUserLogged()) {
         header('Location: /index.php?page=Pages&action=notlogged');
         die;
     }
     if (!empty($_POST)) {
         $stmt = Ubermodel::$pdo->prepare("\n                    UPDATE posts\n                    SET title=:title, body=:body, modified=:modified\n                    WHERE id=:id\n            ");
         $stmt->execute(array(':id' => $_POST['id'], ':title' => $_POST['title'], ':body' => $_POST['body'], ':modified' => date('Y-m-d H:i:s')));
         header('Location: /index.php?page=Posts');
         die;
     }
     $data = Ubermodel::getOne($this->tableName, 'id', $options['id']);
     echo $this->renderView('Posts/edit', compact('data'));
 }
예제 #2
0
    define("__ROOT__", __DIR__);
}
if (!defined("__APPNAME__")) {
    define("__APPNAME__", array_pop(explode('/', __ROOT__)));
}
// This is either dev.{developer handle} or just production
if (!defined("__ENVIRONMENT__")) {
    define("__ENVIRONMENT__", 'dev.peter');
}
if (__ENVIRONMENT__ == 'production') {
    if (!defined("__SITENAME__")) {
        define("__SITENAME__", 'partyplant.eu');
    }
}
if (__ENVIRONMENT__ == 'dev.peter') {
    if (!defined("__SITENAME__")) {
        define("__SITENAME__", 'partyplant.dev');
    }
}
function autoloadAll($class)
{
    $parts = explode('\\', $class);
    include __ROOT__ . '/' . implode('/', $parts) . '.php';
}
spl_autoload_register('autoloadAll');
// Composer Autoloader
require __ROOT__ . '/vendor/autoload.php';
\core\wrapper\FacebookWrapper::init();
\app\model\Ubermodel::initialize();
class_alias('\\core\\utils\\Utils', 'Utils', true);
$router = new \core\router\Router($_GET);
예제 #3
0
 private function registerValidation($data = array())
 {
     if (empty($data)) {
         return array();
     }
     $errors = array();
     if (!empty($data['name']) && !preg_match('/^[a-z][a-z ]*$/i', $data['name'])) {
         $errors['name'] = true;
     }
     if (!empty($data['email']) && !filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
         $errors['email'] = true;
     }
     $x = Ubermodel::getOne($this->tableName, 'email', $data['email']);
     if (!empty($x)) {
         $errors['clone'] = true;
     }
     // Regex taken from http://stackoverflow.com/questions/13384008/php-regex-password-validation-not-working
     if (!empty($data['password']) && !preg_match("/^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}\$/", $data['password'])) {
         $errors['password'] = true;
         if ($data['password'] != $data['repassword']) {
             $errors['repassword'] = true;
         }
     }
     if (!empty($data['gender']) && !($data['gender'] === 'male' || $data['gender'] === 'female')) {
         $errors['gender'] = true;
     }
     if (!empty($data['birth_day']) && !($data['birth_day'] >= 1 && $data['birth_day'] <= 31)) {
         $errors['birth_day'] = true;
     }
     if (!empty($data['birth_month']) && !($data['birth_month'] >= 1 && $data['birth_month'] <= 12)) {
         $errors['birth_month'] = true;
     }
     if (!empty($data['birth_year']) && !($data['birth_year'] >= 1900 && $data['birth_year'] <= 2014)) {
         $errors['birth_year'] = true;
     }
     // $captcha = \core\wrapper\CaptchaWrapper::createCaptcha(__ENVIRONMENT__);
     // $response = $captcha->check($_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
     // if (!$response->isValid())
     // {
     //     $errors['captcha'] = true;
     // }
     return $errors;
 }
예제 #4
0
 public function apiView($args = array())
 {
     //$user = Ubermodel::getOne('users', $args['column'], $args['data']);
     $user = Ubermodel::getAll('users', array('SELECT' => array('email', 'name', 'gender', 'birth_date'), 'WHERE' => array($args['column'] => $args['data'])));
     return $user;
 }