Changeset 866
- Timestamp:
- 10/22/2007 12:29:02 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 5 added
- 1 removed
- 22 modified
-
application/config/config.php (modified) (1 diff)
-
application/controllers/admin (deleted)
-
application/controllers/examples.php (added)
-
application/controllers/welcome.php (modified) (1 diff)
-
index.php (modified) (1 diff)
-
makedocs.sh (added)
-
system/config/cookie.php (modified) (1 diff)
-
system/config/creditcard.php (modified) (1 diff)
-
system/config/database.php (modified) (1 diff)
-
system/config/encryption.php (modified) (1 diff)
-
system/config/hooks.php (modified) (1 diff)
-
system/config/locale.php (modified) (1 diff)
-
system/config/log.php (modified) (1 diff)
-
system/config/mimes.php (modified) (1 diff)
-
system/config/pagination.php (modified) (1 diff)
-
system/config/routes.php (modified) (1 diff)
-
system/config/session.php (modified) (1 diff)
-
system/config/upload.php (modified) (1 diff)
-
system/config/user_agents.php (modified) (1 diff)
-
system/core/Benchmark.php (modified) (5 diffs)
-
system/core/Bootstrap.php (modified) (2 diffs)
-
system/core/Config.php (added)
-
system/core/Event.php (added)
-
system/core/Kohana.php (modified) (35 diffs)
-
system/core/Log.php (added)
-
system/core/utf8.php (modified) (4 diffs)
-
system/libraries/Profiler.php (modified) (3 diffs)
-
system/libraries/View.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/application/config/config.php
r848 r866 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /* 3 | ------------------------------------------------------------------------- 4 | Site Domain 5 | ------------------------------------------------------------------------- 6 | 7 | Domain part of the URL to your Kohana installation, with the install path. 8 | 9 | Example: your-site.com/kohana/ 10 | 11 */ 12 $config['site_domain'] = $_SERVER['SERVER_NAME'].'/kohana/'; 13 14 /* 15 | ----------------------------------------------------------------------------- 16 | Site Protocol 17 | ----------------------------------------------------------------------------- 18 | 19 | Protocol part of the URL to your Kohana installation. 20 | 21 | Note: This will almost always be "http" or "https" 22 | 23 */ 24 $config['site_protocol'] = 'http'; 25 26 /* 27 | ----------------------------------------------------------------------------- 28 | Index File 29 | ----------------------------------------------------------------------------- 30 | 31 | Typically this will be your index.php file, unless you've renamed it to 32 | something else. If you are using mod_rewrite to remove the page set this 33 | variable to an empty string. 34 | 35 */ 36 $config['index_page'] = ''; 37 38 /* 39 | ----------------------------------------------------------------------------- 40 | URL Suffix 41 | ----------------------------------------------------------------------------- 42 | 43 | You can set an arbitrary filename extension to Kohana URLs. This extension is 44 | completely freeform, but should start with a period. 45 | 46 */ 47 $config['url_suffix'] = '.html'; 48 49 /* 50 | ----------------------------------------------------------------------------- 51 | Global XSS Filtering 52 | ----------------------------------------------------------------------------- 53 | 54 | Enable or disable global XSS (Cross-Site-Scripting) attack filtering on all 55 | user input, include POST, GET, and FILES. 56 | 57 */ 58 $config['global_xss_filtering'] = FALSE; 59 60 /* 61 | ----------------------------------------------------------------------------- 62 | Include Paths 63 | ----------------------------------------------------------------------------- 64 | 65 | User Guide: http://kohanaphp.com/user_guide/en/general/configuration.html 66 | 67 */ 68 $config['include_paths'] = array 3 * File: config.php 4 * This configuration file is unique to every application. 5 * 6 * Options: 7 * site_domain - domain and installation directory 8 * site_protocol - protocol used to access the site, usually HTTP 9 * index_page - name of the front controller, can be removed with URL rewriting 10 * url_suffix - an extension that will be added to all generated URLs 11 * global_xss_filtering - enable or disable XSS attack filtering on all user input 12 * extension_prefix - filename prefix for library extensions 13 * include_paths - extra Kohana resource paths, see <Kohana.find_file> 14 * autoload - libraries and models to be loaded with the controller 15 */ 16 $config = array 69 17 ( 70 'modules/user_guide', 71 'modules/orm' 18 'site_domain' => 'localhost/kohana/', 19 'site_protocol' => 'http', 20 'index_page' => 'index.php', 21 'url_suffix' => '.html', 22 'global_xss_filtering' => FALSE, 23 'extension_prefix' => 'MY_', 24 'include_paths' => array 25 ( 26 'modules/user_guide', 27 'modules/orm' 28 ), 29 'autoload' => array 30 ( 31 'libraries' => '', 32 'models' => '' 33 ) 72 34 ); 73 74 /*75 | -----------------------------------------------------------------------------76 | Extension Prefix77 | -----------------------------------------------------------------------------78 |79 | This prefix is used for the filename of your extended libraries, eg:80 | MY_Controller.php, MY_Database.php, MY_Validation.php81 |82 */83 $config['extension_prefix'] = 'MY_';84 85 /*86 | -----------------------------------------------------------------------------87 | Auto-Load88 | -----------------------------------------------------------------------------89 |90 | You can autoload libraries and models. This feature is not necessary due to91 | Kohana's internal auto-loading methods, but you can use it to save a small92 | amount of overhead.93 |94 | Set the class names in a comma separated list, eg:95 |96 | 'libraries' => 'Database, Validation',97 | 'models' => 'Users, Pages'98 |99 */100 $config['autoload'] = array101 (102 'libraries' => '',103 'models' => ''104 ); -
trunk/application/controllers/welcome.php
r856 r866 1 <?php 2 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 /* 3 * Class: Welcome 4 * Default Kohana controller. 5 */ 3 6 class Welcome_Controller extends Controller { 4 7 5 8 function index() 6 9 { 7 foreach(get_class_methods(__CLASS__) as $method) 8 { 9 if ( ! preg_match('/_example$/', $method)) continue; 10 echo html::anchor('welcome/'.$method, $method)."<br/>\n"; 11 } 12 } 13 14 function rss_example() 15 { 16 include Kohana::find_file('vendor', 'Markdown'); 17 18 $feed = new DOMDocument(); 19 $feed->load(APPPATH.'cache/rss.xml'); 20 21 foreach($feed->getElementsByTagName('item') as $index => $node) 22 { 23 if ($index > 4) break; 24 25 $title = $node->getElementsByTagName('title')->item(0)->nodeValue; 26 $desc = $node->getElementsByTagName('description')->item(0)->nodeValue; 27 $link = $node->getElementsByTagName('link')->item(0)->nodeValue; 28 $date = $node->getElementsByTagName('pubDate')->item(0)->nodeValue; 29 30 print Markdown("### [{$title}]({$link})\n$desc\n"); 31 } 32 33 print Kohana::lang('core.stats_footer'); 34 } 35 36 function session_example() 37 { 38 $this->load->database(); 39 $s = new Session(); 40 41 print "SESSID: <pre>".session_id()."</pre>\n"; 42 43 print "<pre>".print_r($_SESSION, TRUE)."</pre>\n"; 44 45 print "<br/>{execution_time} seconds"; 46 } 47 48 function form_example() 49 { 50 $this->load->library('validation'); 51 52 print form::open('', array('enctype' => 'multipart/form-data')); 53 54 print form::label('imageup', 'Image Uploads').':<br/>'; 55 print form::upload('imageup').'<br/>'; 56 // print form::upload('imageup[]').'<br/>'; 57 // print form::upload('imageup[]').'<br/>'; 58 print form::submit('upload', 'Upload!'); 59 60 print form::close(); 61 62 if ( ! empty($_POST)) 63 { 64 $this->validation->set_rules('imageup', 'required|upload[gif,png,jpg,500K]', 'Image Upload'); 65 print '<p>validation result: '.var_export($this->validation->run(), TRUE).'</p>'; 66 } 67 68 print $this->validation->debug(); 69 } 70 71 function validation_example() 72 { 73 // To demonstrate Validation being able to validate any array, I will 74 // be using a pre-built array. When you load validation with no arguments 75 // it will default to validating the POST array. 76 $data = array 77 ( 78 'user' => 'hello', 79 'pass' => 'bigsecret', 80 'reme' => '1' 81 ); 82 83 // Same as CI, but supports passing an array to the constructor 84 $this->load->library('validation', $data); 85 86 // Looks familiar... 87 $this->validation->set_rules(array 88 ( 89 // Format: 90 // key friendly name, validation rules 91 'user' => array('username', 'trim|required[1,2]'), 92 'pass' => array('password', 'required|sha1'), 93 'reme' => array('remember me', 'required') 94 )); 95 96 // Same syntax as before 97 $this->validation->run(); 98 99 // Same syntax, but dynamcially generated wth __get() 100 print $this->validation->user_error; 101 102 // Yay! 103 print "{execution_time} ALL DONE!"; 104 } 105 106 function database_example() 107 { 108 $this->load->database(); 109 $table = 'pages'; 110 echo 'Does the '.$table.' table exist? '; 111 if ($this->db->table_exists($table)) 112 { 113 echo '<p>YES! Lets do some work =)</p>'; 114 115 $query = $this->db->select('title')->from($table)->get(); 116 echo '<h3>Iterate through the result:</h3>'; 117 foreach($query as $item) 118 { 119 echo '<p>'.$item->title.'</p>'; 120 } 121 print "<h3>Numrows using count(): ".count($query)."</h3>"; 122 echo 'Table Listing:<pre>'.print_r($this->db->list_tables(), TRUE).'</pre>'; 123 124 echo '<h3>Try Query Binding with objects:</h3>'; 125 $sql = 'SELECT * FROM '.$table.' WHERE id = ?'; 126 $query = $this->db->query($sql, array(1)); 127 echo '<p>'.$this->db->last_query().'</p>'; 128 $query->result(TRUE); 129 foreach($query as $item) 130 { 131 echo '<pre>'.print_r($item, true).'</pre>'; 132 } 133 134 echo '<h3>Try Query Binding with arrays (returns both associative and numeric because I pass MYSQL_BOTH to result():</h3>'; 135 $sql = 'SELECT * FROM '.$table.' WHERE id = ?'; 136 $query = $this->db->query($sql, array(1)); 137 echo '<p>'.$this->db->last_query().'</p>'; 138 $query->result(FALSE, MYSQL_BOTH); 139 foreach($query as $item) 140 { 141 echo '<pre>'.print_r($item, true).'</pre>'; 142 } 143 144 echo '<h3>Look, we can also manually advance the result pointer!</h3>'; 145 $query = $this->db->select('title')->from($table)->get(); 146 echo 'First:<pre>'.print_r($query->current(), true).'</pre><br />'; 147 $query->next(); 148 echo 'Second:<pre>'.print_r($query->current(), true).'</pre><br />'; 149 $query->next(); 150 echo 'Third:<pre>'.print_r($query->current(), true).'</pre>'; 151 echo '<h3>And we can reset it to the beginning:</h3>'; 152 $query->rewind(); 153 echo 'Rewound:<pre>'.print_r($query->current(), true).'</pre>'; 154 155 echo '<p>Number of rows using count_records(): '.$this->db->count_records('pages').'</p>'; 156 } 157 else 158 { 159 echo 'NO! The '.$table.' table doesn\'t exist, so we can\'t continue =( '; 160 } 161 print "<br/><br/>\n"; 162 print "done in {execution_time} seconds"; 163 } 164 165 function pagination_example() 166 { 167 // You HAVE TO use $this->pagination when initializing the Pagination library. 168 // This is because the pagination views call $this->pagination->url(). 169 // Problem: what in case your page has multiple pagination areas? Hmm... 170 $this->pagination = new Pagination(array( 171 // 'base_url' => 'welcome/pagination_example/page/', // base_url will default to current uri 172 'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality 173 'total_items' => 254, // use db count query here of course 174 'items_per_page' => 10, // it may be handy to set defaults for stuff like this in config/pagination.php 175 'style' => 'classic' // pick one from: classic (default), digg, extended, punbb, or add your own! 176 )); 177 178 // Just echoing it is enough to display the links (__toString() rocks!) 179 echo 'Classic style: '.$this->pagination; 180 181 // You can also use the create_links() method and pick a style on the fly if you want 182 echo '<hr />Digg style: '.$this->pagination->create_links('digg'); 183 echo '<hr />Extended style: '.$this->pagination->create_links('extended'); 184 echo '<hr />PunBB style: '.$this->pagination->create_links('punbb'); 185 echo "done in {execution_time} seconds"; 186 } 187 188 function user_agent_example() 189 { 190 $this->load->library('user_agent'); 191 192 foreach(array('agent', 'browser', 'version') as $key) 193 { 194 print $key.': '.$this->user_agent->$key.'<br/>'."\n"; 195 } 196 197 print "<br/><br/>\n"; 198 print "done in {execution_time} seconds"; 199 } 200 201 function calendar_example() 202 { 203 $this->load->library('calendar'); 204 echo $this->calendar->generate(); 205 } 206 207 function image_example() 208 { 209 $config['source_image'] = '/var/www/dev/kohana/uploads/haha.JPG'; 210 $config['create_thumb'] = TRUE; 211 $config['maintain_ratio'] = TRUE; 212 $config['width'] = 75; 213 $config['height'] = 50; 214 $this->load->library('image_lib', $config); 215 if ( ! $this->image_lib->resize()) 216 { 217 echo $this->image_lib->display_errors(); 218 } 219 } 220 221 function credit_card_example() 222 { 223 $credit_card = new Creditcard(); 224 225 echo '<pre>'.print_r($credit_card, true).'</pre>'; 10 print "This is the default Kohana index page. You can edit <tt>application/controllers/welcome.php</tt> now." 226 11 } 227 12 -
trunk/index.php
r715 r866 1 1 <?php 2 2 /* 3 | ----------------------------------------------------------------------------- 4 | Kohana - The Swift PHP5 Framework 5 | ----------------------------------------------------------------------------- 6 | This file acts as the "front controller" to your application. If you do not 7 | understand the configuration parameters below, please consult the Kohana 8 | User Guide for more information. 9 | ----------------------------------------------------------------------------- 10 | User Guide: http://kohanaphp.com/user_guide/en/kohana/installation.html 11 | ----------------------------------------------------------------------------- 12 | License: http://kohanaphp.com/user_guide/en/license.html 13 | ----------------------------------------------------------------------------- 14 */ 3 * File: index.php 4 * This file acts as the "front controller" to your application. You can 5 * configure your application and system directories here, as well as error 6 * reporting and error display. 7 * 8 * Kohana Source Code: 9 * author - Kohana Team 10 * copyright - (c) 2007 Kohana Team 11 * license - <http://kohanaphp.com/license.html> 12 * 13 * Credits: 14 * - Kohana was originally a fork of CodeIgniter <http://codeigniter.com> (c) 2006 Ellis Labs 15 * - XSS cleaning from popoon <http://www.popoon.org> (c) 2001-2006 Bitflux GmbH 16 * - HTML cleaning from <http://htmlpurifier.org> (c) 2006-2007 Edward Z. Yang 17 */ 15 18 16 /** 17 * Set the error reporting level. E_ALL is a good default. 18 * NOTE: Kohana will always ignore E_STRICT errors 19 /* 20 * About: Error Reporting 21 * Set the error reporting level. By default, Kohana will ignore E_NOTICE 22 * messages. Unless you have a special need, E_ALL is a good level for 23 * error reporting. 19 24 */ 20 25 error_reporting(E_ALL); 21 26 22 /** 23 * Enable or disable error reporting. You should always disable this in production. 27 /* 28 * About: Display Errors 29 * Enable or disable error display. During development, it is very helpful 30 * to display errors. However, errors can give away information about your 31 * application. For greater security, it is recommended that you disable 32 * the displaying of errors in production. 24 33 */ 25 34 ini_set('display_errors', TRUE); 26 35 27 /** 28 * Kohana application directory. This directory must contain a config/ directory. 36 /* 37 * About: Application Directory 38 * Kohana website application directory. Most of your controllers, models, and 39 * views will by placed in this directory. This directory must contain the 40 * <config/config.php> file. 29 41 */ 30 42 $kohana_application = 'application'; 31 43 32 /** 33 * Kohana system directory. This directory must contain the core/ directory. 44 /* 45 * About: System Directory 46 * Kohana core resources, includes libraries, drivers, language files, helpers, 47 * and library-related views. 34 48 */ 35 49 $kohana_system = 'system'; 36 50 37 /** 38 * If you have to rename all of the .php files distributed with Kohana to a 39 * different filename, you set the new extension here. Most people will never 40 * use this option. 51 /* 52 * About: Filename Extension 53 * If you have to rename all of the .php files distributed with Kohana to a 54 * different filename, you set the new extension here. Most people will never 55 * use this option. 41 56 */ 42 57 define('EXT', '.php'); 43 58 44 59 /* 45 | ----------------------------------------------------------------------------- 46 | PLEASE DO NOT EDIT BELOW THIS LINE, unless you understand the repercussions! 47 | ----------------------------------------------------------------------------- 48 | User Guide: http://kohanaphp.com/user_guide/en/general/bootstrapping.html 49 | ----------------------------------------------------------------------------- 50 | $Id$ 51 */ 60 * PLEASE DO NOT EDIT BELOW THIS LINE, unless you understand the repercussions! 61 * ---------------------------------------------------------------------------- 62 * $Id$ 63 */ 52 64 $docroot = pathinfo(str_replace('\\', '/', realpath(__FILE__))); 53 65 66 // Define the docroot 54 67 define('KOHANA', $docroot['basename']); 55 68 define('DOCROOT', $docroot['dirname'].'/'); 56 69 70 // Define application and system paths 57 71 define('APPPATH', str_replace('\\', '/', realpath($kohana_application)).'/'); 58 72 define('SYSPATH', str_replace('\\', '/', realpath($kohana_system)).'/'); 59 73 74 // Clean up 60 75 unset($docroot, $kohana_application, $kohana_system); 61 76 -
trunk/system/config/cookie.php
r647 r866 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 /** 3 * Cookie Configuration 4 * ---------------------------------------------------------------------------- 5 * By default, cookie security is very relaxed. You are encouraged to set a 6 * domain and path to add some security to your cookies. 2 /* 3 * File: Cookie 4 * By default, cookie security is very relaxed. You are encouraged to set a 5 * domain and path to add some security to your cookies. 7 6 * 8 * User Guide: http://kohanaphp.com/user_guide/en/general/cookies.html 9 * 10 * @param string prefix - Prefix to avoid collisions 11 * @param string domain - Domain to restrict cookie to 12 * @param string path - Path to restrict cookie to 13 * @param integer expire - Liftime of cookie in seconds (0 = until browser closes) 14 * @param boolean secure - Only allow the cookie on HTTPS 15 * @param boolean httponly - Only allow cookie access through the HTTP protocol 16 * 7 * Options: 8 * prefix - Prefix to avoid collisions, empty for no prefix 9 * domain - Domain to restrict cookie to, empty to allow any domain 10 * path - Path to restrict cookie to, empty to allow any path 11 * expire - Liftime of cookie in seconds, 0 for a single browser session 12 * secure - Enable or disable HTTPS-only access 13 * httponly - Enable or disable HTTP-only access 17 14 */ 18 15 $config = array -
trunk/system/config/creditcard.php
r856 r866 1 <?php 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 /* 3 * File: Credit Card 4 * Settings related to the CreditCard library. 5 * 6 * Options: 7 * driver - default driver to use 8 */ 2 9 $config['default'] = array 3 10 ( -
trunk/system/config/database.php
r658 r866 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 /** 3 * Database Configuration 4 * ----------------------------------------------------------------------------- 5 * Database connection settings, defined by group name. If no group name is used 6 * when loading the database library, the group named "default" will be used. 7 * All of the variables listed below are explained in detail in the User Guide. 2 /* 3 * File: Database 4 * Database connection settings, defined as arrays, or "groups". If no group 5 * name is used when loading the database library, the group named "default" 6 * will be used. 7 * 8 * Each group can be connected to independantly, and multiple groups can be 9 * connected at once. 8 10 * 9 * User Guide: http://kohanaphp.com/user_guide/en/libraries/database.html 10 * 11 * @param boolean show_errors - Enable or disable database exceptions 12 * @param boolean benchmark - Enable or disable database benchmarking 13 * @param boolean persistent - Enable or disable a persistent connection 14 * @param string connection - DSN identifier: driver://user:password@server/database 15 * @param string character_set - Connection character set 16 * @param string table_prefix - Database table prefix 17 * @param boolean object - Return objects (TRUE) or arrays (FALSE) 18 * 11 * Group Options: 12 * show_errors - Enable or disable database exceptions 13 * benchmark - Enable or disable database benchmarking 14 * persistent - Enable or disable a persistent connection 15 * connection - DSN identifier: driver://user:password@server/database 16 * character_set - Database character set 17 * table_prefix - Database table prefix 18 * object - Enable or disable object results 19 19 */ 20 20 $config['default'] = array -
trunk/system/config/encryption.php
r647 r866 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 /* *3 * Encryption Configuration4 * -----------------------------------------------------------------------------2 /* 3 * File: Encryption 4 * Settings for the Encryption Library 5 5 * 6 * User Guide: http://kohanaphp.com/user_guide/en/libraries/encryption.html7 * 8 * @param string secret - The encryption key, choose something good!9 * 6 * Options: 7 * secret - Default encryption key. To provide a high level of security, 8 * make sure your key is at least 16 characters and contains 9 * letters, numbers, and symbols 10 10 */ 11 12 11 $config = array 13 12 ( -
trunk/system/config/hooks.php
r651 r866 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 /** 3 * Hooks Configuration 4 * ---------------------------------------------------------------------------- 2 /* 3 * File: Hooks 5 4 * 6 * User Guide: http://kohanaphp.com/user_guide/en/general/hooks.html7 * 8 * @param mixed enable - TRUE to enable all hooks, array of filenames to enable, FALSE to disable9 * 5 * Options: 6 * enable - Enable or disable hooks. Setting this option to TRUE will enable 7 * all hooks. By using an array of hook filenames, you can control 8 * which hooks are enabled. Setting this option to FALSE disables hooks. 10 9 */ 11 10 $config = array -
trunk/system/config/locale.php
r842 r866 1 1 <?php defined('SYSPATH') or die('No direct access allowed.'); 2 /* *3 * Locale Configuration4 * -----------------------------------------------------------------------------2 /* 3 * File:
