Skip to content
Browse files

initial add

  • Loading branch information...
0 parents commit edbf973abc61d4ed474b21de651b23ce82ed0dd5 @addyosmani committed Jan 7, 2011
0 README
No changes.
15 index.php
@@ -0,0 +1,15 @@
+<?php
+
+/*****************************************************
+ Simple jQuery Mobile MVC Framework in PHP
+ =========================================
+ Read more at:
+ http://devgrow.com/jquery-mobile-php-mvc-framework/
+
+ This is meant to serve as a simple basis for
+ more complex jQuery Mobile applications that
+ can benefit from an MVC architecture.
+*****************************************************/
+
+require_once('lib/config.php');
+$app = new App;
31 lib/config.php
@@ -0,0 +1,31 @@
+<?php
+
+// Global Variables
+define("APP_NAME","jQuery Mobile MVC Framework");
+define("APP_DESCRIPTION","A simple PHP MVC framework utilizing jQuery Mobile");
+define("APP_KEYWORDS","jquery mobile, jquery mobile mvc, jquery mobile php, jquery mobile framework");
+define("PASSWORD_SALT","justjquerying");
+define("CACHE_ENABLE",true);
+define("BASE_DIR",dirname(dirname(__FILE__)));
+define("LIB_DIR",dirname(__FILE__));
+
+// Be sure to set these!
+define("BASE_URL","http://localhost/jqmobile/");
+define("COOKIE_DOMAIN","localhost");
+
+// Database Config
+$database = array (
+ "user" => "root",
+ "pass" => "",
+ "host" => "localhost",
+ "dbname" => "jqmobile"
+);
+
+// The following controllers/actions will not be cached:
+$do_not_cache = array("user","");
+
+require_once(LIB_DIR."/functions.php");
+require_once(LIB_DIR."/models/cache.php");
+require_once(LIB_DIR."/models/database.php");
+require_once(LIB_DIR."/models/user.php");
+require_once(LIB_DIR."/models/template.php");
67 lib/controllers/app.php
@@ -0,0 +1,67 @@
+<?php
+
+class App {
+
+ function __construct(){
+ global $database, $template, $user, $db;
+ session_start();
+ $db = new DatabaseModel;
+ $db->connect($database);
+ $this->check_tables();
+ $template = new TemplateModel;
+ $user = new UserModel;
+ $this->init();
+ $db->close();
+ }
+
+ function init(){
+ $uri = str_replace(BASE_URL,"","http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ $this->route($uri);
+ }
+
+ function route($uri){
+ $uri = $this->check_pages(explode('/',$uri));
+ $model = $uri[0];
+ $action = $uri[1] ? $uri[1] : 'index';
+ $var = $uri[2];
+ $var2 = $uri[3];
+ $var3 = $uri[4];
+ if($model && $model != "index.php"){
+ if($model == "page"){
+ $page = new Page;
+ $page->load_page($action);
+ }elseif(file_exists(LIB_DIR.'/controllers/'.$model.'.php')){
+ $$model = new $model;
+ if(method_exists($$model,$action)) $$model->$action($var, $var2, $var3);
+ else Home::error();
+ }else Home::error();
+ }else Home::index();
+ }
+
+ function check_pages($name = array()){
+ if(file_exists(LIB_DIR.'/views/pages/'.$name[0].'.php')){
+ $str[0] = "page";
+ $str[1] = $name[0];
+ return $str;
+ }else return $name;
+ }
+
+ function check_tables(){
+ global $db;
+
+ $query = "CREATE TABLE IF NOT EXISTS users (
+ user_id int(9) NOT NULL AUTO_INCREMENT,
+ name varchar(255) DEFAULT NULL,
+ email varchar(255) DEFAULT NULL,
+ password varchar(255) DEFAULT NULL,
+ status int(1) NOT NULL DEFAULT 1,
+ created_ip varchar(255) NOT NULL,
+ created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ last_logged_ip varchar(255) DEFAULT NULL,
+ last_logged_on timestamp NULL DEFAULT NULL,
+ admin tinyint(1) NOT NULL DEFAULT 0,
+ PRIMARY KEY (user_id));
+ ";
+ mysql_query($query) or die(mysql_error());
+ }
+}
16 lib/controllers/home.php
@@ -0,0 +1,16 @@
+<?php
+
+class Home {
+
+ public static function index(){
+ global $template;
+ $template->render("home");
+ }
+
+ public static function error(){
+ global $template;
+ $template->set_title('Error');
+ $template->render("error");
+ }
+
+}
13 lib/controllers/page.php
@@ -0,0 +1,13 @@
+<?php
+
+class Page {
+
+ public static function load_page($name){
+ global $template;
+ $standard = array("faq", "terms", "about");
+ $proper = array("Frequently Asked Questions", "Terms of Service", "About Us");
+ $template->set_title(ucwords(str_replace($standard, $proper, $name)));
+ $template->render("pages", $name, true);
+ }
+
+}
71 lib/controllers/user.php
@@ -0,0 +1,71 @@
+<?php
+
+class User {
+
+ function index(){
+ global $template;
+ login_required();
+ $template->set_title('My Profile');
+ $template->render("user","profile",true);
+ }
+
+ function login(){
+ global $user, $template;
+ if($user->is_logged)
+ return_to('home');
+ else{
+ if($_POST['task'] == 'login'){
+ $user->login($_POST['email'],$_POST['password']);
+ $template->set_msg($user->msg, $user->ok);
+ if($user->ok && $_POST['return_to']){
+ return_to($_POST['return_to']);
+ }elseif($user->ok)
+ return_to('home');
+ }
+ }
+ $template->set_title('Login');
+ $template->render("user","login",true);
+ }
+
+ function logout(){
+ global $user, $template;
+ if($user->is_logged()){
+ $user->logout();
+ $template->set_msg($user->msg, $user->ok);
+ }
+ $template->set_title('Login');
+ $template->render("user","login",true);
+ }
+
+ function edit(){
+ global $user, $template;
+ login_required();
+ if($_POST){
+ if($user->update($_POST)) $template->set_msg($user->msg, $user->ok);
+ $template->set_msg($user->msg, $user->ok);
+ }
+ $template->assign('user_email',$user->email);
+ $template->assign('user_name',$user->name);
+ $template->set_title('Update Information');
+ $template->render("user","edit",true);
+ }
+
+ function register(){
+ global $user, $template;
+ if($_POST){
+ if($user->create($_POST)){
+ $template->set_msg($user->msg, $user->ok);
+ if($_POST['return_to'])
+ return_to($_POST['return_to']);
+ else
+ return_to("home");
+ }
+ $template->set_msg($user->msg, $user->ok);
+ $template->assign('email',$_POST['email']);
+ $template->assign('name',$_POST['name']);
+ }
+ $template->set_title('Register');
+ $template->render("user","register",true);
+ }
+
+}
20 lib/functions.php
@@ -0,0 +1,20 @@
+<?php
+
+function __autoload($name){
+ require_once LIB_DIR.'/controllers/'.strtolower($name).'.php';
+}
+
+function return_to($location){
+ $location = BASE_URL.'#'.$location;
+ header("Location: $location");
+ exit();
+}
+
+function login_required(){
+ global $user, $template;
+ if(!$user->is_logged){
+ $template->set_msg("You must be logged in to access this section.",false);
+ User::login();
+ exit();
+ }
+}
56 lib/models/cache.php
@@ -0,0 +1,56 @@
+<?php
+
+/* For more information on this cache class, check out this post: http://devgrow.com/simple-cache-class/ */
+
+class CacheModel {
+
+ var $cacheDir = "./cache";
+ var $cacheTime = 21600; // 6 hours = 6*60*60
+ var $caching = false;
+ var $cacheFile;
+ var $cacheFileName;
+
+ function __construct(){
+ $this->cacheFile = md5($_SERVER['REQUEST_URI']);
+ $this->cacheFileName = $this->cacheDir.'/'.$this->cacheFile.'.cache';
+ if(!is_dir($this->cacheDir)) mkdir($this->cacheDir, 0755);
+ }
+
+ function start(){
+ global $do_not_cache;
+ $uri = str_replace(BASE_URL,"","http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ $location = explode('/',$uri);
+ if(!in_array($location[0],$do_not_cache) && CACHE_ENABLE){
+ if(file_exists($this->cacheFileName) && (time() - filemtime($this->cacheFileName)) < $this->cacheTime){
+ $this->caching = false;
+ echo file_get_contents($this->cacheFileName);
+ exit();
+ }else{
+ $this->caching = true;
+ ob_start();
+ }
+ }
+ }
+
+ function end(){
+ if($this->caching){
+ file_put_contents($this->cacheFileName,ob_get_contents());
+ ob_end_flush();
+ }
+ }
+
+ function purge(){
+ if(file_exists($this->cacheFile) && is_writable($this->cacheDir)) unlink($this->cacheFile);
+ }
+
+ function purge_all(){
+ if(!$dirhandle = @opendir($this->cacheDir)) return;
+ while(false != ($filename = readdir($dirhandle))){
+ if(substr($filename,-4) == '.cache') {
+ $filename = $this->cacheDir. "/". $filename;
+ unlink($filename);
+ }
+ }
+ }
+
+}
48 lib/models/database.php
@@ -0,0 +1,48 @@
+<?php
+
+class DatabaseModel {
+
+ var $error = array();
+ var $count = 0;
+ var $con = "";
+ var $result;
+
+ function connect($db){
+ $this->con = mysql_connect($db['host'], $db['user'], $db['pass']) OR $this->error(1,"Can't connect to mySQL Server.");
+ mysql_select_db($db['dbname'], $this->con) OR $this->error(1,"Can't select mySQL Database.");
+ }
+
+ function query($sql){
+ $this->result = mysql_query($sql, $this->con) OR $this->error(1, mysql_error());
+ $this->count++;
+ return $this->result;
+ }
+
+ function fetch($query){
+ $this->result = mysql_fetch_array($query);
+ return $this->result;
+ }
+
+ function get_rows($sql){
+ $this->result = mysql_fetch_array(mysql_query($sql));
+ return $this->result;
+ }
+
+ function num($query){
+ $this->result = mysql_num_rows($query);
+ return $this->result;
+ }
+
+ function insert_id(){
+ return mysql_insert_id($this->con);
+ }
+
+ function close(){
+ mysql_close($this->con);
+ }
+
+ function error($error, $quote){
+ if($error = 1) die("An error has occurred");
+ }
+
+}
60 lib/models/template.php
@@ -0,0 +1,60 @@
+<?php
+
+class TemplateModel {
+
+ var $variables = array();
+ var $title;
+ var $msg;
+ var $msg_type;
+
+ function load($file){
+ global $user, $template;
+ include_once LIB_DIR."/views/$file.php";
+ }
+
+ function render($model = "", $action = "", $html = false){
+ global $user, $template;
+ $profile = $user->get_info();
+ extract($this->variables);
+ include_once(LIB_DIR."/views/header.php");
+ $cache = new CacheModel;
+ $cache->start();
+ $file = './lib/views/';
+ if($html) echo '<div class="'.$model.'">';
+ if($model) $file .= $model;
+ if($action) $file .= '/'.$action;
+ $file .= '.php';
+ if(file_exists($file)) include_once $file;
+ if($html) echo '</div>';
+ include_once(LIB_DIR."/views/footer.php");
+ $cache->end();
+ }
+
+ function assign($name, $value){
+ $this->variables[$name] = $value;
+ }
+
+ function set_title($title){
+ $this->title = $title;
+ }
+
+ function page_title(){
+ if($this->title) $str = $this->title.' - '.APP_NAME.'.com';
+ else $str = APP_NAME.'.com - '.APP_KEYWORDS;
+ echo $str;
+ }
+
+ function set_msg($the_msg, $type = null){
+ $this->msg = $the_msg;
+ $this->msg_type = $type;
+ }
+
+ function get_msg(){
+ if(isset($this->msg_type)){
+ if($this->msg_type) $style = 'success';
+ else $style = 'error';
+ }
+ if($this->msg) echo "<div class='status message $style'>".$this->msg."</div>\n";
+ }
+
+}
296 lib/models/user.php
@@ -0,0 +1,296 @@
+<?php
+
+class UserModel {
+
+ var $user_id;
+ var $name;
+ var $email;
+ var $password;
+ var $ok;
+ var $msg;
+ var $is_logged;
+
+ function __construct(){
+ global $db;
+
+ $this->user_id = 0;
+ $this->email = "Guest";
+ $this->name = "Guest";
+ $this->ok = false;
+
+ if(!$this->check_session()) $this->check_cookie();
+
+ return $this->ok;
+ }
+
+ function check_session(){
+ if(!empty($_SESSION['auth_email']) && !empty($_SESSION['auth_secret']))
+ return $this->check($_SESSION['auth_email'], $_SESSION['auth_secret']);
+ else
+ return false;
+ }
+
+ function check_cookie(){
+ if(!empty($_COOKIE['auth_email']) && !empty($_COOKIE['auth_secret']))
+ return $this->check($_COOKIE['auth_email'], $_COOKIE['auth_secret']);
+ else
+ return false;
+ }
+
+ function create($info,$login = true){
+ global $db;
+ $name = mysql_real_escape_string($info['name']);
+ $email = mysql_real_escape_string($info['email']);
+ $password = md5(mysql_real_escape_string($info['password']) . PASSWORD_SALT);
+ $status = $info['status'] ? mysql_real_escape_string($info['status']) : 1;
+ $created_ip = $_SERVER['REMOTE_ADDR'];
+ $this->ok = false;
+
+ if(!$info['name'] || !$info['email'] || !$info['password'] || !$info['password2']){
+ $this->msg = "Error! All fields are required.";
+ return false;
+ }elseif($info['password'] != $info['password2']){
+ $this->msg = "Error! Passwords do not match.";
+ return false;
+ }elseif(!$this->validEmail($info['email'])){
+ $this->msg = "Error! Please enter a valid e-mail address.";
+ return false;
+ }
+
+ $db->query("SELECT user_id, password FROM users WHERE email = '".mysql_real_escape_string($email)."'");
+ if(mysql_num_rows($db->result) == 1){
+ $this->msg = "Error! E-mail address is already in use.";
+ }else{
+ $query = $db->query("INSERT INTO users (name,email,password,status,created_ip) VALUES ('$name','$email','$password','$status','$created_ip')");
+ if($query){
+ $this->msg = "User successfully added.";
+ $this->ok = true;
+ if($login) $this->login($info['email'],$info['password']);
+ return true;
+ }else{
+ $this->msg = "There was a problem, please try again.";
+ }
+ }
+ return false;
+ }
+
+ function update($info){
+ global $db;
+
+ $this->ok = false;
+
+ $name = mysql_real_escape_string($info['name']);
+ $email = mysql_real_escape_string($info['email']);
+ $password = md5(mysql_real_escape_string($info['password']) . PASSWORD_SALT);
+
+ if($info['password'] != $info['password2']){
+ $this->msg = "Error! Passwords do not match.";
+ return false;
+ }elseif(!$this->validEmail($info['email'])){
+ $this->msg = "Error! Please enter a valid e-mail address.";
+ return false;
+ }
+ $sql = "name='$name', email='$email'";
+ if($info['password']){
+ $sql .= ", password='$password'";
+ }
+ $query = "UPDATE users SET ".$sql." WHERE user_id = '".$this->user_id."'";
+ $query = $db->query($query);
+ if($query){
+ $this->msg = "Info successfully updated.";
+ $this->ok = true;
+ $_SESSION['auth_email'] = $email;
+ if($info['password']) $_SESSION['auth_secret'] = $password;
+ setcookie("auth_email", $email, time()+60*60*24*30, "/", COOKIE_DOMAIN);
+ if($info['password']) setcookie("auth_secret", $password, time()+60*60*24*30, "/", COOKIE_DOMAIN);
+ $this->name = $name;
+ $this->email = $email;
+ return true;
+ }else{
+ $this->msg = "There was a problem, please try again.";
+ }
+ return false;
+ }
+
+ function login($email, $password){
+ global $db;
+ $sql = $db->query("SELECT user_id, password, name FROM users WHERE email = '".mysql_real_escape_string($email)."'");
+ $this->ok = false;
+ if(!$email || !$password){
+ $this->msg = "Error! Both E-mail and Password are required to login.";
+ }
+ $results = $db->fetch($sql);
+ if($db->num($sql) == 1)
+ {
+ $db_password = $results['password'];
+ $name = $results['name'];
+ if(md5($password . PASSWORD_SALT) == $db_password)
+ {
+ $_SESSION['auth_email'] = $email;
+ $_SESSION['auth_secret'] = md5($password . PASSWORD_SALT);
+ setcookie("auth_email", $email, time()+60*60*24*30, "/", COOKIE_DOMAIN);
+ setcookie("auth_secret", md5($password . PASSWORD_SALT), time()+60*60*24*30, "/", COOKIE_DOMAIN);
+ $this->user_id = $results['user_id'];
+ $this->name = $name;
+ $this->email = $email;
+ $this->ok = true;
+ $this->msg = "Login Successful!";
+ $this->is_logged = true;
+ return true;
+ }else{
+ $this->msg = "Error! Password is incorrect.";
+ }
+ }else{
+ $this->msg = "Error! User does not exist.";
+ }
+ return false;
+ }
+
+ function check($email, $secret){
+ global $db;
+ $sql = $db->query("SELECT user_id, password, name FROM users WHERE email = '".mysql_real_escape_string($email)."'");
+ $results = $db->fetch($sql);
+ if($db->num($sql) == 1)
+ {
+ $db_password = $results['password'];
+ $name = $results['name'];
+ if($db_password == $secret) {
+ $this->user_id = $results['user_id'];
+ $this->email = $email;
+ $this->name = $name;
+ $this->ok = true;
+ $this->is_logged = true;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function is_logged(){
+ if($this->check($_SESSION['auth_email'], $_SESSION['auth_secret'])) return true;
+ else return false;
+ }
+
+ function is_admin(){
+ if($this->is_logged() && $this->get_info('admin') == 1) return true;
+ else return false;
+ }
+
+ function get_info($field = "*", $email = null){
+ global $db;
+ if(!$email) $email = $this->email;
+ $sql = $db->query("SELECT $field FROM users WHERE email = '$email'");
+ $info = $db->fetch($sql);
+ if($field == "*") return $info;
+ else return $info[$field];
+ }
+
+ function logout(){
+ $this->user_id = 0;
+ $this->email = "Guest";
+ $this->name = "Guest";
+ $this->ok = true;
+ $this->msg = "You have been logged out!";
+ $this->is_logged = false;
+
+ $_SESSION['auth_email'] = "";
+ $_SESSION['auth_secret'] = "";
+ setcookie("auth_email", "", time() - 3600, "/", COOKIE_DOMAIN);
+ setcookie("auth_secret", "", time() - 3600, "/", COOKIE_DOMAIN);
+ }
+
+ // Courtesy LinuxJournal.com : http://www.linuxjournal.com/article/9585?page=0,3
+ function validEmail($email){
+ $isValid = true;
+ $atIndex = strrpos($email, "@");
+ if (is_bool($atIndex) && !$atIndex){
+ $isValid = false;
+ }
+ else{
+ $domain = substr($email, $atIndex+1);
+ $local = substr($email, 0, $atIndex);
+ $localLen = strlen($local);
+ $domainLen = strlen($domain);
+ if ($localLen < 1 || $localLen > 64){
+ $isValid = false;
+ }else if ($domainLen < 1 || $domainLen > 255){
+ $isValid = false;
+ }else if ($local[0] == '.' || $local[$localLen-1] == '.'){
+ $isValid = false;
+ }else if (preg_match('/\\.\\./', $local)){
+ $isValid = false;
+ }else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)){
+ $isValid = false;
+ }else if (preg_match('/\\.\\./', $domain)){
+ $isValid = false;
+ }else if(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))){
+ if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))){
+ $isValid = false;
+ }
+ }
+ if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))){
+ $isValid = false;
+ }
+ }
+ return $isValid;
+ }
+
+ function user_table($all = false, $start = 1, $limit = 20, $sort_by = "user_id DESC"){
+ global $user, $db;
+ $query = "SELECT * FROM users";
+ if(!$all) $query .= " WHERE user_id = '".$user->user_id."'";
+ $this->total = $db->num($db->query($query));
+ $query .= " ORDER BY $sort_by LIMIT $start, $limit";
+ if($this->total >= 1){
+ $result = $db->query($query);
+ $str .= '<ul class="order-list"><li class="title"><span class="c2">Name</span><span class="c3">Email</span><span class="c2">Joined On</span><span class="c1">Status</span></li>';
+ while($row = $db->fetch($result)){
+ $str .= '<li><span class="c2">'.$row['name'].'</span><span class="c3">'.$row['email'].'</span><span class="c2">'.date("M j Y",strtotime($row['created_on'])).'</span><span class="c1">';
+ if($all) $str .= '<a href="admin/users/edit/'.$row['user_id'].'">'.$this->status($row['status']).'</a>';
+ else $str .= $this->status($row['status']);
+ $str .= '</span></li>';
+ }
+ $str .= '</ul>';
+ }else
+ $str = "No users found.";
+ return $str;
+ }
+
+ function status($value){
+ switch($value){
+ case 0:
+ return 'Inactive';
+ break;
+ case 1:
+ return 'Active';
+ break;
+ case 2:
+ return 'Banned';
+ break;
+ default:
+ return 'Inactive';
+ break;
+ }
+ }
+
+ function user_info($user_id){
+ global $user, $db;
+ $query = "SELECT * FROM users WHERE user_id = '".$user_id."'";
+ $result = $db->query($query);
+ $info = $db->fetch($result);
+ return $info;
+ }
+
+ function user_update($info, $user_id){
+ global $db;
+ $query = "UPDATE users SET status='".$info['status']."', name='".$info['name']."', email='".$info['email']."', admin='".$info['admin']."'";
+ if($info['password']){
+ $password = md5(mysql_real_escape_string($info['password']) . PASSWORD_SALT);
+ $query .= ", password='".$password."'";
+ }
+ $query .= " WHERE user_id = '".$user_id."'";
+ if($db->query($query)) return true;
+ else return false;
+ }
+
+}
5 lib/views/error.php
@@ -0,0 +1,5 @@
+
+ <div class="content left page">
+ <h1>404 Error</h1>
+ <p>Sorry, we couldn't find that page. Please check the URL or try again later.</p>
+ </div>
12 lib/views/footer.php
@@ -0,0 +1,12 @@
+ </div>
+ <div data-role="footer" data-position="fixed">
+ <p class="left p10">&copy; 2010 <?PHP echo APP_NAME; ?></p>
+ <ul class="right simplenav p10">
+ <li><a href="./about" data-icon="info" class="ui-btn-right">About</a></li>
+ <li><a href="./terms" data-icon="add">Terms of Service</a></li>
+ </ul>
+ </div>
+
+</div>
+</body>
+</html>
35 lib/views/header.php
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+<title><?php $template->page_title(); ?></title>
+
+<base href='<?php echo BASE_URL; ?>' />
+
+<!-- Stylesheets + Favicon: -->
+<link rel="stylesheet" href="./static/css/main.css" type="text/css" media="screen" />
+<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" />
+<link rel="shortcut icon" href="./static/images/favicon.ico" />
+<!-- /Stylesheets + Favicon: -->
+
+<!-- JavaScript: -->
+<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
+<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
+<script type="text/javascript" src="./static/js/functions.js"></script>
+<!-- /JavaScript -->
+
+<!-- SEO: -->
+<meta name="description" content="<?php echo APP_DESCRIPTION; ?>" />
+<meta name="keywords" content="<?php echo APP_KEYWORDS; ?>" />
+<link rel="canonical" href="<?php echo BASE_URL; ?>" />
+<!-- /SEO -->
+
+</head>
+
+<body>
+<div data-role="page" data-theme="c">
+ <div data-role="header" data-theme="a">
+ <h1><?php echo APP_NAME; ?></h1>
+ </div>
+ <div data-role="content" role="main">
+ <?php $template->get_msg(); ?>
15 lib/views/home.php
@@ -0,0 +1,15 @@
+
+ <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
+ <li data-role="list-divider">User Navigation:</li>
+ <?php if($user->is_admin()){ ?><li><a href="./admin">Admin</a></li><?php } ?>
+ <?php if($user->is_logged){ ?>
+ <li><a href="./user" data-transition="slide">Profile</a></li>
+ <li><a href="./user/logout" data-transition="fade">Logout</a></li>
+ <?php }else{ ?>
+ <li><a href="./user/register" data-transition="slide">Register</a></li>
+ <li><a href="./user/login" data-transition="slide">Login</a></li>
+ <?php } ?>
+ <li data-role="list-divider">Pages:</li>
+ <li><a href="./about" data-transition="slide">About</a></li>
+ <li><a href="./terms" data-transition="slide">Terms of Service</a></li>
+ </ul>
8 lib/views/pages/about.php
@@ -0,0 +1,8 @@
+
+ <h2>About <?PHP echo APP_NAME; ?></h2>
+
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod nulla non sem varius at semper libero malesuada.</p>
+
+ <p>Duis laoreet nibh non leo fringilla luctus. Nam vitae arcu purus, ut facilisis elit. Vivamus at purus metus, ut venenatis nisi. Sed sed sem tortor. Mauris et pellentesque odio. Phasellus sit amet velit fringilla nibh dapibus tincidunt non at metus. Integer feugiat arcu elit. Donec at elementum elit. Cras faucibus ligula a erat egestas ut volutpat neque convallis. Pellentesque pretium libero in velit suscipit in mollis orci posuere. Donec velit magna, ultrices eu tincidunt sit amet, lacinia non quam.</p>
+
+ <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam erat volutpat. Sed viverra, nisi in rhoncus varius, diam tellus placerat magna, ac pharetra quam massa tempor arcu. Mauris accumsan eros non orci lacinia laoreet. Pellentesque pretium tempor tempus.</p>
4 lib/views/pages/terms.php
@@ -0,0 +1,4 @@
+
+ <h2>Terms of Service</h2>
+
+ <p>These are our terms of service.</p>
25 lib/views/user/edit.php
@@ -0,0 +1,25 @@
+
+ <h2>Update Contact Info</h2>
+ <p><strong>Note:</strong> Only enter your password if you wish to change it, otherwise leave it blank.</p>
+ <form action='edit' method='post' class='register-form'>
+ <p>
+ <label for='name'>Name:</label>
+ <input type='text' name='name' class='text' id='name' value='<?php echo $user_name; ?>' />
+ </p>
+ <p>
+ <label for='email'>E-mail Address:</label>
+ <input type='text' name='email' class='text' id='email' value='<?php echo $user_email; ?>' />
+ </p>
+ <p>
+ <label for='password'>Password:</label>
+ <input type='password' name='password' class='text' id='password' />
+ </p>
+ <p>
+ <label for='password2'>Confirm Password:</label>
+ <input type='password' name='password2' class='text' id='password2' />
+ </p>
+ <p>
+ <label></label>
+ <input type='submit' class='button contact' value='Update' />
+ </p>
+ </form>
4 lib/views/user/error.php
@@ -0,0 +1,4 @@
+
+ <h2>Authentication Error</h2>
+
+ <p>You must be logged in or an administrator to access this content. Please <a href="./user">login</a> and try again.</p>
20 lib/views/user/login.php
@@ -0,0 +1,20 @@
+
+ <h2>Login</h2>
+
+ <p>Please login to view your order status or support requests.</p>
+
+ <form method="post" action="login">
+ <div data-role="fieldcontain">
+ <label for="email" class="ui-input-text">E-mail Address:</label>
+ <input type="text" name="email" class="text" id="email" value="" />
+ </div>
+ <div data-role="fieldcontain">
+ <label for="password">Password:</label>
+ <input type="password" name="password" class="text" id="password" />
+ </div>
+ <div data-role="fieldcontain">
+ <input type="hidden" name="task" value="login" />
+ <input type="hidden" name="return_to" value="" />
+ <input type="submit" data-icon="check" class="button submit" value="Login">
+ </div>
+ </form>
18 lib/views/user/profile.php
@@ -0,0 +1,18 @@
+
+ <h2>Your Profile</h2>
+
+ <div class="profile">
+ <p class='field'>
+ <label>Name:</label>
+ <span><?php echo $profile['name']; ?></span>
+ </p>
+ <p class='field'>
+ <label>E-mail:</label>
+ <span><?php echo $profile['email']; ?></span>
+ </p>
+ <p class='field'>
+ <label>Password:</label>
+ <span>************</span>
+ </p>
+ </div>
+ <a href="user/edit" data-icon="gear" data-role="button">Update Information</a>
24 lib/views/user/register.php
@@ -0,0 +1,24 @@
+
+ <h2>Register</h2>
+ <form action='' method='post' class='register-form'>
+ <p>
+ <label for='name'>Name:</label>
+ <input type='text' name='name' class='text' id='name' value='' />
+ </p>
+ <p>
+ <label for='email'>E-mail Address:</label>
+ <input type='text' name='email' class='text' id='email' value='' />
+ </p>
+ <p>
+ <label for='password'>Password:</label>
+ <input type='password' name='password' class='text' id='password' />
+ </p>
+ <p>
+ <label for='password2'>Confirm Password:</label>
+ <input type='password' name='password2' class='text' id='password2' />
+ </p>
+ <p>
+ <label></label>
+ <input type='submit' data-icon='check' class='button contact' value='Register' />
+ </p>
+ </form>
3 nginx.conf
@@ -0,0 +1,3 @@
+if (!-e $request_filename) {
+ rewrite ^/(.*)$ /index.php?$1 last;
+}
19 static/css/main.css
@@ -0,0 +1,19 @@
+/* Derived from the Simple jQuery Mobile MVC/PHP Framework */
+/* http://devgrow.com/jquery-mobile-php-mvc-framework/ */
+
+body { font-family: arial, sans-serif; font-size: 13px; }
+strong { font-weight: 700; }
+em { font-style: italic; }
+p { line-height: 19px; margin: 0 0 20px; }
+
+.left { float: left; }
+.right { float: right; }
+.p10 { padding: 10px; }
+.mr10 { margin: 0 10px 0 0; }
+
+ul.simplenav { list-style-type: none; margin: 0; }
+ul.simplenav li { float: left; margin-left: 5px; }
+
+.status { padding: 5px; border: 2px solid #ccc; background: #f3f3f3; }
+.status.error { border-color: #f1e4e4; background: #fcf8f8; }
+.status.success { border-color: #e5eed7; background: #f2f7e8; }
BIN static/images/favicon.ico
Binary file not shown.
3 static/js/functions.js
@@ -0,0 +1,3 @@
+$(document).ready(function() {
+ // Enter necessary functions here
+});

0 comments on commit edbf973

Please sign in to comment.
Something went wrong with that request. Please try again.