nav-left cat-right
cat-right

XajaxBook By PHP+Mysql+Xajax+Adodb+Smarty

历时三天的XajaxBook终于发布了,这只是一个学习的作品,所以用到了一些类库和框架,先放出这个带分页功能不带管理功能的Ajax留言本程序,程序中已经有较详细的注释,本作品供初学Xajax+Adodb+Smarty 开发的朋友参考,欢迎达人对这个本本抛砖。
演示:http://www.797audio.com/gb/
下载:在全文最下面
废话少说,看目录结构:

|+adodb
|+smarty
|+templates
|+templates_c
|+xajax
|-init.php
|-db.config.php
|-index.php

db.config.php

/**
* XajaxBook 留言簿数据库配置文件
* ============================================================================
* 版权所有 (C) 2007 im502@126.com,并保留所有权利。
* 网站地址: http://www.im502.com
* ============================================================================
* @file: db.config.php
* @author: im502
* @version: V1.0 Beta
* @update: 2007-10-26
* ———————————————
*/
// database host
$db_host = ‘localhost’;

// database name
$db_name = ‘mydb’;

// database username
$db_user = ‘root’;

// database password
$db_pass = ‘password’;
?>

init.php

/**
* XajaxBook 留言簿公用文件
* ============================================================================
* 版权所有 (C) 2007 im502@126.com,并保留所有权利。
* 网站地址: http://www.im502.com
* ============================================================================
* @file: init.php
* @author: im502
* @version: V1.0 Beta
* @update: 2007-10-26
* ———————————————
*/

/*包含数据库连接文件,adodb类库,Smarty类库,xajax类库*/
include_once(“db.config.php”);
require_once(“adodb/adodb.inc.php”);
require_once(“smarty/Smarty.class.php”);
require_once(“xajax/xajax.inc.php”);

/* 初始化数据库类 */
$db = &NewADOConnection(‘mysql’);
$db->Connect($db_host, $db_user, $db_pass, $db_name) or die(“Connect database failed”);
$db->query(“SET NAMES ‘gb2312′;”);
$db->debug = 0;//是否开启mysql侦错

/* 创建 Smarty 对象。*/
$smarty = new Smarty;
if (!file_exists(‘templates/caches’))
{
@mkdir(‘templates/caches’);
@chmod(‘templates/caches’, 0777);
}
if (!file_exists(‘templates_c’))
{
@mkdir(‘templates_c’);
@chmod(‘templates_c’, 0777);
}
clearstatcache();
$smarty->template_dir = ‘templates’;
$smarty->cache_dir = ‘templates/caches’;
$smarty->compile_dir = ‘templates_c’;
$smarty->caching = false;
$smarty->compile_force = false;
$smarty->left_delimiter = “<{“; //为防止与js冲突,使用<{}> 这样的定界符 替换默认的{}
$smarty->right_delimiter = “}>”;
$smarty->compile_check = 1;
$smarty->register_resource(“db”, array(“db_get_template”, “db_get_timestamp”, “db_get_secure”, “db_get_trusted”));
?>

index.php 代码略
下载:http://code.google.com/p/xajaxbook/

注:压缩包中不包含adodb和smarty的包,请自行从别处下载

没有评论

还没有评论呢。

这篇文章上的评论的 RSS feed

抱歉,评论已关闭。