示例#1
0
 function authenticate()
 {
     if (!empty($_POST['username']) && !empty($_POST['password'] != '')) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         // Load the CRUD
         require ROOT . '/justit-php-test/models/crud.php';
         $crud_login = new Crud();
         if ($crud_login->login($username, md5($password))) {
             // Set sessions
             $_SESSION['is_logged_in'] = TRUE;
             // redirect to users
             header('Location: ' . global_url() . 'users');
             die;
         } else {
             echo 'Sorry login details are wrong';
             // Set error return to login page
             $this->index();
         }
     } else {
         // Return back to the login
         $this->error_message = "Please fill out the form";
         $this->index();
     }
 }
示例#2
0
 public function primeiroLogin()
 {
     $pL = new Crud();
     $pL->setTabela("users");
     $result = $pL->consultar(array("id", "nome", "email"), "id = {$this->idInserido}");
     $_SESSION['dehbora']['user'] = $result->fetch(PDO::FETCH_ASSOC);
 }
示例#3
0
 public function insert()
 {
     $params = Param::params();
     $crud = new Crud();
     $crud->insertQuestion($params);
     $params['q_id'] = $crud->getInsertedId();
     $crud->insertAnswer($params);
     $this->render('index');
 }
 public function actionCreate()
 {
     $model = new Crud();
     $form = new Form('codegen.CrudForm', $model);
     if ($form->submitted() && $model->validate()) {
         Yii::import('codegen.controllers.FormAdminController');
         FormAdminController::generateAndSaveForm($model->class);
         $params = $model->attributes;
         $params['module'] = AppManager::getModelModule($model->class);
         $controllers_path = 'codegen.views.templates.crud.controllers';
         $controllers_files = glob(Yii::getPathOfAlias($controllers_path) . DS . '*');
         foreach ($controllers_files as $controller_file) {
             $file_name = pathinfo($controller_file, PATHINFO_FILENAME);
             $code = $this->renderPartial($controllers_path . '.' . $file_name, $params, true);
             $file_name = $model->class . $file_name . '.php';
             $dir = MODULES_PATH . $params['module'] . DS . 'controllers' . DS;
             if (!is_dir($dir)) {
                 mkdir($dir, 0777, true);
                 chmod($dir, 0777);
             }
             $file_path = $dir . $file_name;
             file_put_contents($file_path, $code);
             chmod($file_path, 0777);
         }
         $views_path = 'codegen.views.templates.crud.views';
         $views_files = glob(Yii::getPathOfAlias($views_path) . DS . '*' . DS . '*');
         foreach ($views_files as $view_file) {
             $view_file = str_replace(Yii::getPathOfAlias($views_path), '', $view_file);
             $file_name = pathinfo($view_file, PATHINFO_BASENAME);
             $file_code = $this->renderPartial($views_path . str_replace(array(DS, '.php'), array('.', ''), $view_file), $params, true);
             $view_file_path = MODULES_PATH . $params['module'] . DS . 'views' . $view_file;
             $view_file_dir = pathinfo($view_file_path, PATHINFO_DIRNAME);
             $child_dir = pathinfo($view_file_dir, PATHINFO_FILENAME);
             if ($child_dir == 'client') {
                 $view_file_dir = str_replace('client', lcfirst($model->class), $view_file_dir);
             } else {
                 if ($child_dir == 'admin') {
                     $view_file_dir = str_replace('admin', lcfirst($model->class) . 'Admin', $view_file_dir);
                 }
             }
             if (!is_dir($view_file_dir)) {
                 mkdir($view_file_dir, 0777, true);
                 chmod($view_file_dir, 0777);
             }
             $file_path = $view_file_dir . DS . $file_name;
             file_put_contents($file_path, $file_code);
             chmod($file_path, 0777);
         }
         $msg = "Добавьте  в метод adminMenu()  в файле " . ucfirst($params['module']) . "Module.php<br/>\r\n                   'Управление {$params['instrumental']}'    => Yii::app()->createUrl('/{$params['module']}/" . lcfirst($params['class']) . "Admin/manage'), <br/>\r\n                   'Создать {$params['accusative']}' => Yii::app()->createUrl(''/{$params['module']}/" . lcfirst($params['class']) . "Admin/create'),";
         Yii::app()->user->setFlash(Controller::MSG_SUCCESS, 'CRUD создан!');
         Yii::app()->user->setFlash(Controller::MSG_INFO, $msg);
         $this->redirect($_SERVER['REQUEST_URI']);
     }
     $this->render('create', array('form' => $form));
 }
