深入PHP与jQuery开发源代码下载(Pro PHP and jQuery source code)(25页).doc
-深入PHP与jQuery开发源代码下载(Pro PHP and jQuery source code)-第 25 页深入PHP与jQuery开发源代码下载(Pro PHP and jQuery source code) 看完这本书后觉得内容挺不错的,书中的代码基本上都能实现,为方便广大同仁更好的学习和参考,能以我个人的能力给大家做点贡献我也觉得非常荣幸,欢迎大家踊跃下载!本想免费供大家下载的,可是为了同时也能让我下载更多的学习资料,所以还是决定跟大家要点财富值吧,嘿嘿!下面是这个项目的目录结构!下面是运行效果图:首先是app目录下的文件,代码如下:<?php * Created on 2012-4-24 by xiongxuebing include_once './system/core/init.inc.php' if ( !isset($_SESSION'user') ) header("Location: ./"); exit;* Output the header$page_title = "Add/Edit Event"$css_files = array("style.css","admin.css");include_once 'assets/common/header.inc.php'* Load the calendar$cal = new Calendar($dbo);<div id="content"><?php echo $cal->displayForm(); ?></div><!- end #content -><?php* Output the footerinclude_once 'assets/common/footer.inc.php'下面是文件:<?php * Created on 2012-4-24 by xiongxuebinginclude_once './system/core/init.inc.php'* Make sure the event ID was passedif ( isset($_POST'event_id')&& isset($_SESSION'user') )* Collect the event ID from the URL string$id = (int) $_POST'event_id'else* Send the user to the main page if no ID is suppliedheader("Location: ./");exit;$cal = new Calendar($dbo);$markup = $cal->confirmDelete($id);* Output the header$page_title = "View Event"$css_files = array("style.css", "admin.css");include_once 'assets/common/header.inc.php'<div id="content"><?php echo $markup; ?></div><!- end #content -><?php* Output the footerinclude_once 'assets/common/footer.inc.php'I<?php * Created on 2012-4-24 by xiongxuebing* Include necessary filesinclude_once './system/core/init.inc.php'* Load the calendar for January$cal = new Calendar($dbo, "2012-04-01 12:00:00");$page_title = "Events Calendar"$css_files = array('style.css','admin.css','ajax.css');include_once 'assets/common/header.inc.php'<div id="content"><?phpecho $cal->buildCalendar();</div><!- end #content -><p><?phpecho isset($_SESSION'user') ? "欢迎您,".$_SESSION'user''name'."!" : "还未登录!"</p><?php* Include the footerinclude_once 'assets/common/footer.inc.php'L<?php * Created on 2012-4-25 by xiongxuebing* Include necessary filesinclude_once './system/core/init.inc.php'* Output the header$page_title = "Please Log In"$css_files = array("style.css", "admin.css");include_once 'assets/common/header.inc.php' <div id="content"> <form action="assets/inc/process.inc.php" method="post"> <fieldset> <legend>Please Log In</legend> <label for="uname">Username</label> <input type="text" name="uname" id="uname" value="" /> <label for="pword">Password</label> <input type="password" name="pword" id="pword" value="" /> <input type="hidden" name="token" value="<?php echo $_SESSION'token' ?>" /> <input type="hidden" name="action" value="user_login" /> <input type="submit" name="login_submit" value="Log In" /> or <a href="./">cancel</a> </fieldset> </form> </div><!- end #content -><?php* Output the footerinclude_once 'assets/common/footer.inc.php'V<?php * Created on 2012-4-24 by xiongxuebing if ( isset($_GET'event_id') ) $id = preg_replace('/0-9/', '', $_GET'event_id'); if ( empty($id) ) header("Location: ./"); exit; else header("Location: ./"); exit; include_once './system/core/init.inc.php' $page_title = "View Event" $css_files = array("style.css","admin.css"); include_once 'assets/common/header.inc.php' $cal = new Calendar($dbo);<div id="content"><?php echo $cal->displayEvent($id) ?><a href="./">« Back to the calendar</a></div><!- end #content -><?phpinclude_once 'assets/common/footer.inc.php'下面是app目录assets目录下文件:首先是Commen目录:F<script type="text/javascript" src="assets/js/jquery-1.7.2.js"></script><script type="text/javascript" src="assets/js/valid-date.js"></script><script type="text/javascript" src="assets/js/init.js"></script></body></html><!DOCTYPE htmlPUBLIC "-/W3C/DTD XHTML 1.0 Strict/EN""http:/www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http:/www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type"content="text/html;charset=utf-8" /><title><?php echo $page_title; ?></title><?php foreach ( $css_files as $css ): ?><link rel="stylesheet" type="text/css" media="screen,projection"href="assets/css/<?php echo $css; ?>" /><?php endforeach; ?></head><body>Css目录:Afieldset border: 0;legend font-size: 24px;font-weight: bold;inputtype=text,inputtype=password,label display: block;width: 70%;font-weight: bold;textarea width: 99%;height: 200px;inputtype=text,inputtype=password,textarea border: 1px solid #123;-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px;-moz-box-shadow: inset 1px 2px 4px #789;-webkit-box-shadow: inset 1px 2px 4px #789;box-shadow: inset 1px 2px 4px #789;padding: 4px;margin: 0 0 4px;font-size: 16px;font-family: georgia, serif;inputtype=submit margin: 4px 0;padding: 4px;border: 1px solid #123;-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px;-moz-box-shadow: inset -2px -1px 3px #345,inset 1px 1px 3px #BCF,1px 2px 6px #789;-webkit-box-shadow: inset -2px -1px 3px #345,inset 1px 1px 3px #BCF,1px 2px 6px #789;box-shadow: inset -2px -1px 3px #345,inset 1px 1px 3px #BCF,1px 2px 6px #789;background-color: #789;font-family: georgia, serif;text-transform: uppercase;font-weight: bold;font-size: 14px;text-shadow: 0px 0px 1px #fff;.admin-options text-align: center;.admin-options form,.admin-options p display: inline;display: inline-block;margin: 4px 0;padding: 4px;border: 1px solid #123;-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px;-moz-box-shadow: inset -2px -1px 3px #345,inset 1px 1px 3px #BCF,1px 2px 6px #789;-webkit-box-shadow: inset -2px -1px 3px #345,inset 1px 1px 3px #BCF,1px 2px 6px #789;box-shadow: inset -2px -1px 3px #345,inset 1px 1px 3px #BCF,1px 2px 6px #789;background-color: #789;color: black;text-decoration: none;font-family: georgia, serif;text-transform: uppercase;font-weight: bold;font-size: 14px;text-shadow: 0px 0px 1px #fff;A.modal-overlay position: fixed;top: 0;left: 0;bottom: 0;width: 100%;height: 100%;background-color: rgba(0,0,0,.5);z-index: 4;.modal-window position: absolute;top: 140px;left: 50%;width: 300px;height: auto;margin-left: -150px;padding: 20px;border: 2px solid #000;background-color: #FFF;-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px;-moz-box-shadow: 0 0 14px #123;-webkit-box-shadow: 0 0 14px #123;box-shadow: 0 0 14px #123;z-index: 5;.modal-close-btn position: absolute;top: 0;right: 4px;margin: 0;padding: 0;text-decoration: none;color: black;font-size: 16px;.modal-close-btn:before position: relative;top: -1px;content: "Close"text-transform: uppercase;font-size: 10px;S body background-color: #789;font-family: georgia, serif;font-size: 13px;#content display: block;width: 812px;margin: 40px auto 10px;padding: 10px;background-color: #FFF;-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px;border:2px solid black;-moz-box-shadow: 0 0 14px #123;-webkit-box-shadow: 0 0 14px #123;box-shadow: 0 0 14px #123;h2,p margin: 0 auto 14px;text-align: center;ul display: block;clear: left;height: 82px;width: 812px;margin: 0 auto;padding: 0;list-style: none;background-color: #FFF;text-align: center;border: 1px solid black;border-top: 0;border-bottom: 2px solid black;li position: relative;float: left;margin: 0;padding: 20px 2px 2px;border-left: 1px solid black;border-right: 1px solid black;width: 110px;height: 60px;overflow: hidden;background-color: white;li:hover background-color: #FCB;z-index: 1;-moz-box-shadow: 0 0 10px #789;-webkit-box-shadow: 0 0 10px #789;box-shadow: 0 0 10px #789;.weekdays height: 20px;border-top: 2px solid black;.weekdays li height: 16px;padding: 2px 2px;background-color: #BCF;.fill background-color: #BCD;.weekdays li:hover,li.fill:hover background-color: #BCD;-moz-box-shadow: none;-webkit-box-shadow: none;box-shadow: none;.weekdays li:hover,.today background-color: #BCF;li strong position: absolute;top: 2px;right: 2px;li a position: relative;display: block;border: 1px dotted black;margin: 2px;padding: 2px;font-size: 11px;background-color: #DEF;text-align: left;-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px;z-index: 1;text-decoration: none;color: black;font-weight: bold;font-style: italic;li a:hover background-color: #BCF;z-index: 2;-moz-box-shadow: 0 0 6px #789;-webkit-box-shadow: 0 0 6px #789;box-shadow: 0 0 6px #789;下面是inc目录:首先是<?php * Created on 2012-4-25 by xiongxuebing* Enable sessionssession_start();* Include necessary filesinclude_once './././system/config/db-cred.inc.php'* Define constants for config infoforeach ( $C as $name => $val )define($name, $val); $actions = array( 'event_view' => array( 'object' => 'Calendar', 'method' => 'displayEvent' 'edit_event' => array( 'object' => 'Calendar', 'method' => 'displayForm' 'event_edit' => array( 'object' => 'Calendar', 'method' => 'processForm' 'delete_event' => array( 'object' => 'Calendar', 'method' => 'confirmDelete' 'confirm_delete' => array( 'object' => 'Calendar', 'method' => 'confirmDelete'if ( isset($actions$_POST'action') )$use_array = $actions$_POST'action'$obj = new $use_array'object'($dbo); if ( isset($_POST'event_id') ) $id = (int) $_POST'event_id' else $id = NULL; echo $obj->$use_array'method'($id);function _autoload($class_name)$filename = './././system/class/class.'. strtolower($class_name) . '.inc.php'if ( file_exists($filename) )include_once $filename;P<?php * Created on 2012-4-25 by xiongxuebing session_start();* Include necessary files include_once './././system/config/db-cred.inc.php'* Define constants for config info foreach ( $C as $name => $val ) define($name, $val); $actions = array( 'event_edit' => array( 'object' => 'Calendar', 'method' => 'processForm', 'header' => 'Location: ././' 'user_login' => array( 'object' => 'Admin', 'method' => 'processLoginForm', 'header' => 'Location: ././' 'user_logout' => array( 'object' => 'Admin', 'method' => 'processLogout', 'header' => 'Location: ././'* Make sure the anti-CSRF token was passed and that the* requested action exists in the lookup array if ( $_POST'token'=$_SESSION'token'&& isset($actions$_POST'action') ) $use_array = $actions$_POST'action' $obj = new $use_array'object'($dbo); if (TRUE = $msg=$obj->$use_array'method'() header($use_array'header'); exit; else die ( $msg ); else/ Redirect to the main index if the token/action is invalid header("Location: ././"); exit; function _autoload($class_name) $filename = './././system/class/class.'.strtolower($class_name) . '.inc.php' if ( file_exists($filename) ) include_once $filename;下面是js目录:IjQuery(function($) var processFile = "assets/inc/ajax.inc.php", fx = "initModal" : function() / If no elements are matched, the length / property will return 0 if ( $(".modal-window").length=0 ) / Creates a div, adds a class, and / appends it to the body tag return $("<div>") .hide() .addClass("modal-window") .appendTo("body"); else return $(".modal-window"); "boxin" : function(data, modal) $("<div>") .hide() .addClass("modal-overlay") .click(function(event) / Removes event fx.boxout(event); .appendTo("body"); modal .hide() .append(data) .appendTo("body"); / Fades in the modal window and overlay $(".modal-window,.modal-overlay") .fadeIn("slow"); "removeevent" : function() / Removes any event with the class "active" $(".active") .fadeOut("slow", function() $(this).remove(); "boxout" : function(event) / If an event was triggered by the element / that called this function, prevents the / default action from firing if ( event!=undefined ) event.preventDefault(); / Removes the active class from all links $("a").removeClass("active"); / Fades out the modal window, then removes / it from the DOM entirely $(".modal-window,.modal-overlay") .fadeOut("slow", function() $(this).remove(); "addevent" : function(data, formData) /?¡ã?£¤¨¨¡¥¡é?-?|?2¨¨?¡é?a?¡¥1¨¨¡À? var entry = fx.deserialize(formData); cal = new Date(NaN), / Makes a date object for the new event event = new Date(NaN), / Extracts the calendar month from the H2 ID cdata = $("h2").attr("id").split('-'), / Extracts the event day, month, and year date = entry.event_start.split(' ')0, / Splits the event data into pieces edata = date.split('-'); / Sets the date for the calendar date object cal.setFullYear(cdata1, cdata2, 1); / Sets the date for the event date object event.setFullYear(edata0, edata1, edata2); event.setMinutes(1); if ( cal.getFullYear()=event.getFullYear() && cal.getMonth()=event.getMonth() ) / Gets the day of the month for event var day = String(event.getDate(); / Adds a leading zero to 1-digit days day = day.length=1 ? "0"+day : day; $("<a>") .hide() .attr("href", "view.php?event_id="+data) .text(entry.event_title) .insertA