Example #1
0
 public function run($static = false)
 {
     $form = new Form();
     $form->post('login')->val('blank')->post('password')->val('blank');
     if (!$form->submit()) {
         // Error
         $this->_error($static);
         return false;
     }
     $data = $form->fetch();
     $login = $data['login'];
     $password = Hash::create('sha256', $data['password'], PASS_HASH_KEY);
     $query = "SELECT userid, login, role FROM user WHERE login = :login AND password = :password";
     if (!($result = $this->db->select($query, array(':login' => $login, ':password' => $password)))) {
         $this->_error($static);
         return false;
     }
     Session::init();
     Session::set('userid', $result[0]['userid']);
     Session::set('login', $result[0]['login']);
     Session::set('role', $result[0]['role']);
     Session::set('loggedIn', true);
     if ($static) {
         header('location:' . URL . 'dashboard');
     }
     echo json_encode('success');
 }
 /**
  * __construct
  *
  * @param array   $post Description.
  *
  * @access public
  *
  * @return mixed Value.
  */
 public function __construct($post = array())
 {
     self::$post = $post;
     if (!$this->dbProcess) {
         $this->dbProcess = new DbProcess();
     }
     if (count($post) === 0) {
         throw new Exception('POST is empty!');
     }
 }
 public function updateSlideshow($contentID)
 {
     $form = new Form();
     $form->post('animationSpeed')->val('blank')->val('digit')->post('slideDuration')->val('blank')->val('digit')->post('autoplay')->post('animationType');
     if (!$form->submit()) {
         $error = $form->fetchError();
         $this->_returnError(reset($error), key($error));
         return false;
     }
     $data = $form->fetch();
     // Form passed
     $this->db->update('slideshow', $data, '`contentID` =' . $contentID);
     return array('error' => false, 'results' => $data);
 }
 private function save($p_nId = null)
 {
     try {
         $l_oValidator = new Form();
         $l_oValidator->post('event_name');
         $l_oValidator->val('minLength', 1);
         if (empty($p_nId)) {
             $l_oValidator->file('event_img');
             $l_oValidator->val('validFile');
         } else {
             if (!empty($_FILES['event_img']['name'])) {
                 $l_oValidator->file('event_img');
                 $l_oValidator->val('validFile');
             }
         }
         $l_oValidator->submit();
     } catch (arrayException $e) {
         $l_sError = $e->getResults();
     }
     if (isset($l_sError)) {
         $this->view->errorMsg = $l_sError;
     } else {
         $data = array();
         $data['event_name'] = $_POST['event_name'];
         $data['event_date'] = $_POST['event_date'];
         $data['event_date_end'] = $_POST['event_date_end'];
         $data['event_description'] = $_POST['event_description'];
         if (!empty($_FILES['event_img']['name'])) {
             $data['event_image'] = $_FILES['event_img'];
             $data['cropped'] = array((int) $_POST['x1'], (int) $_POST['x2'], (int) $_POST['y1'], (int) $_POST['y2'], (int) $_POST['w'], (int) $_POST['h']);
         }
         if (!empty($_FILES['event_file']['name'])) {
             $data['event_file'] = $_FILES['event_file'];
         }
         if (!empty($p_nId)) {
             if (!empty($_FILES['event_img']['name'])) {
                 $this->model->delete($p_nId, 1);
             }
             if (!empty($_FILES['event_file']['name'])) {
                 $this->model->deleteFile($p_nId);
             }
             $data['event_id'] = $p_nId;
             $this->model->edit($data);
         } else {
             $this->model->create($data);
         }
         header('location: ' . URL . 'admin_event');
     }
 }
 function email()
 {
     try {
         $l_oValidator = new Form();
         $l_oValidator->post('signUpEmail');
         $l_oValidator->val('notEmpty');
         $l_oValidator->val('isEmail');
         $l_oValidator->submit();
     } catch (arrayException $e) {
         $l_sError = $e->getResults();
     }
     if (isset($l_sError['signUpEmail'])) {
         $this->view->emailError = $l_sError['signUpEmail'];
     } else {
         $this->model->signUp($_POST['signUpEmail']);
         $this->view->emailSuccess = "Signup successful";
     }
 }
Example #6
0
 public function editNavLink($contentID)
 {
     // Validate
     $form = new Form();
     $form->post('name')->val('blank')->post('url')->val('blank');
     if (!$form->submit()) {
         // Error
         $error = $form->fetchError();
         $this->_returnError(reset($error), key($error));
         return false;
     }
     $data = $form->fetch();
     // Form passed
     // Update Content DB Entry
     $this->db->update('content', array('url' => $data['url']), "`contentID` = " . $contentID);
     $this->db->update('navLink', array('name' => $data['name']), "`contentID` = " . $contentID);
     echo json_encode(array('error' => false));
 }
Example #7
0
<?php