示例#5
0
 public function testCrud()
 {
     $c = new Crud();
     $c->addSubject(array('data' => array(array('id' => '123', 'title' => 'shirt', 'images' => array('https://upload.wikimedia.org/wikipedia/commons/8/8c/Polo_Shirt_Basic_Pattern.png'), 'thumbnails' => array('https://upload.wikimedia.org/wikipedia/commons/8/8c/Polo_Shirt_Basic_Pattern.png')))));
     $r = $this->engine->upload($c);
     $this->assertEquals($r->status, 200);
     $r = $this->engine->update($c);
     $this->assertEquals($r->status, 200);
     $r = $this->engine->delete($c);
     $this->assertEquals($r->status, 200);
 }
示例#6
0
 public function Email($codeIgniterDb = null)
 {
     parent::Crud($codeIgniterDb);
     $this->data = array('ID' => '', 'sender' => '', 'receiver' => '', 'subject' => '', 'message' => '', 'error' => '', 'status' => '');
     $this->table = 'emails';
     $this->key = 'ID';
 }
示例#7
0
 public function Offer($codeIgniterDb = null)
 {
     parent::Crud($codeIgniterDb);
     $this->data = array('id' => '', 'question' => '', 'value' => '', 'count' => '');
     $this->table = 'offers';
     $this->key = 'script';
 }
示例#8
0
 public function Activator($codeIgniterDB = null)
 {
     parent::Crud($codeIgniterDB);
     $this->table = 'activations';
     $this->data = array('email' => '', 'activationKey' => '');
     $this->key = 'activationKey';
 }
示例#9
0
 /**
  * Marks relate to scripts on a one-to-one basis, and therefore they share
  * a primary key: the ID field of script, thus script.ID = mark.script
  *
  * @param unknown_type $codeIgniterDb
  * @return Mark
  */
 public function Assessment($codeIgniterDb = null)
 {
     parent::Crud($codeIgniterDb);
     $this->data = array('script' => '', 'marker' => '', 'markData' => '', 'status' => '', 'targets' => '', 'generalComment' => '');
     $this->table = 'assessments';
     $this->key = 'marker';
 }
示例#10
0
 public function __construct()
 {
     parent::__construct();
     $this->table = 'good';
     $this->idkey = 'id_good';
     $this->load->library('MY_Form_validation');
 }
示例#11
0
 public function AssessmentFix($codeIgniterDb = null)
 {
     parent::Crud($codeIgniterDb);
     $this->data = array('email' => '', 'hadProblem' => '', 'paid' => '');
     $this->table = 'assessmentFix';
     $this->key = 'email';
 }
示例#12
0
 public function get($field)
 {
     if ($field === 'marks') {
         return unserialize($this->data['marks']);
     }
     return Crud::get($field);
 }
示例#13
0
 public function Ticket($codeIgniterDb = null)
 {
     parent::Crud($codeIgniterDb);
     $this->data = array('ID' => '', 'email' => '', 'subject' => '', 'message' => '');
     $this->table = 'tickets';
     $this->key = 'ID';
 }
示例#14
0
 function get($key)
 {
     if ($key === 'scripts') {
         return unserialize($this->data['scripts']);
     }
     return Crud::get($key);
 }
示例#15
0
 function get($key)
 {
     if ($key === 'alertSubjects') {
         return unserialize($this->data['alertSubjects']);
     }
     return Crud::get($key);
 }
示例#16
0
 public function __construct()
 {
     parent::__construct();
     $this->table = 'order';
     $this->idkey = 'id_sessions';
     $this->lib_auth->check_admin();
 }
 public static function run($obj, $webClass)
 {
     if ($obj instanceof Model) {
         $cmd = isset($_GET['cmd']) ? addslashes($_GET['cmd']) : 'read';
         if ($cmd == "edit") {
             Crud::createForm($obj, $webClass);
             die;
         }
         if ($cmd == "add") {
             //Crud::createForm($obj,$webClass);
             $json = Crud::addPrecon($obj);
             die(json_encode($json));
         }
         if ($cmd == "delete") {
             $json['bool'] = 1;
             $id = isset($_POST['id']) ? addslashes($_POST['id']) : '';
             $json['bool'] = $obj->delete($id);
             die(json_encode($json));
         }
         if ($cmd == "ws") {
             Crud::workWebService($obj, $webClass);
             die;
         }
         Crud::read($obj, $webClass);
     } else {
         die('Crud hanya bisa dipakai dengan object Crud');
     }
 }
