$ wget http://framework.zend.com/download/tgz $ tar -xvzf ZendFramework-0.1.2.tar.gz
RewriteEngine on RewriteRule !/.(js|ico|gif|jpg|png|css)$ index.php
php_value include_path "/path/to/lib"
<?php include 'Zend.php'; ?>
<?php
include 'Zend.php';
Zend::loadClass('Zend_Controller_Front');
?>
<?php
include 'Zend.php';
Zend::loadClass('Zend_Controller_Front');
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory('/path/to/controllers');
$controller->dispatch();
?>
<?php
include 'Zend.php';
Zend::loadClass('Zend_Controller_Front');
$controller = Zend_Controller_Front::getInstance()
->setControllerDirectory('/path/to/controllers')
->dispatch();
?>
<?php
Zend::loadClass('Zend_Controller_Action');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'IndexController::indexAction()';
}
}
?>
<?php
Zend::loadClass('Zend_Controller_Action');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'IndexController::indexAction()';
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
<?php
Zend::loadClass('Zend_Controller_Action');
class FooController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'FooController::indexAction()';
}
public function barAction()
{
echo 'FooController::barAction()';
}
}
?>
<?php
Zend::loadClass('Zend_Controller_Action');
class FooController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'FooController::indexAction()';
}
public function barAction()
{
echo 'FooController::barAction()';
}
public function __call($action, $arguments)
{
echo 'FooController:__call()';
}
}
?>
<?php
Zend::loadClass('Zend_Controller_Action');
Zend::loadClass('Zend_View');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$view = new Zend_View();
$view->setScriptPath('/path/to/views');
echo $view->render('example.php');
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
<html> <head> <title>This Is an Example</title> </head> <body> <p>This is an example.</p> </body> </html>
<html> <head> <title><?php echo $this->escape($this->title); ?></title> </head> <body> <?php echo $this->escape($this->body); ?> </body> </html>
<?php
Zend::loadClass('Zend_Controller_Action');
Zend::loadClass('Zend_View');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$view = new Zend_View();
$view->setScriptPath('/path/to/views');
$view->title = 'Dynamic Title';
$view->body = 'This is a dynamic body.';
echo $view->render('example.php');
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
<?php
Zend::register('view', $view);
?>
<?php
$view = Zend::registry('view');
?>
<?php $filterPost = new Zend_InputFilter($_POST); ?>
<?php
/* $_POST['name'] = 'John123Doe'; */
$filterPost = new Zend_InputFilter($_POST);
/* $_POST = NULL; */
$alphaName = $filterPost->getAlpha('name');
/* $alphaName = 'JohnDoe'; */
?>
<?php
Zend::loadClass('Zend_Controller_Action');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
/* List the news. */
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
<?php
Zend::loadClass('Zend_Controller_Action');
class AddController extends Zend_Controller_Action
{
function indexAction()
{
$this->_redirect('/');
}
function commentAction()
{
/* Add a comment. */
}
function newsAction()
{
/* Add news. */
}
function __call($action, $arguments)
{
$this->_redirect('/');
}
}
?>
<?php
Zend::loadClass('Zend_Controller_Action');
class AdminController extends Zend_Controller_Action
{
function indexAction()
{
/* Display admin interface. */
}
function approveAction()
{
/* Approve news. */
}
function __call($action, $arguments)
{
$this->_redirect('/');
}
}
?>
<?php
Zend::loadClass('Zend_Controller_Action');
class ViewController extends Zend_Controller_Action
{
function indexAction()
{
$this->_redirect('/');
}
function __call($id, $arguments)
{
/* Display news and comments for $id. */
}
}
?>
<?php
class Database
{
private $_db;
public function __construct($filename)
{
$this->_db = new SQLiteDatabase($filename);
}
public function addComment($name, $comment, $newsId)
{
$name = sqlite_escape_string($name);
$comment = sqlite_escape_string($comment);
$newsId = sqlite_escape_string($newsId);
$sql = "INSERT
INTO comments (name, comment, newsId)
VALUES ('$name', '$comment', '$newsId')";
return $this->_db->query($sql);
}
public function addNews($title, $content)
{
$title = sqlite_escape_string($title);
$content = sqlite_escape_string($content);
$sql = "INSERT
INTO news (title, content)
VALUES ('$title', '$content')";
return $this->_db->query($sql);
}
public function approveNews($ids)
{
foreach ($ids as $id) {
$id = sqlite_escape_string($id);
$sql = "UPDATE news
SET approval = 'T'
WHERE id = '$id'";
if (!$this->_db->query($sql)) {
return FALSE;
}
}
return TRUE;
}
public function getComments($newsId)
{
$newsId = sqlite_escape_string($newsId);
$sql = "SELECT name, comment
FROM comments
WHERE newsId = '$newsId'";
if ($result = $this->_db->query($sql)) {
return $result->fetchAll();
}
return FALSE;
}
public function getNews($id = 'ALL')
{
$id = sqlite_escape_string($id);
switch ($id) {
case 'ALL':
$sql = "SELECT id,
title
FROM news
WHERE approval = 'T'";
break;
case 'NEW':
$sql = "SELECT *
FROM news
WHERE approval != 'T'";
break;
default:
$sql = "SELECT *
FROM news
WHERE id = '$id'";
break;
}
if ($result = $this->_db->query($sql)) {
if ($result->numRows() != 1) {
return $result->fetchAll();
} else {
return $result->fetch();
}
}
return FALSE;
}
}
?>
<?php
$db = new SQLiteDatabase('/path/to/db.sqlite');
$db->query("CREATE TABLE news (
id INTEGER PRIMARY KEY,
title VARCHAR(255),
content TEXT,
approval CHAR(1) DEFAULT 'F'
)");
$db->query("CREATE TABLE comments (
id INTEGER PRIMARY KEY,
name VARCHAR(255),
comment TEXT,
newsId INTEGER
)");
?>
<?php
$db = new Database('/path/to/db.sqlite');
?>
<?php
include 'Zend.php';
function __autoload($class)
{
Zend::loadClass($class);
}
$db = new Database('/path/to/db.sqlite');
Zend::register('db', $db);
$view = new Zend_View;
$view->setScriptPath('/path/to/views');
Zend::register('view', $view);
$controller = Zend_Controller_Front::getInstance()
->setControllerDirectory('/path/to/controllers')
->dispatch();
?>
<html>
<head>
<title>News</title>
</head>
<body>
<h1>News</h1>
<?php foreach ($this->news as $entry) { ?>
<p>
<a href="/view/<?php echo $this->escape($entry['id']); ?>">
<?php echo $this->escape($entry['title']); ?>
</a>
</p>
<?php } ?>
<h1>Add News</h1>
<form action="/add/news" method="POST">
<p>Title:<br /><input type="text" name="title" /></p>
<p>Content:<br /><textarea name="content"></textarea></p>
<p><input type="submit" value="Add News" /></p>
</form>
</body>
</html>
<html>
<head>
<title>
<?php echo $this->escape($this->news['title']); ?>
</title>
</head>
<body>
<h1>
<?php echo $this->escape($this->news['title']); ?>
</h1>
<p>
<?php echo $this->escape($this->news['content']); ?>
</p>
<h1>Comments</h1>
<?php foreach ($this->comments as $comment) { ?>
<p>
<?php echo $this->escape($comment['name']); ?> writes:
</p>
<blockquote>
<?php echo $this->escape($comment['comment']); ?>
</blockquote>
<?php } ?>
<h1>Add a Comment</h1>
<form action="/add/comment" method="POST">
<input type="hidden" name="newsId"
value="<?php echo $this->escape($this->id); ?>" />
<p>Name:<br /><input type="text" name="name" /></p>
<p>Comment:<br /><textarea name="comment"></textarea></p>
<p><input type="submit" value="Add Comment" /></p>
</form>
</body>
</html>
<html>
<head>
<title>News Admin</title>
</head>
<body>
<form action="/admin/approve" method="POST">
<?php foreach ($this->news as $entry) { ?>
<p>
<input type="checkbox" name="ids[]"
value="<?php echo $this->escape($entry['id']); ?>" />
<?php echo $this->escape($entry['title']); ?>
<?php echo $this->escape($entry['content']); ?>
</p>
<?php } ?>
<p>
Password:<br /><input type="password" name="password" />
</p>
<p><input type="submit" value="Approve" /></p>
</form>
</body>
</html>
<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
/* List the news. */
$db = Zend::registry('db');
$view = Zend::registry('view');
$view->news = $db->getNews();
echo $view->render('index.php');
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
<?php
class AddController extends Zend_Controller_Action
{
function indexAction()
{
$this->_redirect('/');
}
function commentAction()
{
/* Add a comment. */
$filterPost = new Zend_InputFilter($_POST);
$db = Zend::registry('db');
$name = $filterPost->getAlpha('name');
$comment = $filterPost->noTags('comment');
$newsId = $filterPost->getDigits('newsId');
$db->addComment($name, $comment, $newsId);
$this->_redirect("/view/$newsId");
}
function newsAction()
{
/* Add news. */
$filterPost = new Zend_InputFilter($_POST);
$db = Zend::registry('db');
$title = $filterPost->noTags('title');
$content = $filterPost->noTags('content');
$db->addNews($title, $content);
$this->_redirect('/');
}
function __call($action, $arguments)
{
$this->_redirect('/');
}
}
?>
<?php
class AdminController extends Zend_Controller_Action
{
function indexAction()
{
/* Display admin interface. */
$db = Zend::registry('db');
$view = Zend::registry('view');
$view->news = $db->getNews('NEW');
echo $view->render('admin.php');
}
function approveAction()
{
/* Approve news. */
$filterPost = new Zend_InputFilter($_POST);
$db = Zend::registry('db');
if ($filterPost->getRaw('password') == 'mypass') {
$db->approveNews($filterPost->getRaw('ids'));
$this->_redirect('/');
} else {
echo 'The password is incorrect.';
}
}
function __call($action, $arguments)
{
$this->_redirect('/');
}
}
?>
<?php
class ViewController extends Zend_Controller_Action
{
function indexAction()
{
$this->_redirect('/');
}
function __call($id, $arguments)
{
/* Display news and comments for $id. */
$id = Zend_Filter::getDigits($id);
$db = Zend::registry('db');
$view = Zend::registry('view');
$view->news = $db->getNews($id);
$view->comments = $db->getComments($id);
$view->id = $id;
echo $view->render('view.php');
}
}
?>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有