Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: atk4/dvdrental
base: day2
...
head fork: atk4/dvdrental
compare: day3
Checking mergeability… Don't worry, you can still create the pull request.
  • 13 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
4 admin/config-default.php
@@ -0,0 +1,4 @@
+<?php
+include_once'../config-default.php';
+$config['atk']['base_path']='../atk4/';
+$config['auth']['key']='secret';
View
4 admin/index.php
@@ -0,0 +1,4 @@
+<?php
+include '../atk4/loader.php';
+$api=new Admin('rentaladmin','default');
+$api->main();
View
37 admin/lib/Admin.php
@@ -0,0 +1,37 @@
+<?php
+class Admin extends ApiFrontend {
+
+ public $is_admin=true;
+
+ function init(){
+ parent::init();
+ $this->dbConnect();
+
+ $this->addLocation('..',array(
+ 'php'=>array(
+ 'lib',
+ 'atk4-addons/mvc',
+ 'atk4-addons/billing/lib',
+ 'atk4-addons/misc/lib',
+ )
+ ))
+ ->setParent($this->pathfinder->base_location);
+
+ $this->add('jUI');
+ $this->js()
+ ->_load('atk4_univ')
+ ->_load('ui.atk4_notify')
+ ;
+
+ // Allow user: "admin", with password: "demo" to use this application
+ $this->add('Auth_Basic')->allow('admin','demo')->check();
+
+ $menu=$this->add('Menu',null,'Menu');
+ $menu->addMenuItem('Schema Generator','sg');
+ $menu->addMenuItem('Manager','mgr');
+
+ }
+ function page_index($p){
+ $this->api->redirect('mgr');
+ }
+}
View
25 admin/page/mgr.php
@@ -0,0 +1,25 @@
+<?php
+class page_mgr extends Page {
+ function init(){
+ parent::init();
+
+ $tabs=$this->add('Tabs');
+ $crud=$tabs->addTab('Customers')->add('CRUD');
+ $crud->setModel('Customer');
+ if($crud->grid){
+ $crud->grid->addColumn('prompt','set_password');
+ if($_GET['set_password']){
+ $auth = $this->add('RentalAuth');
+ $model = $auth->getModel()->loadData($_GET['set_password']);
+ $enc_p = $auth->encryptPassword($_GET['value'],$model->get('email'));
+ $model->set('password',$enc_p)->update();
+ $this->js()->univ()->successMessage('Changed password for '.$model->get('email'))
+ ->execute();
+ }
+ }
+
+ $tabs->addTab('Movies')->add('CRUD')->setModel('Movie');
+ $tabs->addTab('DVDs')->add('CRUD')->setModel('DVD');
+ $tabs->addTab('Rentals')->add('CRUD')->setModel('Rental');
+ }
+}
View
0  page/sg.php → admin/page/sg.php
File renamed without changes
View
2  doc/dbupdates/dvdrental-001-01.sql
@@ -0,0 +1,2 @@
+alter table customer add email varchar(255);
+alter table customer add password varchar(255);
View
2  lib/Frontend.php
@@ -16,6 +16,6 @@ function init(){
$this->dbConnect();
$menu = $this->add('Menu',null,'Menu');
- $menu->addMenuItem('mgr','Manager');
+ $menu->addMenuItem($this->api->url('/admin/'),'Admin');
}
}
View
1  lib/Model/Customer.php
@@ -6,5 +6,6 @@ function init(){
parent::init();
$this->addField('name');
+ $this->addField('email');
}
}
View
25 lib/RentalAuth.php
@@ -0,0 +1,25 @@
+<?php
+class RentalAuth extends BasicAuth {
+ function init(){
+ parent::init();
+ $this->setModel('Model_Customer');
+ $this->getModel()->addField('password')->system(true);
+
+ $this->usePasswordEncryption('sha256/salt');
+ }
+ function check(){
+ if(!$this->isLoggedIn()){
+ $this->api->redirect('/');
+ }
+ }
+ function verifyCredintials($email,$password){
+ $model = $this->getModel()->loadBy('email',$email);
+ if(!$model->isInstanceLoaded())return false;
+ if($password == $model->get('password')){
+ $this->addInfo($model->get());
+ unset($this->info['password']);
+ return true;
+ }else return false;
+
+ }
+}
View
15 page/mgr.php
@@ -1,12 +1,7 @@
<?php
class page_mgr extends Page {
- function init(){
- parent::init();
-
- $tabs=$this->add('Tabs');
- $tabs->addTab('Customers')->add('CRUD')->setModel('Customer');
- $tabs->addTab('Movies')->add('CRUD')->setModel('Movie');
- $tabs->addTab('DVDs')->add('CRUD')->setModel('DVD');
- $tabs->addTab('Rentals')->add('CRUD')->setModel('Rental');
- }
-}
+ function init(){
+ parent::init();
+ $this->api->redirect('/');
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.