示例#18
0
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
		
		$this->_setTableName($this->table_name);
    }
示例#19
0
 function Referral($codeIgniterDB = null)
 {
     parent::Crud($codeIgniterDB);
     $this->data = array('user' => '', 'referee' => '', 'ipRequested' => '', 'paypalRef' => '');
     $this->table = 'referrals';
     $this->key = 'referee';
 }
 public function page()
 {
     //create the model object
     $cal = new Page();
     //send the webclass
     $webClass = __CLASS__;
     //by pass the form
     $cmd = isset($_GET['cmd']) ? addslashes($_GET['cmd']) : 'read';
     if ($cmd == "edit") {
         //Crud::createForm($obj,$webClass);
         //die('edit');
         $id = isset($_GET['id']) ? addslashes($_GET['id']) : 0;
         if ($id) {
             $cal->getByID($id);
         }
         $mps['id'] = $id;
         $mps['obj'] = $cal;
         Mold::plugin("Page", "pageForm", $mps);
         exit;
     }
     $cid = addslashes($_GET['cid']);
     if ($cid != "") {
         $_SESSION['pageConID'] = $cid;
     } else {
         //unset($_SESSION['pageConID']);
     }
     $cal->read_filter_array = array("post_gallery_id" => $_SESSION['pageConID']);
     //echo $cid;
     //pr($cal);
     //run the crud utility
     Crud::run($cal, $webClass);
     //pr($mps);
 }
 function tambah()
 {
     $acc = new SiteMember();
     $_SESSION['sementara']['admin_email'] = $_POST['admin_email'];
     $_SESSION['sementara']['admin_password'] = $_POST['admin_password'];
     $_SESSION['sementara']['firsttime'] = 1;
     Crud::AddManual($acc);
 }
 public function qRRequestModel()
 {
     //create the model object
     $cal = new QRRequestModel();
     $webClass = __CLASS__;
     //run the crud utility
     Crud::run($cal, $webClass);
 }
 function MTranDetail()
 {
     $cal = new MTranDetail();
     //        $cal->printColumlistAsAttributes();
     //send the webclass
     $webClass = __CLASS__;
     Crud::run($cal, $webClass);
 }
示例#24
0
文件: index.php 项目: nemis/Fm
 public function crud($model)
 {
     if (!isset($_GET['id'])) {
         $this->template->content = Crud::table($model, $this->db);
     } else {
         $this->template->content = Crud::form($model, $this->db, (int) $_GET['id']);
     }
 }
 public function masterReceiptModel()
 {
     //create the model object
     $cal = new MasterReceiptModel();
     $webClass = __CLASS__;
     //run the crud utility
     Crud::run($cal, $webClass);
 }
示例#26
0
文件: viev.php 项目: angel224/podarok
 public function __construct()
 {
     parent::__construct();
     $this->table = 'menu';
     $this->idkey = 'id';
     $this->p = 1;
     header('Content-type: text/html; charset=utf-8');
 }
 function Testing()
 {
     //create the model object
     $cal = new Testing();
     //send the webclass
     $webClass = __CLASS__;
     //run the crud utility
     Crud::run($cal, $webClass);
 }
 public function QuizIklan()
 {
     //create the model object
     $cal = new QuizIklan();
     //send the webclass
     $webClass = __CLASS__;
     //run the crud utility
     Crud::run($cal, $webClass);
 }
示例#29
0
 public function CampaignModel()
 {
     //create the model object
     $cal = new CampaignModel();
     //send the webclass
     $webClass = __CLASS__;
     //run the crud utility
     Crud::run($cal, $webClass);
 }
 public function topicmap()
 {
     //create the model object
     $gr = new Topicmap();
     //send the webclass
     $webClass = __CLASS__;
     //run the crud utility
     Crud::run($gr, $webClass);
 }