require_once '../config/config.php';
require_once '../libs/form.php';
require_once '../libs/database.php';
if (isset($_REQUEST['run'])) {
    try {
        $form = new Form();
        $form->post('name')->validate('minLength', 2)->post('age')->validate('integer')->validate('maxLength', 3)->post('gender');
        $form->submit();
        echo 'The form passed';
        $data = $form->fetch();
        echo '<pre>';
        print_r($data);
        echo '</pre>';
        $db = new Database(DB_TYPE, DB_HOST, DB_NAME, DB_USER, DB_PASS);
        $db->insert('person', $data);
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    // print_r($form);
}
?>

<form action="?run" method="post">
    Name <input type="text" name="name"/>
    Age <input type="text" name="age"/>
    Gender <select name="gender" >
        <option value="m">male</option>
        <option value="f">female</option>
    </select>
Example #8
0
 function edit($id)
 {
     global $REG;
     $this->_setting = $REG;
     try {
         //print_r($_SERVER); die();
         $form = new Form();
         $form->post('id')->post('name')->val('minlength', 6)->post('description')->val('minlength', 6);
         $form->submit();
         //echo 'Form passed';
         $postf = $form->fetch();
         $id = $postf['id'] > 0 ? $postf['id'] : $id;
         //echo "UPDATE users SET name='".$postf['name']."', description='".$postf['description']."', modifiedon=NOW() WHERE id=".$id;
         $sth = $this->db->prepare("UPDATE users SET name=:name, description=:description, modifiedon=NOW() WHERE id=:id");
         $sth->bindValue(':name', $postf['name']);
         $sth->bindValue(':description', $postf['description']);
         $sth->bindValue(':id', $id);
         $res = $sth->execute();
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
<?php

require '../libs/Database.php';
require '../config.php';
require '../' . Libs . 'Form' . '.php';
/*
 * OR
 * require '../libs/Form.php';
 */
if (isset($_REQUEST['run'])) {
    try {
        $form = new Form();
        $form->post('name')->val('minlength', 4)->post('age')->val('integerVal')->post('gender');
        $form->submit();
        echo 'Form Passed';
        $data = $form->fetch();
        echo '<pre>';
        print_r($data);
        echo '</pre>';
        $db = new Database(DB_TYPE, DB_HOST, DB_NAME, DB_USER, DB_PASS);
        $db->insert('person', $data);
        //print_r($form);
        /*
         $a = $form->fetch();
         $b = $form->fetch('age');
        
         print_r($a);
         echo $b;
        * 
        */
    } catch (Exception $ex) {
Example #10
0
<?php

require '../../core/Form.php';
require '../../core/Hash.php';
require '../util/Token.php';
if (isset($_REQUEST['run'])) {
    try {
        $form = new Form();
        $form->post('name')->val('minlength', 2)->post('age')->val('minlength', 2)->val('digit')->post('gender')->post('token')->post('remember');
        $form->submit();
        echo 'Form passed';
        $data = $form->fetch();
        if (!isset($_SESSION['fToken']) && $_SESSION['fToken'] != $data['token']) {
            exit;
        }
        echo '<pre>';
        print_r($data);
        print 'Remember: ' . boolval($data['remember']);
        echo '</pre>';
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
$token = $_SESSION['fToken'] = Token::create('form');
?>
<form method="post" action="?run">
    Name <input type="text" name="name"/>
    Age <input type="text" name="age"/>
    Gender <select name="gender">
        <option value="m">male</option>
        <option value="f">female</option>
 public function saveView($p_nId = null)
 {
     try {
         $l_oValidator = new Form();
         $l_oValidator->post('view_name');
         $l_oValidator->val('minLength', 2);
         $l_oValidator->submit();
     } catch (arrayException $e) {
         $l_sError = $e->getResults();
     }
     if (isset($l_sError)) {
         $this->view->errorMsg = $l_sError;
     } else {
         $l_aData = array();
         $l_aData['view_name'] = $_POST['view_name'];
         $l_aData['view_type'] = $_POST['targetType'];
         $l_aData['view_target'] = $_POST['targetMark'];
         $this->model->createView($l_aData);
         header('location: ' . URL . 'admin_frontpage');
     }
 }
Example #12
0
 function verifycode()
 {
     global $REG;
     $this->_setting = $REG;
     try {
         //print_r($_SERVER); die();
         $form = new Form();
         $form->post('provider')->val('minlength', 3)->post('code')->val('digit')->post('remember')->post('rememberBrowser');
         $form->submit();
         //echo 'Form passed';
         $postf = $form->fetch();
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
Example #13
0
<?php

/**
 * Created by PhpStorm.
 * User: ristee
 * Date: 17/12/15
 * Time: 00:00
 */
require "../libs/Form.php";
require "../libs/Database.php";
require "../config.php";
echo "<pre>";
if (isset($_REQUEST['run'])) {
    try {
        $form = new Form();
        $form->post('name')->val('maxLength', 20)->post('age')->val('integer')->post('gender');
        $form->submit();
        echo "The form passed!";
        $data = $form->fetch();
        echo '<pre>';
        var_dump($data);
        echo '</pre>';
        $db = new Database(DBTYPE, HOSTNAME, DBNAME, USERNAME, PASSWORD);
        $db->insert('person', $data);
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
echo "</pre>";
?>
Example #14
0
<?php

require '../config.php';
require '../libs/Database.php';
require '../libs/Form.php';
if (isset($_REQUEST['run'])) {
    try {
        $form = new Form();
        $form->post('name')->val('minlength', 4)->val('maxlength', 10)->post('age')->val('integer')->val('maxlength', 2)->post('gender');
        $form->submit();
        $data = $form->fetch();
        echo 'winner winner chicken dinner';
        $db = new Database();
        $db->insert('person', $data);
        echo '<pre>';
        print_r($data);
        echo '</pre>';
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    //print_r($form);
}
?>

<form method="post" action="?run">

		<label> Name: <input type="text" name="name" /> </label>
		<label> Age: <input type="text" name="age" /> </label>
		<label>	Gender: <select name="gender">
					<option value="m">Male</option>
					<option value="f">Female</option>
 public function save($p_nId = null)
 {
     try {
         $l_oValidator = new Form();
         $l_oValidator->post('artist_name');
         $l_oValidator->val('minLength', 2);
         if (empty($p_nId)) {
             $l_oValidator->file('artist_img');
             $l_oValidator->val('validFile');
         } else {
             if (!empty($_FILES['artist_img']['name'])) {
                 $l_oValidator->file('artist_img');
                 $l_oValidator->val('validFile');
             }
         }
         $l_oValidator->submit();
     } catch (arrayException $e) {
         $l_sError = $e->getResults();
     }
     if (isset($l_sError)) {
         $this->view->errorMsg = $l_sError;
     } else {
         $l_aData = array();
         if (!empty($p_nId)) {
             $l_aData['artist_id'] = $p_nId;
         }
         $l_aData['artist_name'] = $_POST['artist_name'];
         $l_aData['artist_description'] = $_POST['artist_description'];
         $l_aData['artist_active'] = $_POST['artist_active'];
         $l_aData['artist_country'] = $_POST['artist_country'];
         $l_aData['artist_website'] = $_POST['artist_website'];
         if (isset($_POST['artist_featured'])) {
             $l_aData['artist_featured'] = 1;
         } else {
             $l_aData['artist_featured'] = 0;
         }
         if (!empty($_FILES['artist_img']['name'])) {
             $l_aData['artist_image'] = $_FILES['artist_img'];
             $l_aData['cropped'] = array((int) $_POST['x1'], (int) $_POST['x2'], (int) $_POST['y1'], (int) $_POST['y2'], (int) $_POST['w'], (int) $_POST['h']);
         }
         if (!empty($p_nId)) {
             if (!empty($_FILES['artist_img']['name'])) {
                 $this->model->delete($p_nId, 1);
             }
             $this->model->edit($l_aData);
         } else {
             $this->model->create($l_aData);
         }
         header('location: ' . URL . 'admin_artist');
     }
 }
Example #16
0
<?php

require '../libs/Val.php';
require '../libs/Form.php';
if (isset($_REQUEST['run'])) {
    $form = new Form();
    $form->post('name')->val('minlength', 2)->post('age')->val('digit')->post('gender');
    if (!$form->submit()) {
        print_r($form->fetchError());
    } else {
        echo 'The form passed!';
        $data = $form->fetch();
        echo '<pre>';
        print_r($data);
        echo '</pre>';
    }
    // try {
    // 	$form = new Form();
    // 	$form	->post('name')
    // 			->val('minlength', 2)
    // 			->post('age')
    // 			->val('digit')
    // 			->post('gender');
    // 	$form	->submit();
    // 	echo 'The form passed!';
    // 	$data = $form->fetch()	;
    // 	echo '<pre>';
    // 	print_r($data);
    // 	echo '</pre>';
    // } catch (Exception $e) {
    // 	print_r($e->getMessage());
Example #17
0
 function edit($id)
 {
     global $REG;
     $this->_setting = $REG;
     try {
         //print_r($_SERVER); die();
         $form = new Form();
         $form->post('projects')->post('name')->val('minlength', 6)->post('description')->val('minlength', 6)->post('type')->post('priority');
         $form->submit();
         //echo 'Form passed';
         $postf = $form->fetch();
         $id = $postf['id'] > 0 ? $postf['id'] : $id;
         echo "UPDATE issues SET issue_title='" . $postf['title'] . "', issue_description='" . $postf['description'] . "', issue_type=" . $postf['type'] . ", issue_priority=" . $postf['priority'] . ", issue_resolutionsummary=" . $postf['resolution'] . ", project_id=" . $postf['projects'] . " WHERE id=" . $id;
         $sth = $this->db->prepare("UPDATE issues SET name=:name, description=:description, issue_type=:type, issue_priority=:priority, issue_resolutionsummary=:resolution, project_id=:project_id WHERE id=:id");
         $sth->bindValue(':title', $postf['title']);
         $sth->bindValue(':description', $postf['description']);
         $sth->bindValue(':type', $postf['type']);
         $sth->bindValue(':priority', $postf['priority']);
         $sth->bindValue(':resolution', $postf['resolution']);
         $sth->bindValue(':id', $id);
         $res = $sth->execute();
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }