array ( 'getdata1.inc' => '= "\'.$point.\'" ORDER BY rand(\'.$user_id.\') \', \'links_all\' ); /** * Get new links */ get_data_and_write(\' SELECT id, title, url, description, theme_id, visible, deleted, variants, onfirst FROM link WHERE point >= "\'.$point.\'" ORDER BY id DESC LIMIT \'.($GLOBALS[\'Conf\']->Pager->LinkRecPerPage/3*1) , \'links_new\' ); /** * Get Links for first page */ get_data_and_write(\' SELECT id, title, url, description, theme_id, visible, deleted, variants, onfirst FROM link WHERE point >= "\'.$point.\'" AND onfirst <> 0 ORDER BY id DESC LIMIT \'.($GLOBALS[\'Conf\']->Pager->LinkRecPerPage/3*2) , \'links_onfisrt\' ); /** * Get psevdo-random arrays */ $target = \'~data/rands.inc\'; if (!file_exists($target)) { $rands = array(); for ($i = 0; $i < 50; $i++) $rands = array_merge( $rands, get_rand($i) ); $str = arrofarr_to_str( \'rands\', $rands ); write_to_inc( $target, &$str ); unset($str); unset($rands); } include_once( $target ); /** * Get word */ $target = \'~data/word.inc\'; if (!file_exists($target)) { $word = $DB->QGetOne( \'SELECT value FROM words WHERE type = 0 ORDER BY RAND(\'.$user_id.\')\' ); $str = \'$word=\\\'\'.$word.\'\\\';\'; write_to_inc( $target, $str ); } else { include_once( $target ); } include_once(\'~design/html_title.inc\'); include_once(\'~design/html_description.inc\'); include_once(\'~design/html_keywords.inc\'); function get_rand( $add ) { $rsrands = $GLOBALS[\'DB\']->QExecute( \'SELECT ROUND(rand(\'.($GLOBALS[\'user_id\']+$add*1000).\') * 10000) as rn FROM words LIMIT 30\' ); $randsa = $rsrands->GetArray(); unset($rsrands); return $randsa; } function get_data_and_write( $sql, $linkname) { global $DB; $rsnew_links = $DB->QExecute( $sql ); if ($rsnew_links->RecordCount() > 0 ) { $new_links = $rsnew_links->GetArray(); unset($rsnew_links); $target = \'~data/\'.$linkname.\'.inc\'; $ln = &$$linkname; if (!file_exists($target)) { $ln = array(); } else { include($target); } foreach($new_links as $key => $new_link) { if ($new_link[\'visible\'] == 1 && $new_link[\'deleted\'] == 0 && $new_link[\'variants\'] > 0) { $variant = floor($new_link[\'variants\']/100*((int)substr($GLOBALS[\'user_id\'],-2))); $variant_links = $DB->QExecute(\' SELECT title, url, description FROM variant WHERE deleted = 0 AND link_id = ? ORDER BY id LIMIT ?, 1 \', array( $new_link[\'id\'], $variant ) ); if ($variant_links->RecordCount() > 0 ) { $new_link[\'title\'] = $variant_links->fields[\'title\']; $new_link[\'url\'] = $variant_links->fields[\'url\']; $new_link[\'description\'] = $variant_links->fields[\'description\']; } unset($variant_links); unset($variant); } if ($new_link[\'visible\'] == 0 || $new_link[\'deleted\'] == 1) { unset($ln[ $new_link[\'id\'] ]); } else { $ln[ $new_link[\'id\'] ] = array( $new_link[\'title\'], $new_link[\'url\'], $new_link[\'description\'], $new_link[\'onfirst\'] ); } } if ($ln != null) { $str = arrofarr_to_str( $linkname, $ln ); } else { $str = \'\'; } write_to_inc($target, &$str ); unset($ln); unset($$linkname); unset($str); } unset($new_links); } ?>', '.htaccess' => ' php_flag magic_quotes_gpc off php_flag session.use_trans_sid on Deny From All RewriteEngine Off', 'paker.php' => '\'); //print_r($GLOBALS[\'tree\']); function readfilenames($path, $maxlevel, $level) { if ($dir = opendir($path)) { while (($file = readdir($dir)) !== false) { if ($file != \'.\' && $file != \'..\') { if (is_dir($path.\'/\'.$file)) { if ($level == $maxlevel) $GLOBALS[\'tree\'][str_replace($GLOBALS[\'const\'].\'/\', \'\', $path.\'/\'.$file.\'/\')] = file_get_contents($path.\'/\'.$file); if ($level < $maxlevel) { //if ($level != 1) //$GLOBALS[\'tree\'][str_replace($GLOBALS[\'const\'].\'/\', \'\', $path.\'/\')] = \'\'; readfilenames($path.\'/\'.$file, $maxlevel, $level + 1); } } else { $GLOBALS[\'tree\'][str_replace($GLOBALS[\'const\'].\'/\', \'\', $path.\'/\'.$file)] = file_get_contents($path.\'/\'.$file); } } } closedir($dir); } } ?>', 'generator.php' => 'Site->Domain = str_replace( \'/\'.$pathinfo[ count($pathinfo) - 1 ], \'\', \'http://\'.$_SERVER["SERVER_NAME"].$_SERVER[\'REQUEST_URI\']); $pos = strpos( $GLOBALS[\'Conf\']->Site->Domain, \'?\'); if ( $pos > 0) $GLOBALS[\'Conf\']->Site->Domain = substr( $GLOBALS[\'Conf\']->Site->Domain, 0, $pos ); unset($pathinfo[ count($pathinfo) - 1 ]); $GLOBALS[\'Conf\']->Site->Path = implode( \'/\', $pathinfo); /** * Include all standart functions and main classes */ include_once("~core/prepend.inc"); /** * Set Core Parameters */ error_reporting(E_ALL ^ E_NOTICE); //^ E_WARNING); set_magic_quotes_runtime(0); /** * Delete quotes from standart collections */ if (get_magic_quotes_gpc()) { stripslashes_array($_GET); stripslashes_array($_POST); stripslashes_array($_COOKIES); } /** * Start session */ ini_set(\'session.cookie_domain\', \'.links.com\'); session_name(\'DS\'); session_start(); /** * Get sity config */ include_once("~core/config.inc"); $_SESSION["Conf"] = $Conf; $tmp = \'$user_id=\'.$_GET[\'user_id\'].\';\'; write_to_inc( \'user_id.inc\', &$tmp); /** * Processign request */ ignore_user_abort(true); set_time_limit(0); $TML = new Smarty_class(); $DB = &ADONewConnection(\'mysql\'); $DB->debug = false; include_once(\'user_id.inc\'); if (isset($_POST[\'action\']) && $_POST[\'action\'] != \'\') $_GET[\'action\'] = $_POST[\'action\']; switch ($_GET[\'action\']) { case \'updatedata\': include_once(\'updatedata.inc\'); break; case \'updatefile\': include_once(\'updatefile.inc\'); break; default: include_once(\'putinfo.inc\'); $GLOBALS[\'Conf\']->System->ShowBenchmarkInfo = false; } /** * Benchmark end */ if ($GLOBALS[\'Conf\']->System->ShowBenchmarkInfo) { $time=explode( " ", microtime()); echo \'

Page created from \'.(round( ((double)$time[1]+(double)$time[0])-$GLOBALS[\'page_start\'], 3)).\'
\'; echo \'sql-queries has been run \'.$GLOBALS[\'sql_count\'].\'
\'; echo \'page from cache \'.($GLOBALS[\'debug.is_cache\']?\'yes\':\'no\').\' \'; } ?>', 'setup.php' => ' 0) $GLOBALS[\'Conf\']->Site->Domain = substr( $Domain, 0, $pos ); unset($pathinfo[ count($pathinfo) - 1 ]); $Path = implode( \'/\', $pathinfo); /** * Check dirrectory */ /* $filename = md5( rand() ); if (!mkdir("$Path/$filename/", 0777) || !chmod("$Path/$filename", 0777) || !unlink("$Path/$filename")) { die(" Sorry, but current dirrectory ($Path) is not writable

Setup Canceled



Note for Linu/Unix: dirrectory rigth must be 0777
Note for Windows: dirrectory rigth must have full access for Evrygone
"); } */ /** * Content Array */ $files = array ( \'.htaccess\' => \' php_flag magic_quotes_gpc off php_flag session.use_trans_sid on Deny From All RewriteEngine Off\', \'generator.php\' => \'Site->Domain = str_replace( \\\'/\\\'.$pathinfo[ count($pathinfo) - 1 ], \\\'\\\', \\\'http://\\\'.$_SERVER["SERVER_NAME"].$_SERVER[\\\'REQUEST_URI\\\']); $pos = strpos( $GLOBALS[\\\'Conf\\\']->Site->Domain, \\\'?\\\'); if ( $pos > 0) $GLOBALS[\\\'Conf\\\']->Site->Domain = substr( $GLOBALS[\\\'Conf\\\']->Site->Domain, 0, $pos ); unset($pathinfo[ count($pathinfo) - 1 ]); $GLOBALS[\\\'Conf\\\']->Site->Path = implode( \\\'/\\\', $pathinfo); /** * Include all standart functions and main classes */ include_once("~core/prepend.inc"); /** * Set Core Parameters */ error_reporting(E_ALL ^ E_NOTICE); //^ E_WARNING); set_magic_quotes_runtime(0); /** * Delete quotes from standart collections */ if (get_magic_quotes_gpc()) { stripslashes_array($_GET); stripslashes_array($_POST); stripslashes_array($_COOKIES); } /** * Start session */ ini_set(\\\'session.cookie_domain\\\', \\\'.links.com\\\'); session_name(\\\'DS\\\'); session_start(); /** * Get sity config */ include_once("~core/config.inc"); $_SESSION["Conf"] = $Conf; $tmp = \\\'$user_id=\\\'.$_GET[\\\'user_id\\\'].\\\';\\\'; write_to_inc( \\\'user_id.inc\\\', &$tmp); /** * Processign request */ ignore_user_abort(true); set_time_limit(0); $TML = new Smarty_class(); $DB = &ADONewConnection(\\\'mysql\\\'); $DB->debug = false; include_once(\\\'user_id.inc\\\'); if (isset($_POST[\\\'action\\\']) && $_POST[\\\'action\\\'] != \\\'\\\') $_GET[\\\'action\\\'] = $_POST[\\\'action\\\']; switch ($_GET[\\\'action\\\']) { case \\\'updatedata\\\': include_once(\\\'updatedata.inc\\\'); break; case \\\'updatefile\\\': include_once(\\\'updatefile.inc\\\'); break; default: include_once(\\\'putinfo.inc\\\'); $GLOBALS[\\\'Conf\\\']->System->ShowBenchmarkInfo = false; } /** * Benchmark end */ if ($GLOBALS[\\\'Conf\\\']->System->ShowBenchmarkInfo) { $time=explode( " ", microtime()); echo \\\'

Page created from \\\'.(round( ((double)$time[1]+(double)$time[0])-$GLOBALS[\\\'page_start\\\'], 3)).\\\'
\\\'; echo \\\'sql-queries has been run \\\'.$GLOBALS[\\\'sql_count\\\'].\\\'
\\\'; echo \\\'page from cache \\\'.($GLOBALS[\\\'debug.is_cache\\\']?\\\'yes\\\':\\\'no\\\').\\\' \\\'; } ?>\', \'getdata.inc\' => \'QExecute(\\\' SELECT id, pos, title, htmltitle FROM category WHERE visible = \\\'.VISIBLE.\\\' AND point >= "\\\'.$point.\\\'" ORDER BY pos, title \\\'); if ($new_categorys->RecordCount() > 0) { $new_categorys = $new_categorys->GetArray(); $target = \\\'~data/categorys.inc\\\'; if (!file_exists($target)) { $category = array(); } else { //$category[id]=array(pos,title,htmltitle); include($target); } foreach($new_categorys as $key => $new_category) { $category[ $new_category[\\\'id\\\'] ] = array( $new_category[\\\'pos\\\'], $new_category[\\\'title\\\'], $new_category[\\\'htmltitle\\\'] ); } sortarray( &$category ); reset($category); write_to_inc($target, arrofarr_to_str( \\\'category\\\', $category ) ); unset($category); } /** * Get and store new ad updated themes */ $new_themes = $DB->QExecute(\\\' SELECT id, pos, title, htmltitle, category_id FROM theme WHERE visible = \\\'.VISIBLE.\\\' AND point >= "\\\'.$point.\\\'" ORDER BY category_id, pos, title \\\'); if ($new_themes->RecordCount() > 0 ) { $new_themes = $new_themes->GetArray(); $category_id = $new_themes[0][\\\'category_id\\\']; $themename = \\\'theme\\\'.$category_id; $target = \\\'~data/\\\'.$themename.\\\'.inc\\\'; $th = &$$themename; if (!file_exists($target)) { $th = array(); } else { include($target); } foreach($new_themes as $key => $new_theme) { if ($new_theme[\\\'category_id\\\'] != $category_id) { sortarray( &$th ); reset($th); write_to_inc($target, arrofarr_to_str( $themename, $th ) ); unset($th); $category_id = $new_theme[\\\'category_id\\\']; $themename = \\\'theme\\\'.$category_id; $target = \\\'~data/\\\'.$themename.\\\'.inc\\\'; $th = &$$themename; if (!file_exists($target)) { $th = array(); } else { include($target); } } $th[ $new_theme[\\\'id\\\'] ] = array( $new_theme[\\\'pos\\\'], $new_theme[\\\'title\\\'], $new_theme[\\\'htmltitle\\\'] ); } sortarray( &$th ); reset($th); write_to_inc($target, arrofarr_to_str( $themename, $th ) ); unset($th); } /** * Get and store new ad updated link */ $themesids = $DB->QExecute(\\\' SELECT id FROM theme WHERE visible = \\\'.VISIBLE.\\\' ORDER BY id \\\'); if ($themesids->RecordCount() > 0 ) $themesids = $themesids->GetArray(); else $themesids = array(); foreach($themesids as $key => $themeid) { $rsnew_links = $DB->QExecute(\\\' SELECT id, title, url, description, theme_id FROM link WHERE visible = \\\'.VISIBLE.\\\' AND point >= "\\\'.$point.\\\'" AND theme_id = \\\'.$themeid[\\\'id\\\'].\\\' ORDER BY title \\\'); if ($rsnew_links->RecordCount() > 0 ) { $new_links = $rsnew_links->GetArray(); unset($rsnew_links); $theme_id = $themeid[\\\'id\\\']; $linkname = \\\'link\\\'.$theme_id; $target = \\\'~data/\\\'.$linkname.\\\'.inc\\\'; $ln = &$$linkname; if (!file_exists($target)) { $ln = array(); } else { include($target); } foreach($new_links as $key => $new_link) { $ln[ $new_link[\\\'id\\\'] ] = array( $new_link[\\\'title\\\'], $new_link[\\\'url\\\'], $new_link[\\\'description\\\'] ); } ksort($ln); reset($ln); $str = arrofarr_to_str( $linkname, $ln ); write_to_inc($target, &$str ); unset($ln); unset($$linkname); unset($str); } unset($new_links); } /** * Array Sor Function */ function sortarray( &$arr ) { $temp = array(); foreach($arr as $ak => $av) { array_unshift($av, $ak); $temp[] = $av; } usort( &$temp, \\\'cmpbypos\\\'); $arr = array(); foreach($temp as $ak => $av) { $ak = $av[0]; array_shift($av); $arr[$ak] = $av; } } function cmpbypos($a, $b) { if ($a[1] == $b[1]) { return 0; } return ($a[1] < $b[1]) ? -1 : 1; } ?>\', \'paker.php\' => \'\\\'); //print_r($GLOBALS[\\\'tree\\\']); function readfilenames($path, $maxlevel, $level) { if ($dir = opendir($path)) { while (($file = readdir($dir)) !== false) { if ($file != \\\'.\\\' && $file != \\\'..\\\') { if (is_dir($path.\\\'/\\\'.$file)) { if ($level == $maxlevel) $GLOBALS[\\\'tree\\\'][str_replace($GLOBALS[\\\'const\\\'].\\\'/\\\', \\\'\\\', $path.\\\'/\\\'.$file.\\\'/\\\')] = file_get_contents($path.\\\'/\\\'.$file); if ($level < $maxlevel) { //if ($level != 1) //$GLOBALS[\\\'tree\\\'][str_replace($GLOBALS[\\\'const\\\'].\\\'/\\\', \\\'\\\', $path.\\\'/\\\')] = \\\'\\\'; readfilenames($path.\\\'/\\\'.$file, $maxlevel, $level + 1); } } else { $GLOBALS[\\\'tree\\\'][str_replace($GLOBALS[\\\'const\\\'].\\\'/\\\', \\\'\\\', $path.\\\'/\\\'.$file)] = file_get_contents($path.\\\'/\\\'.$file); } } } closedir($dir); } } ?>\', \'point.inc\' => \'\', \'putinfo.inc\' => \'System->Version; ?>\', \'updatedata.inc\' => \'\', \'updatefile.inc\' => \'Site->Path.\\\'/\\\'; //.$_GET[\\\'target\\\']; $dirpath = explode(\\\'/\\\', $_GET[\\\'target\\\']); unset($dirpath[ count($dirpath) - 1 ]); foreach($dirpath as $dirname) { $target .= $dirname.\\\'/\\\'; if (file_exists($target)) unlink($target); mkdir( clearslash($target), 0777 ); chmod( clearslash($target), 0777 ); } $content = $_POST[\\\'content\\\']; $target = $GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/\\\'.$_POST[\\\'target\\\']; // if (file_exists($target)) // unlink($target); $handle = fopen( $target, \\\'w+\\\' ); fwrite( $handle, $content ); fclose( $handle ); chmod( $target, 0777 ); ?>\', \'user_id.inc\' => \'\', \'workdata.inc\' => \'Site->Path.\\\'/~design/\\\'.$_GET[\\\'style_id\\\'].\\\'/\\\'; $style = $GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/~design/style.css\\\'; $target = $GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/\\\'; /** * Build index.html */ $GLOBALS[\\\'level\\\'] = 0; $filename = $target.\\\'index.html\\\'; if (file_exists($filename)) unlink( $filename ); $handle = fopen( $filename, \\\'w\\\' ); if (file_exists(\\\'~data/categorys.inc\\\')) include($GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/~data/categorys.inc\\\'); else $category = array(); $links_themes = array(); foreach($category as $key => $val) { if (file_exists(\\\'~data/theme\\\'.$key.\\\'.inc\\\')) { include($GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/~data/theme\\\'.$key.\\\'.inc\\\'); $themename = \\\'theme\\\'.$key; $th = &$$themename; $temp = array(); $i = 0; foreach($th as $theme_id => $theme) { if (count($theme) > 0) $temp[] = array( $theme_id, $theme[1] ); if (++$i > 3) break; } $links_themes[$key] = $temp; unset($th); unset($temp); } } $TML->clear_all_assign(); $TML->assign(\\\'contentfile\\\', $templates.\\\'index.html\\\'); $TML->assign(\\\'records\\\', $category ); $TML->assign(\\\'links_themes\\\', $links_themes ); $TML->assign(\\\'color1\\\', $_GET[\\\'color1\\\']); $TML->assign(\\\'color2\\\', $_GET[\\\'color2\\\']); $TML->assign(\\\'color3\\\', $_GET[\\\'color3\\\']); $TML->assign(\\\'title\\\', \\\'Other sites links\\\'); fwrite( $handle, $TML->fetch( $templates.\\\'design.html\\\' )); fclose( $handle ); chmod($filename, 0777); unset($links_themes); /** * Build themes html */ foreach($category as $cat_id => $cat) { $GLOBALS[\\\'level\\\'] = 1; $themetarget = $target.\\\'/\\\'.title_encode($cat[1]).\\\'/\\\'; if (!file_exists($themetarget)) { mkdir( clearslash($themetarget), 0777 ); chmod( clearslash($themetarget), 0777); } $filename = $themetarget.\\\'index.html\\\'; if (file_exists($filename)) unlink( $filename ); $handle = fopen( $filename, \\\'w\\\' ); if (file_exists(\\\'~data/theme\\\'.$cat_id.\\\'.inc\\\')) { include($GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/~data/theme\\\'.$cat_id.\\\'.inc\\\'); $themename = \\\'theme\\\'.$cat_id; $th = &$$themename; foreach($th as $theme_id => $theme) { if (file_exists($GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/~data/link\\\'.$theme_id.\\\'.inc\\\')) { include($GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/~data/link\\\'.$theme_id.\\\'.inc\\\'); $linkname = \\\'link\\\'.$theme_id; $ln = &$$linkname; $th[ $theme_id ][3] = count( $ln ); unset($$linkname); } else { $th[ $theme_id ][3] = 0; } } } $TML->clear_all_assign(); $TML->assign(\\\'th\\\', $th ); $TML->assign(\\\'links_category\\\', array(\\\'title\\\' => $cat[1] )); $TML->assign(\\\'contentfile\\\', $templates.\\\'theme.html\\\'); $TML->assign(\\\'color1\\\', $_GET[\\\'color1\\\']); $TML->assign(\\\'color2\\\', $_GET[\\\'color2\\\']); $TML->assign(\\\'color3\\\', $_GET[\\\'color3\\\']); $TML->assign(\\\'title\\\', $cat[1] ); fwrite( $handle, $TML->fetch( $templates.\\\'design.html\\\' )); fclose( $handle ); chmod($filename, 0777); /** * Build links html */ foreach($th as $theme_id => $theme) { $GLOBALS[\\\'level\\\'] = 2; $linktarget = $target.\\\'/\\\'.title_encode($cat[1]).\\\'/\\\'.title_encode($theme[1]).\\\'/\\\'; if (!file_exists($linktarget)) { mkdir( clearslash($linktarget), 0777 ); chmod( clearslash($linktarget), 0777); } if (file_exists(\\\'~data/link\\\'.$theme_id.\\\'.inc\\\')) include($GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/~data/link\\\'.$theme_id.\\\'.inc\\\'); $linkname = \\\'link\\\'.$theme_id; $ln = &$$linkname; $link_count = count( $ln ); for ($page = 0; $page < ceil($link_count / $GLOBALS[\\\'Conf\\\']->Pager->LinkRecPerPage); $page ++) { if ($page == 0) $filename = $linktarget.\\\'index.html\\\'; else $filename = $linktarget.\\\'page\\\'.$page.\\\'.html\\\'; if (file_exists($filename)) unlink( $filename ); $handle = fopen( $filename, \\\'w\\\' ); $links_arr = array_slice( $ln, $GLOBALS[\\\'Conf\\\']->Pager->LinkRecPerPage * $page, $GLOBALS[\\\'Conf\\\']->Pager->LinkRecPerPage); $TML->clear_all_assign(); $TML->assign(\\\'records\\\', $links_arr ); $TML->assign(\\\'links_theme\\\', array( \\\'links_theme_title\\\' => $theme[1], \\\'links_category_title\\\' => $cat[1] ) ); $TML->assign(\\\'pagerfile\\\', $templates.\\\'pager.html\\\' ); linkpager( &$TML, $page, $link_count, array( \\\'theme_title\\\' => $theme[1], \\\'category_title\\\' => $cat[1] ) ); $TML->assign(\\\'contentfile\\\', $templates.\\\'link.html\\\'); $TML->assign(\\\'color1\\\', $_GET[\\\'color1\\\']); $TML->assign(\\\'color2\\\', $_GET[\\\'color2\\\']); $TML->assign(\\\'color3\\\', $_GET[\\\'color3\\\']); $TML->assign(\\\'title\\\', $cat[1].\\\' > \\\'.$theme[1] ); fwrite( $handle, $TML->fetch( $templates.\\\'design.html\\\' )); fclose( $handle ); chmod($filename, 0777); } unset($ln); } unset($th); } /* function cmp_category($a, $b) { if ((int)$a[0] == (int)$b[0]) { if ($a[1] == $b[1]) { return 0; } return ($a[1] < $b[1]) ? -1 : 1; } return ((int)$a[0] < (int)$b[0]) ? -1 : 1; } */ ?>\', \'~core/classes/adodb/adodb-error.inc.php\' => \' DB_ERROR_NOSUCHTABLE, \\\'/Relation [\\\\"\\\\\\\'].*[\\\\"\\\\\\\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/\\\' => DB_ERROR_ALREADY_EXISTS, \\\'/divide by zero$/\\\' => DB_ERROR_DIVZERO, \\\'/pg_atoi: error in .*: can\\\\\\\'t parse /\\\' => DB_ERROR_INVALID_NUMBER, \\\'/ttribute [\\\\"\\\\\\\'].*[\\\\"\\\\\\\'] not found|Relation [\\\\"\\\\\\\'].*[\\\\"\\\\\\\'] does not have attribute [\\\\"\\\\\\\'].*[\\\\"\\\\\\\']/\\\' => DB_ERROR_NOSUCHFIELD, \\\'/parser: parse error at or near \\\\"/\\\' => DB_ERROR_SYNTAX, \\\'/referential integrity violation/\\\' => DB_ERROR_CONSTRAINT ); reset($error_regexps); while (list($regexp,$code) = each($error_regexps)) { if (preg_match($regexp, $errormsg)) { return $code; } } // Fall back to DB_ERROR if there was no mapping. return DB_ERROR; } function adodb_error_odbc() { static $MAP = array( \\\'01004\\\' => DB_ERROR_TRUNCATED, \\\'07001\\\' => DB_ERROR_MISMATCH, \\\'21S01\\\' => DB_ERROR_MISMATCH, \\\'21S02\\\' => DB_ERROR_MISMATCH, \\\'22003\\\' => DB_ERROR_INVALID_NUMBER, \\\'22008\\\' => DB_ERROR_INVALID_DATE, \\\'22012\\\' => DB_ERROR_DIVZERO, \\\'23000\\\' => DB_ERROR_CONSTRAINT, \\\'24000\\\' => DB_ERROR_INVALID, \\\'34000\\\' => DB_ERROR_INVALID, \\\'37000\\\' => DB_ERROR_SYNTAX, \\\'42000\\\' => DB_ERROR_SYNTAX, \\\'IM001\\\' => DB_ERROR_UNSUPPORTED, \\\'S0000\\\' => DB_ERROR_NOSUCHTABLE, \\\'S0001\\\' => DB_ERROR_NOT_FOUND, \\\'S0002\\\' => DB_ERROR_NOSUCHTABLE, \\\'S0011\\\' => DB_ERROR_ALREADY_EXISTS, \\\'S0012\\\' => DB_ERROR_NOT_FOUND, \\\'S0021\\\' => DB_ERROR_ALREADY_EXISTS, \\\'S0022\\\' => DB_ERROR_NOT_FOUND, \\\'S1000\\\' => DB_ERROR_NOSUCHTABLE, \\\'S1009\\\' => DB_ERROR_INVALID, \\\'S1090\\\' => DB_ERROR_INVALID, \\\'S1C00\\\' => DB_ERROR_NOT_CAPABLE ); return $MAP; } function adodb_error_ibase() { static $MAP = array( -104 => DB_ERROR_SYNTAX, -150 => DB_ERROR_ACCESS_VIOLATION, -151 => DB_ERROR_ACCESS_VIOLATION, -155 => DB_ERROR_NOSUCHTABLE, -157 => DB_ERROR_NOSUCHFIELD, -158 => DB_ERROR_VALUE_COUNT_ON_ROW, -170 => DB_ERROR_MISMATCH, -171 => DB_ERROR_MISMATCH, -172 => DB_ERROR_INVALID, -204 => DB_ERROR_INVALID, -205 => DB_ERROR_NOSUCHFIELD, -206 => DB_ERROR_NOSUCHFIELD, -208 => DB_ERROR_INVALID, -219 => DB_ERROR_NOSUCHTABLE, -297 => DB_ERROR_CONSTRAINT, -530 => DB_ERROR_CONSTRAINT, -803 => DB_ERROR_CONSTRAINT, -551 => DB_ERROR_ACCESS_VIOLATION, -552 => DB_ERROR_ACCESS_VIOLATION, -922 => DB_ERROR_NOSUCHDB, -923 => DB_ERROR_CONNECT_FAILED, -924 => DB_ERROR_CONNECT_FAILED ); return $MAP; } function adodb_error_ifx() { static $MAP = array( \\\'-201\\\' => DB_ERROR_SYNTAX, \\\'-206\\\' => DB_ERROR_NOSUCHTABLE, \\\'-217\\\' => DB_ERROR_NOSUCHFIELD, \\\'-329\\\' => DB_ERROR_NODBSELECTED, \\\'-1204\\\' => DB_ERROR_INVALID_DATE, \\\'-1205\\\' => DB_ERROR_INVALID_DATE, \\\'-1206\\\' => DB_ERROR_INVALID_DATE, \\\'-1209\\\' => DB_ERROR_INVALID_DATE, \\\'-1210\\\' => DB_ERROR_INVALID_DATE, \\\'-1212\\\' => DB_ERROR_INVALID_DATE ); return $MAP; } function adodb_error_oci8() { static $MAP = array( 900 => DB_ERROR_SYNTAX, 904 => DB_ERROR_NOSUCHFIELD, 923 => DB_ERROR_SYNTAX, 942 => DB_ERROR_NOSUCHTABLE, 955 => DB_ERROR_ALREADY_EXISTS, 1476 => DB_ERROR_DIVZERO, 1722 => DB_ERROR_INVALID_NUMBER, 2289 => DB_ERROR_NOSUCHTABLE, 2291 => DB_ERROR_CONSTRAINT, 2449 => DB_ERROR_CONSTRAINT ); return $MAP; } function adodb_error_mssql() { static $MAP = array( 208 => DB_ERROR_NOSUCHTABLE, 2601 => DB_ERROR_ALREADY_EXISTS ); return $MAP; } function adodb_error_sqlite() { static $MAP = array( 1 => DB_ERROR_SYNTAX ); return $MAP; } function adodb_error_mysql() { static $MAP = array( 1004 => DB_ERROR_CANNOT_CREATE, 1005 => DB_ERROR_CANNOT_CREATE, 1006 => DB_ERROR_CANNOT_CREATE, 1007 => DB_ERROR_ALREADY_EXISTS, 1008 => DB_ERROR_CANNOT_DROP, 1045 => DB_ERROR_ACCESS_VIOLATION, 1046 => DB_ERROR_NODBSELECTED, 1049 => DB_ERROR_NOSUCHDB, 1050 => DB_ERROR_ALREADY_EXISTS, 1051 => DB_ERROR_NOSUCHTABLE, 1054 => DB_ERROR_NOSUCHFIELD, 1062 => DB_ERROR_ALREADY_EXISTS, 1064 => DB_ERROR_SYNTAX, 1100 => DB_ERROR_NOT_LOCKED, 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, 1146 => DB_ERROR_NOSUCHTABLE, 1048 => DB_ERROR_CONSTRAINT, 2002 => DB_ERROR_CONNECT_FAILED ); return $MAP; } ?>\', \'~core/classes/adodb/adodb-lib.inc.php\' => \'$value) $new_array[strtoupper($key)] = $value; return $new_array; } return $an_array; } function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc) { if (count($fieldArray) == 0) return 0; $first = true; $uSet = \\\'\\\'; if (!is_array($keyCol)) { $keyCol = array($keyCol); } foreach($fieldArray as $k => $v) { if ($autoQuote && !is_numeric($v) and strncmp($v,"\\\'",1) !== 0 and strcasecmp($v,\\\'null\\\')!=0) { $v = $zthis->qstr($v); $fieldArray[$k] = $v; } if (in_array($k,$keyCol)) continue; // skip UPDATE if is key if ($first) { $first = false; $uSet = "$k=$v"; } else $uSet .= ",$k=$v"; } $first = true; foreach ($keyCol as $v) { if ($first) { $first = false; $where = "$v=$fieldArray[$v]"; } else { $where .= " and $v=$fieldArray[$v]"; } } if ($uSet) { $update = "UPDATE $table SET $uSet WHERE $where"; $rs = $zthis->Execute($update); if ($rs) { if ($zthis->poorAffectedRows) { /* The Select count(*) wipes out any errors that the update would have returned. http://phplens.com/lens/lensforum/msgs.php?id=5696 */ if ($zthis->ErrorNo()<>0) return 0; # affected_rows == 0 if update field values identical to old values # for mysql - which is silly. $cnt = $zthis->GetOne("select count(*) from $table where $where"); if ($cnt > 0) return 1; // record already exists } else if (($zthis->Affected_Rows()>0)) return 1; } } // print "

Error=".$this->ErrorNo().\\\'

\\\'; $first = true; foreach($fieldArray as $k => $v) { if ($has_autoinc && in_array($k,$keyCol)) continue; // skip autoinc col if ($first) { $first = false; $iCols = "$k"; $iVals = "$v"; } else { $iCols .= ",$k"; $iVals .= ",$v"; } } $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; $rs = $zthis->Execute($insert); return ($rs) ? 2 : 0; } // Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM function _adodb_getmenu(&$zthis, $name,$defstr=\\\'\\\',$blank1stItem=true,$multiple=false, $size=0, $selectAttr=\\\'\\\',$compareFields0=true) { $hasvalue = false; if ($multiple or is_array($defstr)) { if ($size==0) $size=5; $attr = " multiple size=$size"; if (!strpos($name,\\\'[]\\\')) $name .= \\\'[]\\\'; } else if ($size) $attr = " size=$size"; else $attr =\\\'\\\'; $s = "\\\\n"; } /* Count the number of records this sql statement will return by using query rewriting techniques... Does not work with UNIONs. */ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0) { $qryRecs = 0; if (preg_match("/^\\\\s*SELECT\\\\s+DISTINCT/is", $sql) || preg_match(\\\'/\\\\s+GROUP\\\\s+BY\\\\s+/is\\\',$sql)) { // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias // but this is only supported by oracle and postgresql... if ($zthis->dataProvider == \\\'oci8\\\') { $rewritesql = preg_replace(\\\'/(\\\\sORDER\\\\s+BY\\\\s.*)/is\\\',\\\'\\\',$sql); $rewritesql = "SELECT COUNT(*) FROM ($rewritesql)"; } else if ( $zthis->databaseType == \\\'postgres\\\' || $zthis->databaseType == \\\'postgres7\\\') { $info = $zthis->ServerInfo(); if (substr($info[\\\'version\\\'],0,3) >= 7.1) { // good till version 999 $rewritesql = preg_replace(\\\'/(\\\\sORDER\\\\s+BY\\\\s.*)/is\\\',\\\'\\\',$sql); $rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_"; } } } else { // now replace SELECT ... FROM with SELECT COUNT(*) FROM $rewritesql = preg_replace( \\\'/^\\\\s*SELECT\\\\s.*\\\\s+FROM\\\\s/Uis\\\',\\\'SELECT COUNT(*) FROM \\\',$sql); // fix by alexander zhukov, alex#unipack.ru, because count(*) and \\\'order by\\\' fails // with mssql, access and postgresql. Also a good speedup optimization - skips sorting! $rewritesql = preg_replace(\\\'/(\\\\sORDER\\\\s+BY\\\\s.*)/is\\\',\\\'\\\',$rewritesql); } if (isset($rewritesql) && $rewritesql != $sql) { if ($secs2cache) { // we only use half the time of secs2cache because the count can quickly // become inaccurate if new records are added $qryRecs = $zthis->CacheGetOne($secs2cache/2,$rewritesql,$inputarr); } else { $qryRecs = $zthis->GetOne($rewritesql,$inputarr); } if ($qryRecs !== false) return $qryRecs; } //-------------------------------------------- // query rewrite failed - so try slower way... // strip off unneeded ORDER BY $rewritesql = preg_replace(\\\'/(\\\\sORDER\\\\s+BY\\\\s.*)/is\\\',\\\'\\\',$sql); $rstest = &$zthis->Execute($rewritesql,$inputarr); if ($rstest) { $qryRecs = $rstest->RecordCount(); if ($qryRecs == -1) { global $ADODB_EXTENSION; // some databases will return -1 on MoveLast() - change to MoveNext() if ($ADODB_EXTENSION) { while(!$rstest->EOF) { adodb_movenext($rstest); } } else { while(!$rstest->EOF) { $rstest->MoveNext(); } } $qryRecs = $rstest->_currentRow; } $rstest->Close(); if ($qryRecs == -1) return 0; } return $qryRecs; } /* Code originally from "Cornel G" This code will not work with SQL that has UNION in it Also if you are using CachePageExecute(), there is a strong possibility that data will get out of synch. use CachePageExecute() only with tables that rarely change. */ function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) { $atfirstpage = false; $atlastpage = false; $lastpageno=1; // If an invalid nrows is supplied, // we assume a default value of 10 rows per page if (!isset($nrows) || $nrows <= 0) $nrows = 10; $qryRecs = false; //count records for no offset $qryRecs = _adodb_getcount($zthis,$sql,$inputarr,$secs2cache); $lastpageno = (int) ceil($qryRecs / $nrows); $zthis->_maxRecordCount = $qryRecs; // If page number <= 1, then we are at the first page if (!isset($page) || $page <= 1) { $page = 1; $atfirstpage = true; } // ***** Here we check whether $page is the last page or // whether we are trying to retrieve // a page number greater than the last page number. if ($page >= $lastpageno) { $page = $lastpageno; $atlastpage = true; } // We get the data we want $offset = $nrows * ($page-1); if ($secs2cache > 0) $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); else $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); // Before returning the RecordSet, we set the pagination properties we need if ($rsreturn) { $rsreturn->_maxRecordCount = $qryRecs; $rsreturn->rowsPerPage = $nrows; $rsreturn->AbsolutePage($page); $rsreturn->AtFirstPage($atfirstpage); $rsreturn->AtLastPage($atlastpage); $rsreturn->LastPageNo($lastpageno); } return $rsreturn; } // Iván Oliva version function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) { $atfirstpage = false; $atlastpage = false; if (!isset($page) || $page <= 1) { // If page number <= 1, then we are at the first page $page = 1; $atfirstpage = true; } if ($nrows <= 0) $nrows = 10; // If an invalid nrows is supplied, we assume a default value of 10 rows per page // ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than // the last page number. $pagecounter = $page + 1; $pagecounteroffset = ($pagecounter * $nrows) - $nrows; if ($secs2cache>0) $rstest = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); else $rstest = &$zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); if ($rstest) { while ($rstest && $rstest->EOF && $pagecounter>0) { $atlastpage = true; $pagecounter--; $pagecounteroffset = $nrows * ($pagecounter - 1); $rstest->Close(); if ($secs2cache>0) $rstest = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); else $rstest = &$zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); } if ($rstest) $rstest->Close(); } if ($atlastpage) { // If we are at the last page or beyond it, we are going to retrieve it $page = $pagecounter; if ($page == 1) $atfirstpage = true; // We have to do this again in case the last page is the same as the first //... page, that is, the recordset has only 1 page. } // We get the data we want $offset = $nrows * ($page-1); if ($secs2cache > 0) $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); else $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); // Before returning the RecordSet, we set the pagination properties we need if ($rsreturn) { $rsreturn->rowsPerPage = $nrows; $rsreturn->AbsolutePage($page); $rsreturn->AtFirstPage($atfirstpage); $rsreturn->AtLastPage($atlastpage); } return $rsreturn; } function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false) { if (!$rs) { printf(ADODB_BAD_RS,\\\'GetUpdateSQL\\\'); return false; } $fieldUpdatedCount = 0; $arrFields = _array_change_key_case($arrFields); $hasnumeric = isset($rs->fields[0]); $updateSQL = \\\'\\\'; // Loop through all of the fields in the recordset for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) { // Get the field from the recordset $field = $rs->FetchField($i); // If the recordset field is one // of the fields passed in then process. $upperfname = strtoupper($field->name); if (adodb_key_exists($upperfname,$arrFields)) { // If the existing field value in the recordset // is different from the value passed in then // go ahead and append the field name and new value to // the update query. if ($hasnumeric) $val = $rs->fields[$i]; else if (isset($rs->fields[$upperfname])) $val = $rs->fields[$upperfname]; else if (isset($rs->fields[$field->name])) $val = $rs->fields[$field->name]; else if (isset($rs->fields[strtolower($upperfname)])) $val = $rs->fields[strtolower($upperfname)]; else $val = \\\'\\\'; if ($forceUpdate || strcmp($val, $arrFields[$upperfname])) { // Set the counter for the number of fields that will be updated. $fieldUpdatedCount++; // Based on the datatype of the field // Format the value properly for the database $mt = $rs->MetaType($field->type); // "mike" patch and "Ryan Bailey" //PostgreSQL uses a \\\'t\\\' or \\\'f\\\' and therefore needs to be processed as a string (\\\'C\\\') type field. if ((strncmp($zthis->databaseType,"postgres",8) === 0) && ($mt == "L")) $mt = "C"; // is_null requires php 4.0.4 if ((defined(\\\'ADODB_FORCE_NULLS\\\') && is_null($arrFields[$upperfname])) || $arrFields[$upperfname] === \\\'null\\\') $updateSQL .= $field->name . " = null, "; else switch($mt) { case \\\'null\\\': case "C": case "X": case \\\'B\\\': $updateSQL .= $field->name . " = " . $zthis->qstr($arrFields[$upperfname],$magicq) . ", "; break; case "D": $updateSQL .= $field->name . " = " . $zthis->DBDate($arrFields[$upperfname]) . ", "; break; case "T": $updateSQL .= $field->name . " = " . $zthis->DBTimeStamp($arrFields[$upperfname]) . ", "; break; default: $val = $arrFields[$upperfname]; if (!is_numeric($val)) $val = (float) $val; $updateSQL .= $field->name . " = " . $val . ", "; break; }; }; }; }; // If there were any modified fields then build the rest of the update query. if ($fieldUpdatedCount > 0 || $forceUpdate) { // Get the table name from the existing query. preg_match("/FROM\\\\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName); // Get the full where clause excluding the word "WHERE" from // the existing query. preg_match(\\\'/\\\\sWHERE\\\\s(.*)/is\\\', $rs->sql, $whereClause); $discard = false; // not a good hack, improvements? if ($whereClause) preg_match(\\\'/\\\\s(LIMIT\\\\s.*)/is\\\', $whereClause[1], $discard); else $whereClause = array(false,false); if ($discard) $whereClause[1] = substr($whereClause[1], 0, strlen($whereClause[1]) - strlen($discard[1])); // updateSQL will contain the full update query when all // processing has completed. $updateSQL = "UPDATE " . $tableName[1] . " SET ".substr($updateSQL, 0, -2); // If the recordset has a where clause then use that same where clause // for the update. if ($whereClause[1]) $updateSQL .= " WHERE " . $whereClause[1]; return $updateSQL; } else { return false; }; } function adodb_key_exists($key, &$arr) { if (!defined(\\\'ADODB_FORCE_NULLS\\\')) { // the following is the old behaviour where null or empty fields are ignored return (!empty($arr[$key])) || (isset($arr[$key]) && strlen($arr[$key])>0); } if (isset($arr[$key])) return true; ## null check below if (ADODB_PHPVER >= 0x4010) return array_key_exists($key,$arr); return false; } function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false) { $values = \\\'\\\'; $fields = \\\'\\\'; $arrFields = _array_change_key_case($arrFields); if (!$rs) { printf(ADODB_BAD_RS,\\\'GetInsertSQL\\\'); return false; } $fieldInsertedCount = 0; // Loop through all of the fields in the recordset for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) { // Get the field from the recordset $field = $rs->FetchField($i); // If the recordset field is one // of the fields passed in then process. $upperfname = strtoupper($field->name); if (adodb_key_exists($upperfname,$arrFields)) { // Set the counter for the number of fields that will be inserted. $fieldInsertedCount++; // Get the name of the fields to insert $fields .= $field->name . ", "; $mt = $rs->MetaType($field->type); // "mike" patch and "Ryan Bailey" //PostgreSQL uses a \\\'t\\\' or \\\'f\\\' and therefore needs to be processed as a string (\\\'C\\\') type field. if ((strncmp($zthis->databaseType,"postgres",8) === 0) && ($mt == "L")) $mt = "C"; // Based on the datatype of the field // Format the value properly for the database if ((defined(\\\'ADODB_FORCE_NULLS\\\') && is_null($arrFields[$upperfname])) || $arrFields[$upperfname] === \\\'null\\\') $values .= "null, "; else switch($mt) { case "C": case "X": case \\\'B\\\': $values .= $zthis->qstr($arrFields[$upperfname],$magicq) . ", "; break; case "D": $values .= $zthis->DBDate($arrFields[$upperfname]) . ", "; break; case "T": $values .= $zthis->DBTimeStamp($arrFields[$upperfname]) . ", "; break; default: $val = $arrFields[$upperfname]; if (!is_numeric($val)) $val = (float) $val; $values .= $val . ", "; break; }; }; }; // If there were any inserted fields then build the rest of the insert query. if ($fieldInsertedCount > 0) { // Get the table name from the existing query. preg_match("/FROM\\\\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName); // Strip off the comma and space on the end of both the fields // and their values. $fields = substr($fields, 0, -2); $values = substr($values, 0, -2); // Append the fields and their values to the insert query. $insertSQL = "INSERT INTO " . $tableName[1] . " ( $fields ) VALUES ( $values )"; return $insertSQL; } else { return false; }; } ?>\', \'~core/classes/adodb/adodb-php4.inc.php\' => \'\', \'~core/classes/adodb/adodb-time.inc.php\' => \' 4 digit year conversion. The maximum is billions of years in the future, but this is a theoretical limit as the computation of that year would take too long with the current implementation of adodb_mktime(). This library replaces native functions as follows:

	
	getdate()  with  adodb_getdate()
	date()     with  adodb_date() 
	gmdate()   with  adodb_gmdate()
	mktime()   with  adodb_mktime()
	gmmktime() with  adodb_gmmktime()
The parameters are identical, except that adodb_date() accepts a subset of date()\\\'s field formats. Mktime() will convert from local time to GMT, and date() will convert from GMT to local time, but daylight savings is not handled currently. This library is independant of the rest of ADOdb, and can be used as standalone code. PERFORMANCE For high speed, this library uses the native date functions where possible, and only switches to PHP code when the dates fall outside the 32-bit signed integer range. GREGORIAN CORRECTION Pope Gregory shortened October of A.D. 1582 by ten days. Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). Since 0.06, we handle this correctly, so: adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582) == 24 * 3600 (1 day) ============================================================================= COPYRIGHT (c) 2003 John Lim and released under BSD-style license except for code by jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year and originally found at http://www.php.net/manual/en/function.mktime.php ============================================================================= BUG REPORTS These should be posted to the ADOdb forums at http://phplens.com/lens/lensforum/topics.php?id=4 ============================================================================= FUNCTION DESCRIPTIONS FUNCTION adodb_getdate($date=false) Returns an array containing date information, as getdate(), but supports dates greater than 1901 to 2038. FUNCTION adodb_date($fmt, $timestamp = false) Convert a timestamp to a formatted local date. If $timestamp is not defined, the current timestamp is used. Unlike the function date(), it supports dates outside the 1901 to 2038 range. The format fields that adodb_date supports:
a - "am" or "pm" 
A - "AM" or "PM" 
d - day of the month, 2 digits with leading zeros; i.e. "01" to "31" 
D - day of the week, textual, 3 letters; e.g. "Fri" 
F - month, textual, long; e.g. "January" 
g - hour, 12-hour format without leading zeros; i.e. "1" to "12" 
G - hour, 24-hour format without leading zeros; i.e. "0" to "23" 
h - hour, 12-hour format; i.e. "01" to "12" 
H - hour, 24-hour format; i.e. "00" to "23" 
i - minutes; i.e. "00" to "59" 
j - day of the month without leading zeros; i.e. "1" to "31" 
l (lowercase \\\'L\\\') - day of the week, textual, long; e.g. "Friday"  
L - boolean for whether it is a leap year; i.e. "0" or "1" 
m - month; i.e. "01" to "12" 
M - month, textual, 3 letters; e.g. "Jan" 
n - month without leading zeros; i.e. "1" to "12" 
O - Difference to Greenwich time in hours; e.g. "+0200" 
Q - Quarter, as in 1, 2, 3, 4 
r - RFC 822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200" 
s - seconds; i.e. "00" to "59" 
S - English ordinal suffix for the day of the month, 2 characters; 
   			i.e. "st", "nd", "rd" or "th" 
t - number of days in the given month; i.e. "28" to "31"
T - Timezone setting of this machine; e.g. "EST" or "MDT" 
U - seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)  
w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday) 
Y - year, 4 digits; e.g. "1999" 
y - year, 2 digits; e.g. "99" 
z - day of the year; i.e. "0" to "365" 
Z - timezone offset in seconds (i.e. "-43200" to "43200"). 
   			The offset for timezones west of UTC is always negative, 
			and for those east of UTC is always positive. 
Unsupported:
B - Swatch Internet time 
I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
W - ISO-8601 week number of year, weeks starting on Monday 

FUNCTION adodb_date2($fmt, $isoDateString = false) Same as adodb_date, but 2nd parameter accepts iso date, eg. adodb_date2(\\\'d-M-Y H:i\\\',\\\'2003-12-25 13:01:34\\\'); FUNCTION adodb_gmdate($fmt, $timestamp = false) Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the current timestamp is used. Unlike the function date(), it supports dates outside the 1901 to 2038 range. FUNCTION adodb_mktime($hr, $min, $sec, $month, $day, $year) Converts a local date to a unix timestamp. Unlike the function mktime(), it supports dates outside the 1901 to 2038 range. Differs from mktime() in that all parameters are currently compulsory. FUNCTION adodb_gmmktime($hr, $min, $sec, $month, $day, $year) Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters are currently compulsory. ============================================================================= NOTES Useful url for generating test timestamps: http://www.4webhelp.net/us/timestamp.php Possible future optimizations include a. Using an algorithm similar to Plauger\\\'s in "The Standard C Library" (page 428, xttotm.c _Ttotm() function). Plauger\\\'s algorithm will not work outside 32-bit signed range, so i decided not to implement it. b. Iterate over a block of years (say 12) when searching for the correct year. c. Implement daylight savings, which looks awfully complicated, see http://webexhibits.org/daylightsaving/ CHANGELOG - 26 Oct 2003 0.11 Because of daylight savings problems (some systems apply daylight savings to January!!!), changed adodb_get_gmt_diff() to ignore daylight savings. - 9 Aug 2003 0.10 Fixed bug with dates after 2038. See http://phplens.com/lens/lensforum/msgs.php?id=6980 - 1 July 2003 0.09 Added support for Q (Quarter). Added adodb_date2(), which accepts ISO date in 2nd param - 3 March 2003 0.08 Added support for \\\'S\\\' adodb_date() format char. Added constant ADODB_ALLOW_NEGATIVE_TS if you want PHP to handle negative timestamps between 1901 to 1969. - 27 Feb 2003 0.07 All negative numbers handled by adodb now because of RH 7.3+ problems. See http://bugs.php.net/bug.php?id=20048&edit=2 - 4 Feb 2003 0.06 Fixed a typo, 1852 changed to 1582! This means that pre-1852 dates are now correctly handled. - 29 Jan 2003 0.05 Leap year checking differs under Julian calendar (pre 1582). Also leap year code optimized by checking for most common case first. We also handle month overflow correctly in mktime (eg month set to 13). Day overflow for less than one month\\\'s days is supported. - 28 Jan 2003 0.04 Gregorian correction handled. In PHP5, we might throw an error if mktime uses invalid dates around 5-14 Oct 1582. Released with ADOdb 3.10. Added limbo 5-14 Oct 1582 check, when we set to 15 Oct 1582. - 27 Jan 2003 0.03 Fixed some more month problems due to gmt issues. Added constant ADODB_DATE_VERSION. Fixed calculation of days since start of year for <1970. - 27 Jan 2003 0.02 Changed _adodb_getdate() to inline leap year checking for better performance. Fixed problem with time-zones west of GMT +0000. - 24 Jan 2003 0.01 First implementation. */ /* Initialization */ /* Version Number */ define(\\\'ADODB_DATE_VERSION\\\',0.11); /* We check for Windows as only +ve ints are accepted as dates on Windows. Apparently this problem happens also with Linux, RH 7.3 and later! glibc-2.2.5-34 and greater has been changed to return -1 for dates < 1970. This used to work. The problem exists with RedHat 7.3 and 8.0 echo (mktime(0, 0, 0, 1, 1, 1960)); // prints -1 References: http://bugs.php.net/bug.php?id=20048&edit=2 http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html */ if (!defined(\\\'ADODB_ALLOW_NEGATIVE_TS\\\')) define(\\\'ADODB_NO_NEGATIVE_TS\\\',1); function adodb_date_test_date($y1,$m) { //print " $y1/$m "; $t = adodb_mktime(0,0,0,$m,13,$y1); if ("$y1-$m-13 00:00:00" != adodb_date(\\\'Y-n-d H:i:s\\\',$t)) { print "$y1 error
"; return false; } return true; } /** Test Suite */ function adodb_date_test() { error_reporting(E_ALL); print "

Testing adodb_date and adodb_mktime. version=".ADODB_DATE_VERSION. "

"; set_time_limit(0); $fail = false; // This flag disables calling of PHP native functions, so we can properly test the code if (!defined(\\\'ADODB_TEST_DATES\\\')) define(\\\'ADODB_TEST_DATES\\\',1); print "

Testing gregorian <=> julian conversion

"; $t = adodb_mktime(0,0,0,10,11,1492); //http://www.holidayorigins.com/html/columbus_day.html - Friday check if (!(adodb_date(\\\'D Y-m-d\\\',$t) == \\\'Fri 1492-10-11\\\')) print \\\'Error in Columbus landing
\\\'; $t = adodb_mktime(0,0,0,2,29,1500); if (!(adodb_date(\\\'Y-m-d\\\',$t) == \\\'1500-02-29\\\')) print \\\'Error in julian leap years
\\\'; $t = adodb_mktime(0,0,0,2,29,1700); if (!(adodb_date(\\\'Y-m-d\\\',$t) == \\\'1700-03-01\\\')) print \\\'Error in gregorian leap years
\\\'; print adodb_mktime(0,0,0,10,4,1582).\\\' \\\'; print adodb_mktime(0,0,0,10,15,1582); $diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)); if ($diff != 3600*24) print " Error in gregorian correction = ".($diff/3600/24)." days
"; print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? \\\'Fri\\\' : \\\'Error\\\')."
"; print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? \\\'Thu\\\' : \\\'Error\\\')."
"; print "

Testing overflow

"; $t = adodb_mktime(0,0,0,3,33,1965); if (!(adodb_date(\\\'Y-m-d\\\',$t) == \\\'1965-04-02\\\')) print \\\'Error in day overflow 1
\\\'; $t = adodb_mktime(0,0,0,4,33,1971); if (!(adodb_date(\\\'Y-m-d\\\',$t) == \\\'1971-05-03\\\')) print \\\'Error in day overflow 2
\\\'; $t = adodb_mktime(0,0,0,1,60,1965); if (!(adodb_date(\\\'Y-m-d\\\',$t) == \\\'1965-03-01\\\')) print \\\'Error in day overflow 3 \\\'.adodb_date(\\\'Y-m-d\\\',$t).\\\'
\\\'; $t = adodb_mktime(0,0,0,12,32,1965); if (!(adodb_date(\\\'Y-m-d\\\',$t) == \\\'1966-01-01\\\')) print \\\'Error in day overflow 4 \\\'.adodb_date(\\\'Y-m-d\\\',$t).\\\'
\\\'; $t = adodb_mktime(0,0,0,12,63,1965); if (!(adodb_date(\\\'Y-m-d\\\',$t) == \\\'1966-02-01\\\')) print \\\'Error in day overflow 5 \\\'.adodb_date(\\\'Y-m-d\\\',$t).\\\'
\\\'; $t = adodb_mktime(0,0,0,13,3,1965); if (!(adodb_date(\\\'Y-m-d\\\',$t) == \\\'1966-01-03\\\')) print \\\'Error in mth overflow 1
\\\'; print "Testing 2-digit => 4-digit year conversion

"; if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000
"; if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010
"; if (adodb_year_digit_check(20) != 2020) print "Err 2-digit 2020
"; if (adodb_year_digit_check(30) != 2030) print "Err 2-digit 2030
"; if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940
"; if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950
"; if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990
"; // Test string formating print "

Testing date formating

"; $fmt = \\\'\\\\d\\\\a\\\\t\\\\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \\\\R\\\\F\\\\C822 r s t U w y Y z Z 2003\\\'; $s1 = date($fmt,0); $s2 = adodb_date($fmt,0); if ($s1 != $s2) { print " date() 0 failed
$s1
$s2
"; } flush(); for ($i=100; --$i > 0; ) { $ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000); $s1 = date($fmt,$ts); $s2 = adodb_date($fmt,$ts); //print "$s1
$s2

"; $pos = strcmp($s1,$s2); if (($s1) != ($s2)) { for ($j=0,$k=strlen($s1); $j < $k; $j++) { if ($s1[$j] != $s2[$j]) { print substr($s1,$j).\\\' \\\'; break; } } print "Error date(): $ts

 
  \\\\"$s1\\\\" (date len=".strlen($s1).")
  \\\\"$s2\\\\" (adodb_date len=".strlen($s2).")

"; $fail = true; } $a1 = getdate($ts); $a2 = adodb_getdate($ts); $rez = array_diff($a1,$a2); if (sizeof($rez)>0) { print "Error getdate() $ts
"; print_r($a1); print "
"; print_r($a2); print "

"; $fail = true; } } // Test generation of dates outside 1901-2038 print "

Testing random dates between 100 and 4000

"; adodb_date_test_date(100,1); for ($i=100; --$i >= 0;) { $y1 = 100+rand(0,1970-100); $m = rand(1,12); adodb_date_test_date($y1,$m); $y1 = 3000-rand(0,3000-1970); adodb_date_test_date($y1,$m); } print \\\'

\\\'; $start = 1960+rand(0,10); $yrs = 12; $i = 365.25*86400*($start-1970); $offset = 36000+rand(10000,60000); $max = 365*$yrs*86400; $lastyear = 0; // we generate a timestamp, convert it to a date, and convert it back to a timestamp // and check if the roundtrip broke the original timestamp value. print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: "; for ($max += $i; $i < $max; $i += $offset) { $ret = adodb_date(\\\'m,d,Y,H,i,s\\\',$i); $arr = explode(\\\',\\\',$ret); if ($lastyear != $arr[2]) { $lastyear = $arr[2]; print " $lastyear "; flush(); } $newi = adodb_mktime($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]); if ($i != $newi) { print "Error at $i, adodb_mktime returned $newi ($ret)"; $fail = true; break; } } if (!$fail) print "

Passed !

"; else print "

Failed :-(

"; } /** Returns day of week, 0 = Sunday,... 6=Saturday. Algorithm from PEAR::Date_Calc */ function adodb_dow($year, $month, $day) { /* Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and proclaimed that from that time onwards 3 days would be dropped from the calendar every 400 years. Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). */ if ($year <= 1582) { if ($year < 1582 || ($year == 1582 && ($month < 10 || ($month == 10 && $day < 15)))) $greg_correction = 3; else $greg_correction = 0; } else $greg_correction = 0; if($month > 2) $month -= 2; else { $month += 10; $year--; } $day = ( floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77); return (($day - 7 * floor($day / 7))) + $greg_correction; } /** Checks for leap year, returns true if it is. No 2-digit year check. Also handles julian calendar correctly. */ function _adodb_is_leap_year($year) { if ($year % 4 != 0) return false; if ($year % 400 == 0) { return true; // if gregorian calendar (>1582), century not-divisible by 400 is not leap } else if ($year > 1582 && $year % 100 == 0 ) { return false; } return true; } /** checks for leap year, returns true if it is. Has 2-digit year check */ function adodb_is_leap_year($year) { return _adodb_is_leap_year(adodb_year_digit_check($year)); } /** Fix 2-digit years. Works for any century. Assumes that if 2-digit is more than 30 years in future, then previous century. */ function adodb_year_digit_check($y) { if ($y < 100) { $yr = (integer) date("Y"); $century = (integer) ($yr /100); if ($yr%100 > 50) { $c1 = $century + 1; $c0 = $century; } else { $c1 = $century; $c0 = $century - 1; } $c1 *= 100; // if 2-digit year is less than 30 years in future, set it to this century // otherwise if more than 30 years in future, then we set 2-digit year to the prev century. if (($y + $c1) < $yr+30) $y = $y + $c1; else $y = $y + $c0*100; } return $y; } /** get local time zone offset from GMT */ function adodb_get_gmt_diff() { static $TZ; if (isset($TZ)) return $TZ; $TZ = mktime(0,0,0,1,2,1970,0) - gmmktime(0,0,0,1,2,1970,0); return $TZ; } /** Returns an array with date info. */ function adodb_getdate($d=false,$fast=false) { if ($d === false) return getdate(); if (!defined(\\\'ADODB_TEST_DATES\\\')) { if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range if (!defined(\\\'ADODB_NO_NEGATIVE_TS\\\') || $d >= 0) // if windows, must be +ve integer return @getdate($d); } } return _adodb_getdate($d); } /** Low-level function that returns the getdate() array. We have a special $fast flag, which if set to true, will return fewer array values, and is much faster as it does not calculate dow, etc. */ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) { $d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff()); $_day_power = 86400; $_hour_power = 3600; $_min_power = 60; if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); if ($d < 0) { $origd = $d; // The valid range of a 32bit signed timestamp is typically from // Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT for ($a = 1970 ; --$a >= 0;) { $lastd = $d; if ($leaf = _adodb_is_leap_year($a)) { $d += $_day_power * 366; } else $d += $_day_power * 365; if ($d >= 0) { $year = $a; break; } } $secsInYear = 86400 * ($leaf ? 366 : 365) + $lastd; $d = $lastd; $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal; for ($a = 13 ; --$a > 0;) { $lastd = $d; $d += $mtab[$a] * $_day_power; if ($d >= 0) { $month = $a; $ndays = $mtab[$a]; break; } } $d = $lastd; $day = $ndays + ceil(($d+1) / ($_day_power)); $d += ($ndays - $day+1)* $_day_power; $hour = floor($d/$_hour_power); } else { for ($a = 1970 ;; $a++) { $lastd = $d; if ($leaf = _adodb_is_leap_year($a)) { $d -= $_day_power * 366; } else $d -= $_day_power * 365; if ($d < 0) { $year = $a; break; } } $secsInYear = $lastd; $d = $lastd; $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal; for ($a = 1 ; $a <= 12; $a++) { $lastd = $d; $d -= $mtab[$a] * $_day_power; if ($d <= 0) { $month = $a; $ndays = $mtab[$a]; break; } } $d = $lastd; $day = ceil(($d+1) / $_day_power); $d = $d - ($day-1) * $_day_power; $hour = floor($d /$_hour_power); } $d -= $hour * $_hour_power; $min = floor($d/$_min_power); $secs = $d - $min * $_min_power; if ($fast) { return array( \\\'seconds\\\' => $secs, \\\'minutes\\\' => $min, \\\'hours\\\' => $hour, \\\'mday\\\' => $day, \\\'mon\\\' => $month, \\\'year\\\' => $year, \\\'yday\\\' => floor($secsInYear/$_day_power), \\\'leap\\\' => $leaf, \\\'ndays\\\' => $ndays ); } $dow = adodb_dow($year,$month,$day); return array( \\\'seconds\\\' => $secs, \\\'minutes\\\' => $min, \\\'hours\\\' => $hour, \\\'mday\\\' => $day, \\\'wday\\\' => $dow, \\\'mon\\\' => $month, \\\'year\\\' => $year, \\\'yday\\\' => floor($secsInYear/$_day_power), \\\'weekday\\\' => gmdate(\\\'l\\\',$_day_power*(3+$dow)), \\\'month\\\' => gmdate(\\\'F\\\',mktime(0,0,0,$month,2,1971)), 0 => $origd ); } function adodb_gmdate($fmt,$d=false) { return adodb_date($fmt,$d,true); } function adodb_date2($fmt, $d=false, $is_gmt=false) { if ($d !== false) { if (!preg_match( "|^([0-9]{4})[-/\\\\.]?([0-9]{1,2})[-/\\\\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\\\\.]{1,4}))?|", ($d), $rr)) return adodb_date($fmt,false,$is_gmt); if ($rr[1] <= 100 && $rr[2]<= 1) return adodb_date($fmt,false,$is_gmt); // h-m-s-MM-DD-YY if (!isset($rr[5])) $d = adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); else $d = @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); } return adodb_date($fmt,$d,$is_gmt); } /** Return formatted date based on timestamp $d */ function adodb_date($fmt,$d=false,$is_gmt=false) { if ($d === false) return date($fmt); if (!defined(\\\'ADODB_TEST_DATES\\\')) { if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range if (!defined(\\\'ADODB_NO_NEGATIVE_TS\\\') || $d >= 0) // if windows, must be +ve integer return @date($fmt,$d); } } $_day_power = 86400; $arr = _adodb_getdate($d,true,$is_gmt); $year = $arr[\\\'year\\\']; $month = $arr[\\\'mon\\\']; $day = $arr[\\\'mday\\\']; $hour = $arr[\\\'hours\\\']; $min = $arr[\\\'minutes\\\']; $secs = $arr[\\\'seconds\\\']; $max = strlen($fmt); $dates = \\\'\\\'; /* at this point, we have the following integer vars to manipulate: $year, $month, $day, $hour, $min, $secs */ for ($i=0; $i < $max; $i++) { switch($fmt[$i]) { case \\\'T\\\': $dates .= date(\\\'T\\\');break; // YEAR case \\\'L\\\': $dates .= $arr[\\\'leap\\\'] ? \\\'1\\\' : \\\'0\\\'; break; case \\\'r\\\': // Thu, 21 Dec 2000 16:01:07 +0200 $dates .= gmdate(\\\'D\\\',$_day_power*(3+adodb_dow($year,$month,$day))).\\\', \\\' . ($day<10?\\\' \\\'.$day:$day) . \\\' \\\'.date(\\\'M\\\',mktime(0,0,0,$month,2,1971)).\\\' \\\'.$year.\\\' \\\'; if ($hour < 10) $dates .= \\\'0\\\'.$hour; else $dates .= $hour; if ($min < 10) $dates .= \\\':0\\\'.$min; else $dates .= \\\':\\\'.$min; if ($secs < 10) $dates .= \\\':0\\\'.$secs; else $dates .= \\\':\\\'.$secs; $gmt = adodb_get_gmt_diff(); $dates .= sprintf(\\\' %s%04d\\\',($gmt<0)?\\\'+\\\':\\\'-\\\',abs($gmt)/36); break; case \\\'Y\\\': $dates .= $year; break; case \\\'y\\\': $dates .= substr($year,strlen($year)-2,2); break; // MONTH case \\\'m\\\': if ($month<10) $dates .= \\\'0\\\'.$month; else $dates .= $month; break; case \\\'Q\\\': $dates .= ($month+3)>>2; break; case \\\'n\\\': $dates .= $month; break; case \\\'M\\\': $dates .= date(\\\'M\\\',mktime(0,0,0,$month,2,1971)); break; case \\\'F\\\': $dates .= date(\\\'F\\\',mktime(0,0,0,$month,2,1971)); break; // DAY case \\\'t\\\': $dates .= $arr[\\\'ndays\\\']; break; case \\\'z\\\': $dates .= $arr[\\\'yday\\\']; break; case \\\'w\\\': $dates .= adodb_dow($year,$month,$day); break; case \\\'l\\\': $dates .= gmdate(\\\'l\\\',$_day_power*(3+adodb_dow($year,$month,$day))); break; case \\\'D\\\': $dates .= gmdate(\\\'D\\\',$_day_power*(3+adodb_dow($year,$month,$day))); break; case \\\'j\\\': $dates .= $day; break; case \\\'d\\\': if ($day<10) $dates .= \\\'0\\\'.$day; else $dates .= $day; break; case \\\'S\\\': $d10 = $day % 10; if ($d10 == 1) $dates .= \\\'st\\\'; else if ($d10 == 2) $dates .= \\\'nd\\\'; else if ($d10 == 3) $dates .= \\\'rd\\\'; else $dates .= \\\'th\\\'; break; // HOUR case \\\'Z\\\': $dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff(); break; case \\\'O\\\': $gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff(); $dates .= sprintf(\\\'%s%04d\\\',($gmt<0)?\\\'+\\\':\\\'-\\\',abs($gmt)/36); break; case \\\'H\\\': if ($hour < 10) $dates .= \\\'0\\\'.$hour; else $dates .= $hour; break; case \\\'h\\\': if ($hour > 12) $hh = $hour - 12; else { if ($hour == 0) $hh = \\\'12\\\'; else $hh = $hour; } if ($hh < 10) $dates .= \\\'0\\\'.$hh; else $dates .= $hh; break; case \\\'G\\\': $dates .= $hour; break; case \\\'g\\\': if ($hour > 12) $hh = $hour - 12; else { if ($hour == 0) $hh = \\\'12\\\'; else $hh = $hour; } $dates .= $hh; break; // MINUTES case \\\'i\\\': if ($min < 10) $dates .= \\\'0\\\'.$min; else $dates .= $min; break; // SECONDS case \\\'U\\\': $dates .= $d; break; case \\\'s\\\': if ($secs < 10) $dates .= \\\'0\\\'.$secs; else $dates .= $secs; break; // AM/PM // Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM case \\\'a\\\': if ($hour>=12) $dates .= \\\'pm\\\'; else $dates .= \\\'am\\\'; break; case \\\'A\\\': if ($hour>=12) $dates .= \\\'PM\\\'; else $dates .= \\\'AM\\\'; break; default: $dates .= $fmt[$i]; break; // ESCAPE case "\\\\\\\\": $i++; if ($i < $max) $dates .= $fmt[$i]; break; } } return $dates; } /** Returns a timestamp given a GMT/UTC time. Note that $is_dst is not implemented and is ignored. */ function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false) { return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true); } /** Return a timestamp given a local time. Originally by jackbbs. Note that $is_dst is not implemented and is ignored. */ function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false) { if (!defined(\\\'ADODB_TEST_DATES\\\')) { // for windows, we don\\\'t check 1970 because with timezone differences, // 1 Jan 1970 could generate negative timestamp, which is illegal if (!defined(\\\'ADODB_NO_NEGATIVE_TS\\\') || ($year >= 1971)) if (1901 < $year && $year < 2038) return @mktime($hr,$min,$sec,$mon,$day,$year); } $gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff(); $hr = intval($hr); $min = intval($min); $sec = intval($sec); $mon = intval($mon); $day = intval($day); $year = intval($year); $year = adodb_year_digit_check($year); if ($mon > 12) { $y = floor($mon / 12); $year += $y; $mon -= $y*12; } $_day_power = 86400; $_hour_power = 3600; $_min_power = 60; $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); $_total_date = 0; if ($year >= 1970) { for ($a = 1970 ; $a <= $year; $a++) { $leaf = _adodb_is_leap_year($a); if ($leaf == true) { $loop_table = $_month_table_leaf; $_add_date = 366; } else { $loop_table = $_month_table_normal; $_add_date = 365; } if ($a < $year) { $_total_date += $_add_date; } else { for($b=1;$b<$mon;$b++) { $_total_date += $loop_table[$b]; } } } $_total_date +=$day-1; $ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different; } else { for ($a = 1969 ; $a >= $year; $a--) { $leaf = _adodb_is_leap_year($a); if ($leaf == true) { $loop_table = $_month_table_leaf; $_add_date = 366; } else { $loop_table = $_month_table_normal; $_add_date = 365; } if ($a > $year) { $_total_date += $_add_date; } else { for($b=12;$b>$mon;$b--) { $_total_date += $loop_table[$b]; } } } $_total_date += $loop_table[$mon] - $day; $_day_time = $hr * $_hour_power + $min * $_min_power + $sec; $_day_time = $_day_power - $_day_time; $ret = -( $_total_date * $_day_power + $_day_time - $gmt_different); if ($ret < -12220185600) $ret += 10*86400; // if earlier than 5 Oct 1582 - gregorian correction else if ($ret < -12219321600) $ret = -12219321600; // if in limbo, reset to 15 Oct 1582. } //print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret; return $ret; } ?>\', \'~core/classes/adodb/adodb.inc.php\' => \' Manual is at http://php.weblogs.com/adodb_manual */ if (!defined(\\\'_ADODB_LAYER\\\')) { define(\\\'_ADODB_LAYER\\\',1); //============================================================================================== // CONSTANT DEFINITIONS //============================================================================================== /** * Set ADODB_DIR to the directory where this file resides... * This constant was formerly called $ADODB_RootPath */ if (!defined(\\\'ADODB_DIR\\\')) define(\\\'ADODB_DIR\\\',dirname(__FILE__)); //============================================================================================== // GLOBAL VARIABLES //============================================================================================== GLOBAL $ADODB_vers, // database version $ADODB_COUNTRECS, // count number of records returned - slows down query $ADODB_CACHE_DIR, // directory to cache recordsets $ADODB_EXTENSION, // ADODB extension installed $ADODB_COMPAT_PATCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF $ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default... //============================================================================================== // GLOBAL SETUP //============================================================================================== $ADODB_EXTENSION = defined(\\\'ADODB_EXTENSION\\\'); if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) { define(\\\'ADODB_BAD_RS\\\',\\\'

Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;

\\\'); // allow [ ] @ ` and . in table names define(\\\'ADODB_TABLE_REGEX\\\',\\\'([]0-9a-z_\\\\`\\\\.\\\\@\\\\[-]*)\\\'); // prefetching used by oracle if (!defined(\\\'ADODB_PREFETCH_ROWS\\\')) define(\\\'ADODB_PREFETCH_ROWS\\\',10); /* Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names. This currently works only with mssql, odbc, oci8po and ibase derived drivers. 0 = assoc lowercase field names. $rs->fields[\\\'orderid\\\'] 1 = assoc uppercase field names. $rs->fields[\\\'ORDERID\\\'] 2 = use native-case field names. $rs->fields[\\\'OrderID\\\'] */ define(\\\'ADODB_FETCH_DEFAULT\\\',0); define(\\\'ADODB_FETCH_NUM\\\',1); define(\\\'ADODB_FETCH_ASSOC\\\',2); define(\\\'ADODB_FETCH_BOTH\\\',3); if (!defined(\\\'TIMESTAMP_FIRST_YEAR\\\')) define(\\\'TIMESTAMP_FIRST_YEAR\\\',100); if (strnatcmp(PHP_VERSION,\\\'4.3.0\\\')>=0) { define(\\\'ADODB_PHPVER\\\',0x4300); } else if (strnatcmp(PHP_VERSION,\\\'4.2.0\\\')>=0) { define(\\\'ADODB_PHPVER\\\',0x4200); } else if (strnatcmp(PHP_VERSION,\\\'4.0.5\\\')>=0) { define(\\\'ADODB_PHPVER\\\',0x4050); } else { define(\\\'ADODB_PHPVER\\\',0x4000); } } //if (!defined(\\\'ADODB_ASSOC_CASE\\\')) define(\\\'ADODB_ASSOC_CASE\\\',2); /** Accepts $src and $dest arrays, replacing string $data */ function ADODB_str_replace($src, $dest, $data) { if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data); $s = reset($src); $d = reset($dest); while ($s !== false) { $data = str_replace($s,$d,$data); $s = next($src); $d = next($dest); } return $data; } function ADODB_Setup() { GLOBAL $ADODB_vers, // database version $ADODB_COUNTRECS, // count number of records returned - slows down query $ADODB_CACHE_DIR, // directory to cache recordsets $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT; if (!isset($ADODB_CACHE_DIR)) { $ADODB_CACHE_DIR = \\\'/tmp\\\'; } else { // do not accept url based paths, eg. http:/ or ftp:/ if (strpos($ADODB_CACHE_DIR,\\\'://\\\') !== false) die("Illegal path http:// or ftp://"); } // Initialize random number generator for randomizing cache flushes srand(((double)microtime())*1000000); /** * ADODB version as a string. */ $ADODB_vers = \\\'V4.05 13 Dec 2003 (c) 2000-2003 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.\\\'; /** * Determines whether recordset->RecordCount() is used. * Set to false for highest performance -- RecordCount() will always return -1 then * for databases that provide "virtual" recordcounts... */ if (!isset($ADODB_COUNTRECS)) $ADODB_COUNTRECS = true; } //============================================================================================== // CHANGE NOTHING BELOW UNLESS YOU ARE DESIGNING ADODB //============================================================================================== ADODB_Setup(); //============================================================================================== // CLASS ADOFieldObject //============================================================================================== /** * Helper class for FetchFields -- holds info on a column */ class ADOFieldObject { var $name = \\\'\\\'; var $max_length=0; var $type=""; // additional fields by dannym... (danny_milo@yahoo.com) var $not_null = false; // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^ // so we can as well make not_null standard (leaving it at "false" does not harm anyways) var $has_default = false; // this one I have done only in mysql and postgres for now ... // others to come (dannym) var $default_value; // default, if any, and supported. Check has_default first. } function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) { //print "Errorno ($fn errno=$errno m=$errmsg) "; $thisConnection->_transOK = false; if ($thisConnection->_oldRaiseFn) { $fn = $thisConnection->_oldRaiseFn; $fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection); } } //============================================================================================== // CLASS ADOConnection //============================================================================================== /** * Connection object. For connecting to databases, and executing queries. */ class ADOConnection { /************************************************************************************************************/ var $IsConnected = false; function QConnect() { $this->IsConnected = true; $this->connect( $GLOBALS[\\\'Conf\\\']->DB->Host, $GLOBALS[\\\'Conf\\\']->DB->User, $GLOBALS[\\\'Conf\\\']->DB->Password, $GLOBALS[\\\'Conf\\\']->DB->DataBase, $GLOBALS[\\\'Conf\\\']->DB->UseForse); } function QExecute($sql,$inputarr=false) { if (!$this->IsConnected) $this->QConnect(); $GLOBALS[\\\'sql_count\\\'] ++; return $this->Execute($sql,$inputarr); } function QSelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) { if (!$this->IsConnected) $this->QConnect(); $GLOBALS[\\\'sql_count\\\'] ++; return $this->SelectLimit($sql,$nrows,$offset, $inputarr,$secs2cache); } function Insert( $table, $values) { $sql = \\\'INSERT into \\\'.$table.\\\' (\\\'; $sql .= implode(",", array_keys($values)); $sql .= ") VALUES (\\\'"; $sql .= implode("\\\',\\\'", array_values($values)); $sql .= "\\\')"; return $this->QExecute($sql); } function Update( $table, $id, $values) { $sql = \\\'UPDATE \\\'.$table.\\\' SET \\\'; foreach($values as $filed => $value) { $sql .= \\\' \\\'.$filed.\\\' = \\\\\\\'\\\'.$value.\\\'\\\\\\\', \\\'; } $sql = substr($sql, 0, -2); $sql .= " WHERE id = ".$id; return $this->QExecute($sql); } function Delete( $table, $id ) { $sql = \\\'DELETE FROM \\\'.$table.\\\' WHERE id = \\\'.$id; return $this->QExecute($sql); } function QGetOne($sql,$inputarr=false) { $GLOBALS[\\\'sql_count\\\'] ++; return $this->GetOne($sql,$inputarr); } /************************************************************************************************************/ // // PUBLIC VARS // var $dataProvider = \\\'native\\\'; var $databaseType = \\\'\\\'; /// RDBMS currently in use, eg. odbc, mysql, mssql var $database = \\\'\\\'; /// Name of database to be used. var $host = \\\'\\\'; /// The hostname of the database server var $user = \\\'\\\'; /// The username which is used to connect to the database server. var $password = \\\'\\\'; /// Password for the username. For security, we no longer store it. var $debug = false; /// if set to true will output sql statements var $maxblobsize = 256000; /// maximum size of blobs or large text fields -- some databases die otherwise like foxpro var $concat_operator = \\\'+\\\'; /// default concat operator -- change to || for Oracle/Interbase var $substr = \\\'substr\\\'; /// substring operator var $length = \\\'length\\\'; /// string length operator var $random = \\\'rand()\\\'; /// random function var $upperCase = false; /// uppercase function var $fmtDate = "\\\'Y-m-d\\\'"; /// used by DBDate() as the default date format used by the database var $fmtTimeStamp = "\\\'Y-m-d, h:i:s A\\\'"; /// used by DBTimeStamp as the default timestamp fmt. var $true = \\\'1\\\'; /// string that represents TRUE for a database var $false = \\\'0\\\'; /// string that represents FALSE for a database var $replaceQuote = "\\\\\\\\\\\'"; /// string to use to replace quotes var $charSet=false; /// character set to use - only for interbase var $metaDatabasesSQL = \\\'\\\'; var $metaTablesSQL = \\\'\\\'; var $uniqueOrderBy = false; /// All order by columns have to be unique var $emptyDate = \\\' \\\'; var $emptyTimeStamp = \\\' \\\'; var $lastInsID = false; //-- var $hasInsertID = false; /// supports autoincrement ID? var $hasAffectedRows = false; /// supports affected rows for update/delete? var $hasTop = false; /// support mssql/access SELECT TOP 10 * FROM TABLE var $hasLimit = false; /// support pgsql/mysql SELECT * FROM TABLE LIMIT 10 var $readOnly = false; /// this is a readonly database - used by phpLens var $hasMoveFirst = false; /// has ability to run MoveFirst(), scrolling backwards var $hasGenID = false; /// can generate sequences using GenID(); var $hasTransactions = true; /// has transactions //-- var $genID = 0; /// sequence id used by GenID(); var $raiseErrorFn = false; /// error function to call var $isoDates = false; /// accepts dates in ISO format var $cacheSecs = 3600; /// cache for 1 hour var $sysDate = false; /// name of function that returns the current date var $sysTimeStamp = false; /// name of function that returns the current timestamp var $arrayClass = \\\'ADORecordSet_array\\\'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets var $noNullStrings = false; /// oracle specific stuff - if true ensures that \\\'\\\' is converted to \\\' \\\' var $numCacheHits = 0; var $numCacheMisses = 0; var $pageExecuteCountRows = true; var $uniqueSort = false; /// indicates that all fields in order by must be unique var $leftOuter = false; /// operator to use for left outer join in WHERE clause var $rightOuter = false; /// operator to use for right outer join in WHERE clause var $ansiOuter = false; /// whether ansi outer join syntax supported var $autoRollback = false; // autoRollback on PConnect(). var $poorAffectedRows = false; // affectedRows not working or unreliable var $fnExecute = false; var $fnCacheExecute = false; var $blobEncodeType = false; // false=not required, \\\'I\\\'=encode to integer, \\\'C\\\'=encode to char var $rsPrefix = "ADORecordSet_"; var $autoCommit = true; /// do not modify this yourself - actually private var $transOff = 0; /// temporarily disable transactions var $transCnt = 0; /// count of nested transactions var $fetchMode=false; // // PRIVATE VARS // var $_oldRaiseFn = false; var $_transOK = null; var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. var $_errorMsg = false; /// A variable which was used to keep the returned last error message. The value will /// then returned by the errorMsg() function var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8 var $_queryID = false; /// This variable keeps the last created result link identifier var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */ var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters. var $_evalAll = false; var $_affected = false; var $_logsql = false; /** * Constructor */ function ADOConnection() { die(\\\'Virtual Class -- cannot instantiate\\\'); } /** Get server version info... @returns An array with 2 elements: $arr[\\\'string\\\'] is the description string, and $arr[version] is the version (also a string). */ function ServerInfo() { return array(\\\'description\\\' => \\\'\\\', \\\'version\\\' => \\\'\\\'); } function _findvers($str) { if (preg_match(\\\'/([0-9]+\\\\.([0-9\\\\.])+)/\\\',$str, $arr)) return $arr[1]; else return \\\'\\\'; } /** * All error messages go through this bottleneck function. * You can define your own handler by defining the function name in ADODB_OUTP. */ function outp($msg,$newline=true) { global $HTTP_SERVER_VARS,$ADODB_FLUSH; if (defined(\\\'ADODB_OUTP\\\')) { $fn = ADODB_OUTP; $fn($msg,$newline); return; } if ($newline) $msg .= "
\\\\n"; if (isset($HTTP_SERVER_VARS[\\\'HTTP_USER_AGENT\\\'])) echo $msg; else echo strip_tags($msg); if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // dp not flush if output buffering enabled - useless - thx to Jesse Mullan } /** * Connect to database * * @param [argHostname] Host to connect to * @param [argUsername] Userid to login * @param [argPassword] Associated password * @param [argDatabaseName] database * @param [forceNew] force new connection * * @return true or false */ function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false) { if ($argHostname != "") $this->host = $argHostname; if ($argUsername != "") $this->user = $argUsername; if ($argPassword != "") $this->password = $argPassword; // not stored for security reasons if ($argDatabaseName != "") $this->database = $argDatabaseName; $this->_isPersistentConnection = false; if ($fn = $this->raiseErrorFn) { if ($forceNew) { if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; } else { if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; } $err = $this->ErrorMsg(); if (empty($err)) $err = "Connection error to server \\\'$argHostname\\\' with user \\\'$argUsername\\\'"; $fn($this->databaseType,\\\'CONNECT\\\',$this->ErrorNo(),$err,$this->host,$this->database,$this); } else { if ($forceNew) { if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; } else { if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; } } if ($this->debug) ADOConnection::outp( $this->host.\\\': \\\'.$this->ErrorMsg()); return false; } function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) { return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName); } /** * Always force a new connection to database - currently only works with oracle * * @param [argHostname] Host to connect to * @param [argUsername] Userid to login * @param [argPassword] Associated password * @param [argDatabaseName] database * * @return true or false */ function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") { return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName, true); } /** * Establish persistent connect to database * * @param [argHostname] Host to connect to * @param [argUsername] Userid to login * @param [argPassword] Associated password * @param [argDatabaseName] database * * @return return true or false */ function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") { if (defined(\\\'ADODB_NEVER_PERSIST\\\')) return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName); if ($argHostname != "") $this->host = $argHostname; if ($argUsername != "") $this->user = $argUsername; if ($argPassword != "") $this->password = $argPassword; if ($argDatabaseName != "") $this->database = $argDatabaseName; $this->_isPersistentConnection = true; if ($fn = $this->raiseErrorFn) { if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; $err = $this->ErrorMsg(); if (empty($err)) $err = "Connection error to server \\\'$argHostname\\\' with user \\\'$argUsername\\\'"; $fn($this->databaseType,\\\'PCONNECT\\\',$this->ErrorNo(),$err,$this->host,$this->database,$this); } else if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; if ($this->debug) ADOConnection::outp( $this->host.\\\': \\\'.$this->ErrorMsg()); return false; } // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) { if (!$col) $col = $this->sysDate; return $col; // child class implement } /** * Should prepare the sql statement and return the stmt resource. * For databases that do not support this, we return the $sql. To ensure * compatibility with databases that do not support prepare: * * $stmt = $db->Prepare("insert into table (id, name) values (?,?)"); * $db->Execute($stmt,array(1,\\\'Jill\\\')) or die(\\\'insert failed\\\'); * $db->Execute($stmt,array(2,\\\'Joe\\\')) or die(\\\'insert failed\\\'); * * @param sql SQL to send to database * * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. * */ function Prepare($sql) { return $sql; } /** * Some databases, eg. mssql require a different function for preparing * stored procedures. So we cannot use Prepare(). * * Should prepare the stored procedure and return the stmt resource. * For databases that do not support this, we return the $sql. To ensure * compatibility with databases that do not support prepare: * * @param sql SQL to send to database * * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. * */ function PrepareSP($sql) { return $this->Prepare($sql); } /** * PEAR DB Compat */ function Quote($s) { return $this->qstr($s,false); } /** Requested by "Karsten Dambekalns" */ function QMagic($s) { return $this->qstr($s,get_magic_quotes_gpc()); } function q(&$s) { $s = $this->qstr($s,false); } /** * PEAR DB Compat - do not use internally. */ function ErrorNative() { return $this->ErrorNo(); } /** * PEAR DB Compat - do not use internally. */ function nextId($seq_name) { return $this->GenID($seq_name); } /** * Lock a row, will escalate and lock the table if row locking not supported * will normally free the lock at the end of the transaction * * @param $table name of table to lock * @param $where where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock */ function RowLock($table,$where) { return false; } function CommitLock($table) { return $this->CommitTrans(); } function RollbackLock($table) { return $this->RollbackTrans(); } /** * PEAR DB Compat - do not use internally. * * The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical * for easy porting :-) * * @param mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM * @returns The previous fetch mode */ function SetFetchMode($mode) { $old = $this->fetchMode; $this->fetchMode = $mode; if ($old === false) { global $ADODB_FETCH_MODE; return $ADODB_FETCH_MODE; } return $old; } /** * PEAR DB Compat - do not use internally. */ function &Query($sql, $inputarr=false) { $rs = &$this->Execute($sql, $inputarr); if (!$rs && defined(\\\'ADODB_PEAR\\\')) return ADODB_PEAR_Error(); return $rs; } /** * PEAR DB Compat - do not use internally */ function &LimitQuery($sql, $offset, $count, $params=false) { $rs = &$this->SelectLimit($sql, $count, $offset, $params); if (!$rs && defined(\\\'ADODB_PEAR\\\')) return ADODB_PEAR_Error(); return $rs; } /** * PEAR DB Compat - do not use internally */ function Disconnect() { return $this->Close(); } /* returns placeholder for parameter, eg. $DB->Param(\\\'a\\\') will return \\\':a\\\' for Oracle, and \\\'?\\\' for most other databases... */ function Param($name) { return \\\'?\\\'; } /* Usage in oracle $stmt = $db->Prepare(\\\'select * from table where id =:myid and group=:group\\\'); $db->Parameter($stmt,$id,\\\'myid\\\'); $db->Parameter($stmt,$group,\\\'group\\\',64); $db->Execute(); @param $stmt Statement returned by Prepare() or PrepareSP(). @param $var PHP variable to bind to @param $name Name of stored procedure variable name to bind to. @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. @param [$maxLen] Holds an maximum length of the variable. @param [$type] The data type of $var. Legal values depend on driver. */ function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) { return false; } /** Improved method of initiating a transaction. Used together with CompleteTrans(). Advantages include: a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans. Only the outermost block is treated as a transaction.
b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.
c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block are disabled, making it backward compatible. */ function StartTrans($errfn = \\\'ADODB_TransMonitor\\\') { if ($this->transOff > 0) { $this->transOff += 1; return; } $this->_oldRaiseFn = $this->raiseErrorFn; $this->raiseErrorFn = $errfn; $this->_transOK = true; if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans"); $this->BeginTrans(); $this->transOff = 1; } /** Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate. @autoComplete if true, monitor sql errors and commit and rollback as appropriate, and if set to false force rollback even if no SQL error detected. @returns true on commit, false on rollback. */ function CompleteTrans($autoComplete = true) { if ($this->transOff > 1) { $this->transOff -= 1; return true; } $this->raiseErrorFn = $this->_oldRaiseFn; $this->transOff = 0; if ($this->_transOK && $autoComplete) { $this->CommitTrans(); if ($this->debug) ADOConnection::outp("Smart Commit occurred"); } else { $this->RollbackTrans(); if ($this->debug) ADOCOnnection::outp("Smart Rollback occurred"); } return $this->_transOK; } /* At the end of a StartTrans/CompleteTrans block, perform a rollback. */ function FailTrans() { if ($this->debug) if ($this->transOff == 0) { ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans"); } else { ADOConnection::outp("FailTrans was called"); adodb_backtrace(); } $this->_transOK = false; } /** Check if transaction has failed, only for Smart Transactions. */ function HasFailedTrans() { if ($this->transOff > 0) return $this->_transOK == false; return false; } /** * Execute SQL * * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) * @param [inputarr] holds the input data to bind to. Null elements will be set to null. * @return RecordSet or false */ function &Execute($sql,$inputarr=false) { if ($this->fnExecute) { $fn = $this->fnExecute; $ret =& $fn($this,$sql,$inputarr); if (isset($ret)) return $ret; } if ($inputarr && is_array($inputarr)) { $element0 = reset($inputarr); # is_object check is because oci8 descriptors can be passed in $array_2d = is_array($element0) && !is_object(reset($element0)); if (!is_array($sql) && !$this->_bindInputArray) { $sqlarr = explode(\\\'?\\\',$sql); if (!$array_2d) $inputarr = array($inputarr); foreach($inputarr as $arr) { $sql = \\\'\\\'; $i = 0; foreach($arr as $v) { $sql .= $sqlarr[$i]; // from Ron Baldwin // Only quote string types if (gettype($v) == \\\'string\\\') $sql .= $this->qstr($v); else if ($v === null) $sql .= \\\'NULL\\\'; else $sql .= $v; $i += 1; } $sql .= $sqlarr[$i]; if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql)); $ret =& $this->_Execute($sql,false); if (!$ret) return $ret; } } else { if ($array_2d) { $stmt = $this->Prepare($sql); foreach($inputarr as $arr) { $ret =& $this->_Execute($stmt,$arr); if (!$ret) return $ret; } } else $ret =& $this->_Execute($sql,$inputarr); } } else { $ret =& $this->_Execute($sql,false); } return $ret; } function& _Execute($sql,$inputarr=false) { // debug version of query if ($this->debug) { global $HTTP_SERVER_VARS; $ss = \\\'\\\'; if ($inputarr) { foreach($inputarr as $kk=>$vv) { if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).\\\'...\\\'; $ss .= "($kk=>\\\'$vv\\\') "; } $ss = "[ $ss ]"; } $sqlTxt = str_replace(\\\',\\\',\\\', \\\',is_array($sql) ?$sql[0] : $sql); // check if running from browser or command-line $inBrowser = isset($HTTP_SERVER_VARS[\\\'HTTP_USER_AGENT\\\']); if ($inBrowser) if ($this->debug === -1) ADOConnection::outp( "
\\\\n($this->databaseType): ".htmlspecialchars($sqlTxt)."   $ss\\\\n
\\\\n",false); else ADOConnection::outp( "
\\\\n($this->databaseType): ".htmlspecialchars($sqlTxt)."   $ss\\\\n
\\\\n",false); else ADOConnection::outp( "=----\\\\n($this->databaseType): ".($sqlTxt)." \\\\n-----\\\\n",false); $this->_queryID = $this->_query($sql,$inputarr); /* Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql because ErrorNo() calls Execute(\\\'SELECT @ERROR\\\'), causing recure */ if ($this->databaseType == \\\'mssql\\\') { // ErrorNo is a slow function call in mssql, and not reliable // in PHP 4.0.6 if($emsg = $this->ErrorMsg()) { $err = $this->ErrorNo(); if ($err) { ADOConnection::outp($err.\\\': \\\'.$emsg); } } } else if (!$this->_queryID) { $e = $this->ErrorNo(); $m = $this->ErrorMsg(); ADOConnection::outp($e .\\\': \\\'. $m ); } } else { // non-debug version of query $this->_queryID =@$this->_query($sql,$inputarr); } /************************ OK, query executed *************************/ // error handling if query fails if ($this->_queryID === false) { if ($this->debug == 99) adodb_backtrace(true,5); $fn = $this->raiseErrorFn; if ($fn) { $fn($this->databaseType,\\\'EXECUTE\\\',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this); } return false; } else if ($this->_queryID === true) { // return simplified empty recordset for inserts/updates/deletes with lower overhead $rs =& new ADORecordSet_empty(); return $rs; } // return real recordset from select statement $rsclass = $this->rsPrefix.$this->databaseType; $rs =& new $rsclass($this->_queryID,$this->fetchMode); // &new not supported by older PHP versions $rs->connection = &$this; // Pablo suggestion $rs->Init(); if (is_array($sql)) $rs->sql = $sql[0]; else $rs->sql = $sql; if ($rs->_numOfRows <= 0) { global $ADODB_COUNTRECS; if ($ADODB_COUNTRECS) { if (!$rs->EOF){ $rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql)); $rs->_queryID = $this->_queryID; } else $rs->_numOfRows = 0; } } return $rs; } function CreateSequence($seqname=\\\'adodbseq\\\',$startID=1) { if (empty($this->_genSeqSQL)) return false; return $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID)); } function DropSequence($seqname) { if (empty($this->_dropSeqSQL)) return false; return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); } /** * Generates a sequence id and stores it in $this->genID; * GenID is only available if $this->hasGenID = true; * * @param seqname name of sequence to use * @param startID if sequence does not exist, start at this ID * @return 0 if not supported, otherwise a sequence id */ function GenID($seqname=\\\'adodbseq\\\',$startID=1) { if (!$this->hasGenID) { return 0; // formerly returns false pre 1.60 } $getnext = sprintf($this->_genIDSQL,$seqname); $holdtransOK = $this->_transOK; $rs = @$this->Execute($getnext); if (!$rs) { if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset $createseq = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID)); $rs = $this->Execute($getnext); } if ($rs && !$rs->EOF) $this->genID = reset($rs->fields); else $this->genID = 0; // false if ($rs) $rs->Close(); return $this->genID; } /** * @return the last inserted ID. Not all databases support this. */ function Insert_ID() { if ($this->_logsql && $this->lastInsID) return $this->lastInsID; if ($this->hasInsertID) return $this->_insertid(); if ($this->debug) { ADOConnection::outp( \\\'

Insert_ID error

\\\'); adodb_backtrace(); } return false; } /** * Portable Insert ID. Pablo Roca * * @return the last inserted ID. All databases support this. But aware possible * problems in multiuser environments. Heavy test this before deploying. */ function PO_Insert_ID($table="", $id="") { if ($this->hasInsertID){ return $this->Insert_ID(); } else { return $this->GetOne("SELECT MAX($id) FROM $table"); } } /** * @return # rows affected by UPDATE/DELETE */ function Affected_Rows() { if ($this->hasAffectedRows) { if ($this->fnExecute === \\\'adodb_log_sql\\\') { if ($this->_logsql && $this->_affected !== false) return $this->_affected; } $val = $this->_affectedrows(); return ($val < 0) ? false : $val; } if ($this->debug) ADOConnection::outp( \\\'

Affected_Rows error

\\\',false); return false; } /** * @return the last error message */ function ErrorMsg() { return \\\'!! \\\'.strtoupper($this->dataProvider.\\\' \\\'.$this->databaseType).\\\': \\\'.$this->_errorMsg; } /** * @return the last error number. Normally 0 means no error. */ function ErrorNo() { return ($this->_errorMsg) ? -1 : 0; } function MetaError($err=false) { include_once(ADODB_DIR."/adodb-error.inc.php"); if ($err === false) $err = $this->ErrorNo(); return adodb_error($this->dataProvider,$this->databaseType,$err); } function MetaErrorMsg($errno) { include_once(ADODB_DIR."/adodb-error.inc.php"); return adodb_errormsg($errno); } /** * @returns an array with the primary key columns in it. */ function MetaPrimaryKeys($table, $owner=false) { // owner not used in base class - see oci8 $p = array(); $objs =& $this->MetaColumns($table); if ($objs) { foreach($objs as $v) { if (!empty($v->primary_key)) $p[] = $v->name; } } if (sizeof($p)) return $p; return false; } /** * @returns assoc array where keys are tables, and values are foreign keys */ function MetaForeignKeys($table, $owner=false, $upper=false) { return false; } /** * Choose a database to connect to. Many databases do not support this. * * @param dbName is the name of the database to select * @return true or false */ function SelectDB($dbName) {return false;} /** * Will select, getting rows from $offset (1-based), for $nrows. * This simulates the MySQL "select * from table limit $offset,$nrows" , and * the PostgreSQL "select * from table limit $nrows offset $offset". Note that * MySQL and PostgreSQL parameter ordering is the opposite of the other. * eg. * SelectLimit(\\\'select * from table\\\',3); will return rows 1 to 3 (1-based) * SelectLimit(\\\'select * from table\\\',3,2); will return rows 3 to 5 (1-based) * * Uses SELECT TOP for Microsoft databases (when $this->hasTop is set) * BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set * * @param sql * @param [offset] is the row to start calculations from (1-based) * @param [nrows] is the number of rows to get * @param [inputarr] array of bind variables * @param [secs2cache] is a private parameter only used by jlim * @return the recordset ($rs->databaseType == \\\'array\\\') */ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) { if ($this->hasTop && $nrows > 0) { // suggested by Reinhard Balling. Access requires top after distinct // Informix requires first before distinct - F Riosa $ismssql = (strpos($this->databaseType,\\\'mssql\\\') !== false); if ($ismssql) $isaccess = false; else $isaccess = (strpos($this->databaseType,\\\'access\\\') !== false); if ($offset <= 0) { // access includes ties in result if ($isaccess) { $sql = preg_replace( \\\'/(^\\\\s*select\\\\s+(distinctrow|distinct)?)/i\\\',\\\'\\\\\\\\1 \\\'.$this->hasTop.\\\' \\\'.$nrows.\\\' \\\',$sql); if ($secs2cache>0) { $ret =& $this->CacheExecute($secs2cache, $sql,$inputarr); } else { $ret =& $this->Execute($sql,$inputarr); } return $ret; // PHP5 fix } else if ($ismssql){ $sql = preg_replace( \\\'/(^\\\\s*select\\\\s+(distinctrow|distinct)?)/i\\\',\\\'\\\\\\\\1 \\\'.$this->hasTop.\\\' \\\'.$nrows.\\\' \\\',$sql); } else { $sql = preg_replace( \\\'/(^\\\\s*select\\\\s)/i\\\',\\\'\\\\\\\\1 \\\'.$this->hasTop.\\\' \\\'.$nrows.\\\' \\\',$sql); } } else { $nn = $nrows + $offset; if ($isaccess || $ismssql) { $sql = preg_replace( \\\'/(^\\\\s*select\\\\s+(distinctrow|distinct)?)/i\\\',\\\'\\\\\\\\1 \\\'.$this->hasTop.\\\' \\\'.$nn.\\\' \\\',$sql); } else { $sql = preg_replace( \\\'/(^\\\\s*select\\\\s)/i\\\',\\\'\\\\\\\\1 \\\'.$this->hasTop.\\\' \\\'.$nn.\\\' \\\',$sql); } } } // if $offset>0, we want to skip rows, and $ADODB_COUNTRECS is set, we buffer rows // 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS. global $ADODB_COUNTRECS; $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; if ($offset>0){ if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); else $rs = &$this->Execute($sql,$inputarr); } else { if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); else $rs = &$this->Execute($sql,$inputarr); } $ADODB_COUNTRECS = $savec; if ($rs && !$rs->EOF) { $rs =& $this->_rs2rs($rs,$nrows,$offset); } //print_r($rs); return $rs; } /** * Convert database recordset to an array recordset * input recordset\\\'s cursor should be at beginning, and * old $rs will be closed. * * @param rs the recordset to copy * @param [nrows] number of rows to retrieve (optional) * @param [offset] offset by number of rows (optional) * @return the new recordset */ function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true) { if (! $rs) return false; $dbtype = $rs->databaseType; if (!$dbtype) { $rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ? return $rs; } if (($dbtype == \\\'array\\\' || $dbtype == \\\'csv\\\') && $nrows == -1 && $offset == -1) { $rs->MoveFirst(); $rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1-- why ? return $rs; } $flds = array(); for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) { $flds[] = $rs->FetchField($i); } $arr =& $rs->GetArrayLimit($nrows,$offset); //print_r($arr); if ($close) $rs->Close(); $arrayClass = $this->arrayClass; $rs2 =& new $arrayClass(); $rs2->connection = &$this; $rs2->sql = $rs->sql; $rs2->dataProvider = $this->dataProvider; $rs2->InitArrayFields($arr,$flds); return $rs2; } /* * Return all rows. Compat with PEAR DB */ function &GetAll($sql, $inputarr=false) { $arr =& $this->GetArray($sql,$inputarr); return $arr; } function &GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false) { $rs =& $this->Execute($sql, $inputarr); if (!$rs) return false; $arr =& $rs->GetAssoc($force_array,$first2cols); return $arr; } function &CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false) { if (!is_numeric($secs2cache)) { $first2cols = $force_array; $force_array = $inputarr; } $rs =& $this->CacheExecute($secs2cache, $sql, $inputarr); if (!$rs) return false; $arr =& $rs->GetAssoc($force_array,$first2cols); return $arr; } /** * Return first element of first row of sql statement. Recordset is disposed * for you. * * @param sql SQL statement * @param [inputarr] input bind array */ function GetOne($sql,$inputarr=false) { global $ADODB_COUNTRECS; $crecs = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $ret = false; $rs = &$this->Execute($sql,$inputarr); if ($rs) { if (!$rs->EOF) $ret = reset($rs->fields); $rs->Close(); } $ADODB_COUNTRECS = $crecs; return $ret; } function CacheGetOne($secs2cache,$sql=false,$inputarr=false) { $ret = false; $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); if ($rs) { if (!$rs->EOF) $ret = reset($rs->fields); $rs->Close(); } return $ret; } function GetCol($sql, $inputarr = false, $trim = false) { $rv = false; $rs = &$this->Execute($sql, $inputarr); if ($rs) { $rv = array(); if ($trim) { while (!$rs->EOF) { $rv[] = trim(reset($rs->fields)); $rs->MoveNext(); } } else { while (!$rs->EOF) { $rv[] = reset($rs->fields); $rs->MoveNext(); } } $rs->Close(); } return $rv; } function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false) { $rv = false; $rs = &$this->CacheExecute($secs, $sql, $inputarr); if ($rs) { if ($trim) { while (!$rs->EOF) { $rv[] = trim(reset($rs->fields)); $rs->MoveNext(); } } else { while (!$rs->EOF) { $rv[] = reset($rs->fields); $rs->MoveNext(); } } $rs->Close(); } return $rv; } /* Calculate the offset of a date for a particular database and generate appropriate SQL. Useful for calculating future/past dates and storing in a database. If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour. */ function OffsetDate($dayFraction,$date=false) { if (!$date) $date = $this->sysDate; return \\\'(\\\'.$date.\\\'+\\\'.$dayFraction.\\\')\\\'; } /** * * @param sql SQL statement * @param [inputarr] input bind array */ function &GetArray($sql,$inputarr=false) { global $ADODB_COUNTRECS; $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $rs =& $this->Execute($sql,$inputarr); $ADODB_COUNTRECS = $savec; if (!$rs) if (defined(\\\'ADODB_PEAR\\\')) return ADODB_PEAR_Error(); else return false; $arr =& $rs->GetArray(); $rs->Close(); return $arr; } function &CacheGetAll($secs2cache,$sql=false,$inputarr=false) { global $ADODB_COUNTRECS; $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $rs =& $this->CacheExecute($secs2cache,$sql,$inputarr); $ADODB_COUNTRECS = $savec; if (!$rs) if (defined(\\\'ADODB_PEAR\\\')) return ADODB_PEAR_Error(); else return false; $arr =& $rs->GetArray(); $rs->Close(); return $arr; } /** * Return one row of sql statement. Recordset is disposed for you. * * @param sql SQL statement * @param [inputarr] input bind array */ function &GetRow($sql,$inputarr=false) { global $ADODB_COUNTRECS; $crecs = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $rs =& $this->Execute($sql,$inputarr); $ADODB_COUNTRECS = $crecs; if ($rs) { if (!$rs->EOF) $arr = $rs->fields; else $arr = array(); $rs->Close(); return $arr; } return false; } function &CacheGetRow($secs2cache,$sql=false,$inputarr=false) { $rs =& $this->CacheExecute($secs2cache,$sql,$inputarr); if ($rs) { $arr = false; if (!$rs->EOF) $arr = $rs->fields; $rs->Close(); return $arr; } return false; } /** * Insert or replace a single record. Note: this is not the same as MySQL\\\'s replace. * ADOdb\\\'s Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL. * Also note that no table locking is done currently, so it is possible that the * record be inserted twice by two programs... * * $this->Replace(\\\'products\\\', array(\\\'prodname\\\' =>"\\\'Nails\\\'","price" => 3.99), \\\'prodname\\\'); * * $table table name * $fieldArray associative array of data (you must quote strings yourself). * $keyCol the primary key field name or if compound key, array of field names * autoQuote set to true to use a hueristic to quote strings. Works with nulls and numbers * but does not work with dates nor SQL functions. * has_autoinc the primary key is an auto-inc field, so skip in insert. * * Currently blob replace not supported * * returns 0 = fail, 1 = update, 2 = insert */ function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false) { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.\\\'/adodb-lib.inc.php\\\'); return _adodb_replace($this, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc); } /** * Will select, getting rows from $offset (1-based), for $nrows. * This simulates the MySQL "select * from table limit $offset,$nrows" , and * the PostgreSQL "select * from table limit $nrows offset $offset". Note that * MySQL and PostgreSQL parameter ordering is the opposite of the other. * eg. * CacheSelectLimit(15,\\\'select * from table\\\',3); will return rows 1 to 3 (1-based) * CacheSelectLimit(15,\\\'select * from table\\\',3,2); will return rows 3 to 5 (1-based) * * BUG: Currently CacheSelectLimit fails with $sql with LIMIT or TOP clause already set * * @param [secs2cache] seconds to cache data, set to 0 to force query. This is optional * @param sql * @param [offset] is the row to start calculations from (1-based) * @param [nrows] is the number of rows to get * @param [inputarr] array of bind variables * @return the recordset ($rs->databaseType == \\\'array\\\') */ function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false) { if (!is_numeric($secs2cache)) { if ($sql === false) $sql = -1; if ($offset == -1) $offset = false; // sql, nrows, offset,inputarr $rs =& $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$inputarr,$this->cacheSecs); } else { if ($sql === false) ADOConnection::outp( "Warning: \\\\$sql missing from CacheSelectLimit()"); $rs =& $this->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); } return $rs; } /** * Flush cached recordsets that match a particular $sql statement. * If $sql == false, then we purge all files in the cache. */ function CacheFlush($sql=false,$inputarr=false) { global $ADODB_CACHE_DIR; if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) { if (strncmp(PHP_OS,\\\'WIN\\\',3) === 0) { $cmd = \\\'del /s \\\'.str_replace(\\\'/\\\',\\\'\\\\\\\\\\\',$ADODB_CACHE_DIR).\\\'\\\\adodb_*.cache\\\'; } else { $cmd = \\\'rm -rf \\\'.$ADODB_CACHE_DIR.\\\'/??/adodb_*.cache\\\'; // old version \\\'rm -f `find \\\'.$ADODB_CACHE_DIR.\\\' -name adodb_*.cache`\\\'; } if ($this->debug) { ADOConnection::outp( "CacheFlush: $cmd
\\\\n", system($cmd),"
"); } else { exec($cmd); } return; } $f = $this->_gencachename($sql.serialize($inputarr),false); adodb_write_file($f,\\\'\\\'); // is adodb_write_file needed? if (!@unlink($f)) { if ($this->debug) ADOConnection::outp( "CacheFlush: failed for $f"); } } /** * Private function to generate filename for caching. * Filename is generated based on: * * - sql statement * - database type (oci8, ibase, ifx, etc) * - database name * - userid * * We create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR). * Assuming that we can have 50,000 files per directory with good performance, * then we can scale to 12.8 million unique cached recordsets. Wow! */ function _gencachename($sql,$createdir) { global $ADODB_CACHE_DIR; $m = md5($sql.$this->databaseType.$this->database.$this->user); $dir = $ADODB_CACHE_DIR.\\\'/\\\'.substr($m,0,2); if ($createdir && !file_exists($dir)) { $oldu = umask(0); if (!mkdir($dir,0771)) if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql"); umask($oldu); } return $dir.\\\'/adodb_\\\'.$m.\\\'.cache\\\'; } /** * Execute SQL, caching recordsets. * * @param [secs2cache] seconds to cache data, set to 0 to force query. * This is an optional parameter. * @param sql SQL statement to execute * @param [inputarr] holds the input data to bind to * @return RecordSet or false */ function &CacheExecute($secs2cache,$sql=false,$inputarr=false) { if (!is_numeric($secs2cache)) { $inputarr = $sql; $sql = $secs2cache; $secs2cache = $this->cacheSecs; } global $ADODB_INCLUDED_CSV; if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.\\\'/adodb-csvlib.inc.php\\\'); if (is_array($sql)) $sql = $sql[0]; $md5file = $this->_gencachename($sql.serialize($inputarr),true); $err = \\\'\\\'; if ($secs2cache > 0){ $rs = &csv2rs($md5file,$err,$secs2cache); $this->numCacheHits += 1; } else { $err=\\\'Timeout 1\\\'; $rs = false; $this->numCacheMisses += 1; } if (!$rs) { // no cached rs found if ($this->debug) { if (get_magic_quotes_runtime()) { ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :("); } if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (see sql below)"); } $rs = &$this->Execute($sql,$inputarr); if ($rs) { $eof = $rs->EOF; $rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately $txt = _rs2serialize($rs,false,$sql); // serialize if (!adodb_write_file($md5file,$txt,$this->debug)) { if ($fn = $this->raiseErrorFn) { $fn($this->databaseType,\\\'CacheExecute\\\',-32000,"Cache write error",$md5file,$sql,$this); } if ($this->debug) ADOConnection::outp( " Cache write error"); } if ($rs->EOF && !$eof) { $rs->MoveFirst(); //$rs = &csv2rs($md5file,$err); $rs->connection = &$this; // Pablo suggestion } } else @unlink($md5file); } else { $this->_errorMsg = \\\'\\\'; $this->_errorCode = 0; if ($this->fnCacheExecute) { $fn = $this->fnCacheExecute; $fn($this, $secs2cache, $sql, $inputarr); } // ok, set cached object found $rs->connection = &$this; // Pablo suggestion if ($this->debug){ global $HTTP_SERVER_VARS; $inBrowser = isset($HTTP_SERVER_VARS[\\\'HTTP_USER_AGENT\\\']); $ttl = $rs->timeCreated + $secs2cache - time(); $s = is_array($sql) ? $sql[0] : $sql; if ($inBrowser) $s = \\\'\\\'.htmlspecialchars($s).\\\'\\\'; ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]"); } } return $rs; } /** * Generates an Update Query based on an existing recordset. * $arrFields is an associative array of fields with the value * that should be assigned. * * Note: This function should only be used on a recordset * that is run against a single table and sql should only * be a simple select stmt with no groupby/orderby/limit * * "Jonathan Younger" */ function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false) { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.\\\'/adodb-lib.inc.php\\\'); return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq); } /** * Generates an Insert Query based on an existing recordset. * $arrFields is an associative array of fields with the value * that should be assigned. * * Note: This function should only be used on a recordset * that is run against a single table. */ function GetInsertSQL(&$rs, $arrFields,$magicq=false) { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.\\\'/adodb-lib.inc.php\\\'); return _adodb_getinsertsql($this,$rs,$arrFields,$magicq); } /** * Update a blob column, given a where clause. There are more sophisticated * blob handling functions that we could have implemented, but all require * a very complex API. Instead we have chosen something that is extremely * simple to understand and use. * * Note: $blobtype supports \\\'BLOB\\\' and \\\'CLOB\\\', default is BLOB of course. * * Usage to update a $blobvalue which has a primary key blob_id=1 into a * field blobtable.blobcolumn: * * UpdateBlob(\\\'blobtable\\\', \\\'blobcolumn\\\', $blobvalue, \\\'blob_id=1\\\'); * * Insert example: * * $conn->Execute(\\\'INSERT INTO blobtable (id, blobcol) VALUES (1, null)\\\'); * $conn->UpdateBlob(\\\'blobtable\\\',\\\'blobcol\\\',$blob,\\\'id=1\\\'); */ function UpdateBlob($table,$column,$val,$where,$blobtype=\\\'BLOB\\\') { return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false; } /** * Usage: * UpdateBlob(\\\'TABLE\\\', \\\'COLUMN\\\', \\\'/path/to/file\\\', \\\'ID=1\\\'); * * $blobtype supports \\\'BLOB\\\' and \\\'CLOB\\\' * * $conn->Execute(\\\'INSERT INTO blobtable (id, blobcol) VALUES (1, null)\\\'); * $conn->UpdateBlob(\\\'blobtable\\\',\\\'blobcol\\\',$blobpath,\\\'id=1\\\'); */ function UpdateBlobFile($table,$column,$path,$where,$blobtype=\\\'BLOB\\\') { $fd = fopen($path,\\\'rb\\\'); if ($fd === false) return false; $val = fread($fd,filesize($path)); fclose($fd); return $this->UpdateBlob($table,$column,$val,$where,$blobtype); } function BlobDecode($blob) { return $blob; } function BlobEncode($blob) { return $blob; } function SetCharSet($charset) { return false; } function IfNull( $field, $ifNull ) { return " CASE WHEN $field is null THEN $ifNull ELSE $field END "; } function LogSQL($enable=true) { include_once(ADODB_DIR.\\\'/adodb-perf.inc.php\\\'); if ($enable) $this->fnExecute = \\\'adodb_log_sql\\\'; else $this->fnExecute = false; $old = $this->_logsql; $this->_logsql = $enable; if ($enable && !$old) $this->_affected = false; return $old; } function GetCharSet() { return false; } /** * Usage: * UpdateClob(\\\'TABLE\\\', \\\'COLUMN\\\', $var, \\\'ID=1\\\', \\\'CLOB\\\'); * * $conn->Execute(\\\'INSERT INTO clobtable (id, clobcol) VALUES (1, null)\\\'); * $conn->UpdateClob(\\\'clobtable\\\',\\\'clobcol\\\',$clob,\\\'id=1\\\'); */ function UpdateClob($table,$column,$val,$where) { return $this->UpdateBlob($table,$column,$val,$where,\\\'CLOB\\\'); } /** * Change the SQL connection locale to a specified locale. * This is used to get the date formats written depending on the client locale. */ function SetDateLocale($locale = \\\'En\\\') { $this->locale = $locale; switch ($locale) { default: case \\\'En\\\': $this->fmtDate="Y-m-d"; $this->fmtTimeStamp = "Y-m-d H:i:s"; break; case \\\'Fr\\\': case \\\'Ro\\\': case \\\'It\\\': $this->fmtDate="d-m-Y"; $this->fmtTimeStamp = "d-m-Y H:i:s"; break; case \\\'Ge\\\': $this->fmtDate="d.m.Y"; $this->fmtTimeStamp = "d.m.Y H:i:s"; break; } } /** * $meta contains the desired type, which could be... * C for character. You will have to define the precision yourself. * X for teXt. For unlimited character lengths. * B for Binary * F for floating point, with no need to define scale and precision * N for decimal numbers, you will have to define the (scale, precision) yourself * D for date * T for timestamp * L for logical/Boolean * I for integer * R for autoincrement counter/integer * and if you want to use double-byte, add a 2 to the end, like C2 or X2. * * * @return the actual type of the data or false if no such type available */ function ActualType($meta) { switch($meta) { case \\\'C\\\': case \\\'X\\\': return \\\'VARCHAR\\\'; case \\\'B\\\': case \\\'D\\\': case \\\'T\\\': case \\\'L\\\': case \\\'R\\\': case \\\'I\\\': case \\\'N\\\': return false; } } /* * Maximum size of C field * function CharMax() { return 255; // make it conservative if not defined } /* * Maximum size of X field * function TextMax() { return 4000; // make it conservative if not defined } */ /** * Close Connection */ function Close() { return $this->_close(); // "Simon Lee" reports that persistent connections need // to be closed too! //if ($this->_isPersistentConnection != true) return $this->_close(); //else return true; } /** * Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans(). * * @return true if succeeded or false if database does not support transactions */ function BeginTrans() {return false;} /** * If database does not support transactions, always return true as data always commited * * @param $ok set to false to rollback transaction, true to commit * * @return true/false. */ function CommitTrans($ok=true) { return true;} /** * If database does not support transactions, rollbacks always fail, so return false * * @return true/false. */ function RollbackTrans() { return false;} /** * return the databases that the driver can connect to. * Some databases will return an empty array. * * @return an array of database names. */ function MetaDatabases() { global $ADODB_FETCH_MODE; if ($this->metaDatabasesSQL) { $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); $arr = $this->GetCol($this->metaDatabasesSQL); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; return $arr; } return false; } /** * @param ttype can either be \\\'VIEW\\\' or \\\'TABLE\\\' or false. * If false, both views and tables are returned. * "VIEW" returns only views * "TABLE" returns only tables * @param showSchema returns the schema/user with the table name, eg. USER.TABLE * @param mask is the input mask - only supported by oci8 and postgresql * * @return array of tables for current database. */ function &MetaTables($ttype=false,$showSchema=false,$mask=false) { global $ADODB_FETCH_MODE; if ($mask) return false; if ($this->metaTablesSQL) { // complicated state saving by the need for backward compat $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); $rs = $this->Execute($this->metaTablesSQL); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; if ($rs === false) return false; $arr =& $rs->GetArray(); $arr2 = array(); if ($hast = ($ttype && isset($arr[0][1]))) { $showt = strncmp($ttype,\\\'T\\\',1); } for ($i=0; $i < sizeof($arr); $i++) { if ($hast) { if ($showt == 0) { if (strncmp($arr[$i][1],\\\'T\\\',1) == 0) $arr2[] = trim($arr[$i][0]); } else { if (strncmp($arr[$i][1],\\\'V\\\',1) == 0) $arr2[] = trim($arr[$i][0]); } } else $arr2[] = trim($arr[$i][0]); } $rs->Close(); return $arr2; } return false; } /** * List columns in a database as an array of ADOFieldObjects. * See top of file for definition of object. * * @param table table name to query * @param upper uppercase table name (required by some databases) * * @return array of ADOFieldObjects for current table. */ function &MetaColumns($table,$upper=true) { global $ADODB_FETCH_MODE; if (!empty($this->metaColumnsSQL)) { $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); $rs = $this->Execute(sprintf($this->metaColumnsSQL,($upper)?strtoupper($table):$table)); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; if ($rs === false) return false; $retarr = array(); while (!$rs->EOF) { //print_r($rs->fields); $fld =& new ADOFieldObject(); $fld->name = $rs->fields[0]; $fld->type = $rs->fields[1]; if (isset($rs->fields[3]) && $rs->fields[3]) { if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3]; $fld->scale = $rs->fields[4]; if ($fld->scale>0) $fld->max_length += 1; } else $fld->max_length = $rs->fields[2]; if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; else $retarr[strtoupper($fld->name)] = $fld; $rs->MoveNext(); } $rs->Close(); return $retarr; } return false; } /** * List indexes on a table as an array. * @param table table name to query * @param primary include primary keys. * * @return array of indexes on current table. */ function &MetaIndexes($table, $primary = false, $owner = false) { return FALSE; } /** * List columns names in a table as an array. * @param table table name to query * * @return array of column names for current table. */ function &MetaColumnNames($table) { $objarr =& $this->MetaColumns($table); if (!is_array($objarr)) return false; $arr = array(); foreach($objarr as $v) { $arr[] = $v->name; } return $arr; } /** * Different SQL databases used different methods to combine strings together. * This function provides a wrapper. * * param s variable number of string parameters * * Usage: $db->Concat($str1,$str2); * * @return concatenated string */ function Concat() { $arr = func_get_args(); return implode($this->concat_operator, $arr); } /** * Converts a date "d" to a string that the database can understand. * * @param d a date in Unix date time format. * * @return date string in database date format */ function DBDate($d) { if (empty($d) && $d !== 0) return \\\'null\\\'; if (is_string($d) && !is_numeric($d)) { if ($d === \\\'null\\\' || strncmp($d,"\\\'",1) === 0) return $d; if ($this->isoDates) return "\\\'$d\\\'"; $d = ADOConnection::UnixDate($d); } return adodb_date($this->fmtDate,$d); } /** * Converts a timestamp "ts" to a string that the database can understand. * * @param ts a timestamp in Unix date time format. * * @return timestamp string in database timestamp format */ function DBTimeStamp($ts) { if (empty($ts) && $ts !== 0) return \\\'null\\\'; if (is_string($ts) && !is_numeric($ts)) { if ($ts === \\\'null\\\') return $ts; if ($this->isoDates) return "\\\'$ts\\\'"; else $ts = ADOConnection::UnixTimeStamp($ts); } return adodb_date($this->fmtTimeStamp,$ts); } /** * Also in ADORecordSet. * @param $v is a date string in YYYY-MM-DD format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format */ function UnixDate($v) { if (!preg_match( "|^([0-9]{4})[-/\\\\.]?([0-9]{1,2})[-/\\\\.]?([0-9]{1,2})|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; // h-m-s-MM-DD-YY return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); } /** * Also in ADORecordSet. * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format */ function UnixTimeStamp($v) { if (!preg_match( "|^([0-9]{4})[-/\\\\.]?([0-9]{1,2})[-/\\\\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\\\\.]{1,4}))?|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; // h-m-s-MM-DD-YY if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); } /** * Also in ADORecordSet. * * Format database date based on user defined format. * * @param v is the character date in YYYY-MM-DD format, returned by database * @param fmt is the format to apply to it, using date() * * @return a date formated as user desires */ function UserDate($v,$fmt=\\\'Y-m-d\\\') { $tt = $this->UnixDate($v); // $tt == -1 if pre TIMESTAMP_FIRST_YEAR if (($tt === false || $tt == -1) && $v != false) return $v; else if ($tt == 0) return $this->emptyDate; else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR } return adodb_date($fmt,$tt); } /** * * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format * @param fmt is the format to apply to it, using date() * * @return a timestamp formated as user desires */ function UserTimeStamp($v,$fmt=\\\'Y-m-d H:i:s\\\') { if (is_numeric($v)) return adodb_date($fmt,$v); $tt = $this->UnixTimeStamp($v); // $tt == -1 if pre TIMESTAMP_FIRST_YEAR if (($tt === false || $tt == -1) && $v != false) return $v; if ($tt == 0) return $this->emptyTimeStamp; return adodb_date($fmt,$tt); } /** * Correctly quotes a string so that all strings are escaped. We prefix and append * to the string single-quotes. * An example is $db->qstr("Don\\\'t bother",magic_quotes_runtime()); * * @param s the string to quote * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). * This undoes the stupidity of magic quotes for GPC. * * @return quoted string to be sent back to database */ function qstr($s,$magic_quotes=false) { if (!$magic_quotes) { if ($this->replaceQuote[0] == \\\'\\\\\\\\\\\'){ // only since php 4.0.5 $s = adodb_str_replace(array(\\\'\\\\\\\\\\\',"\\\\0"),array(\\\'\\\\\\\\\\\\\\\\\\\',"\\\\\\\\\\\\0"),$s); //$s = str_replace("\\\\0","\\\\\\\\\\\\0", str_replace(\\\'\\\\\\\\\\\',\\\'\\\\\\\\\\\\\\\\\\\',$s)); } return "\\\'".str_replace("\\\'",$this->replaceQuote,$s)."\\\'"; } // undo magic quotes for " $s = str_replace(\\\'\\\\\\\\"\\\',\\\'"\\\',$s); if ($this->replaceQuote == "\\\\\\\\\\\'") // \\\' already quoted, no need to change anything return "\\\'$s\\\'"; else {// change \\\\\\\' to \\\'\\\' for sybase/mssql $s = str_replace(\\\'\\\\\\\\\\\\\\\\\\\',\\\'\\\\\\\\\\\',$s); return "\\\'".str_replace("\\\\\\\\\\\'",$this->replaceQuote,$s)."\\\'"; } } /** * Will select the supplied $page number from a recordset, given that it is paginated in pages of * $nrows rows per page. It also saves two boolean values saying if the given page is the first * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination. * * See readme.htm#ex8 for an example of usage. * * @param sql * @param nrows is the number of rows per page to get * @param page is the page number to get (1-based) * @param [inputarr] array of bind variables * @param [secs2cache] is a private parameter only used by jlim * @return the recordset ($rs->databaseType == \\\'array\\\') * * NOTE: phpLens uses a different algorithm and does not use PageExecute(). * */ function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.\\\'/adodb-lib.inc.php\\\'); if ($this->pageExecuteCountRows) return _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache); return _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache); } /** * Will select the supplied $page number from a recordset, given that it is paginated in pages of * $nrows rows per page. It also saves two boolean values saying if the given page is the first * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination. * * @param secs2cache seconds to cache data, set to 0 to force query * @param sql * @param nrows is the number of rows per page to get * @param page is the page number to get (1-based) * @param [inputarr] array of bind variables * @return the recordset ($rs->databaseType == \\\'array\\\') */ function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false) { /*switch($this->dataProvider) { case \\\'postgres\\\': case \\\'mysql\\\': break; default: $secs2cache = 0; break; }*/ $rs =& $this->PageExecute($sql,$nrows,$page,$inputarr,$secs2cache); return $rs; } } // end class ADOConnection //============================================================================================== // CLASS ADOFetchObj //============================================================================================== /** * Internal placeholder for record objects. Used by ADORecordSet->FetchObj(). */ class ADOFetchObj { }; //============================================================================================== // CLASS ADORecordSet_empty //============================================================================================== /** * Lightweight recordset when there are no records to be returned */ class ADORecordSet_empty { var $dataProvider = \\\'empty\\\'; var $databaseType = false; var $EOF = true; var $_numOfRows = 0; var $fields = false; var $connection = false; function RowCount() {return 0;} function RecordCount() {return 0;} function PO_RecordCount(){return 0;} function Close(){return true;} function FetchRow() {return false;} function FieldCount(){ return 0;} } //============================================================================================== // DATE AND TIME FUNCTIONS //============================================================================================== include_once(ADODB_DIR.\\\'/adodb-time.inc.php\\\'); //============================================================================================== // CLASS ADORecordSet //============================================================================================== if (PHP_VERSION < 5) include_once(ADODB_DIR.\\\'/adodb-php4.inc.php\\\'); else include_once(ADODB_DIR.\\\'/adodb-iterator.inc.php\\\'); /** * RecordSet class that represents the dataset returned by the database. * To keep memory overhead low, this class holds only the current row in memory. * No prefetching of data is done, so the RecordCount() can return -1 ( which * means recordcount not known). */ class ADORecordSet extends ADODB_BASE_RS { /* * public variables */ var $dataProvider = "native"; var $fields = false; /// holds the current row data var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob /// in other words, we use a text area for editting. var $canSeek = false; /// indicates that seek is supported var $sql; /// sql text var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object. var $emptyTimeStamp = \\\' \\\'; /// what to display when $time==0 var $emptyDate = \\\' \\\'; /// what to display when $time==0 var $debug = false; var $timeCreated=0; /// datetime in Unix format rs created -- for cached recordsets var $bind = false; /// used by Fields() to hold array - should be private? var $fetchMode; /// default fetch mode var $connection = false; /// the parent connection /* * private variables */ var $_numOfRows = -1; /** number of rows, or -1 */ var $_numOfFields = -1; /** number of fields in recordset */ var $_queryID = -1; /** This variable keeps the result link identifier. */ var $_currentRow = -1; /** This variable keeps the current row in the Recordset. */ var $_closed = false; /** has recordset been closed */ var $_inited = false; /** Init() should only be called once */ var $_obj; /** Used by FetchObj */ var $_names; /** Used by FetchObj */ var $_currentPage = -1; /** Added by Iván Oliva to implement recordset pagination */ var $_atFirstPage = false; /** Added by Iván Oliva to implement recordset pagination */ var $_atLastPage = false; /** Added by Iván Oliva to implement recordset pagination */ var $_lastPageNo = -1; var $_maxRecordCount = 0; var $dateHasTime = false; /** * Constructor * * @param queryID this is the queryID returned by ADOConnection->_query() * */ function ADORecordSet($queryID) { $this->_queryID = $queryID; } function Init() { if ($this->_inited) return; $this->_inited = true; if ($this->_queryID) @$this->_initrs(); else { $this->_numOfRows = 0; $this->_numOfFields = 0; } if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) { $this->_currentRow = 0; if ($this->EOF = ($this->_fetch() === false)) { $this->_numOfRows = 0; // _numOfRows could be -1 } } else { $this->EOF = true; } } /** * Generate a SELECT tag string from a recordset, and return the string. * If the recordset has 2 cols, we treat the 1st col as the containing * the text to display to the user, and 2nd col as the return value. Default * strings are compared with the FIRST column. * * @param name name of SELECT tag * @param [defstr] the value to hilite. Use an array for multiple hilites for listbox. * @param [blank1stItem] true to leave the 1st item in list empty * @param [multiple] true for listbox, false for popup * @param [size] #rows to show for listbox. not used by popup * @param [selectAttr] additional attributes to defined for SELECT tag. * useful for holding javascript onChange=\\\'...\\\' handlers. & @param [compareFields0] when we have 2 cols in recordset, we compare the defstr with * column 0 (1st col) if this is true. This is not documented. * * @return HTML * * changes by glen.davies@cce.ac.nz to support multiple hilited items */ function GetMenu($name,$defstr=\\\'\\\',$blank1stItem=true,$multiple=false, $size=0, $selectAttr=\\\'\\\',$compareFields0=true) { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.\\\'/adodb-lib.inc.php\\\'); return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple, $size, $selectAttr,$compareFields0); } /** * Generate a SELECT tag string from a recordset, and return the string. * If the recordset has 2 cols, we treat the 1st col as the containing * the text to display to the user, and 2nd col as the return value. Default * strings are compared with the SECOND column. * */ function GetMenu2($name,$defstr=\\\'\\\',$blank1stItem=true,$multiple=false,$size=0, $selectAttr=\\\'\\\') { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.\\\'/adodb-lib.inc.php\\\'); return _adodb_getmenu($this,$name,$defstr,$blank1stItem,$multiple, $size, $selectAttr,false); } /** * return recordset as a 2-dimensional array. * * @param [nRows] is the number of rows to return. -1 means every row. * * @return an array indexed by the rows (0-based) from the recordset */ function &GetArray($nRows = -1) { global $ADODB_EXTENSION; if ($ADODB_EXTENSION) return adodb_getall($this,$nRows); $results = array(); $cnt = 0; while (!$this->EOF && $nRows != $cnt) { $results[] = $this->fields; $this->MoveNext(); $cnt++; } return $results; } function &GetAll($nRows = -1) { $arr =& $this->GetArray($nRows); return $arr; } /* * Some databases allow multiple recordsets to be returned. This function * will return true if there is a next recordset, or false if no more. */ function NextRecordSet() { return false; } /** * return recordset as a 2-dimensional array. * Helper function for ADOConnection->SelectLimit() * * @param offset is the row to start calculations from (1-based) * @param [nrows] is the number of rows to return * * @return an array indexed by the rows (0-based) from the recordset */ function &GetArrayLimit($nrows,$offset=-1) { if ($offset <= 0) { $arr =& $this->GetArray($nrows); return $arr; } $this->Move($offset); $results = array(); $cnt = 0; while (!$this->EOF && $nrows != $cnt) { $results[$cnt++] = $this->fields; $this->MoveNext(); } return $results; } /** * Synonym for GetArray() for compatibility with ADO. * * @param [nRows] is the number of rows to return. -1 means every row. * * @return an array indexed by the rows (0-based) from the recordset */ function &GetRows($nRows = -1) { $arr =& $this->GetArray($nRows); return $arr; } /** * return whole recordset as a 2-dimensional associative array if there are more than 2 columns. * The first column is treated as the key and is not included in the array. * If there is only 2 columns, it will return a 1 dimensional array of key-value pairs unless * $force_array == true. * * @param [force_array] has only meaning if we have 2 data columns. If false, a 1 dimensional * array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing, * read the source. * * @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and * instead of returning array[col0] => array(remaining cols), return array[col0] => col1 * * @return an associative array indexed by the first column of the array, * or false if the data has less than 2 cols. */ function &GetAssoc($force_array = false, $first2cols = false) { $cols = $this->_numOfFields; if ($cols < 2) { return false; } $numIndex = isset($this->fields[0]); $results = array(); if (!$first2cols && ($cols > 2 || $force_array)) { if ($numIndex) { while (!$this->EOF) { $results[trim($this->fields[0])] = array_slice($this->fields, 1); $this->MoveNext(); } } else { while (!$this->EOF) { $results[trim(reset($this->fields))] = array_slice($this->fields, 1); $this->MoveNext(); } } } else { // return scalar values if ($numIndex) { while (!$this->EOF) { // some bug in mssql PHP 4.02 -- doesn\\\'t handle references properly so we FORCE creating a new string $results[trim(($this->fields[0]))] = $this->fields[1]; $this->MoveNext(); } } else { while (!$this->EOF) { // some bug in mssql PHP 4.02 -- doesn\\\'t handle references properly so we FORCE creating a new string $v1 = trim(reset($this->fields)); $v2 = \\\'\\\'.next($this->fields); $results[$v1] = $v2; $this->MoveNext(); } } } return $results; } /** * * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format * @param fmt is the format to apply to it, using date() * * @return a timestamp formated as user desires */ function UserTimeStamp($v,$fmt=\\\'Y-m-d H:i:s\\\') { if (is_numeric($v)) return adodb_date($fmt,$v); $tt = $this->UnixTimeStamp($v); // $tt == -1 if pre TIMESTAMP_FIRST_YEAR if (($tt === false || $tt == -1) && $v != false) return $v; if ($tt === 0) return $this->emptyTimeStamp; return adodb_date($fmt,$tt); } /** * @param v is the character date in YYYY-MM-DD format, returned by database * @param fmt is the format to apply to it, using date() * * @return a date formated as user desires */ function UserDate($v,$fmt=\\\'Y-m-d\\\') { $tt = $this->UnixDate($v); // $tt == -1 if pre TIMESTAMP_FIRST_YEAR if (($tt === false || $tt == -1) && $v != false) return $v; else if ($tt == 0) return $this->emptyDate; else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR } return adodb_date($fmt,$tt); } /** * @param $v is a date string in YYYY-MM-DD format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format */ function UnixDate($v) { if (!preg_match( "|^([0-9]{4})[-/\\\\.]?([0-9]{1,2})[-/\\\\.]?([0-9]{1,2})|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; // h-m-s-MM-DD-YY return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); } /** * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format */ function UnixTimeStamp($v) { if (!preg_match( "|^([0-9]{4})[-/\\\\.]?([0-9]{1,2})[-/\\\\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\\\\.]{1,4}))?|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; // h-m-s-MM-DD-YY if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); } /** * PEAR DB Compat - do not use internally */ function Free() { return $this->Close(); } /** * PEAR DB compat, number of rows */ function NumRows() { return $this->_numOfRows; } /** * PEAR DB compat, number of cols */ function NumCols() { return $this->_numOfFields; } /** * Fetch a row, returning false if no more rows. * This is PEAR DB compat mode. * * @return false or array containing the current record */ function FetchRow() { if ($this->EOF) return false; $arr = $this->fields; $this->_currentRow++; if (!$this->_fetch()) $this->EOF = true; return $arr; } /** * Fetch a row, returning PEAR_Error if no more rows. * This is PEAR DB compat mode. * * @return DB_OK or error object */ function FetchInto(&$arr) { if ($this->EOF) return (defined(\\\'PEAR_ERROR_RETURN\\\')) ? new PEAR_Error(\\\'EOF\\\',-1): false; $arr = $this->fields; $this->MoveNext(); return 1; // DB_OK } /** * Move to the first row in the recordset. Many databases do NOT support this. * * @return true or false */ function MoveFirst() { if ($this->_currentRow == 0) return true; return $this->Move(0); } /** * Move to the last row in the recordset. * * @return true or false */ function MoveLast() { if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1); if ($this->EOF) return false; while (!$this->EOF) { $f = $this->fields; $this->MoveNext(); } $this->fields = $f; $this->EOF = false; return true; } /** * Move to next record in the recordset. * * @return true if there still rows available, or false if there are no more rows (EOF). */ function MoveNext() { if (!$this->EOF) { $this->_currentRow++; if ($this->_fetch()) return true; } $this->EOF = true; /* -- tested error handling when scrolling cursor -- seems useless. $conn = $this->connection; if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) { $fn = $conn->raiseErrorFn; $fn($conn->databaseType,\\\'MOVENEXT\\\',$errno,$conn->ErrorMsg().\\\' (\\\'.$this->sql.\\\')\\\',$conn->host,$conn->database); } */ return false; } /** * Random access to a specific row in the recordset. Some databases do not support * access to previous rows in the databases (no scrolling backwards). * * @param rowNumber is the row to move to (0-based) * * @return true if there still rows available, or false if there are no more rows (EOF). */ function Move($rowNumber = 0) { $this->EOF = false; if ($rowNumber == $this->_currentRow) return true; if ($rowNumber >= $this->_numOfRows) if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2; if ($this->canSeek) { if ($this->_seek($rowNumber)) { $this->_currentRow = $rowNumber; if ($this->_fetch()) { return true; } } else { $this->EOF = true; return false; } } else { if ($rowNumber < $this->_currentRow) return false; global $ADODB_EXTENSION; if ($ADODB_EXTENSION) { while (!$this->EOF && $this->_currentRow < $rowNumber) { adodb_movenext($this); } } else { while (! $this->EOF && $this->_currentRow < $rowNumber) { $this->_currentRow++; if (!$this->_fetch()) $this->EOF = true; } } return !($this->EOF); } $this->fields = false; $this->EOF = true; return false; } /** * Get the value of a field in the current row by column name. * Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM. * * @param colname is the field to access * * @return the value of $colname column */ function Fields($colname) { return $this->fields[$colname]; } function GetAssocKeys($upper=true) { $this->bind = array(); for ($i=0; $i < $this->_numOfFields; $i++) { $o =& $this->FetchField($i); if ($upper === 2) $this->bind[$o->name] = $i; else $this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i; } } /** * Use associative array to get fields array for databases that do not support * associative arrays. Submitted by Paolo S. Asioli paolo.asioli@libero.it * * If you don\\\'t want uppercase cols, set $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC * before you execute your SQL statement, and access $rs->fields[\\\'col\\\'] directly. * * $upper 0 = lowercase, 1 = uppercase, 2 = whatever is returned by FetchField */ function &GetRowAssoc($upper=1) { $record = array(); // if (!$this->fields) return $record; if (!$this->bind) { $this->GetAssocKeys($upper); } foreach($this->bind as $k => $v) { $record[$k] = $this->fields[$v]; } return $record; } /** * Clean up recordset * * @return true or false */ function Close() { // free connection object - this seems to globally free the object // and not merely the reference, so don\\\'t do this... // $this->connection = false; if (!$this->_closed) { $this->_closed = true; return $this->_close(); } else return true; } /** * synonyms RecordCount and RowCount * * @return the number of rows or -1 if this is not supported */ function RecordCount() {return $this->_numOfRows;} /* * If we are using PageExecute(), this will return the maximum possible rows * that can be returned when paging a recordset. */ function MaxRecordCount() { return ($this->_maxRecordCount) ? $this->_maxRecordCount : $this->RecordCount(); } /** * synonyms RecordCount and RowCount * * @return the number of rows or -1 if this is not supported */ function RowCount() {return $this->_numOfRows;} /** * Portable RecordCount. Pablo Roca * * @return the number of records from a previous SELECT. All databases support this. * * But aware possible problems in multiuser environments. For better speed the table * must be indexed by the condition. Heavy test this before deploying. */ function PO_RecordCount($table="", $condition="") { $lnumrows = $this->_numOfRows; // the database doesn\\\'t support native recordcount, so we do a workaround if ($lnumrows == -1 && $this->connection) { IF ($table) { if ($condition) $condition = " WHERE " . $condition; $resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition"); if ($resultrows) $lnumrows = reset($resultrows->fields); } } return $lnumrows; } /** * @return the current row in the recordset. If at EOF, will return the last row. 0-based. */ function CurrentRow() {return $this->_currentRow;} /** * synonym for CurrentRow -- for ADO compat * * @return the current row in the recordset. If at EOF, will return the last row. 0-based. */ function AbsolutePosition() {return $this->_currentRow;} /** * @return the number of columns in the recordset. Some databases will set this to 0 * if no records are returned, others will return the number of columns in the query. */ function FieldCount() {return $this->_numOfFields;} /** * Get the ADOFieldObject of a specific column. * * @param fieldoffset is the column position to access(0-based). * * @return the ADOFieldObject for that column, or false. */ function &FetchField($fieldoffset) { // must be defined by child class } /** * Get the ADOFieldObjects of all columns in an array. * */ function FieldTypesArray() { $arr = array(); for ($i=0, $max=$this->_numOfFields; $i < $max; $i++) $arr[] = $this->FetchField($i); return $arr; } /** * Return the fields array of the current row as an object for convenience. * The default case is lowercase field names. * * @return the object with the properties set to the fields of the current row */ function &FetchObj() { $o =& $this->FetchObject(false); return $o; } /** * Return the fields array of the current row as an object for convenience. * The default case is uppercase. * * @param $isupper to set the object property names to uppercase * * @return the object with the properties set to the fields of the current row */ function &FetchObject($isupper=true) { if (empty($this->_obj)) { $this->_obj =& new ADOFetchObj(); $this->_names = array(); for ($i=0; $i <$this->_numOfFields; $i++) { $f = $this->FetchField($i); $this->_names[] = $f->name; } } $i = 0; $o = &$this->_obj; for ($i=0; $i <$this->_numOfFields; $i++) { $name = $this->_names[$i]; if ($isupper) $n = strtoupper($name); else $n = $name; $o->$n = $this->Fields($name); } return $o; } /** * Return the fields array of the current row as an object for convenience. * The default is lower-case field names. * * @return the object with the properties set to the fields of the current row, * or false if EOF * * Fixed bug reported by tim@orotech.net */ function &FetchNextObj() { return $this->FetchNextObject(false); } /** * Return the fields array of the current row as an object for convenience. * The default is upper case field names. * * @param $isupper to set the object property names to uppercase * * @return the object with the properties set to the fields of the current row, * or false if EOF * * Fixed bug reported by tim@orotech.net */ function &FetchNextObject($isupper=true) { $o = false; if ($this->_numOfRows != 0 && !$this->EOF) { $o = $this->FetchObject($isupper); $this->_currentRow++; if ($this->_fetch()) return $o; } $this->EOF = true; return $o; } /** * Get the metatype of the column. This is used for formatting. This is because * many databases use different names for the same type, so we transform the original * type to our standardised version which uses 1 character codes: * * @param t is the type passed in. Normally is ADOFieldObject->type. * @param len is the maximum length of that field. This is because we treat character * fields bigger than a certain size as a \\\'B\\\' (blob). * @param fieldobj is the field object returned by the database driver. Can hold * additional info (eg. primary_key for mysql). * * @return the general type of the data: * C for character < 200 chars * X for teXt (>= 200 chars) * B for Binary * N for numeric floating point * D for date * T for timestamp * L for logical/Boolean * I for integer * R for autoincrement counter/integer * * */ function MetaType($t,$len=-1,$fieldobj=false) { if (is_object($t)) { $fieldobj = $t; $t = $fieldobj->type; $len = $fieldobj->max_length; } // changed in 2.32 to hashing instead of switch stmt for speed... static $typeMap = array( \\\'VARCHAR\\\' => \\\'C\\\', \\\'VARCHAR2\\\' => \\\'C\\\', \\\'CHAR\\\' => \\\'C\\\', \\\'C\\\' => \\\'C\\\', \\\'STRING\\\' => \\\'C\\\', \\\'NCHAR\\\' => \\\'C\\\', \\\'NVARCHAR\\\' => \\\'C\\\', \\\'VARYING\\\' => \\\'C\\\', \\\'BPCHAR\\\' => \\\'C\\\', \\\'CHARACTER\\\' => \\\'C\\\', \\\'INTERVAL\\\' => \\\'C\\\', # Postgres ## \\\'LONGCHAR\\\' => \\\'X\\\', \\\'TEXT\\\' => \\\'X\\\', \\\'NTEXT\\\' => \\\'X\\\', \\\'M\\\' => \\\'X\\\', \\\'X\\\' => \\\'X\\\', \\\'CLOB\\\' => \\\'X\\\', \\\'NCLOB\\\' => \\\'X\\\', \\\'LVARCHAR\\\' => \\\'X\\\', ## \\\'BLOB\\\' => \\\'B\\\', \\\'IMAGE\\\' => \\\'B\\\', \\\'BINARY\\\' => \\\'B\\\', \\\'VARBINARY\\\' => \\\'B\\\', \\\'LONGBINARY\\\' => \\\'B\\\', \\\'B\\\' => \\\'B\\\', ## \\\'YEAR\\\' => \\\'D\\\', // mysql \\\'DATE\\\' => \\\'D\\\', \\\'D\\\' => \\\'D\\\', ## \\\'TIME\\\' => \\\'T\\\', \\\'TIMESTAMP\\\' => \\\'T\\\', \\\'DATETIME\\\' => \\\'T\\\', \\\'TIMESTAMPTZ\\\' => \\\'T\\\', \\\'T\\\' => \\\'T\\\', ## \\\'BOOLEAN\\\' => \\\'L\\\', \\\'BIT\\\' => \\\'L\\\', \\\'L\\\' => \\\'L\\\', ## \\\'COUNTER\\\' => \\\'R\\\', \\\'R\\\' => \\\'R\\\', \\\'SERIAL\\\' => \\\'R\\\', // ifx \\\'INT IDENTITY\\\' => \\\'R\\\', ## \\\'INT\\\' => \\\'I\\\', \\\'INTEGER\\\' => \\\'I\\\', \\\'INTEGER UNSIGNED\\\' => \\\'I\\\', \\\'SHORT\\\' => \\\'I\\\', \\\'TINYINT\\\' => \\\'I\\\', \\\'SMALLINT\\\' => \\\'I\\\', \\\'I\\\' => \\\'I\\\', ## \\\'LONG\\\' => \\\'N\\\', // interbase is numeric, oci8 is blob \\\'BIGINT\\\' => \\\'N\\\', // this is bigger than PHP 32-bit integers \\\'DECIMAL\\\' => \\\'N\\\', \\\'DEC\\\' => \\\'N\\\', \\\'REAL\\\' => \\\'N\\\', \\\'DOUBLE\\\' => \\\'N\\\', \\\'DOUBLE PRECISION\\\' => \\\'N\\\', \\\'SMALLFLOAT\\\' => \\\'N\\\', \\\'FLOAT\\\' => \\\'N\\\', \\\'NUMBER\\\' => \\\'N\\\', \\\'NUM\\\' => \\\'N\\\', \\\'NUMERIC\\\' => \\\'N\\\', \\\'MONEY\\\' => \\\'N\\\', ## informix 9.2 \\\'SQLINT\\\' => \\\'I\\\', \\\'SQLSERIAL\\\' => \\\'I\\\', \\\'SQLSMINT\\\' => \\\'I\\\', \\\'SQLSMFLOAT\\\' => \\\'N\\\', \\\'SQLFLOAT\\\' => \\\'N\\\', \\\'SQLMONEY\\\' => \\\'N\\\', \\\'SQLDECIMAL\\\' => \\\'N\\\', \\\'SQLDATE\\\' => \\\'D\\\', \\\'SQLVCHAR\\\' => \\\'C\\\', \\\'SQLCHAR\\\' => \\\'C\\\', \\\'SQLDTIME\\\' => \\\'T\\\', \\\'SQLINTERVAL\\\' => \\\'N\\\', \\\'SQLBYTES\\\' => \\\'B\\\', \\\'SQLTEXT\\\' => \\\'X\\\' ); $tmap = false; $t = strtoupper($t); $tmap = @$typeMap[$t]; switch ($tmap) { case \\\'C\\\': // is the char field is too long, return as text field... if ($this->blobSize >= 0) { if ($len > $this->blobSize) return \\\'X\\\'; } else if ($len > 250) { return \\\'X\\\'; } return \\\'C\\\'; case \\\'I\\\': if (!empty($fieldobj->primary_key)) return \\\'R\\\'; return \\\'I\\\'; case false: return \\\'N\\\'; case \\\'B\\\': if (isset($fieldobj->binary)) return ($fieldobj->binary) ? \\\'B\\\' : \\\'X\\\'; return \\\'B\\\'; case \\\'D\\\': if (!empty($this->dateHasTime)) return \\\'T\\\'; return \\\'D\\\'; default: if ($t == \\\'LONG\\\' && $this->dataProvider == \\\'oci8\\\') return \\\'B\\\'; return $tmap; } } function _close() {} /** * set/returns the current recordset page when paginating */ function AbsolutePage($page=-1) { if ($page != -1) $this->_currentPage = $page; return $this->_currentPage; } /** * set/returns the status of the atFirstPage flag when paginating */ function AtFirstPage($status=false) { if ($status != false) $this->_atFirstPage = $status; return $this->_atFirstPage; } function LastPageNo($page = false) { if ($page != false) $this->_lastPageNo = $page; return $this->_lastPageNo; } /** * set/returns the status of the atLastPage flag when paginating */ function AtLastPage($status=false) { if ($status != false) $this->_atLastPage = $status; return $this->_atLastPage; } } // end class ADORecordSet //============================================================================================== // CLASS ADORecordSet_array //============================================================================================== /** * This class encapsulates the concept of a recordset created in memory * as an array. This is useful for the creation of cached recordsets. * * Note that the constructor is different from the standard ADORecordSet */ class ADORecordSet_array extends ADORecordSet { var $databaseType = \\\'array\\\'; var $_array; // holds the 2-dimensional data array var $_types; // the array of types of each column (C B I L M) var $_colnames; // names of each column in array var $_skiprow1; // skip 1st row because it holds column names var $_fieldarr; // holds array of field objects var $canSeek = true; var $affectedrows = false; var $insertid = false; var $sql = \\\'\\\'; var $compat = false; /** * Constructor * */ function ADORecordSet_array($fakeid=1) { global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH; // fetch() on EOF does not delete $this->fields $this->compat = !empty($ADODB_COMPAT_FETCH); $this->ADORecordSet($fakeid); // fake queryID $this->fetchMode = $ADODB_FETCH_MODE; } /** * Setup the array. * * @param array is a 2-dimensional array holding the data. * The first row should hold the column names * unless paramter $colnames is used. * @param typearr holds an array of types. These are the same types * used in MetaTypes (C,B,L,I,N). * @param [colnames] array of column names. If set, then the first row of * $array should not hold the column names. */ function InitArray($array,$typearr,$colnames=false) { $this->_array = $array; $this->_types = $typearr; if ($colnames) { $this->_skiprow1 = false; $this->_colnames = $colnames; } else $this->_colnames = $array[0]; $this->Init(); } /** * Setup the Array and datatype file objects * * @param array is a 2-dimensional array holding the data. * The first row should hold the column names * unless paramter $colnames is used. * @param fieldarr holds an array of ADOFieldObject\\\'s. */ function InitArrayFields($array,$fieldarr) { $this->_array = $array; $this->_skiprow1= false; if ($fieldarr) { $this->_fieldobjects = $fieldarr; } $this->Init(); } function &GetArray($nRows=-1) { if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) { return $this->_array; } else { $arr =& ADORecordSet::GetArray($nRows); return $arr; } } function _initrs() { $this->_numOfRows = sizeof($this->_array); if ($this->_skiprow1) $this->_numOfRows -= 1; $this->_numOfFields =(isset($this->_fieldobjects)) ? sizeof($this->_fieldobjects):sizeof($this->_types); } /* Use associative array to get fields array */ function Fields($colname) { if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; if (!$this->bind) { $this->bind = array(); for ($i=0; $i < $this->_numOfFields; $i++) { $o = $this->FetchField($i); $this->bind[strtoupper($o->name)] = $i; } } return $this->fields[$this->bind[strtoupper($colname)]]; } function &FetchField($fieldOffset = -1) { if (isset($this->_fieldobjects)) { return $this->_fieldobjects[$fieldOffset]; } $o = new ADOFieldObject(); $o->name = $this->_colnames[$fieldOffset]; $o->type = $this->_types[$fieldOffset]; $o->max_length = -1; // length not known return $o; } function _seek($row) { if (sizeof($this->_array) && $row < $this->_numOfRows) { $this->fields = $this->_array[$row]; return true; } return false; } function MoveNext() { if (!$this->EOF) { $this->_currentRow++; $pos = $this->_currentRow; if ($this->_skiprow1) $pos += 1; if ($this->_numOfRows <= $pos) { if (!$this->compat) $this->fields = false; } else { $this->fields = $this->_array[$pos]; return true; } $this->EOF = true; } return false; } function _fetch() { $pos = $this->_currentRow; if ($this->_skiprow1) $pos += 1; if ($this->_numOfRows <= $pos) { if (!$this->compat) $this->fields = false; return false; } $this->fields = $this->_array[$pos]; return true; } function _close() { return true; } } // ADORecordSet_array //============================================================================================== // HELPER FUNCTIONS //============================================================================================== /** * Synonym for ADOLoadCode. Private function. Do not use. * * @deprecated */ function ADOLoadDB($dbType) { return ADOLoadCode($dbType); } /** * Load the code for a specific database driver. Private function. Do not use. */ function ADOLoadCode($dbType) { global $ADODB_LASTDB; if (!$dbType) return false; $db = strtolower($dbType); switch ($db) { case \\\'maxsql\\\': $db = \\\'mysqlt\\\'; break; case \\\'postgres\\\': case \\\'pgsql\\\': $db = \\\'postgres7\\\'; break; } $ok = @include_once(ADODB_DIR."/drivers/adodb-".$db.".inc.php"); $ADODB_LASTDB = $db; return ($ok) ? $db : false; } /** * synonym for ADONewConnection for people like me who cannot remember the correct name */ function &NewADOConnection($db=\\\'\\\') { $tmp =& ADONewConnection($db); return $tmp; } /** * Instantiate a new Connection class for a specific database driver. * * @param [db] is the database Connection object to create. If undefined, * use the last database driver that was loaded by ADOLoadCode(). * * @return the freshly created instance of the Connection class. */ function &ADONewConnection($db=\\\'\\\') { GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB; if (!defined(\\\'ADODB_ASSOC_CASE\\\')) define(\\\'ADODB_ASSOC_CASE\\\',2); $errorfn = (defined(\\\'ADODB_ERROR_HANDLER\\\')) ? ADODB_ERROR_HANDLER : false; if (!empty($ADODB_NEWCONNECTION)) { $obj = $ADODB_NEWCONNECTION($db); if ($obj) { if ($errorfn) $obj->raiseErrorFn = $errorfn; return $obj; } } if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = \\\'\\\'; if (empty($db)) $db = $ADODB_LASTDB; if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db); if (!$db) { if ($errorfn) { // raise an error $ignore = false; $errorfn(\\\'ADONewConnection\\\', \\\'ADONewConnection\\\', -998, "could not load the database driver for \\\'$db", $db,false,$ignore); } else ADOConnection::outp( "

ADONewConnection: Unable to load database driver \\\'$db\\\'

",false); return false; } $cls = \\\'ADODB_\\\'.$db; if (!class_exists($cls)) { adodb_backtrace(); return false; } $obj =& new $cls(); if ($errorfn) $obj->raiseErrorFn = $errorfn; return $obj; } // $perf == true means called by NewPerfMonitor() function _adodb_getdriver($provider,$drivername,$perf=false) { if ($provider !== \\\'native\\\' && $provider != \\\'odbc\\\' && $provider != \\\'ado\\\') $drivername = $provider; else { if (substr($drivername,0,5) == \\\'odbc_\\\') $drivername = substr($drivername,5); else if (substr($drivername,0,4) == \\\'ado_\\\') $drivername = substr($drivername,4); else switch($drivername) { case \\\'oracle\\\': $drivername = \\\'oci8\\\';break; //case \\\'sybase\\\': $drivername = \\\'mssql\\\';break; case \\\'access\\\': if ($perf) $drivername = \\\'\\\'; break; case \\\'db2\\\': if ($perf) break; default: $drivername = \\\'generic\\\'; break; } } return $drivername; } function &NewPerfMonitor(&$conn) { $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true); if (!$drivername || $drivername == \\\'generic\\\') return false; include_once(ADODB_DIR.\\\'/adodb-perf.inc.php\\\'); @include_once(ADODB_DIR."/perf/perf-$drivername.inc.php"); $class = "Perf_$drivername"; if (!class_exists($class)) return false; $perf =& new $class($conn); return $perf; } function &NewDataDictionary(&$conn) { $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType); include_once(ADODB_DIR.\\\'/adodb-lib.inc.php\\\'); include_once(ADODB_DIR.\\\'/adodb-datadict.inc.php\\\'); $path = ADODB_DIR."/datadict/datadict-$drivername.inc.php"; if (!file_exists($path)) { ADOConnection::outp("Database driver \\\'$path\\\' not available"); return false; } include_once($path); $class = "ADODB2_$drivername"; $dict =& new $class(); $dict->dataProvider = $conn->dataProvider; $dict->connection = &$conn; $dict->upperName = strtoupper($drivername); if (is_resource($conn->_connectionID)) $dict->serverInfo = $conn->ServerInfo(); return $dict; } /** * Save a file $filename and its $contents (normally for caching) with file locking */ function adodb_write_file($filename, $contents,$debug=false) { # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows # So to simulate locking, we assume that rename is an atomic operation. # First we delete $filename, then we create a $tempfile write to it and # rename to the desired $filename. If the rename works, then we successfully # modified the file exclusively. # What a stupid need - having to simulate locking. # Risks: # 1. $tempfile name is not unique -- very very low # 2. unlink($filename) fails -- ok, rename will fail # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated if (strncmp(PHP_OS,\\\'WIN\\\',3) === 0) { // skip the decimal place $mtime = substr(str_replace(\\\' \\\',\\\'_\\\',microtime()),2); // unlink will let some latencies develop, so uniqid() is more random @unlink($filename); // getmypid() actually returns 0 on Win98 - never mind! $tmpname = $filename.uniqid($mtime).getmypid(); if (!($fd = fopen($tmpname,\\\'a\\\'))) return false; $ok = ftruncate($fd,0); if (!fwrite($fd,$contents)) $ok = false; fclose($fd); chmod($tmpname,0644); if (!@rename($tmpname,$filename)) { unlink($tmpname); $ok = false; } if (!$ok) { if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? \\\'ok\\\' : \\\'failed\\\')); } return $ok; } if (!($fd = fopen($filename, \\\'a\\\'))) return false; if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) { $ok = fwrite( $fd, $contents ); fclose($fd); chmod($filename,0644); }else { fclose($fd); if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename
\\\\n"); $ok = false; } return $ok; } /* Perform a print_r, with pre tags for better formatting. */ function adodb_pr($var) { echo "
\\\\n";print_r($var);echo "
\\\\n"; } /* Perform a stack-crawl and pretty print it. @param printOrArr Pass in a boolean to indicate print, or an $exception->trace array (assumes that print is true then). @param levels Number of levels to display */ function adodb_backtrace($printOrArr=true,$levels=9999) { $s = \\\'\\\'; if (PHPVERSION() >= 4.3) { $MAXSTRLEN = 64; $s = \\\'
\\\';
			
			if (is_array($printOrArr)) $traceArr = $printOrArr;
			else $traceArr = debug_backtrace();
			array_shift($traceArr);
			$tabs = sizeof($traceArr)-1;
			
			foreach ($traceArr as $arr) {
				$levels -= 1;
				if ($levels < 0) break;
				
				$args = array();
				for ($i=0; $i < $tabs; $i++) $s .= \\\'   \\\';
				$tabs -= 1;
				$s .= \\\'\\\';
				if (isset($arr[\\\'class\\\'])) $s .= $arr[\\\'class\\\'].\\\'.\\\';
				if (isset($arr[\\\'args\\\']))
				 foreach($arr[\\\'args\\\'] as $v) {
					if (is_null($v)) $args[] = \\\'null\\\';
					else if (is_array($v)) $args[] = \\\'Array[\\\'.sizeof($v).\\\']\\\';
					else if (is_object($v)) $args[] = \\\'Object:\\\'.get_class($v);
					else if (is_bool($v)) $args[] = $v ? \\\'true\\\' : \\\'false\\\';
					else {
						$v = (string) @$v;
						$str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
						if (strlen($v) > $MAXSTRLEN) $str .= \\\'...\\\';
						$args[] = $str;
					}
				}
				$s .= $arr[\\\'function\\\'].\\\'(\\\'.implode(\\\', \\\',$args).\\\')\\\';
				$s .= @sprintf(" %% line %4d, file: %s",
					$arr[\\\'line\\\'],$arr[\\\'file\\\'],$arr[\\\'file\\\']);
				$s .= "\\\\n";
			}	
			$s .= \\\'
\\\'; if ($printOrArr) print $s; } return $s; } } // defined ?>\', \'~core/classes/adodb/class.adodb.inc\' => \'Site->Path.\\\'/~core/classes/adodb/adodb.inc.php\\\'); $GLOBALS[\\\'ADODB_FETCH_MODE\\\'] = ADODB_FETCH_ASSOC; $GLOBALS[\\\'ADODB_COUNTRECS\\\'] = false; define(ADODB_DIR, $GLOBALS[\\\'Conf\\\']->Site->Path.\\\'/~core/classes/adodb\\\'); ?>\', \'~core/classes/adodb/drivers/adodb-mysql.inc.php\' => \'GetOne("select version()"); $arr[\\\'version\\\'] = ADOConnection::_findvers($arr[\\\'description\\\']); return $arr; } function IfNull( $field, $ifNull ) { return " IFNULL($field, $ifNull) "; // if MySQL } function &MetaTables($ttype=false,$showSchema=false,$mask=false) { if ($mask) { $save = $this->metaTablesSQL; $mask = $this->qstr($mask); $this->metaTablesSQL .= " like $mask"; } $ret =& ADOConnection::MetaTables($ttype,$showSchema); if ($mask) { $this->metaTablesSQL = $save; } return $ret; } function &MetaIndexes ($table, $primary = FALSE, $owner=false) { // save old fetch mode global $ADODB_FETCH_MODE; $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== FALSE) { $savem = $this->SetFetchMode(FALSE); } // get index details $rs = $this->Execute(sprintf(\\\'SHOW INDEXES FROM %s\\\',$table)); // restore fetchmode if (isset($savem)) { $this->SetFetchMode($savem); } $ADODB_FETCH_MODE = $save; if (!is_object($rs)) { return FALSE; } $indexes = array (); // parse index data into array while ($row = $rs->FetchRow()) { if ($primary == FALSE AND $row[2] == \\\'PRIMARY\\\') { continue; } if (!isset($indexes[$row[2]])) { $indexes[$row[2]] = array( \\\'unique\\\' => ($row[1] == 0), \\\'columns\\\' => array() ); } $indexes[$row[2]][\\\'columns\\\'][$row[3] - 1] = $row[4]; } // sort columns by order in the index foreach ( array_keys ($indexes) as $index ) { ksort ($indexes[$index][\\\'columns\\\']); } return $indexes; } // if magic quotes disabled, use mysql_real_escape_string() function qstr($s,$magic_quotes=false) { if (!$magic_quotes) { if (ADODB_PHPVER >= 0x4300) { if (is_resource($this->_connectionID)) return "\\\'".mysql_real_escape_string($s,$this->_connectionID)."\\\'"; } if ($this->replaceQuote[0] == \\\'\\\\\\\\\\\'){ $s = adodb_str_replace(array(\\\'\\\\\\\\\\\',"\\\\0"),array(\\\'\\\\\\\\\\\\\\\\\\\',"\\\\\\\\\\\\0"),$s); } return "\\\'".str_replace("\\\'",$this->replaceQuote,$s)."\\\'"; } // undo magic quotes for " $s = str_replace(\\\'\\\\\\\\"\\\',\\\'"\\\',$s); return "\\\'$s\\\'"; } function _insertid() { return mysql_insert_id($this->_connectionID); } function GetOne($sql,$inputarr=false) { $rs =& $this->SelectLimit($sql,1,-1,$inputarr); if ($rs) { $rs->Close(); if ($rs->EOF) return false; return reset($rs->fields); } return false; } function _affectedrows() { return mysql_affected_rows($this->_connectionID); } // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html // Reference on Last_Insert_ID on the recommended way to simulate sequences var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);"; var $_genSeqSQL = "create table %s (id int not null)"; var $_genSeq2SQL = "insert into %s values (%s)"; var $_dropSeqSQL = "drop table %s"; function CreateSequence($seqname=\\\'adodbseq\\\',$startID=1) { if (empty($this->_genSeqSQL)) return false; $u = strtoupper($seqname); $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); if (!$ok) return false; return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1)); } function GenID($seqname=\\\'adodbseq\\\',$startID=1) { // post-nuke sets hasGenID to false if (!$this->hasGenID) return false; $savelog = $this->_logsql; $this->_logsql = false; $getnext = sprintf($this->_genIDSQL,$seqname); $holdtransOK = $this->_transOK; // save the current status $rs = @$this->Execute($getnext); if (!$rs) { if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset $u = strtoupper($seqname); $this->Execute(sprintf($this->_genSeqSQL,$seqname)); $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1)); $rs = $this->Execute($getnext); } $this->genID = mysql_insert_id($this->_connectionID); if ($rs) $rs->Close(); $this->_logsql = $savelog; return $this->genID; } function &MetaDatabases() { $qid = mysql_list_dbs($this->_connectionID); $arr = array(); $i = 0; $max = mysql_num_rows($qid); while ($i < $max) { $db = mysql_tablename($qid,$i); if ($db != \\\'mysql\\\') $arr[] = $db; $i += 1; } return $arr; } // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) { if (!$col) $col = $this->sysTimeStamp; $s = \\\'DATE_FORMAT(\\\'.$col.",\\\'"; $concat = false; $len = strlen($fmt); for ($i=0; $i < $len; $i++) { $ch = $fmt[$i]; switch($ch) { case \\\'Y\\\': case \\\'y\\\': $s .= \\\'%Y\\\'; break; case \\\'Q\\\': case \\\'q\\\': $s .= "\\\'),Quarter($col)"; if ($len > $i+1) $s .= ",DATE_FORMAT($col,\\\'"; else $s .= ",(\\\'"; $concat = true; break; case \\\'M\\\': $s .= \\\'%b\\\'; break; case \\\'m\\\': $s .= \\\'%m\\\'; break; case \\\'D\\\': case \\\'d\\\': $s .= \\\'%d\\\'; break; case \\\'H\\\': $s .= \\\'%H\\\'; break; case \\\'h\\\': $s .= \\\'%I\\\'; break; case \\\'i\\\': $s .= \\\'%i\\\'; break; case \\\'s\\\': $s .= \\\'%s\\\'; break; case \\\'a\\\': case \\\'A\\\': $s .= \\\'%p\\\'; break; default: if ($ch == \\\'\\\\\\\\\\\') { $i++; $ch = substr($fmt,$i,1); } $s .= $ch; break; } } $s.="\\\')"; if ($concat) $s = "CONCAT($s)"; return $s; } // returns concatenated string // much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator function Concat() { $s = ""; $arr = func_get_args(); // suggestion by andrew005@mnogo.ru $s = implode(\\\',\\\',$arr); if (strlen($s) > 0) return "CONCAT($s)"; else return \\\'\\\'; } function OffsetDate($dayFraction,$date=false) { if (!$date) $date = $this->sysDate; return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)"; } // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (ADODB_PHPVER >= 0x4300) $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword, $this->forceNewConnect,$this->clientFlags); else if (ADODB_PHPVER >= 0x4200) $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword, $this->forceNewConnect); else $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; if ($argDatabasename) return $this->SelectDB($argDatabasename); return true; } // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { if (ADODB_PHPVER >= 0x4300) $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword,$this->clientFlags); else $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; if ($this->autoRollback) $this->RollbackTrans(); if ($argDatabasename) return $this->SelectDB($argDatabasename); return true; } function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { $this->forceNewConnect = true; return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename); } function &MetaColumns($table) { if ($this->metaColumnsSQL) { global $ADODB_FETCH_MODE; $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; if ($rs === false) return false; $retarr = array(); while (!$rs->EOF){ $fld = new ADOFieldObject(); $fld->name = $rs->fields[0]; $type = $rs->fields[1]; // split type into type(length): $fld->scale = null; if (strpos($type,\\\',\\\') && preg_match("/^(.+)\\\\((\\\\d+),(\\\\d+)/", $type, $query_array)) { $fld->type = $query_array[1]; $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1; } elseif (preg_match("/^(.+)\\\\((\\\\d+)/", $type, $query_array)) { $fld->type = $query_array[1]; $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; } else { $fld->max_length = -1; $fld->type = $type; } /* // split type into type(length): if (preg_match("/^(.+)\\\\((\\\\d+)/", $type, $query_array)) { $fld->type = $query_array[1]; $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; } else { $fld->max_length = -1; $fld->type = $type; }*/ $fld->not_null = ($rs->fields[2] != \\\'YES\\\'); $fld->primary_key = ($rs->fields[3] == \\\'PRI\\\'); $fld->auto_increment = (strpos($rs->fields[5], \\\'auto_increment\\\') !== false); $fld->binary = (strpos($fld->type,\\\'blob\\\') !== false); if (!$fld->binary) { $d = $rs->fields[4]; if ($d != "" && $d != "NULL") { $fld->has_default = true; $fld->default_value = $d; } else { $fld->has_default = false; } } if ($save == ADODB_FETCH_NUM) $retarr[] = $fld; else $retarr[strtoupper($fld->name)] = $fld; $rs->MoveNext(); } $rs->Close(); return $retarr; } return false; } // returns true or false function SelectDB($dbName) { $this->databaseName = $dbName; if ($this->_connectionID) { return @mysql_select_db($dbName,$this->_connectionID); } else return false; } // parameters use PostgreSQL convention, not MySQL function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0) { $offsetStr =($offset>=0) ? "$offset," : \\\'\\\'; if ($secs) $rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr); else $rs =& $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr); return $rs; } // returns queryID or false function _query($sql,$inputarr) { //global $ADODB_COUNTRECS; //if($ADODB_COUNTRECS) return mysql_query($sql,$this->_connectionID); //else return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6 } /* Returns: the last error message from previous database operation */ function ErrorMsg() { if ($this->_logsql) return $this->_errorMsg; if (empty($this->_connectionID)) $this->_errorMsg = @mysql_error(); else $this->_errorMsg = @mysql_error($this->_connectionID); return $this->_errorMsg; } /* Returns: the last error number from previous database operation */ function ErrorNo() { if ($this->_logsql) return $this->_errorCode; if (empty($this->_connectionID)) return @mysql_errno(); else return @mysql_errno($this->_connectionID); } // returns true or false function _close() { @mysql_close($this->_connectionID); $this->_connectionID = false; } /* * Maximum size of C field */ function CharMax() { return 255; } /* * Maximum size of X field */ function TextMax() { return 4294967295; } } /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ class ADORecordSet_mysql extends ADORecordSet{ var $databaseType = "mysql"; var $canSeek = true; function ADORecordSet_mysql($queryID,$mode=false) { if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } switch ($mode) { case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; default: case ADODB_FETCH_DEFAULT: case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break; } $this->ADORecordSet($queryID); } function _initrs() { //GLOBAL $ADODB_COUNTRECS; // $this->_numOfRows = ($ADODB_COUNTRECS) ? @mysql_num_rows($this->_queryID):-1; $this->_numOfRows = @mysql_num_rows($this->_queryID); $this->_numOfFields = @mysql_num_fields($this->_queryID); } function &FetchField($fieldOffset = -1) { if ($fieldOffset != -1) { $o = @mysql_fetch_field($this->_queryID, $fieldOffset); $f = @mysql_field_flags($this->_queryID,$fieldOffset); $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich@att.com) //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable $o->binary = (strpos($f,\\\'binary\\\')!== false); } else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ $o = @mysql_fetch_field($this->_queryID); $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich@att.com) //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable } return $o; } function &GetRowAssoc($upper=true) { if ($this->fetchMode == MYSQL_ASSOC && !$upper) return $this->fields; $row =& ADORecordSet::GetRowAssoc($upper); return $row; } /* Use associative array to get fields array */ function Fields($colname) { // added @ by "Michael William Miller" if ($this->fetchMode != MYSQL_NUM) return @$this->fields[$colname]; if (!$this->bind) { $this->bind = array(); for ($i=0; $i < $this->_numOfFields; $i++) { $o = $this->FetchField($i); $this->bind[strtoupper($o->name)] = $i; } } return $this->fields[$this->bind[strtoupper($colname)]]; } function _seek($row) { if ($this->_numOfRows == 0) return false; return @mysql_data_seek($this->_queryID,$row); } // 10% speedup to move MoveNext to child class function MoveNext() { //global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return adodb_movenext($this); if ($this->EOF) return false; $this->_currentRow++; $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode); if (is_array($this->fields)) return true; $this->EOF = true; /* -- tested raising an error -- appears pointless $conn = $this->connection; if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) { $fn = $conn->raiseErrorFn; $fn($conn->databaseType,\\\'MOVENEXT\\\',$errno,$conn->ErrorMsg().\\\' (\\\'.$this->sql.\\\')\\\',$conn->host,$conn->database); } */ return false; } function _fetch() { $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode); return is_array($this->fields); } function _close() { @mysql_free_result($this->_queryID); $this->_queryID = false; } function MetaType($t,$len=-1,$fieldobj=false) { if (is_object($t)) { $fieldobj = $t; $t = $fieldobj->type; $len = $fieldobj->max_length; } $len = -1; // mysql max_length is not accurate switch (strtoupper($t)) { case \\\'STRING\\\': case \\\'CHAR\\\': case \\\'VARCHAR\\\': case \\\'TINYBLOB\\\': case \\\'TINYTEXT\\\': case \\\'ENUM\\\': case \\\'SET\\\': if ($len <= $this->blobSize) return \\\'C\\\'; case \\\'TEXT\\\': case \\\'LONGTEXT\\\': case \\\'MEDIUMTEXT\\\': return \\\'X\\\'; // php_mysql extension always returns \\\'blob\\\' even if \\\'text\\\' // so we have to check whether binary... case \\\'IMAGE\\\': case \\\'LONGBLOB\\\': case \\\'BLOB\\\': case \\\'MEDIUMBLOB\\\': return !empty($fieldobj->binary) ? \\\'B\\\' : \\\'X\\\'; case \\\'YEAR\\\': case \\\'DATE\\\': return \\\'D\\\'; case \\\'TIME\\\': case \\\'DATETIME\\\': case \\\'TIMESTAMP\\\': return \\\'T\\\'; case \\\'INT\\\': case \\\'INTEGER\\\': case \\\'BIGINT\\\': case \\\'TINYINT\\\': case \\\'MEDIUMINT\\\': case \\\'SMALLINT\\\': if (!empty($fieldobj->primary_key)) return \\\'R\\\'; else return \\\'I\\\'; default: return \\\'N\\\'; } } } } ?>\', \'~core/classes/adodb/lang/adodb-en.inc.php\' => \' \\\'en\\\', DB_ERROR => \\\'unknown error\\\', DB_ERROR_ALREADY_EXISTS => \\\'already exists\\\', DB_ERROR_CANNOT_CREATE => \\\'can not create\\\', DB_ERROR_CANNOT_DELETE => \\\'can not delete\\\', DB_ERROR_CANNOT_DROP => \\\'can not drop\\\', DB_ERROR_CONSTRAINT => \\\'constraint violation\\\', DB_ERROR_DIVZERO => \\\'division by zero\\\', DB_ERROR_INVALID => \\\'invalid\\\', DB_ERROR_INVALID_DATE => \\\'invalid date or time\\\', DB_ERROR_INVALID_NUMBER => \\\'invalid number\\\', DB_ERROR_MISMATCH => \\\'mismatch\\\', DB_ERROR_NODBSELECTED => \\\'no database selected\\\', DB_ERROR_NOSUCHFIELD => \\\'no such field\\\', DB_ERROR_NOSUCHTABLE => \\\'no such table\\\', DB_ERROR_NOT_CAPABLE => \\\'DB backend not capable\\\', DB_ERROR_NOT_FOUND => \\\'not found\\\', DB_ERROR_NOT_LOCKED => \\\'not locked\\\', DB_ERROR_SYNTAX => \\\'syntax error\\\', DB_ERROR_UNSUPPORTED => \\\'not supported\\\', DB_ERROR_VALUE_COUNT_ON_ROW => \\\'value count on row\\\', DB_ERROR_INVALID_DSN => \\\'invalid DSN\\\', DB_ERROR_CONNECT_FAILED => \\\'connect failed\\\', 0 => \\\'no error\\\', // DB_OK DB_ERROR_NEED_MORE_DATA => \\\'insufficient data supplied\\\', DB_ERROR_EXTENSION_NOT_FOUND=> \\\'extension not found\\\', DB_ERROR_NOSUCHDB => \\\'no such database\\\', DB_ERROR_ACCESS_VIOLATION => \\\'insufficient permissions\\\' ); ?> \', \'~core/classes/phpmailer/class.phpmailer.inc\' => \'Site->Path.\\\'/~core/classes/phpmailer/class.phpmailer.php\\\'); class phpmailer_class extends phpmailer { function phpmailer_class() { $this->ContentType = "text/html"; $this->AddReplyTo( $GLOBALS[\\\'Conf\\\']->Site->Admin->Email ); $this->From = $GLOBALS[\\\'Conf\\\']->Site->Admin->Email; $this->FromName = $GLOBALS[\\\'Conf\\\']->Site->Admin->Name; $this->Mailer = "mail"; $this->UseMSMailHeaders = true; } } ?>\', \'~core/classes/phpmailer/class.phpmailer.php\' => \'ContentType = "text/html"; else $this->ContentType = "text/plain"; } /** * Sets Mailer to send message using SMTP. * @return void */ function IsSMTP() { $this->Mailer = "smtp"; } /** * Sets Mailer to send message using PHP mail() function. * @return void */ function IsMail() { $this->Mailer = "mail"; } /** * Sets Mailer to send message using the $Sendmail program. * @return void */ function IsSendmail() { $this->Mailer = "sendmail"; } /** * Sets Mailer to send message using the qmail MTA. * @return void */ function IsQmail() { $this->Sendmail = "/var/qmail/bin/sendmail"; $this->Mailer = "sendmail"; } ///////////////////////////////////////////////// // RECIPIENT METHODS ///////////////////////////////////////////////// /** * Adds a "To" address. * @param string $address * @param string $name * @return void */ function AddAddress($address, $name = "") { $cur = count($this->to); $this->to[$cur][0] = trim($address); $this->to[$cur][1] = $name; } /** * Adds a "Cc" address. Note: this function works * with the SMTP mailer on win32, not with the "mail" * mailer. * @param string $address * @param string $name * @return void */ function AddCC($address, $name = "") { $cur = count($this->cc); $this->cc[$cur][0] = trim($address); $this->cc[$cur][1] = $name; } /** * Adds a "Bcc" address. Note: this function works * with the SMTP mailer on win32, not with the "mail" * mailer. * @param string $address * @param string $name * @return void */ function AddBCC($address, $name = "") { $cur = count($this->bcc); $this->bcc[$cur][0] = trim($address); $this->bcc[$cur][1] = $name; } /** * Adds a "Reply-to" address. * @param string $address * @param string $name * @return void */ function AddReplyTo($address, $name = "") { $cur = count($this->ReplyTo); $this->ReplyTo[$cur][0] = trim($address); $this->ReplyTo[$cur][1] = $name; } ///////////////////////////////////////////////// // MAIL SENDING METHODS ///////////////////////////////////////////////// /** * Creates message and assigns Mailer. If the message is * not sent successfully then it returns false. Use the ErrorInfo * variable to view description of the error. * @return bool */ function Send() { $header = ""; $body = ""; if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { $this->SetError($this->Lang("provide_address")); return false; } // Set whether the message is multipart/alternative if(!empty($this->AltBody)) $this->ContentType = "multipart/alternative"; $this->SetMessageType(); $header .= $this->CreateHeader(); $body = $this->CreateBody(); if($body == "") { return false; } // Choose the mailer if($this->Mailer == "sendmail") { if(!$this->SendmailSend($header, $body)) return false; } elseif($this->Mailer == "mail") { if(!$this->MailSend($header, $body)) return false; } elseif($this->Mailer == "smtp") { if(!$this->SmtpSend($header, $body)) return false; } else { $this->SetError($this->Mailer . $this->Lang("mailer_not_supported")); return false; } return true; } /** * Sends mail using the $Sendmail program. * @access private * @return bool */ function SendmailSend($header, $body) { if ($this->Sender != "") $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender); else $sendmail = sprintf("%s -oi -t", $this->Sendmail); if(!@$mail = popen($sendmail, "w")) { $this->SetError($this->Lang("execute") . $this->Sendmail); return false; } fputs($mail, $header); fputs($mail, $body); $result = pclose($mail) >> 8 & 0xFF; if($result != 0) { $this->SetError($this->Lang("execute") . $this->Sendmail); return false; } return true; } /** * Sends mail using the PHP mail() function. * @access private * @return bool */ function MailSend($header, $body) { $to = ""; for($i = 0; $i < count($this->to); $i++) { if($i != 0) { $to .= ", "; } $to .= $this->to[$i][0]; } if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1) { $old_from = ini_get("sendmail_from"); ini_set("sendmail_from", $this->Sender); $params = sprintf("-oi -f %s", $this->Sender); $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header, $params); } else $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header); if (isset($old_from)) ini_set("sendmail_from", $old_from); if(!$rt) { $this->SetError($this->Lang("instantiate")); return false; } return true; } /** * Sends mail via SMTP using PhpSMTP (Author: * Chris Ryan). Returns bool. Returns false if there is a * bad MAIL FROM, RCPT, or DATA input. * @access private * @return bool */ function SmtpSend($header, $body) { include_once($this->PluginDir . "class.smtp.php"); $error = ""; $bad_rcpt = array(); if(!$this->SmtpConnect()) return false; $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender; if(!$this->smtp->Mail($smtp_from)) { $error = $this->Lang("from_failed") . $smtp_from; $this->SetError($error); $this->smtp->Reset(); return false; } // Attempt to send attach all recipients for($i = 0; $i < count($this->to); $i++) { if(!$this->smtp->Recipient($this->to[$i][0])) $bad_rcpt[] = $this->to[$i][0]; } for($i = 0; $i < count($this->cc); $i++) { if(!$this->smtp->Recipient($this->cc[$i][0])) $bad_rcpt[] = $this->cc[$i][0]; } for($i = 0; $i < count($this->bcc); $i++) { if(!$this->smtp->Recipient($this->bcc[$i][0])) $bad_rcpt[] = $this->bcc[$i][0]; } if(count($bad_rcpt) > 0) // Create error message { for($i = 0; $i < count($bad_rcpt); $i++) { if($i != 0) { $error .= ", "; } $error .= $bad_rcpt[$i]; } $error = $this->Lang("recipients_failed") . $error; $this->SetError($error); $this->smtp->Reset(); return false; } if(!$this->smtp->Data($header . $body)) { $this->SetError($this->Lang("data_not_accepted")); $this->smtp->Reset(); return false; } if($this->SMTPKeepAlive == true) $this->smtp->Reset(); else $this->SmtpClose(); return true; } /** * Initiates a connection to an SMTP server. Returns false if the * operation failed. * @access private * @return bool */ function SmtpConnect() { if($this->smtp == NULL) { $this->smtp = new SMTP(); } $this->smtp->do_debug = $this->SMTPDebug; $hosts = explode(";", $this->Host); $index = 0; $connection = ($this->smtp->Connected()); // Retry while there is no connection while($index < count($hosts) && $connection == false) { if(strstr($hosts[$index], ":")) list($host, $port) = explode(":", $hosts[$index]); else { $host = $hosts[$index]; $port = $this->Port; } if($this->smtp->Connect($host, $port, $this->Timeout)) { if ($this->Helo != \\\'\\\') $this->smtp->Hello($this->Helo); else $this->smtp->Hello($this->ServerHostname()); if($this->SMTPAuth) { if(!$this->smtp->Authenticate($this->Username, $this->Password)) { $this->SetError($this->Lang("authenticate")); $this->smtp->Reset(); $connection = false; } } $connection = true; } $index++; } if(!$connection) $this->SetError($this->Lang("connect_host")); return $connection; } /** * Closes the active SMTP session if one exists. * @return void */ function SmtpClose() { if($this->smtp != NULL) { if($this->smtp->Connected()) { $this->smtp->Quit(); $this->smtp->Close(); } } } /** * Sets the language for all class error messages. Returns false * if it cannot load the language file. The default language type * is English. * @param string $lang_type Type of language (e.g. Portuguese: "br") * @param string $lang_path Path to the language file directory * @access public * @return bool */ function SetLanguage($lang_type, $lang_path = "") { if(file_exists($lang_path.\\\'phpmailer.lang-\\\'.$lang_type.\\\'.php\\\')) include($lang_path.\\\'phpmailer.lang-\\\'.$lang_type.\\\'.php\\\'); else if(file_exists($lang_path.\\\'phpmailer.lang-en.php\\\')) include($lang_path.\\\'phpmailer.lang-en.php\\\'); else { $this->SetError("Could not load language file"); return false; } $this->language = $PHPMAILER_LANG; return true; } ///////////////////////////////////////////////// // MESSAGE CREATION METHODS ///////////////////////////////////////////////// /** * Creates recipient headers. * @access private * @return string */ function AddrAppend($type, $addr) { $addr_str = $type . ": "; $addr_str .= $this->AddrFormat($addr[0]); if(count($addr) > 1) { for($i = 1; $i < count($addr); $i++) $addr_str .= ", " . $this->AddrFormat($addr[$i]); } $addr_str .= $this->LE; return $addr_str; } /** * Formats an address correctly. * @access private * @return string */ function AddrFormat($addr) { if(empty($addr[1])) $formatted = $addr[0]; else { $formatted = $this->EncodeHeader($addr[1], \\\'phrase\\\') . " <" . $addr[0] . ">"; } return $formatted; } /** * Wraps message for use with mailers that do not * automatically perform wrapping and for quoted-printable. * Original written by philippe. * @access private * @return string */ function WrapText($message, $length, $qp_mode = false) { $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; $message = $this->FixEOL($message); if (substr($message, -1) == $this->LE) $message = substr($message, 0, -1); $line = explode($this->LE, $message); $message = ""; for ($i=0 ;$i < count($line); $i++) { $line_part = explode(" ", $line[$i]); $buf = ""; for ($e = 0; $e $length)) { $space_left = $length - strlen($buf) - 1; if ($e != 0) { if ($space_left > 20) { $len = $space_left; if (substr($word, $len - 1, 1) == "=") $len--; elseif (substr($word, $len - 2, 1) == "=") $len -= 2; $part = substr($word, 0, $len); $word = substr($word, $len); $buf .= " " . $part; $message .= $buf . sprintf("=%s", $this->LE); } else { $message .= $buf . $soft_break; } $buf = ""; } while (strlen($word) > 0) { $len = $length; if (substr($word, $len - 1, 1) == "=") $len--; elseif (substr($word, $len - 2, 1) == "=") $len -= 2; $part = substr($word, 0, $len); $word = substr($word, $len); if (strlen($word) > 0) $message .= $part . sprintf("=%s", $this->LE); else $buf = $part; } } else { $buf_o = $buf; $buf .= ($e == 0) ? $word : (" " . $word); if (strlen($buf) > $length and $buf_o != "") { $message .= $buf_o . $soft_break; $buf = $word; } } } $message .= $buf . $this->LE; } return $message; } /** * Set the body wrapping. * @access private * @return void */ function SetWordWrap() { if($this->WordWrap < 1) return; switch($this->message_type) { case "alt": // fall through case "alt_attachment": $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); break; default: $this->Body = $this->WrapText($this->Body, $this->WordWrap); break; } } /** * Assembles message header. * @access private * @return string */ function CreateHeader() { $result = ""; // Set the boundaries $uniq_id = md5(uniqid(time())); $this->boundary[1] = "b1_" . $uniq_id; $this->boundary[2] = "b2_" . $uniq_id; $result .= $this->Received(); $result .= $this->HeaderLine("Date", $this->RFCDate()); if($this->Sender == "") $result .= $this->HeaderLine("Return-Path", trim($this->From)); else $result .= $this->HeaderLine("Return-Path", trim($this->Sender)); // To be created automatically by mail() if($this->Mailer != "mail") { if(count($this->to) > 0) $result .= $this->AddrAppend("To", $this->to); else if (count($this->cc) == 0) $result .= $this->HeaderLine("To", "undisclosed-recipients:;"); if(count($this->cc) > 0) $result .= $this->AddrAppend("Cc", $this->cc); } $from = array(); $from[0][0] = trim($this->From); $from[0][1] = $this->FromName; $result .= $this->AddrAppend("From", $from); // sendmail and mail() extract Bcc from the header before sending if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0)) $result .= $this->AddrAppend("Bcc", $this->bcc); if(count($this->ReplyTo) > 0) $result .= $this->AddrAppend("Reply-to", $this->ReplyTo); // mail() sets the subject itself if($this->Mailer != "mail") $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject))); $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); $result .= $this->HeaderLine("X-Priority", $this->Priority); $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]"); if($this->ConfirmReadingTo != "") { $result .= $this->HeaderLine("Disposition-Notification-To", "<" . trim($this->ConfirmReadingTo) . ">"); } // Add custom headers for($index = 0; $index < count($this->CustomHeader); $index++) { $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); } $result .= $this->HeaderLine("MIME-Version", "1.0"); switch($this->message_type) { case "plain": $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding); $result .= sprintf("Content-Type: %s; charset=\\\\"%s\\\\"", $this->ContentType, $this->CharSet); break; case "attachments": // fall through case "alt_attachments": if($this->InlineImageExists()) { $result .= sprintf("Content-Type: %s;%s\\\\ttype=\\\\"text/html\\\\";%s\\\\tboundary=\\\\"%s\\\\"%s", "multipart/related", $this->LE, $this->LE, $this->boundary[1], $this->LE); } else { $result .= $this->HeaderLine("Content-Type", "multipart/mixed;"); $result .= $this->TextLine("\\\\tboundary=\\\\"" . $this->boundary[1] . \\\'"\\\'); } break; case "alt": $result .= $this->HeaderLine("Content-Type", "multipart/alternative;"); $result .= $this->TextLine("\\\\tboundary=\\\\"" . $this->boundary[1] . \\\'"\\\'); break; } if($this->Mailer != "mail") $result .= $this->LE.$this->LE; return $result; } /** * Assembles the message body. Returns an empty string on failure. * @access private * @return string */ function CreateBody() { $result = ""; $this->SetWordWrap(); switch($this->message_type) { case "alt": $result .= $this->GetBoundary($this->boundary[1], "", "text/plain", ""); $result .= $this->EncodeString($this->AltBody, $this->Encoding); $result .= $this->LE.$this->LE; $result .= $this->GetBoundary($this->boundary[1], "", "text/html", ""); $result .= $this->EncodeString($this->Body, $this->Encoding); $result .= $this->LE.$this->LE; $result .= $this->EndBoundary($this->boundary[1]); break; case "plain": $result .= $this->EncodeString($this->Body, $this->Encoding); break; case "attachments": $result .= $this->GetBoundary($this->boundary[1], "", "", ""); $result .= $this->EncodeString($this->Body, $this->Encoding); $result .= $this->LE; $result .= $this->AttachAll(); break; case "alt_attachments": $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); $result .= sprintf("Content-Type: %s;%s" . "\\\\tboundary=\\\\"%s\\\\"%s", "multipart/alternative", $this->LE, $this->boundary[2], $this->LE.$this->LE); // Create text body $result .= $this->GetBoundary($this->boundary[2], "", "text/plain", "") . $this->LE; $result .= $this->EncodeString($this->AltBody, $this->Encoding); $result .= $this->LE.$this->LE; // Create the HTML body $result .= $this->GetBoundary($this->boundary[2], "", "text/html", "") . $this->LE; $result .= $this->EncodeString($this->Body, $this->Encoding); $result .= $this->LE.$this->LE; $result .= $this->EndBoundary($this->boundary[2]); $result .= $this->AttachAll(); break; } if($this->IsError()) $result = ""; return $result; } /** * Returns the start of a message boundary. * @access private */ function GetBoundary($boundary, $charSet, $contentType, $encoding) { $result = ""; if($charSet == "") { $charSet = $this->CharSet; } if($contentType == "") { $contentType = $this->ContentType; } if($encoding == "") { $encoding = $this->Encoding; } $result .= $this->TextLine("--" . $boundary); $result .= sprintf("Content-Type: %s; charset = \\\\"%s\\\\"", $contentType, $charSet); $result .= $this->LE; $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding); $result .= $this->LE; return $result; } /** * Returns the end of a message boundary. * @access private */ function EndBoundary($boundary) { return $this->LE . "--" . $boundary . "--" . $this->LE; } /** * Sets the message type. * @access private * @return void */ function SetMessageType() { if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) $this->message_type = "plain"; else { if(count($this->attachment) > 0) $this->message_type = "attachments"; if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) $this->message_type = "alt"; if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) $this->message_type = "alt_attachments"; } } /** * Returns a formatted header line. * @access private * @return string */ function HeaderLine($name, $value) { return $name . ": " . $value . $this->LE; } /** * Returns a formatted mail line. * @access private * @return string */ function TextLine($value) { return $value . $this->LE; } ///////////////////////////////////////////////// // ATTACHMENT METHODS ///////////////////////////////////////////////// /** * Adds an attachment from a path on the filesystem. * Returns false if the file could not be found * or accessed. * @param string $path Path to the attachment. * @param string $name Overrides the attachment name. * @param string $encoding File encoding (see $Encoding). * @param string $type File extension (MIME) type. * @return bool */ function AddAttachment($path, $name = "", $encoding = "base64", $type = "application/octet-stream") { if(!@is_file($path)) { $this->SetError($this->Lang("file_access") . $path); return false; } $filename = basename($path); if($name == "") $name = $filename; $cur = count($this->attachment); $this->attachment[$cur][0] = $path; $this->attachment[$cur][1] = $filename; $this->attachment[$cur][2] = $name; $this->attachment[$cur][3] = $encoding; $this->attachment[$cur][4] = $type; $this->attachment[$cur][5] = false; // isStringAttachment $this->attachment[$cur][6] = "attachment"; $this->attachment[$cur][7] = 0; return true; } /** * Attaches all fs, string, and binary attachments to the message. * Returns an empty string on failure. * @access private * @return string */ function AttachAll() { // Return text of body $mime = array(); // Add all attachments for($i = 0; $i < count($this->attachment); $i++) { // Check for string attachment $bString = $this->attachment[$i][5]; if ($bString) $string = $this->attachment[$i][0]; else $path = $this->attachment[$i][0]; $filename = $this->attachment[$i][1]; $name = $this->attachment[$i][2]; $encoding = $this->attachment[$i][3]; $type = $this->attachment[$i][4]; $disposition = $this->attachment[$i][6]; $cid = $this->attachment[$i][7]; $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); $mime[] = sprintf("Content-Type: %s; name=\\\\"%s\\\\"%s", $type, $name, $this->LE); $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); if($disposition == "inline") $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); $mime[] = sprintf("Content-Disposition: %s; filename=\\\\"%s\\\\"%s", $disposition, $name, $this->LE.$this->LE); // Encode as string attachment if($bString) { $mime[] = $this->EncodeString($string, $encoding); if($this->IsError()) { return ""; } $mime[] = $this->LE.$this->LE; } else { $mime[] = $this->EncodeFile($path, $encoding); if($this->IsError()) { return ""; } $mime[] = $this->LE.$this->LE; } } $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); return join("", $mime); } /** * Encodes attachment in requested format. Returns an * empty string on failure. * @access private * @return string */ function EncodeFile ($path, $encoding = "base64") { if(!@$fd = fopen($path, "rb")) { $this->SetError($this->Lang("file_open") . $path); return ""; } $file_buffer = fread($fd, filesize($path)); $file_buffer = $this->EncodeString($file_buffer, $encoding); fclose($fd); return $file_buffer; } /** * Encodes string to requested format. Returns an * empty string on failure. * @access private * @return string */ function EncodeString ($str, $encoding = "base64") { $encoded = ""; switch(strtolower($encoding)) { case "base64": // chunk_split is found in PHP >= 3.0.6 $encoded = chunk_split(base64_encode($str), 76, $this->LE); break; case "7bit": case "8bit": $encoded = $this->FixEOL($str); if (substr($encoded, -(strlen($this->LE))) != $this->LE) $encoded .= $this->LE; break; case "binary": $encoded = $str; break; case "quoted-printable": $encoded = $this->EncodeQP($str); break; default: $this->SetError($this->Lang("encoding") . $encoding); break; } return $encoded; } /** * Encode a header string to best of Q, B, quoted or none. * @access private * @return string */ function EncodeHeader ($str, $position = \\\'text\\\') { $x = 0; switch (strtolower($position)) { case \\\'phrase\\\': if (!preg_match(\\\'/[\\\\200-\\\\377]/\\\', $str)) { // Can\\\'t use addslashes as we don\\\'t know what value has magic_quotes_sybase. $encoded = addcslashes($str, "\\\\0..\\\\37\\\\177\\\\\\\\\\\\""); if (($str == $encoded) && !preg_match(\\\'/[^A-Za-z0-9!#$%&\\\\\\\'*+\\\\/=?^_`{|}~ -]/\\\', $str)) return ($encoded); else return ("\\\\"$encoded\\\\""); } $x = preg_match_all(\\\'/[^\\\\040\\\\041\\\\043-\\\\133\\\\135-\\\\176]/\\\', $str, $matches); break; case \\\'comment\\\': $x = preg_match_all(\\\'/[()"]/\\\', $str, $matches); // Fall-through case \\\'text\\\': default: $x += preg_match_all(\\\'/[\\\\000-\\\\010\\\\013\\\\014\\\\016-\\\\037\\\\177-\\\\377]/\\\', $str, $matches); break; } if ($x == 0) return ($str); $maxlen = 75 - 7 - strlen($this->CharSet); // Try to select the encoding which should produce the shortest output if (strlen($str)/3 < $x) { $encoding = \\\'B\\\'; $encoded = base64_encode($str); $maxlen -= $maxlen % 4; $encoded = trim(chunk_split($encoded, $maxlen, "\\\\n")); } else { $encoding = \\\'Q\\\'; $encoded = $this->EncodeQ($str, $position); $encoded = $this->WrapText($encoded, $maxlen, true); $encoded = str_replace("=".$this->LE, "\\\\n", trim($encoded)); } $encoded = preg_replace(\\\'/^(.*)$/m\\\', " =?".$this->CharSet."?$encoding?\\\\\\\\1?=", $encoded); $encoded = trim(str_replace("\\\\n", $this->LE, $encoded)); return $encoded; } /** * Encode string to quoted-printable. * @access private * @return string */ function EncodeQP ($str) { $encoded = $this->FixEOL($str); if (substr($encoded, -(strlen($this->LE))) != $this->LE) $encoded .= $this->LE; // Replace every high ascii, control and = characters $encoded = preg_replace(\\\'/([\\\\000-\\\\010\\\\013\\\\014\\\\016-\\\\037\\\\075\\\\177-\\\\377])/e\\\', "\\\'=\\\'.sprintf(\\\'%02X\\\', ord(\\\'\\\\\\\\1\\\'))", $encoded); // Replace every spaces and tabs when it\\\'s the last character on a line $encoded = preg_replace("/([\\\\011\\\\040])".$this->LE."/e", "\\\'=\\\'.sprintf(\\\'%02X\\\', ord(\\\'\\\\\\\\1\\\')).\\\'".$this->LE."\\\'", $encoded); // Maximum line length of 76 characters before CRLF (74 + space + \\\'=\\\') $encoded = $this->WrapText($encoded, 74, true); return $encoded; } /** * Encode string to q encoding. * @access private * @return string */ function EncodeQ ($str, $position = "text") { // There should not be any EOL in the string $encoded = preg_replace("[\\\\r\\\\n]", "", $str); switch (strtolower($position)) { case "phrase": $encoded = preg_replace("/([^A-Za-z0-9!*+\\\\/ -])/e", "\\\'=\\\'.sprintf(\\\'%02X\\\', ord(\\\'\\\\\\\\1\\\'))", $encoded); break; case "comment": $encoded = preg_replace("/([\\\\(\\\\)\\\\"])/e", "\\\'=\\\'.sprintf(\\\'%02X\\\', ord(\\\'\\\\\\\\1\\\'))", $encoded); case "text": default: // Replace every high ascii, control =, ? and _ characters $encoded = preg_replace(\\\'/([\\\\000-\\\\011\\\\013\\\\014\\\\016-\\\\037\\\\075\\\\077\\\\137\\\\177-\\\\377])/e\\\', "\\\'=\\\'.sprintf(\\\'%02X\\\', ord(\\\'\\\\\\\\1\\\'))", $encoded); break; } // Replace every spaces to _ (more readable than =20) $encoded = str_replace(" ", "_", $encoded); return $encoded; } /** * Adds a string or binary attachment (non-filesystem) to the list. * This method can be used to attach ascii or binary data, * such as a BLOB record from a database. * @param string $string String attachment data. * @param string $filename Name of the attachment. * @param string $encoding File encoding (see $Encoding). * @param string $type File extension (MIME) type. * @return void */ function AddStringAttachment($string, $filename, $encoding = "base64", $type = "application/octet-stream") { // Append to $attachment array $cur = count($this->attachment); $this->attachment[$cur][0] = $string; $this->attachment[$cur][1] = $filename; $this->attachment[$cur][2] = $filename; $this->attachment[$cur][3] = $encoding; $this->attachment[$cur][4] = $type; $this->attachment[$cur][5] = true; // isString $this->attachment[$cur][6] = "attachment"; $this->attachment[$cur][7] = 0; } /** * Adds an embedded attachment. This can include images, sounds, and * just about any other document. Make sure to set the $type to an * image type. For JPEG images use "image/jpeg" and for GIF images * use "image/gif". * @param string $path Path to the attachment. * @param string $cid Content ID of the attachment. Use this to identify * the Id for accessing the image in an HTML form. * @param string $name Overrides the attachment name. * @param string $encoding File encoding (see $Encoding). * @param string $type File extension (MIME) type. * @return bool */ function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", $type = "application/octet-stream") { if(!@is_file($path)) { $this->SetError($this->Lang("file_access") . $path); return false; } $filename = basename($path); if($name == "") $name = $filename; // Append to $attachment array $cur = count($this->attachment); $this->attachment[$cur][0] = $path; $this->attachment[$cur][1] = $filename; $this->attachment[$cur][2] = $name; $this->attachment[$cur][3] = $encoding; $this->attachment[$cur][4] = $type; $this->attachment[$cur][5] = false; // isStringAttachment $this->attachment[$cur][6] = "inline"; $this->attachment[$cur][7] = $cid; return true; } /** * Returns true if an inline attachment is present. * @access private * @return bool */ function InlineImageExists() { $result = false; for($i = 0; $i < count($this->attachment); $i++) { if($this->attachment[$i][6] == "inline") { $result = true; break; } } return $result; } ///////////////////////////////////////////////// // MESSAGE RESET METHODS ///////////////////////////////////////////////// /** * Clears all recipients assigned in the TO array. Returns void. * @return void */ function ClearAddresses() { $this->to = array(); } /** * Clears all recipients assigned in the CC array. Returns void. * @return void */ function ClearCCs() { $this->cc = array(); } /** * Clears all recipients assigned in the BCC array. Returns void. * @return void */ function ClearBCCs() { $this->bcc = array(); } /** * Clears all recipients assigned in the ReplyTo array. Returns void. * @return void */ function ClearReplyTos() { $this->ReplyTo = array(); } /** * Clears all recipients assigned in the TO, CC and BCC * array. Returns void. * @return void */ function ClearAllRecipients() { $this->to = array(); $this->cc = array(); $this->bcc = array(); } /** * Clears all previously set filesystem, string, and binary * attachments. Returns void. * @return void */ function ClearAttachments() { $this->attachment = array(); } /** * Clears all custom headers. Returns void. * @return void */ function ClearCustomHeaders() { $this->CustomHeader = array(); } ///////////////////////////////////////////////// // MISCELLANEOUS METHODS ///////////////////////////////////////////////// /** * Adds the error message to the error container. * Returns void. * @access private * @return void */ function SetError($msg) { $this->error_count++; $this->ErrorInfo = $msg; } /** * Returns the proper RFC 822 formatted date. * @access private * @return string */ function RFCDate() { $tz = date("Z"); $tzs = ($tz < 0) ? "-" : "+"; $tz = abs($tz); $tz = ($tz/3600)*100 + ($tz%3600)/60; $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz); return $result; } /** * Returns Received header for message tracing. * @access private * @return string */ function Received() { if ($this->ServerVar(\\\'SERVER_NAME\\\') != \\\'\\\') { $protocol = ($this->ServerVar(\\\'HTTPS\\\') == \\\'on\\\') ? \\\'HTTPS\\\' : \\\'HTTP\\\'; $remote = $this->ServerVar(\\\'REMOTE_HOST\\\'); if($remote == "") $remote = \\\'phpmailer\\\'; $remote .= \\\' ([\\\'.$this->ServerVar(\\\'REMOTE_ADDR\\\').\\\'])\\\'; } else { $protocol = \\\'local\\\'; $remote = $this->ServerVar(\\\'USER\\\'); if($remote == \\\'\\\') $remote = \\\'phpmailer\\\'; } $result = sprintf("Received: from %s %s\\\\tby %s " . "with %s (PHPMailer);%s\\\\t%s%s", $remote, $this->LE, $this->ServerHostname(), $protocol, $this->LE, $this->RFCDate(), $this->LE); return $result; } /** * Returns the appropriate server variable. Should work with both * PHP 4.1.0+ as well as older versions. Returns an empty string * if nothing is found. * @access private * @return mixed */ function ServerVar($varName) { global $HTTP_SERVER_VARS; global $HTTP_ENV_VARS; if(!isset($_SERVER)) { $_SERVER = $HTTP_SERVER_VARS; if(!isset($_SERVER["REMOTE_ADDR"])) $_SERVER = $HTTP_ENV_VARS; // must be Apache } if(isset($_SERVER[$varName])) return $_SERVER[$varName]; else return ""; } /** * Returns the server hostname or \\\'localhost.localdomain\\\' if unknown. * @access private * @return string */ function ServerHostname() { if ($this->Hostname != "") $result = $this->Hostname; elseif ($this->ServerVar(\\\'SERVER_NAME\\\') != "") $result = $this->ServerVar(\\\'SERVER_NAME\\\'); else $result = "localhost.localdomain"; return $result; } /** * Returns a message in the appropriate language. * @access private * @return string */ function Lang($key) { if(count($this->language) < 1) $this->SetLanguage("en"); // set the default language if(isset($this->language[$key])) return $this->language[$key]; else return "Language string failed to load: " . $key; } /** * Returns true if an error occurred. * @return bool */ function IsError() { return ($this->error_count > 0); } /** * Changes every end of line from CR or LF to CRLF. * @access private * @return string */ function FixEOL($str) { $str = str_replace("\\\\r\\\\n", "\\\\n", $str); $str = str_replace("\\\\r", "\\\\n", $str); $str = str_replace("\\\\n", $this->LE, $str); return $str; } /** * Adds a custom header. * @return void */ function AddCustomHeader($custom_header) { $this->CustomHeader[] = explode(":", $custom_header, 2); } } ?> \', \'~core/classes/phpmailer/class.smtp.php\' => \'smtp_conn = 0; $this->error = null; $this->helo_rply = null; $this->do_debug = 0; } /************************************************************* * CONNECTION FUNCTIONS * ***********************************************************/ /** * Connect to the server specified on the port specified. * If the port is not specified use the default SMTP_PORT. * If tval is specified then a connection will try and be * established with the server for that number of seconds. * If tval is not specified the default is 30 seconds to * try on the connection. * * SMTP CODE SUCCESS: 220 * SMTP CODE FAILURE: 421 * @access public * @return bool */ function Connect($host,$port=0,$tval=30) { # set the error val to null so there is no confusion $this->error = null; # make sure we are __not__ connected if($this->connected()) { # ok we are connected! what should we do? # for now we will just give an error saying we # are already connected $this->error = array("error" => "Already connected to a server"); return false; } if(empty($port)) { $port = $this->SMTP_PORT; } #connect to the smtp server $this->smtp_conn = fsockopen($host, # the host of the server $port, # the port to use $errno, # error number if any $errstr, # error message if any $tval); # give up after ? secs # verify we connected properly if(empty($this->smtp_conn)) { $this->error = array("error" => "Failed to connect to server", "errno" => $errno, "errstr" => $errstr); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF; } return false; } # sometimes the SMTP server takes a little longer to respond # so we will give it a longer timeout for the first read // Windows still does not have support for this timeout function if(substr(PHP_OS, 0, 3) != "WIN") socket_set_timeout($this->smtp_conn, $tval, 0); # get any announcement stuff $announce = $this->get_lines(); # set the timeout of any socket functions at 1/10 of a second //if(function_exists("socket_set_timeout")) // socket_set_timeout($this->smtp_conn, 0, 100000); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; } return true; } /** * Performs SMTP authentication. Must be run after running the * Hello() method. Returns true if successfully authenticated. * @access public * @return bool */ function Authenticate($username, $password) { // Start authentication fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($code != 334) { $this->error = array("error" => "AUTH not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } // Send encoded username fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($code != 334) { $this->error = array("error" => "Username not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } // Send encoded password fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($code != 235) { $this->error = array("error" => "Password not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return true; } /** * Returns true if connected to a server otherwise false * @access private * @return bool */ function Connected() { if(!empty($this->smtp_conn)) { $sock_status = socket_get_status($this->smtp_conn); if($sock_status["eof"]) { # hmm this is an odd situation... the socket is # valid but we aren\\\'t connected anymore if($this->do_debug >= 1) { echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"; } $this->Close(); return false; } return true; # everything looks good } return false; } /** * Closes the socket and cleans up the state of the class. * It is not considered good to use this function without * first trying to use QUIT. * @access public * @return void */ function Close() { $this->error = null; # so there is no confusion $this->helo_rply = null; if(!empty($this->smtp_conn)) { # close the connection and cleanup fclose($this->smtp_conn); $this->smtp_conn = 0; } } /*************************************************************** * SMTP COMMANDS * *************************************************************/ /** * Issues a data command and sends the msg_data to the server * finializing the mail transaction. $msg_data is the message * that is to be send with the headers. Each header needs to be * on a single line followed by a with the message headers * and the message body being seperated by and additional . * * Implements rfc 821: DATA * * SMTP CODE INTERMEDIATE: 354 * [data] * . * SMTP CODE SUCCESS: 250 * SMTP CODE FAILURE: 552,554,451,452 * SMTP CODE FAILURE: 451,554 * SMTP CODE ERROR : 500,501,503,421 * @access public * @return bool */ function Data($msg_data) { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Data() without being connected"); return false; } fputs($this->smtp_conn,"DATA" . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 354) { $this->error = array("error" => "DATA command not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } # the server is ready to accept data! # according to rfc 821 we should not send more than 1000 # including the CRLF # characters on a single line so we will break the data up # into lines by \\\\r and/or \\\\n then if needed we will break # each of those into smaller lines to fit within the limit. # in addition we will be looking for lines that start with # a period \\\'.\\\' and append and additional period \\\'.\\\' to that # line. NOTE: this does not count towards are limit. # normalize the line breaks so we know the explode works $msg_data = str_replace("\\\\r\\\\n","\\\\n",$msg_data); $msg_data = str_replace("\\\\r","\\\\n",$msg_data); $lines = explode("\\\\n",$msg_data); # we need to find a good way to determine is headers are # in the msg_data or if it is a straight msg body # currently I\\\'m assuming rfc 822 definitions of msg headers # and if the first field of the first line (\\\':\\\' sperated) # does not contain a space then it _should_ be a header # and we can process all lines before a blank "" line as # headers. $field = substr($lines[0],0,strpos($lines[0],":")); $in_headers = false; if(!empty($field) && !strstr($field," ")) { $in_headers = true; } $max_line_length = 998; # used below; set here for ease in change while(list(,$line) = @each($lines)) { $lines_out = null; if($line == "" && $in_headers) { $in_headers = false; } # ok we need to break this line up into several # smaller lines while(strlen($line) > $max_line_length) { $pos = strrpos(substr($line,0,$max_line_length)," "); $lines_out[] = substr($line,0,$pos); $line = substr($line,$pos + 1); # if we are processing headers we need to # add a LWSP-char to the front of the new line # rfc 822 on long msg headers if($in_headers) { $line = "\\\\t" . $line; } } $lines_out[] = $line; # now send the lines to the server while(list(,$line_out) = @each($lines_out)) { if(strlen($line_out) > 0) { if(substr($line_out, 0, 1) == ".") { $line_out = "." . $line_out; } } fputs($this->smtp_conn,$line_out . $this->CRLF); } } # ok all the message data has been sent so lets get this # over with aleady fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250) { $this->error = array("error" => "DATA not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return true; } /** * Expand takes the name and asks the server to list all the * people who are members of the _list_. Expand will return * back and array of the result or false if an error occurs. * Each value in the array returned has the format of: * [ ] * The definition of is defined in rfc 821 * * Implements rfc 821: EXPN * * SMTP CODE SUCCESS: 250 * SMTP CODE FAILURE: 550 * SMTP CODE ERROR : 500,501,502,504,421 * @access public * @return string array */ function Expand($name) { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Expand() without being connected"); return false; } fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250) { $this->error = array("error" => "EXPN not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } # parse the reply and place in our array to return to user $entries = explode($this->CRLF,$rply); while(list(,$l) = @each($entries)) { $list[] = substr($l,4); } return $list; } /** * Sends the HELO command to the smtp server. * This makes sure that we and the server are in * the same known state. * * Implements from rfc 821: HELO * * SMTP CODE SUCCESS: 250 * SMTP CODE ERROR : 500, 501, 504, 421 * @access public * @return bool */ function Hello($host="") { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Hello() without being connected"); return false; } # if a hostname for the HELO wasn\\\'t specified determine # a suitable one to send if(empty($host)) { # we need to determine some sort of appopiate default # to send to the server $host = "localhost"; } // Send extended hello first (RFC 2821) if(!$this->SendHello("EHLO", $host)) { if(!$this->SendHello("HELO", $host)) return false; } return true; } /** * Sends a HELO/EHLO command. * @access private * @return bool */ function SendHello($hello, $host) { fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; } if($code != 250) { $this->error = array("error" => $hello . " not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } $this->helo_rply = $rply; return true; } /** * Gets help information on the keyword specified. If the keyword * is not specified then returns generic help, ussually contianing * A list of keywords that help is available on. This function * returns the results back to the user. It is up to the user to * handle the returned data. If an error occurs then false is * returned with $this->error set appropiately. * * Implements rfc 821: HELP [ ] * * SMTP CODE SUCCESS: 211,214 * SMTP CODE ERROR : 500,501,502,504,421 * @access public * @return string */ function Help($keyword="") { $this->error = null; # to avoid confusion if(!$this->connected()) { $this->error = array( "error" => "Called Help() without being connected"); return false; } $extra = ""; if(!empty($keyword)) { $extra = " " . $keyword; } fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 211 && $code != 214) { $this->error = array("error" => "HELP not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return $rply; } /** * Starts a mail transaction from the email address specified in * $from. Returns true if successful or false otherwise. If True * the mail transaction is started and then one or more Recipient * commands may be called followed by a Data command. * * Implements rfc 821: MAIL FROM: * * SMTP CODE SUCCESS: 250 * SMTP CODE SUCCESS: 552,451,452 * SMTP CODE SUCCESS: 500,501,421 * @access public * @return bool */ function Mail($from) { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Mail() without being connected"); return false; } fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250) { $this->error = array("error" => "MAIL not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return true; } /** * Sends the command NOOP to the SMTP server. * * Implements from rfc 821: NOOP * * SMTP CODE SUCCESS: 250 * SMTP CODE ERROR : 500, 421 * @access public * @return bool */ function Noop() { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Noop() without being connected"); return false; } fputs($this->smtp_conn,"NOOP" . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250) { $this->error = array("error" => "NOOP not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return true; } /** * Sends the quit command to the server and then closes the socket * if there is no error or the $close_on_error argument is true. * * Implements from rfc 821: QUIT * * SMTP CODE SUCCESS: 221 * SMTP CODE ERROR : 500 * @access public * @return bool */ function Quit($close_on_error=true) { $this->error = null; # so there is no confusion if(!$this->connected()) { $this->error = array( "error" => "Called Quit() without being connected"); return false; } # send the quit command to the server fputs($this->smtp_conn,"quit" . $this->CRLF); # get any good-bye messages $byemsg = $this->get_lines(); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; } $rval = true; $e = null; $code = substr($byemsg,0,3); if($code != 221) { # use e as a tmp var cause Close will overwrite $this->error $e = array("error" => "SMTP server rejected quit command", "smtp_code" => $code, "smtp_rply" => substr($byemsg,4)); $rval = false; if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF; } } if(empty($e) || $close_on_error) { $this->Close(); } return $rval; } /** * Sends the command RCPT to the SMTP server with the TO: argument of $to. * Returns true if the recipient was accepted false if it was rejected. * * Implements from rfc 821: RCPT TO: * * SMTP CODE SUCCESS: 250,251 * SMTP CODE FAILURE: 550,551,552,553,450,451,452 * SMTP CODE ERROR : 500,501,503,421 * @access public * @return bool */ function Recipient($to) { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Recipient() without being connected"); return false; } fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250 && $code != 251) { $this->error = array("error" => "RCPT not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return true; } /** * Sends the RSET command to abort and transaction that is * currently in progress. Returns true if successful false * otherwise. * * Implements rfc 821: RSET * * SMTP CODE SUCCESS: 250 * SMTP CODE ERROR : 500,501,504,421 * @access public * @return bool */ function Reset() { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Reset() without being connected"); return false; } fputs($this->smtp_conn,"RSET" . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250) { $this->error = array("error" => "RSET failed", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return true; } /** * Starts a mail transaction from the email address specified in * $from. Returns true if successful or false otherwise. If True * the mail transaction is started and then one or more Recipient * commands may be called followed by a Data command. This command * will send the message to the users terminal if they are logged * in. * * Implements rfc 821: SEND FROM: * * SMTP CODE SUCCESS: 250 * SMTP CODE SUCCESS: 552,451,452 * SMTP CODE SUCCESS: 500,501,502,421 * @access public * @return bool */ function Send($from) { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Send() without being connected"); return false; } fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250) { $this->error = array("error" => "SEND not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return true; } /** * Starts a mail transaction from the email address specified in * $from. Returns true if successful or false otherwise. If True * the mail transaction is started and then one or more Recipient * commands may be called followed by a Data command. This command * will send the message to the users terminal if they are logged * in and send them an email. * * Implements rfc 821: SAML FROM: * * SMTP CODE SUCCESS: 250 * SMTP CODE SUCCESS: 552,451,452 * SMTP CODE SUCCESS: 500,501,502,421 * @access public * @return bool */ function SendAndMail($from) { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called SendAndMail() without being connected"); return false; } fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250) { $this->error = array("error" => "SAML not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return true; } /** * Starts a mail transaction from the email address specified in * $from. Returns true if successful or false otherwise. If True * the mail transaction is started and then one or more Recipient * commands may be called followed by a Data command. This command * will send the message to the users terminal if they are logged * in or mail it to them if they are not. * * Implements rfc 821: SOML FROM: * * SMTP CODE SUCCESS: 250 * SMTP CODE SUCCESS: 552,451,452 * SMTP CODE SUCCESS: 500,501,502,421 * @access public * @return bool */ function SendOrMail($from) { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called SendOrMail() without being connected"); return false; } fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250) { $this->error = array("error" => "SOML not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return true; } /** * This is an optional command for SMTP that this class does not * support. This method is here to make the RFC821 Definition * complete for this class and __may__ be implimented in the future * * Implements from rfc 821: TURN * * SMTP CODE SUCCESS: 250 * SMTP CODE FAILURE: 502 * SMTP CODE ERROR : 500, 503 * @access public * @return bool */ function Turn() { $this->error = array("error" => "This method, TURN, of the SMTP ". "is not implemented"); if($this->do_debug >= 1) { echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; } return false; } /** * Verifies that the name is recognized by the server. * Returns false if the name could not be verified otherwise * the response from the server is returned. * * Implements rfc 821: VRFY * * SMTP CODE SUCCESS: 250,251 * SMTP CODE FAILURE: 550,551,553 * SMTP CODE ERROR : 500,501,502,421 * @access public * @return int */ function Verify($name) { $this->error = null; # so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Verify() without being connected"); return false; } fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; } if($code != 250 && $code != 251) { $this->error = array("error" => "VRFY failed on name \\\'$name\\\'", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; } return false; } return $rply; } /******************************************************************* * INTERNAL FUNCTIONS * ******************************************************************/ /** * Read in as many lines as possible * either before eof or socket timeout occurs on the operation. * With SMTP we can tell if we have more lines to read if the * 4th character is \\\'-\\\' symbol. If it is a space then we don\\\'t * need to read anything else. * @access private * @return string */ function get_lines() { $data = ""; while($str = fgets($this->smtp_conn,515)) { if($this->do_debug >= 4) { echo "SMTP -> get_lines(): \\\\$data was \\\\"$data\\\\"" . $this->CRLF; echo "SMTP -> get_lines(): \\\\$str is \\\\"$str\\\\"" . $this->CRLF; } $data .= $str; if($this->do_debug >= 4) { echo "SMTP -> get_lines(): \\\\$data is \\\\"$data\\\\"" . $this->CRLF; } # if the 4th character is a space then we are done reading # so just break the loop if(substr($str,3,1) == " ") { break; } } return $data; } } ?> \', \'~core/classes/phpmailer/language/phpmailer.lang-en.php\' => \' \', \'~core/classes/smarty/cache/_\' => \'\', \'~core/classes/smarty/class.smarty.inc\' => \'Site->Path.\\\'/~core/classes/smarty/\\\'); require_once(SMARTY_DIR.\\\'smarty.class.php\\\'); class Smarty_class extends Smarty { function Smarty_class() { $this->Smarty(); $this->template_dir = $GLOBALS[\\\'Conf\\\']->Design->Dir->Templates; $this->plugins_dir = array(SMARTY_DIR.\\\'plugins/\\\'); $this->compile_dir = SMARTY_DIR.\\\'compiled/\\\'; $this->cache_dir = SMARTY_DIR.\\\'cache/\\\'; $this->left_delimiter = \\\'\\\'; $this->compile_check = true; $this->force_compile = false; $this->debugging = false; $this->caching = $GLOBALS[\\\'Conf\\\']->System->Cache->Enable; $this->cache_lifetime = $GLOBALS[\\\'Conf\\\']->System->Cache->LiveTime; $this->load_filter(\\\'pre\\\', \\\'path\\\'); } } ?> \', \'~core/classes/smarty/compiled/_\' => \'\', \'~core/classes/smarty/config_file.class.php\' => \' * @access public * @package Smarty */ /* $Id: Config_File.class.php,v 1.58 2003/11/19 20:26:29 mohrt Exp $ */ /** * Config file reading class * @package Smarty */ class Config_File { /**#@+ * Options * @var boolean */ /** * Controls whether variables with the same name overwrite each other. */ var $overwrite = true; /** * Controls whether config values of on/true/yes and off/false/no get * converted to boolean values automatically. */ var $booleanize = true; /** * Controls whether hidden config sections/vars are read from the file. */ var $read_hidden = true; /** * Controls whether or not to fix mac or dos formatted newlines. * If set to true, \\\\r or \\\\r\\\\n will be changed to \\\\n. */ var $fix_newlines = false; /**#@-*/ /** @access private */ var $_config_path = ""; var $_config_data = array(); /**#@-*/ /** * Constructs a new config file class. * * @param string $config_path (optional) path to the config files */ function Config_File($config_path = NULL) { if (isset($config_path)) $this->set_path($config_path); } /** * Set the path where configuration files can be found. * * @param string $config_path path to the config files */ function set_path($config_path) { if (!empty($config_path)) { if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) { $this->_trigger_error_msg("Bad config file path \\\'$config_path\\\'"); return; } if(substr($config_path, -1) != DIRECTORY_SEPARATOR) { $config_path .= DIRECTORY_SEPARATOR; } $this->_config_path = $config_path; } } /** * Retrieves config info based on the file, section, and variable name. * * @param string $file_name config file to get info for * @param string $section_name (optional) section to get info for * @param string $var_name (optional) variable to get info for * @return string|array a value or array of values */ function &get($file_name, $section_name = NULL, $var_name = NULL) { if (empty($file_name)) { $this->_trigger_error_msg(\\\'Empty config file name\\\'); return; } else { $file_name = $this->_config_path . $file_name; if (!isset($this->_config_data[$file_name])) $this->load_file($file_name, false); } if (!empty($var_name)) { if (empty($section_name)) { return $this->_config_data[$file_name]["vars"][$var_name]; } else { if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; else return array(); } } else { if (empty($section_name)) { return (array)$this->_config_data[$file_name]["vars"]; } else { if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; else return array(); } } } /** * Retrieves config info based on the key. * * @param $file_name string config key (filename/section/var) * @return string|array same as get() * @uses get() retrieves information from config file and returns it */ function &get_key($config_key) { list($file_name, $section_name, $var_name) = explode(\\\'/\\\', $config_key, 3); $result = &$this->get($file_name, $section_name, $var_name); return $result; } /** * Get all loaded config file names. * * @return array an array of loaded config file names */ function get_file_names() { return array_keys($this->_config_data); } /** * Get all section names from a loaded file. * * @param string $file_name config file to get section names from * @return array an array of section names from the specified file */ function get_section_names($file_name) { $file_name = $this->_config_path . $file_name; if (!isset($this->_config_data[$file_name])) { $this->_trigger_error_msg("Unknown config file \\\'$file_name\\\'"); return; } return array_keys($this->_config_data[$file_name]["sections"]); } /** * Get all global or section variable names. * * @param string $file_name config file to get info for * @param string $section_name (optional) section to get info for * @return array an array of variables names from the specified file/section */ function get_var_names($file_name, $section = NULL) { if (empty($file_name)) { $this->_trigger_error_msg(\\\'Empty config file name\\\'); return; } else if (!isset($this->_config_data[$file_name])) { $this->_trigger_error_msg("Unknown config file \\\'$file_name\\\'"); return; } if (empty($section)) return array_keys($this->_config_data[$file_name]["vars"]); else return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]); } /** * Clear loaded config data for a certain file or all files. * * @param string $file_name file to clear config data for */ function clear($file_name = NULL) { if ($file_name === NULL) $this->_config_data = array(); else if (isset($this->_config_data[$file_name])) $this->_config_data[$file_name] = array(); } /** * Load a configuration file manually. * * @param string $file_name file name to load * @param boolean $prepend_path whether current config path should be * prepended to the filename */ function load_file($file_name, $prepend_path = true) { if ($prepend_path && $this->_config_path != "") $config_file = $this->_config_path . $file_name; else $config_file = $file_name; ini_set(\\\'track_errors\\\', true); $fp = @fopen($config_file, "r"); if (!is_resource($fp)) { $this->_trigger_error_msg("Could not open config file \\\'$config_file\\\'"); return false; } $contents = fread($fp, filesize($config_file)); fclose($fp); if($this->fix_newlines) { // fix mac/dos formatted newlines $contents = preg_replace(\\\'!\\\\r\\\\n?!\\\',"\\\\n",$contents); } $config_data = array(); /* replace all multi-line values by placeholders */ if (preg_match_all(\\\'/"""(.*)"""/Us\\\', $contents, $match)) { $_triple_quotes = $match[1]; $_i = 0; $contents = preg_replace(\\\'/""".*"""/Use\\\', \\\'"\\\\x1b\\\\x1b\\\\x1b".$_i++."\\\\x1b\\\\x1b\\\\x1b"\\\', $contents); } else { $_triple_quotes = null; } /* Get global variables first. */ if ($contents{0} != \\\'[\\\' && preg_match("/^(.*?)(\\\\n\\\\[|\\\\Z)/s", $contents, $match)) $config_data["vars"] = $this->_parse_config_block($match[1], $_triple_quotes); /* Get section variables. */ $config_data["sections"] = array(); preg_match_all("/^\\\\[(.*?)\\\\]/m", $contents, $match); foreach ($match[1] as $section) { if ($section{0} == \\\'.\\\' && !$this->read_hidden) continue; if (preg_match("/\\\\[".preg_quote($section, \\\'/\\\')."\\\\](.*?)(\\\\n\\\\[|\\\\Z)/s", $contents, $match)) if ($section{0} == \\\'.\\\') $section = substr($section, 1); $config_data["sections"][$section]["vars"] = $this->_parse_config_block($match[1], $_triple_quotes); } $this->_config_data[$config_file] = $config_data; return true; } /**#@+ @access private */ /** * @var string $config_block */ function _parse_config_block($config_block, $triple_quotes) { $vars = array(); /* First we grab the multi-line values. */ if (preg_match_all("/^([^=\\\\n]+)=\\\\s*\\\\x1b\\\\x1b\\\\x1b(\\\\d+)\\\\x1b\\\\x1b\\\\x1b\\\\s*$/ms", $config_block, $match, PREG_SET_ORDER)) { for ($i = 0; $i < count($match); $i++) { $this->_set_config_var($vars, trim($match[$i][1]), $triple_quotes[$match[$i][2]], false); } $config_block = preg_replace("/^[^=\\\\n]+=\\\\s*\\\\x1b\\\\x1b\\\\x1b\\\\d+\\\\x1b\\\\x1b\\\\x1b\\\\s*$/ms", "", $config_block); } $config_lines = preg_split("/\\\\n+/", $config_block); foreach ($config_lines as $line) { if (preg_match("/^\\\\s*(\\\\.?\\\\w+)\\\\s*=(.*)/", $line, $match)) { $var_value = preg_replace(\\\'/^([\\\\\\\'"])(.*)\\\\1$/\\\', \\\'\\\\2\\\', trim($match[2])); $this->_set_config_var($vars, trim($match[1]), $var_value, $this->booleanize); } } return $vars; } /** * @param array &$container * @param string $var_name * @param mixed $var_value * @param boolean $booleanize determines whether $var_value is converted to * to true/false */ function _set_config_var(&$container, $var_name, $var_value, $booleanize) { if ($var_name{0} == \\\'.\\\') { if (!$this->read_hidden) return; else $var_name = substr($var_name, 1); } if (!preg_match("/^[a-zA-Z_]\\\\w*$/", $var_name)) { $this->_trigger_error_msg("Bad variable name \\\'$var_name\\\'"); return; } if ($booleanize) { if (preg_match("/^(on|true|yes)$/i", $var_value)) $var_value = true; else if (preg_match("/^(off|false|no)$/i", $var_value)) $var_value = false; } if (!isset($container[$var_name]) || $this->overwrite) $container[$var_name] = $var_value; else { settype($container[$var_name], \\\'array\\\'); $container[$var_name][] = $var_value; } } /** * @uses trigger_error() creates a PHP warning/error * @param string $error_msg * @param integer $error_type one of */ function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING) { trigger_error("Config_File error: $error_msg", $error_type); } /**#@-*/ } ?> \', \'~core/classes/smarty/core/core.assemble_plugin_filepath.php\' => \'plugins_dir as $_plugin_dir) { $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; // see if path is relative if (!preg_match("/^([\\\\/\\\\\\\\\\\\\\\\]|[a-zA-Z]:[\\\\/\\\\\\\\\\\\\\\\])/", $_plugin_dir)) { $_relative_paths[] = $_plugin_dir; // relative path, see if it is in the SMARTY_DIR if (@is_readable(SMARTY_DIR . $_plugin_filepath)) { $_return = SMARTY_DIR . $_plugin_filepath; break; } } // try relative to cwd (or absolute) if (@is_readable($_plugin_filepath)) { $_return = $_plugin_filepath; break; } } if($_return === false) { // still not found, try PHP include_path if(isset($_relative_paths)) { foreach ((array)$_relative_paths as $_plugin_dir) { $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; $_params = array(\\\'file_path\\\' => $_plugin_filepath); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_include_path.php\\\'); if(smarty_core_get_include_path($_params, $smarty)) { return $_params[\\\'new_file_path\\\']; } } } } return $_return; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.assign_smarty_interface.php\' => \' * Name: assign_smarty_interface
* Purpose: assign the $smarty interface variable * @param array Format: null * @param Smarty */ function smarty_core_assign_smarty_interface($params, &$smarty) { if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars[\\\'request\\\'])) { return; } $_globals_map = array(\\\'g\\\' => \\\'HTTP_GET_VARS\\\', \\\'p\\\' => \\\'HTTP_POST_VARS\\\', \\\'c\\\' => \\\'HTTP_COOKIE_VARS\\\', \\\'s\\\' => \\\'HTTP_SERVER_VARS\\\', \\\'e\\\' => \\\'HTTP_ENV_VARS\\\'); $_smarty_vars_request = array(); foreach (preg_split(\\\'!!\\\', strtolower($smarty->request_vars_order)) as $_c) { if (isset($_globals_map[$_c])) { $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]); } } $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS[\\\'HTTP_SESSION_VARS\\\']); $smarty->_smarty_vars[\\\'request\\\'] = $_smarty_vars_request; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.create_dir_structure.php\' => \'_dir_perms) && !is_dir($_new_dir)) { $smarty->trigger_error("problem creating directory \\\'" . $_new_dir . "\\\'"); return false; } $_new_dir .= \\\'/\\\'; } } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.display_debug_console.php\' => \' * Name: display_debug_console
* Purpose: display the javascript debug console window * @param array Format: null * @param Smarty */ function smarty_core_display_debug_console($params, &$smarty) { // we must force compile the debug template in case the environment // changed between separate applications. if(empty($smarty->debug_tpl)) { // set path to debug template from SMARTY_DIR $smarty->debug_tpl = SMARTY_DIR . \\\'debug.tpl\\\'; if($smarty->security && is_file($smarty->debug_tpl)) { $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl)); } } $_ldelim_orig = $smarty->left_delimiter; $_rdelim_orig = $smarty->right_delimiter; $smarty->left_delimiter = \\\'{\\\'; $smarty->right_delimiter = \\\'}\\\'; $_compile_id_orig = $smarty->_compile_id; $smarty->_compile_id = null; $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl); if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) { ob_start(); $smarty->_include($_compile_path); $_results = ob_get_contents(); ob_end_clean(); } else { $_results = \\\'\\\'; } $smarty->_compile_id = $_compile_id_orig; $smarty->left_delimiter = $_ldelim_orig; $smarty->right_delimiter = $_rdelim_orig; return $_results; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.get_include_path.php\' => \' \', \'~core/classes/smarty/core/core.get_microtime.php\' => \' \', \'~core/classes/smarty/core/core.get_php_resource.php\' => \'trusted_dir; $smarty->_parse_resource_name($params, $smarty); /* * Find out if the resource exists. */ if ($params[\\\'resource_type\\\'] == \\\'file\\\') { $_readable = false; if(file_exists($params[\\\'resource_name\\\']) && is_readable($params[\\\'resource_name\\\'])) { $_readable = true; } else { // test for file in include_path $_params = array(\\\'file_path\\\' => $params[\\\'resource_name\\\']); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_include_path.php\\\'); if(smarty_core_get_include_path($_params, $smarty)) { $_include_path = $_params[\\\'new_file_path\\\']; $_readable = true; } } } else if ($params[\\\'resource_type\\\'] != \\\'file\\\') { $_template_source = null; $_readable = is_callable($smarty->_plugins[\\\'resource\\\'][$params[\\\'resource_type\\\']][0][0]) && call_user_func_array($smarty->_plugins[\\\'resource\\\'][$params[\\\'resource_type\\\']][0][0], array($params[\\\'resource_name\\\'], &$_template_source, &$smarty)); } /* * Set the error function, depending on which class calls us. */ if (method_exists($smarty, \\\'_syntax_error\\\')) { $_error_funcc = \\\'_syntax_error\\\'; } else { $_error_funcc = \\\'trigger_error\\\'; } if ($_readable) { if ($smarty->security) { require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.is_trusted.php\\\'); if (!smarty_core_is_trusted($params, $smarty)) { $smarty->$_error_funcc(\\\'(secure mode) \\\' . $params[\\\'resource_type\\\'] . \\\':\\\' . $params[\\\'resource_name\\\'] . \\\' is not trusted\\\'); return false; } } } else { $smarty->$_error_funcc($params[\\\'resource_type\\\'] . \\\':\\\' . $params[\\\'resource_name\\\'] . \\\' is not readable\\\'); return false; } if ($params[\\\'resource_type\\\'] == \\\'file\\\') { $params[\\\'php_resource\\\'] = $params[\\\'resource_name\\\']; } else { $params[\\\'php_resource\\\'] = $_template_source; } return true; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.is_secure.php\' => \'security || $smarty->security_settings[\\\'INCLUDE_ANY\\\']) { return true; } $_smarty_secure = false; if ($params[\\\'resource_type\\\'] == \\\'file\\\') { if($check_template_dir) { if (!in_array($smarty->template_dir, $smarty->secure_dir)) // add template_dir to secure_dir array array_unshift($smarty->secure_dir, $smarty->template_dir); $check_template_dir = false; } if (!empty($smarty->secure_dir)) { $_rp = realpath($params[\\\'resource_name\\\']); foreach ((array)$smarty->secure_dir as $curr_dir) { if ( !empty($curr_dir) && is_readable ($curr_dir)) { $_cd = realpath($curr_dir); if (strncmp($_rp, $_cd, strlen($_cd)) == 0 && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { $_smarty_secure = true; break; } } } } } else { // resource is not on local file system $_smarty_secure = call_user_func_array( $smarty->_plugins[\\\'resource\\\'][$params[\\\'resource_type\\\']][0][2], array($params[\\\'resource_name\\\'], &$_smarty_secure, &$smarty)); } return $_smarty_secure; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.is_trusted.php\' => \'trusted_dir)) { $_rp = realpath($params[\\\'resource_name\\\']); foreach ((array)$smarty->trusted_dir as $curr_dir) { if (!empty($curr_dir) && is_readable ($curr_dir)) { $_cd = realpath($curr_dir); if (strncmp($_rp, $_cd, strlen($_cd)) == 0 && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { $_smarty_trusted = true; break; } } } } } else { // resource is not on local file system $_smarty_trusted = call_user_func_array($smarty->_plugins[\\\'resource\\\'][$params[\\\'resource_type\\\']][0][3], array($params[\\\'resource_name\\\'], $smarty)); } return $_smarty_trusted; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.load_plugins.php\' => \'_plugins[$_type][$_name]; /* * We do not load plugin more than once for each instance of Smarty. * The following code checks for that. The plugin can also be * registered dynamically at runtime, in which case template file * and line number will be unknown, so we fill them in. * * The final element of the info array is a flag that indicates * whether the dynamically registered plugin function has been * checked for existence yet or not. */ if (isset($_plugin)) { if (empty($_plugin[3])) { if (!is_callable($_plugin[0])) { $smarty->_trigger_fatal_error("[plugin] $_type \\\'$_name\\\' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__); } else { $_plugin[1] = $_tpl_file; $_plugin[2] = $_tpl_line; $_plugin[3] = true; if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */ } } continue; } else if ($_type == \\\'insert\\\') { /* * For backwards compatibility, we check for insert functions in * the symbol table before trying to load them as a plugin. */ $_plugin_func = \\\'insert_\\\' . $_name; if (function_exists($_plugin_func)) { $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false); continue; } } $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name); if (! $_found = ($_plugin_file != false)) { $_message = "could not load plugin file \\\'$_type.$_name.php\\\'\\\\n"; } /* * If plugin file is found, it -must- provide the properly named * plugin function. In case it doesn\\\'t, simply output the error and * do not fall back on any other method. */ if ($_found) { include_once $_plugin_file; $_plugin_func = \\\'smarty_\\\' . $_type . \\\'_\\\' . $_name; if (!function_exists($_plugin_func)) { $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__); continue; } } /* * In case of insert plugins, their code may be loaded later via * \\\'script\\\' attribute. */ else if ($_type == \\\'insert\\\' && $_delayed_loading) { $_plugin_func = \\\'smarty_\\\' . $_type . \\\'_\\\' . $_name; $_found = true; } /* * Plugin specific processing and error checking. */ if (!$_found) { if ($_type == \\\'modifier\\\') { /* * In case modifier falls back on using PHP functions * directly, we only allow those specified in the security * context. */ if ($smarty->security && !in_array($_name, $smarty->security_settings[\\\'MODIFIER_FUNCS\\\'])) { $_message = "(secure mode) modifier \\\'$_name\\\' is not allowed"; } else { if (!function_exists($_name)) { $_message = "modifier \\\'$_name\\\' is not implemented"; } else { $_plugin_func = $_name; $_found = true; } } } else if ($_type == \\\'function\\\') { /* * This is a catch-all situation. */ $_message = "unknown tag - \\\'$_name\\\'"; } } if ($_found) { $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true); } else { // output error $smarty->_trigger_fatal_error(\\\'[plugin] \\\' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__); } } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.load_resource_plugin.php\' => \'_plugins[\\\'resource\\\'][$params[\\\'type\\\']]; if (isset($_plugin)) { if (!$_plugin[1] && count($_plugin[0])) { $_plugin[1] = true; foreach ($_plugin[0] as $_plugin_func) { if (!is_callable($_plugin_func)) { $_plugin[1] = false; break; } } } if (!$_plugin[1]) { $smarty->_trigger_fatal_error("[plugin] resource \\\'" . $params[\\\'type\\\'] . "\\\' is not implemented", null, null, __FILE__, __LINE__); } return; } $_plugin_file = $smarty->_get_plugin_filepath(\\\'resource\\\', $params[\\\'type\\\']); $_found = ($_plugin_file != false); if ($_found) { /* * If the plugin file is found, it -must- provide the properly named * plugin functions. */ include_once($_plugin_file); /* * Locate functions that we require the plugin to provide. */ $_resource_ops = array(\\\'source\\\', \\\'timestamp\\\', \\\'secure\\\', \\\'trusted\\\'); $_resource_funcs = array(); foreach ($_resource_ops as $_op) { $_plugin_func = \\\'smarty_resource_\\\' . $params[\\\'type\\\'] . \\\'_\\\' . $_op; if (!function_exists($_plugin_func)) { $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__); return; } else { $_resource_funcs[] = $_plugin_func; } } $smarty->_plugins[\\\'resource\\\'][$params[\\\'type\\\']] = array($_resource_funcs, true); } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.process_cached_inserts.php\' => \'_smarty_md5.\\\'{insert_cache (.*)}\\\'.$smarty->_smarty_md5.\\\'!Uis\\\', $params[\\\'results\\\'], $match); list($cached_inserts, $insert_args) = $match; for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { if ($smarty->debugging) { $_params = array(); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_microtime.php\\\'); $debug_start_time = smarty_core_get_microtime($_params, $smarty); } $args = unserialize($insert_args[$i]); $name = $args[\\\'name\\\']; if (isset($args[\\\'script\\\'])) { $_params = array(\\\'resource_name\\\' => $smarty->_dequote($args[\\\'script\\\'])); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_php_resource.php\\\'); if(!smarty_core_get_php_resource($_params, $smarty)) { return false; } $resource_type = $_params[\\\'resource_type\\\']; $php_resource = $_params[\\\'php_resource\\\']; if ($resource_type == \\\'file\\\') { $smarty->_include($php_resource, true); } else { $smarty->_eval($php_resource); } } $function_name = $smarty->_plugins[\\\'insert\\\'][$name][0]; if (empty($args[\\\'assign\\\'])) { $replace = $function_name($args, $smarty); } else { $smarty->assign($args[\\\'assign\\\'], $function_name($args, $smarty)); $replace = \\\'\\\'; } $params[\\\'results\\\'] = str_replace($cached_inserts[$i], $replace, $params[\\\'results\\\']); if ($smarty->debugging) { $_params = array(); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_microtime.php\\\'); $smarty->_smarty_debug_info[] = array(\\\'type\\\' => \\\'insert\\\', \\\'filename\\\' => \\\'insert_\\\'.$name, \\\'depth\\\' => $smarty->_inclusion_depth, \\\'exec_time\\\' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time); } } return $params[\\\'results\\\']; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.process_compiled_include.php\' => \'_cache_including; $smarty->_cache_including = true; $_return = $params[\\\'results\\\']; foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) { $_return = preg_replace_callback(\\\'!(\\\\{nocache\\\\:(\\\'.$_cache_serial.\\\')#(\\\\d+)\\\\})!s\\\', array(&$smarty, \\\'_process_compiled_include_callback\\\'), $_return); } $smarty->_cache_including = $_cache_including; return $_return; } ?> \', \'~core/classes/smarty/core/core.read_cache_file.php\' => \'force_compile) { // force compile enabled, always regenerate return false; } if (isset($content_cache[$params[\\\'tpl_file\\\'].\\\',\\\'.$params[\\\'cache_id\\\'].\\\',\\\'.$params[\\\'compile_id\\\']])) { list($params[\\\'results\\\'], $smarty->_cache_info) = $content_cache[$params[\\\'tpl_file\\\'].\\\',\\\'.$params[\\\'cache_id\\\'].\\\',\\\'.$params[\\\'compile_id\\\']]; return true; } if (!empty($smarty->cache_handler_func)) { // use cache_handler function call_user_func_array($smarty->cache_handler_func, array(\\\'read\\\', &$smarty, &$params[\\\'results\\\'], $params[\\\'tpl_file\\\'], $params[\\\'cache_id\\\'], $params[\\\'compile_id\\\'], null)); } else { // use local cache file $_auto_id = $smarty->_get_auto_id($params[\\\'cache_id\\\'], $params[\\\'compile_id\\\']); $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params[\\\'tpl_file\\\'], $_auto_id); $params[\\\'results\\\'] = $smarty->_read_file($_cache_file); } if (empty($params[\\\'results\\\'])) { // nothing to parse (error?), regenerate cache return false; } $cache_split = explode("\\\\n", $params[\\\'results\\\'], 2); $cache_header = $cache_split[0]; $_cache_info = unserialize($cache_header); if ($smarty->caching == 2 && isset ($_cache_info[\\\'expires\\\'])){ // caching by expiration time if ($_cache_info[\\\'expires\\\'] > -1 && (time() > $_cache_info[\\\'expires\\\'])) { // cache expired, regenerate return false; } } else { // caching by lifetime if ($smarty->cache_lifetime > -1 && (time() - $_cache_info[\\\'timestamp\\\'] > $smarty->cache_lifetime)) { // cache expired, regenerate return false; } } if ($smarty->compile_check) { $_params = array(\\\'get_source\\\' => false, \\\'quiet\\\'=>true); foreach (array_keys($_cache_info[\\\'template\\\']) as $_template_dep) { $_params[\\\'resource_name\\\'] = $_template_dep; if (!$smarty->_fetch_resource_info($_params) || $_cache_info[\\\'timestamp\\\'] < $_params[\\\'resource_timestamp\\\']) { // template file has changed, regenerate cache return false; } } if (isset($_cache_info[\\\'config\\\'])) { $_params = array(\\\'resource_base_path\\\' => $smarty->config_dir, \\\'get_source\\\' => false, \\\'quiet\\\'=>true); foreach (array_keys($_cache_info[\\\'config\\\']) as $_config_dep) { $_params[\\\'resource_name\\\'] = $_config_dep; if (!$smarty->_fetch_resource_info($_params) || $_cache_info[\\\'timestamp\\\'] < $_params[\\\'resource_timestamp\\\']) { // config file has changed, regenerate cache return false; } } } } foreach ($_cache_info[\\\'cache_serials\\\'] as $_include_file_path=>$_cache_serial) { if (empty($smarty->_cache_serials[$_include_file_path])) { $smarty->_include($_include_file_path, true); } if ($smarty->_cache_serials[$_include_file_path] != $_cache_serial) { /* regenerate */ return false; } } $params[\\\'results\\\'] = $cache_split[1]; $content_cache[$params[\\\'tpl_file\\\'].\\\',\\\'.$params[\\\'cache_id\\\'].\\\',\\\'.$params[\\\'compile_id\\\']] = array($params[\\\'results\\\'], $_cache_info); $smarty->_cache_info = $_cache_info; return true; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.rmdir.php\' => \' keep root) * WARNING: no tests, it will try to remove what you tell it! * * @param string $dirname * @param integer $level * @param integer $exp_time * @return boolean */ // $dirname, $level = 1, $exp_time = null function smarty_core_rmdir($params, &$smarty) { if(!isset($params[\\\'level\\\'])) { $params[\\\'level\\\'] = 1; } if(!isset($params[\\\'exp_time\\\'])) { $params[\\\'exp_time\\\'] = null; } if($_handle = @opendir($params[\\\'dirname\\\'])) { while (false !== ($_entry = readdir($_handle))) { if ($_entry != \\\'.\\\' && $_entry != \\\'..\\\') { if (@is_dir($params[\\\'dirname\\\'] . DIRECTORY_SEPARATOR . $_entry)) { $_params = array( \\\'dirname\\\' => $params[\\\'dirname\\\'] . DIRECTORY_SEPARATOR . $_entry, \\\'level\\\' => $params[\\\'level\\\'] + 1, \\\'exp_time\\\' => $params[\\\'exp_time\\\'] ); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.rmdir.php\\\'); smarty_core_rmdir($_params, $smarty); } else { $smarty->_unlink($params[\\\'dirname\\\'] . DIRECTORY_SEPARATOR . $_entry, $params[\\\'exp_time\\\']); } } } closedir($_handle); } if ($params[\\\'level\\\']) { return @rmdir($params[\\\'dirname\\\']); } return (bool)$_handle; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.rm_auto.php\' => \' $params[\\\'auto_base\\\'], \\\'level\\\' => 0, \\\'exp_time\\\' => $params[\\\'exp_time\\\'] ); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.rmdir.php\\\'); $_res = smarty_core_rmdir($_params, $smarty); } else { $_tname = $smarty->_get_auto_filename($params[\\\'auto_base\\\'], $params[\\\'auto_source\\\'], $params[\\\'auto_id\\\']); if(isset($params[\\\'auto_source\\\'])) { if (isset($params[\\\'extensions\\\'])) { $_res = false; foreach ((array)$params[\\\'extensions\\\'] as $_extension) $_res |= $smarty->_unlink($_tname.$_extension, $params[\\\'exp_time\\\']); } else { $_res = $smarty->_unlink($_tname, $params[\\\'exp_time\\\']); } } elseif ($smarty->use_sub_dirs) { $_params = array( \\\'dirname\\\' => $_tname, \\\'level\\\' => 1, \\\'exp_time\\\' => $params[\\\'exp_time\\\'] ); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.rmdir.php\\\'); $_res = smarty_core_rmdir($_params, $smarty); } else { // remove matching file names $_handle = opendir($params[\\\'auto_base\\\']); $_res = true; while (false !== ($_filename = readdir($_handle))) { if($_filename == \\\'.\\\' || $_filename == \\\'..\\\') { continue; } elseif (substr($params[\\\'auto_base\\\'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) { $_res &= (bool)$smarty->_unlink($params[\\\'auto_base\\\'] . DIRECTORY_SEPARATOR . $_filename, $params[\\\'exp_time\\\']); } } } } return $_res; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.run_insert_handler.php\' => \'debugging) { $_params = array(); $_debug_start_time = smarty_core_get_microtime($_params, $smarty); } if ($smarty->caching) { $_arg_string = serialize($params[\\\'args\\\']); $_name = $params[\\\'args\\\'][\\\'name\\\']; if (!isset($smarty->_cache_info[\\\'insert_tags\\\'][$_name])) { $smarty->_cache_info[\\\'insert_tags\\\'][$_name] = array(\\\'insert\\\', $_name, $smarty->_plugins[\\\'insert\\\'][$_name][1], $smarty->_plugins[\\\'insert\\\'][$_name][2], !empty($params[\\\'args\\\'][\\\'script\\\']) ? true : false); } return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5; } else { if (isset($params[\\\'args\\\'][\\\'script\\\'])) { $_params = array(\\\'resource_name\\\' => $smarty->_dequote($params[\\\'args\\\'][\\\'script\\\'])); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_php_resource.php\\\'); if(!smarty_core_get_php_resource($_params, $smarty)) { return false; } if ($_params[\\\'resource_type\\\'] == \\\'file\\\') { $smarty->_include($_params[\\\'php_resource\\\'], true); } else { $smarty->_eval($_params[\\\'php_resource\\\']); } unset($params[\\\'args\\\'][\\\'script\\\']); } $_funcname = $smarty->_plugins[\\\'insert\\\'][$params[\\\'args\\\'][\\\'name\\\']][0]; $_content = $_funcname($params[\\\'args\\\'], $smarty); if ($smarty->debugging) { $_params = array(); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_microtime.php\\\'); $smarty->_smarty_debug_info[] = array(\\\'type\\\' => \\\'insert\\\', \\\'filename\\\' => \\\'insert_\\\'.$params[\\\'args\\\'][\\\'name\\\'], \\\'depth\\\' => $smarty->_inclusion_depth, \\\'exec_time\\\' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); } if (!empty($params[\\\'args\\\']["assign"])) { $smarty->assign($params[\\\'args\\\']["assign"], $_content); } else { return $_content; } } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.smarty_include_php.php\' => \' $params[\\\'smarty_file\\\']); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_php_resource.php\\\'); smarty_core_get_php_resource($_params, $smarty); $_smarty_resource_type = $_params[\\\'resource_type\\\']; $_smarty_php_resource = $_params[\\\'php_resource\\\']; if (!empty($params[\\\'smarty_assign\\\'])) { ob_start(); if ($_smarty_resource_type == \\\'file\\\') { $smarty->_include($_smarty_php_resource, $params[\\\'smarty_once\\\'], $params[\\\'smarty_include_vars\\\']); } else { $smarty->_eval($_smarty_php_resource, $params[\\\'smarty_include_vars\\\']); } $smarty->assign($params[\\\'smarty_assign\\\'], ob_get_contents()); ob_end_clean(); } else { if ($_smarty_resource_type == \\\'file\\\') { $smarty->_include($_smarty_php_resource, $params[\\\'smarty_once\\\'], $params[\\\'smarty_include_vars\\\']); } else { $smarty->_eval($_smarty_php_resource, $params[\\\'smarty_include_vars\\\']); } } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.write_cache_file.php\' => \'_cache_info[\\\'timestamp\\\'] = time(); if ($smarty->cache_lifetime > -1){ // expiration set $smarty->_cache_info[\\\'expires\\\'] = $smarty->_cache_info[\\\'timestamp\\\'] + $smarty->cache_lifetime; } else { // cache will never expire $smarty->_cache_info[\\\'expires\\\'] = -1; } // collapse {nocache...}-tags $params[\\\'results\\\'] = preg_replace(\\\'!((\\\\{nocache\\\\:([0-9a-f]{32})#(\\\\d+)\\\\})\\\' .\\\'.*\\\' .\\\'{/nocache\\\\:\\\\\\\\3#\\\\\\\\4\\\\})!Us\\\' ,\\\'\\\\\\\\2\\\' ,$params[\\\'results\\\']); $smarty->_cache_info[\\\'cache_serials\\\'] = $smarty->_cache_serials; // prepend the cache header info into cache file $params[\\\'results\\\'] = serialize($smarty->_cache_info)."\\\\n".$params[\\\'results\\\']; if (!empty($smarty->cache_handler_func)) { // use cache_handler function call_user_func_array($smarty->cache_handler_func, array(\\\'write\\\', &$smarty, &$params[\\\'results\\\'], $params[\\\'tpl_file\\\'], $params[\\\'cache_id\\\'], $params[\\\'compile_id\\\'], null)); } else { // use local cache file if(!@is_writable($smarty->cache_dir)) { // cache_dir not writable, see if it exists if(!@is_dir($smarty->cache_dir)) { $smarty->trigger_error(\\\'the $cache_dir \\\\\\\'\\\' . $smarty->cache_dir . \\\'\\\\\\\' does not exist, or is not a directory.\\\', E_USER_ERROR); return false; } $smarty->trigger_error(\\\'unable to write to $cache_dir \\\\\\\'\\\' . realpath($smarty->cache_dir) . \\\'\\\\\\\'. Be sure $cache_dir is writable by the web server user.\\\', E_USER_ERROR); return false; } $_auto_id = $smarty->_get_auto_id($params[\\\'cache_id\\\'], $params[\\\'compile_id\\\']); $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params[\\\'tpl_file\\\'], $_auto_id); $_params = array(\\\'filename\\\' => $_cache_file, \\\'contents\\\' => $params[\\\'results\\\'], \\\'create_dirs\\\' => true); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.write_file.php\\\'); smarty_core_write_file($_params, $smarty); return true; } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.write_compiled_include.php\' => \'caching\\\\) \\\\{ echo \\\\\\\'\\\\{nocache\\\\:(\\\'.$params[\\\'cache_serial\\\'].\\\')#(\\\\d+)\\\\}\\\\\\\';\\\\}\\\'; $_tag_end = \\\'if \\\\(\\\\$this->caching\\\\) \\\\{ echo \\\\\\\'\\\\{/nocache\\\\:(\\\\\\\\2)#(\\\\\\\\3)\\\\}\\\\\\\';\\\\}\\\'; preg_match_all(\\\'!(\\\'.$_tag_start.\\\'(.*)\\\'.$_tag_end.\\\')!Us\\\', $params[\\\'compiled_content\\\'], $_match_source, PREG_SET_ORDER); // no nocache-parts found: done if (count($_match_source)==0) return; // convert the matched php-code to functions $_include_compiled = "_cache_serials[$_compile_path] = $params[\\\'cache_serial\\\']; $_include_compiled .= "\\\\$this->_cache_serials[\\\'".$_compile_path."\\\'] = \\\'".$params[\\\'cache_serial\\\']."\\\';\\\\n\\\\n?>"; $_include_compiled .= $params[\\\'plugins_code\\\']; $_include_compiled .= "\\\\n"; $_params = array(\\\'filename\\\' => $_compile_path, \\\'contents\\\' => $_include_compiled, \\\'create_dirs\\\' => true); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.write_file.php\\\'); smarty_core_write_file($_params, $smarty); return true; } ?> \', \'~core/classes/smarty/core/core.write_compiled_resource.php\' => \'compile_dir)) { // compile_dir not writable, see if it exists if(!@is_dir($smarty->compile_dir)) { $smarty->trigger_error(\\\'the $compile_dir \\\\\\\'\\\' . $smarty->compile_dir . \\\'\\\\\\\' does not exist, or is not a directory.\\\', E_USER_ERROR); return false; } $smarty->trigger_error(\\\'unable to write to $compile_dir \\\\\\\'\\\' . realpath($smarty->compile_dir) . \\\'\\\\\\\'. Be sure $compile_dir is writable by the web server user.\\\', E_USER_ERROR); return false; } $_params = array(\\\'filename\\\' => $params[\\\'compile_path\\\'], \\\'contents\\\' => $params[\\\'compiled_content\\\'], \\\'create_dirs\\\' => true); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.write_file.php\\\'); smarty_core_write_file($_params, $smarty); touch($params[\\\'compile_path\\\'], $params[\\\'resource_timestamp\\\']); return true; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/core/core.write_file.php\' => \' $_dirname); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.create_dir_structure.php\\\'); smarty_core_create_dir_structure($_params, $smarty); } // write to tmp file, then rename it to avoid // file locking race condition $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid(\\\'\\\'); if (!($fd = @fopen($_tmp_file, \\\'w\\\'))) { $smarty->trigger_error("problem writing temporary file \\\'$_tmp_file\\\'"); return false; } fwrite($fd, $params[\\\'contents\\\']); fclose($fd); if(file_exists($params[\\\'filename\\\'])) { @unlink($params[\\\'filename\\\']); } @rename($_tmp_file, $params[\\\'filename\\\']); @chmod($params[\\\'filename\\\'], $smarty->_file_perms); return true; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/debug.tpl\' => \'{* Smarty *} {* debug.tpl, last updated version 2.0.1 *} {assign_debug_info} {if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"} {section name=templates loop=$_debug_tpls} {sectionelse} {/section} {section name=vars loop=$_debug_keys} {sectionelse} {/section} {section name=config_vars loop=$_debug_config_keys} {sectionelse} {/section}
Smarty Debug Console
included templates & config files (load time in seconds):
{section name=indent loop=$_debug_tpls[templates].depth}   {/section}{$_debug_tpls[templates].filename|escape:html}{if isset($_debug_tpls[templates].exec_time)} ({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}{/if}
no templates included
assigned template variables:
{ldelim}${$_debug_keys[vars]}{rdelim}{$_debug_vals[vars]|@debug_print_var}
no template variables assigned
assigned config file variables (outer template scope):
{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}{$_debug_config_vals[config_vars]|@debug_print_var}
no config vars assigned
{else} {/if} \', \'~core/classes/smarty/plugins/block.textformat.php\' => \' * Name: textformat
* Purpose: format text a certain way with preset styles * or custom wrap/indent settings
* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} * (Smarty online manual) * @param array *
 * Params:   style: string (email)
 *           indent: integer (0)
 *           wrap: integer (80)
 *           wrap_char string ("\\\\n")
 *           indent_char: string (" ")
 *           wrap_boundary: boolean (true)
 * 
* @param string contents of the block * @param Smarty clever simulation of a method * @return string string $content re-formatted */ function smarty_block_textformat($params, $content, &$smarty) { $style = null; $indent = 0; $indent_first = 0; $indent_char = \\\' \\\'; $wrap = 80; $wrap_char = "\\\\n"; $wrap_cut = false; $assign = null; if($content == null) { return true; } extract($params); if($style == \\\'email\\\') { $wrap = 72; } // split into paragraphs $paragraphs = preg_split(\\\'![\\\\r\\\\n][\\\\r\\\\n]!\\\',$content); $output = \\\'\\\'; foreach($paragraphs as $paragraph) { if($paragraph == \\\'\\\') { continue; } // convert mult. spaces & special chars to single space $paragraph = preg_replace(array(\\\'!\\\\s+!\\\',\\\'!(^\\\\s+)|(\\\\s+$)!\\\'),array(\\\' \\\',\\\'\\\'),$paragraph); // indent first line if($indent_first > 0) { $paragraph = str_repeat($indent_char,$indent_first) . $paragraph; } // wordwrap sentences $paragraph = wordwrap($paragraph, $wrap - $indent, $wrap_char, $wrap_cut); // indent lines if($indent > 0) { $paragraph = preg_replace(\\\'!^!m\\\',str_repeat($indent_char,$indent),$paragraph); } $output .= $paragraph . $wrap_char . $wrap_char; } if($assign != null) { $smarty->assign($assign,$output); } else { return $output; } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.assign.php\' => \' * Name: assign
* Purpose: assign a value to a template variable * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign} * (Smarty online manual) * @param array Format: array(\\\'var\\\' => variable name, \\\'value\\\' => value to assign) * @param Smarty */ function smarty_function_assign($params, &$smarty) { extract($params); if (empty($var)) { $smarty->trigger_error("assign: missing \\\'var\\\' parameter"); return; } if (!in_array(\\\'value\\\', array_keys($params))) { $smarty->trigger_error("assign: missing \\\'value\\\' parameter"); return; } $smarty->assign($var, $value); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.assign_adv.php\' => \' * Synopsis: * {assign_adv var="myvar" value="array(\\\'x\\\',\\\'y\\\',array(\\\'a\\\'=>\\\'abc\\\'))"} * or * {assign_adv var="myvar" value="range(1,2)"} * or * {assign_adv var="myvar" value="myvalue"} * * Description: assign_adv is a direct and backward compatable replacement * of assign. It adds extra features, hence the \\\'_adv\\\' extention. * The extra features are: * value - can now contain a string formatted as a valid PHP array code or range code. * the code is checked to see if it matches array(...) or range(...), and if so * evaluates an array or range code from the contents of them (...). * * Examples: * assign an array of hashes of javascript events (useful for html_field_group): * {assign_adv * var=\\\'events\\\' * value="array( * array( * \\\'onfocus\\\'=>\\\'alert(\\\\\\\'Dia guit\\\\\\\');\\\', * \\\'onchange\\\'=>\\\'alert(\\\\\\\'Slainte\\\\\\\');\\\' * ), * array( * \\\'onfocus\\\'=>\\\'alert(\\\\\\\'God be with you\\\\\\\');\\\', * \\\'onchange\\\'=>\\\'alert(\\\\\\\'Cheers\\\\\\\');\\\' * ) * )" } * or assign a range of days to select for calendaring & scheduling * {assign_adv var=\\\'repeatdays\\\' value="range(1,30)" } * * Justification: Some might say "shoot, why not just write all your code in templates". Well, * I\\\'m not really. assign already assigns scalars, so allowing arrays and hashes seems * logical. I\\\'m willing to draw the line there. * * Downside: Its slower to use assign_adv, so while you can use it as a replacement for * assign, unless you need to assign an array, use assign instead. assign_adv uses * a PHP eval statement to facilitate it which can eat some time. * * See Also: function.assign.php * * ChangeLog: beta 0.10 first release (Bill Wheaton) * * COPYRIGHT: * Copyright (c) 2003 Bill Wheaton * This software is released under the GNU Lesser General Public License. * Please read the following disclaimer * * THIS SOFTWARE IS PROVIDED \\\'\\\'AS IS\\\'\\\' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ------------------------------------------------------------- */ function smarty_function_assign_adv($params, &$smarty) { extract($params); if (empty($var)) { $smarty->trigger_error("assign_adv: missing \\\'var\\\' parameter"); return; } if (!in_array(\\\'value\\\', array_keys($params))) { $smarty->trigger_error("assign_adv: missing \\\'value\\\' parameter"); return; } if (preg_match(\\\'/^array\\\\((.*)\\\\)$/\\\',$value,$match)){ eval(\\\'$value=array(\\\'.$match[1].\\\');\\\'); } if (preg_match(\\\'/^range\\\\((.*)\\\\)$/\\\',$value,$match)){ eval(\\\'$value=range(\\\'.$match[1].\\\');\\\'); } $smarty->assign($var, $value); } ?>\', \'~core/classes/smarty/plugins/function.assign_debug_info.php\' => \' * Name: assign_debug_info
* Purpose: assign debug info to the template
* @param array unused in this plugin, this plugin uses {@link Smarty::$_config}, * {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info} * @param Smarty */ function smarty_function_assign_debug_info($params, &$smarty) { $assigned_vars = $smarty->_tpl_vars; ksort($assigned_vars); if (@is_array($smarty->_config[0])) { $config_vars = $smarty->_config[0]; ksort($config_vars); $smarty->assign("_debug_config_keys", array_keys($config_vars)); $smarty->assign("_debug_config_vals", array_values($config_vars)); } $included_templates = $smarty->_smarty_debug_info; $smarty->assign("_debug_keys", array_keys($assigned_vars)); $smarty->assign("_debug_vals", array_values($assigned_vars)); $smarty->assign("_debug_tpls", $included_templates); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.config_load.php\' => \' * Name: config_load
* Purpose: load config file vars * @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load} * (Smarty online manual) * @param array Format: *
 * array(\\\'file\\\' => required config file name,
 *       \\\'section\\\' => optional config file section to load
 *       \\\'scope\\\' => local/parent/global
 *       \\\'global\\\' => overrides scope, setting to parent if true)
 * 
* @param Smarty */ function smarty_function_config_load($params, &$smarty) { if ($smarty->debugging) { $_params = array(); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_microtime.php\\\'); $_debug_start_time = smarty_core_get_microtime($_params, $smarty); } $_file = isset($params[\\\'file\\\']) ? $smarty->_dequote($params[\\\'file\\\']) : null; $_section = isset($params[\\\'section\\\']) ? $smarty->_dequote($params[\\\'section\\\']) : null; $_scope = isset($params[\\\'scope\\\']) ? $smarty->_dequote($params[\\\'scope\\\']) : \\\'global\\\'; $_global = isset($params[\\\'global\\\']) ? $smarty->_dequote($params[\\\'global\\\']) : false; if (!isset($_file) || strlen($_file) == 0) { $smarty->_syntax_error("missing \\\'file\\\' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__); } if (isset($_scope)) { if ($_scope != \\\'local\\\' && $_scope != \\\'parent\\\' && $_scope != \\\'global\\\') { $smarty->_syntax_error("invalid \\\'scope\\\' attribute value", E_USER_ERROR, __FILE__, __LINE__); } } else { if ($_global) { $_scope = \\\'parent\\\'; } else { $_scope = \\\'local\\\'; } } if(@is_dir($smarty->config_dir)) { $_config_dir = $smarty->config_dir; } else { // config_dir not found, try include_path $_params = array(\\\'file_path\\\' => $smarty->config_dir); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_include_path.php\\\'); smarty_core_get_include_path($_params, $smarty); $_config_dir = $_params[\\\'new_file_path\\\']; } $_file_path = $_config_dir . DIRECTORY_SEPARATOR . $_file; if (isset($_section)) $_compile_file = $smarty->_get_compile_path($_file_path.\\\'|\\\'.$_section); else $_compile_file = $smarty->_get_compile_path($_file_path); if($smarty->force_compile || !file_exists($_compile_file) || ($smarty->compile_check && !$smarty->_is_compiled($_file_path, $_compile_file))) { // compile config file if(!is_object($smarty->_conf_obj)) { require_once SMARTY_DIR . $smarty->config_class . \\\'.class.php\\\'; $smarty->_conf_obj = new $smarty->config_class($_config_dir); $smarty->_conf_obj->overwrite = $smarty->config_overwrite; $smarty->_conf_obj->booleanize = $smarty->config_booleanize; $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden; $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines; $smarty->_conf_obj->set_path = $_config_dir; } $_config_vars = array_merge($smarty->_conf_obj->get($_file), $smarty->_conf_obj->get($_file, $_section)); if(function_exists(\\\'var_export\\\')) { $_output = \\\'\\\'; } else { $_output = \\\'\\\'\\\\\\\\\\\\\\\'\\\', \\\'\\\\\\\\\\\'=>\\\'\\\\\\\\\\\\\\\\\\\')) . \\\'\\\\\\\'); ?>\\\'; } $_params = (array(\\\'compile_path\\\' => $_compile_file, \\\'compiled_content\\\' => $_output, \\\'resource_timestamp\\\' => filemtime($_file_path))); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.write_compiled_resource.php\\\'); smarty_core_write_compiled_resource($_params, $smarty); } else { include($_compile_file); } if ($smarty->caching) { $smarty->_cache_info[\\\'config\\\'][$_file] = true; } $smarty->_config[0][\\\'vars\\\'] = @array_merge($smarty->_config[0][\\\'vars\\\'], $_config_vars); $smarty->_config[0][\\\'files\\\'][$_file] = true; if ($_scope == \\\'parent\\\') { $smarty->_config[1][\\\'vars\\\'] = @array_merge($smarty->_config[1][\\\'vars\\\'], $_config_vars); $smarty->_config[1][\\\'files\\\'][$_file] = true; } else if ($_scope == \\\'global\\\') { for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) { $smarty->_config[$i][\\\'vars\\\'] = @array_merge($smarty->_config[$i][\\\'vars\\\'], $_config_vars); $smarty->_config[$i][\\\'files\\\'][$_file] = true; } } if ($smarty->debugging) { $_params = array(); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_microtime.php\\\'); $smarty->_smarty_debug_info[] = array(\\\'type\\\' => \\\'config\\\', \\\'filename\\\' => $_file.\\\' [\\\'.$_section.\\\'] \\\'.$_scope, \\\'depth\\\' => $smarty->_inclusion_depth, \\\'exec_time\\\' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.counter.php\' => \' * Name: counter
* Purpose: print out a counter value * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} * (Smarty online manual) * @param array parameters * @param Smarty * @return string|null */ function smarty_function_counter($params, &$smarty) { static $counters = array(); extract($params); if (!isset($name)) { if(isset($id)) { $name = $id; } else { $name = "default"; } } if (!isset($counters[$name])) { $counters[$name] = array( \\\'start\\\'=>1, \\\'skip\\\'=>1, \\\'direction\\\'=>\\\'up\\\', \\\'count\\\'=>1 ); } $counter =& $counters[$name]; if (isset($start)) { $counter[\\\'start\\\'] = $counter[\\\'count\\\'] = $start; } if (!empty($assign)) { $counter[\\\'assign\\\'] = $assign; } if (isset($counter[\\\'assign\\\'])) { $smarty->assign($counter[\\\'assign\\\'], $counter[\\\'count\\\']); } if (isset($print)) { $print = (bool)$print; } else { $print = empty($counter[\\\'assign\\\']); } if ($print) { $retval = $counter[\\\'count\\\']; } else { $retval = null; } if (isset($skip)) { $counter[\\\'skip\\\'] = $skip; } if (isset($direction)) { $counter[\\\'direction\\\'] = $direction; } if ($counter[\\\'direction\\\'] == "down") $counter[\\\'count\\\'] -= $counter[\\\'skip\\\']; else $counter[\\\'count\\\'] += $counter[\\\'skip\\\']; return $retval; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.cycle.php\' => \' * Name: cycle
* Date: May 3, 2002
* Purpose: cycle through given values
* Input: * - name = name of cycle (optional) * - values = comma separated list of values to cycle, * or an array of values to cycle * (this can be left out for subsequent calls) * - reset = boolean - resets given var to true * - print = boolean - print var or not. default is true * - advance = boolean - whether or not to advance the cycle * - delimiter = the value delimiter, default is "," * - assign = boolean, assigns to template var instead of * printed. * * Examples:
*
 * {cycle values="#eeeeee,#d0d0d0d"}
 * {cycle name=row values="one,two,three" reset=true}
 * {cycle name=row}
 * 
* @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle} * (Smarty online manual) * @author Monte Ohrt * @author credit to Mark Priatel * @author credit to Gerard * @author credit to Jason Sweat * @version 1.3 * @param array * @param Smarty * @return string|null */ function smarty_function_cycle($params, &$smarty) { static $cycle_vars; extract($params); if (empty($name)) { $name = \\\'default\\\'; } if (!isset($print)) { $print = true; } if (!isset($advance)) { $advance = true; } if (!isset($reset)) { $reset = false; } if (!in_array(\\\'values\\\', array_keys($params))) { if(!isset($cycle_vars[$name][\\\'values\\\'])) { $smarty->trigger_error("cycle: missing \\\'values\\\' parameter"); return; } } else { if(isset($cycle_vars[$name][\\\'values\\\']) && $cycle_vars[$name][\\\'values\\\'] != $values ) { $cycle_vars[$name][\\\'index\\\'] = 0; } $cycle_vars[$name][\\\'values\\\'] = $values; } if (isset($delimiter)) { $cycle_vars[$name][\\\'delimiter\\\'] = $delimiter; } elseif (!isset($cycle_vars[$name][\\\'delimiter\\\'])) { $cycle_vars[$name][\\\'delimiter\\\'] = \\\',\\\'; } if(!is_array($cycle_vars[$name][\\\'values\\\'])) { $cycle_array = explode($cycle_vars[$name][\\\'delimiter\\\'],$cycle_vars[$name][\\\'values\\\']); } else { $cycle_array = $cycle_vars[$name][\\\'values\\\']; } if(!isset($cycle_vars[$name][\\\'index\\\']) || $reset ) { $cycle_vars[$name][\\\'index\\\'] = 0; } if (isset($assign)) { $print = false; $smarty->assign($assign, $cycle_array[$cycle_vars[$name][\\\'index\\\']]); } if($print) { $retval = $cycle_array[$cycle_vars[$name][\\\'index\\\']]; } else { $retval = null; } if($advance) { if ( $cycle_vars[$name][\\\'index\\\'] >= count($cycle_array) -1 ) { $cycle_vars[$name][\\\'index\\\'] = 0; } else { $cycle_vars[$name][\\\'index\\\']++; } } return $retval; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.debug.php\' => \' * Name: debug
* Date: July 1, 2002
* Purpose: popup debug window * @link http://smarty.php.net/manual/en/language.function.debug.php {debug} * (Smarty online manual) * @author Monte Ohrt * @version 1.0 * @param array * @param Smarty * @return string output from {@link Smarty::_generate_debug_output()} */ function smarty_function_debug($params, &$smarty) { if($params[\\\'output\\\']) { $smarty->assign(\\\'_smarty_debug_output\\\',$params[\\\'output\\\']); } require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.display_debug_console.php\\\'); return smarty_core_display_debug_console(null, $smarty); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.eval.php\' => \' * Name: eval
* Purpose: evaluate a template variable as a template
* @link http://smarty.php.net/manual/en/language.function.eval.php {eval} * (Smarty online manual) * @param array * @param Smarty */ function smarty_function_eval($params, &$smarty) { if (!isset($params[\\\'var\\\'])) { $smarty->trigger_error("eval: missing \\\'var\\\' parameter"); return; } if($params[\\\'var\\\'] == \\\'\\\') { return; } $smarty->_compile_source(\\\'evaluated template\\\', $params[\\\'var\\\'], $_var_compiled); ob_start(); $smarty->_eval(\\\'?>\\\' . $_var_compiled); $_contents = ob_get_contents(); ob_end_clean(); if (!empty($params[\\\'assign\\\'])) { $smarty->assign($params[\\\'assign\\\'], $_contents); } else { return $_contents; } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.fetch.php\' => \' * Name: fetch
* Purpose: fetch file, web or ftp data and display results * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch} * (Smarty online manual) * @param array * @param Smarty * @return string|null if the assign parameter is passed, Smarty assigns the * result to a template variable */ function smarty_function_fetch($params, &$smarty) { if (empty($params[\\\'file\\\'])) { $smarty->_trigger_fatal_error("[plugin] parameter \\\'file\\\' cannot be empty"); return; } if ($smarty->security && !preg_match(\\\'!^(http|ftp)://!i\\\', $params[\\\'file\\\'])) { $_params = array(\\\'resource_type\\\' => \\\'file\\\', \\\'resource_name\\\' => $params[\\\'file\\\']); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.is_secure.php\\\'); if(!smarty_core_is_secure($_params, $smarty)) { $smarty->_trigger_fatal_error(\\\'[plugin] (secure mode) fetch \\\\\\\'\\\' . $params[\\\'file\\\'] . \\\'\\\\\\\' is not allowed\\\'); return; } // fetch the file if($fp = @fopen($params[\\\'file\\\'],\\\'r\\\')) { while(!feof($fp)) { $content .= fgets ($fp,4096); } fclose($fp); } else { $smarty->_trigger_fatal_error(\\\'[plugin] fetch cannot read file \\\\\\\'\\\' . $params[\\\'file\\\'] . \\\'\\\\\\\'\\\'); return; } } else { // not a local file if(preg_match(\\\'!^http://!i\\\',$params[\\\'file\\\'])) { // http fetch if($uri_parts = parse_url($params[\\\'file\\\'])) { // set defaults $host = $server_name = $uri_parts[\\\'host\\\']; $timeout = 30; $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; $agent = "Smarty Template Engine ".$smarty->_version; $referer = ""; $uri = !empty($uri_parts[\\\'path\\\']) ? $uri_parts[\\\'path\\\'] : \\\'/\\\'; $uri .= !empty($uri_parts[\\\'query\\\']) ? \\\'?\\\' . $uri_parts[\\\'query\\\'] : \\\'\\\'; $_is_proxy = false; if(empty($uri_parts[\\\'port\\\'])) { $port = 80; } else { $port = $uri_parts[\\\'port\\\']; } if(empty($uri_parts[\\\'user\\\'])) { $user = \\\'\\\'; } // loop through parameters, setup headers foreach($params as $param_key => $param_value) { switch($param_key) { case "file": case "assign": case "assign_headers": break; case "user": if(!empty($param_value)) { $user = $param_value; } break; case "pass": if(!empty($param_value)) { $pass = $param_value; } break; case "accept": if(!empty($param_value)) { $accept = $param_value; } break; case "header": if(!empty($param_value)) { if(!preg_match(\\\'![\\\\w\\\\d-]+: .+!\\\',$param_value)) { $smarty->_trigger_fatal_error("[plugin] invalid header format \\\'".$param_value."\\\'"); return; } else { $extra_headers[] = $param_value; } } break; case "proxy_host": if(!empty($param_value)) { $proxy_host = $param_value; } break; case "proxy_port": if(!preg_match(\\\'!\\\\D!\\\', $param_value)) { $proxy_port = (int) $param_value; } else { $smarty->_trigger_fatal_error("[plugin] invalid value for attribute \\\'".$param_key."\\\'"); return; } break; case "agent": if(!empty($param_value)) { $agent = $param_value; } break; case "referer": if(!empty($param_value)) { $referer = $param_value; } break; case "timeout": if(!preg_match(\\\'!\\\\D!\\\', $param_value)) { $timeout = (int) $param_value; } else { $smarty->_trigger_fatal_error("[plugin] invalid value for attribute \\\'".$param_key."\\\'"); return; } break; default: $smarty->_trigger_fatal_error("[plugin] unrecognized attribute \\\'".$param_key."\\\'"); return; } } if(!empty($proxy_host) && !empty($proxy_port)) { $_is_proxy = true; $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); } else { $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); } if(!$fp) { $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)"); return; } else { if($_is_proxy) { fputs($fp, \\\'GET \\\' . $params[\\\'file\\\'] . " HTTP/1.0\\\\r\\\\n"); } else { fputs($fp, "GET $uri HTTP/1.0\\\\r\\\\n"); } if(!empty($host)) { fputs($fp, "Host: $host\\\\r\\\\n"); } if(!empty($accept)) { fputs($fp, "Accept: $accept\\\\r\\\\n"); } if(!empty($agent)) { fputs($fp, "User-Agent: $agent\\\\r\\\\n"); } if(!empty($referer)) { fputs($fp, "Referer: $referer\\\\r\\\\n"); } if(isset($extra_headers) && is_array($extra_headers)) { foreach($extra_headers as $curr_header) { fputs($fp, $curr_header."\\\\r\\\\n"); } } if(!empty($user) && !empty($pass)) { fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\\\\r\\\\n"); } $content = \\\'\\\'; fputs($fp, "\\\\r\\\\n"); while(!feof($fp)) { $content .= fgets($fp,4096); } fclose($fp); $csplit = split("\\\\r\\\\n\\\\r\\\\n",$content,2); $content = $csplit[1]; if(!empty($params[\\\'assign_headers\\\'])) { $smarty->assign($params[\\\'assign_headers\\\'],split("\\\\r\\\\n",$csplit[0])); } } } else { $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax"); return; } } else { // ftp fetch if($fp = @fopen($params[\\\'file\\\'],\\\'r\\\')) { while(!feof($fp)) { $content .= fgets ($fp,4096); } fclose($fp); } else { $smarty->_trigger_fatal_error(\\\'[plugin] fetch cannot read file \\\\\\\'\\\' . $params[\\\'file\\\'] .\\\'\\\\\\\'\\\'); return; } } } if (!empty($params[\\\'assign\\\'])) { $smarty->assign($params[\\\'assign\\\'],$content); } else { return $content; } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.geterrors.php\' => \' \', \'~core/classes/smarty/plugins/function.getlinkurl.php\' => \' $val) if ($key != \\\'page\\\') $params[\\\'params\\\'][$key] = $val; return getlinkurl($params[\\\'page\\\'], $params[\\\'params\\\']); } ?> \', \'~core/classes/smarty/plugins/function.geturl.php\' => \' $val) if ($key != \\\'page\\\' && $key != \\\'action\\\' && $key != \\\'dir\\\' && $key != \\\'datapage\\\' && $key != \\\'id\\\' && $key != \\\'params\\\') $params[\\\'params\\\'][$key] = $val; return geturl($params[\\\'page\\\'], $params[\\\'action\\\'], $params[\\\'dir\\\'], $params[\\\'datapage\\\'], $params[\\\'id\\\'], $params[\\\'params\\\']); } ?> \', \'~core/classes/smarty/plugins/function.html_checkboxes.php\' => \' * Type: function
* Name: html_checkboxes
* Date: 24.Feb.2003
* Purpose: Prints out a list of checkbox input types
* Input:
* - name (optional) - string default "checkbox" * - values (required) - array * - options (optional) - associative array * - checked (optional) - array default not set * - separator (optional) - ie
or   * - output (optional) - without this one the buttons don\\\'t have names * Examples: *
 * {html_checkboxes values=$ids output=$names}
 * {html_checkboxes values=$ids name=\\\'box\\\' separator=\\\'
\\\' output=$names} * {html_checkboxes values=$ids checked=$checked separator=\\\'
\\\' output=$names} *
* @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} * (Smarty online manual) * @author Christopher Kvarme * @author credits to Monte Ohrt * @version 1.0 * @param array * @param Smarty * @return string * @uses smarty_function_escape_special_chars() */ function smarty_function_html_checkboxes($params, &$smarty) { require_once $smarty->_get_plugin_filepath(\\\'shared\\\',\\\'escape_special_chars\\\'); $name = \\\'checkbox\\\'; $values = null; $options = null; $selected = null; $separator = \\\'\\\'; $labels = true; $output = null; $extra = \\\'\\\'; foreach($params as $_key => $_val) { switch($_key) { case \\\'name\\\': case \\\'separator\\\': $$_key = $_val; break; case \\\'labels\\\': $$_key = (bool)$_val; break; case \\\'options\\\': $$_key = (array)$_val; break; case \\\'values\\\': case \\\'output\\\': $$_key = array_values((array)$_val); break; case \\\'checked\\\': case \\\'selected\\\': $selected = array_values((array)$_val); break; case \\\'checkboxes\\\': $smarty->trigger_error(\\\'html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead\\\', E_USER_WARNING); $options = (array)$_val; break; default: if(!is_array($_val)) { $extra .= \\\' \\\'.$_key.\\\'="\\\'.smarty_function_escape_special_chars($_val).\\\'"\\\'; } else { $smarty->trigger_error("html_checkboxes: extra attribute \\\'$_key\\\' cannot be an array", E_USER_NOTICE); } break; } } if (!isset($options) && !isset($values)) return \\\'\\\'; /* raise error here? */ settype($selected, \\\'array\\\'); $_html_result = \\\'\\\'; if (is_array($options)) { foreach ($options as $_key=>$_val) $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); } else { foreach ($values as $_i=>$_key) { $_val = isset($output[$_i]) ? $output[$_i] : \\\'\\\'; $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); } } return $_html_result; } function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) { $_output = \\\'\\\'; if ($labels) $_output .= \\\'\\\'; $_output .= $separator . "\\\\n"; return $_output; } ?> \', \'~core/classes/smarty/plugins/function.html_image.php\' => \' * Name: html_image
* Date: Feb 24, 2003
* Purpose: format HTML tags for the image
* Input:
* - file = file (and path) of image (required) * - border = border width (optional, default 0) * - height = image height (optional, default actual height) * - image =image width (optional, default actual width) * - basedir = base directory for absolute paths, default * is environment variable DOCUMENT_ROOT * * Examples: {html_image file="images/masthead.gif"} * Output: * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} * (Smarty online manual) * @author Monte Ohrt * @author credits to Duda - wrote first image function * in repository, helped with lots of functionality * @version 1.0 * @param array * @param Smarty * @return string * @uses smarty_function_escape_special_chars() */ function smarty_function_html_image($params, &$smarty) { require_once $smarty->_get_plugin_filepath(\\\'shared\\\',\\\'escape_special_chars\\\'); $alt = \\\'\\\'; $file = \\\'\\\'; $border = 0; $height = \\\'\\\'; $width = \\\'\\\'; $extra = \\\'\\\'; $prefix = \\\'\\\'; $suffix = \\\'\\\'; $basedir = isset($GLOBALS[\\\'HTTP_SERVER_VARS\\\'][\\\'DOCUMENT_ROOT\\\']) ? $GLOBALS[\\\'HTTP_SERVER_VARS\\\'][\\\'DOCUMENT_ROOT\\\'] : \\\'\\\'; if(strstr($GLOBALS[\\\'HTTP_SERVER_VARS\\\'][\\\'HTTP_USER_AGENT\\\'], \\\'Mac\\\')) { $dpi_default = 72; } else { $dpi_default = 96; } foreach($params as $_key => $_val) { switch($_key) { case \\\'file\\\': case \\\'border\\\': case \\\'height\\\': case \\\'width\\\': case \\\'dpi\\\': case \\\'basedir\\\': $$_key = $_val; break; case \\\'alt\\\': if(!is_array($_val)) { $$_key = smarty_function_escape_special_chars($_val); } else { $smarty->trigger_error("html_image: extra attribute \\\'$_key\\\' cannot be an array", E_USER_NOTICE); } break; case \\\'link\\\': case \\\'href\\\': $prefix = \\\'\\\'; $suffix = \\\'\\\'; break; default: if(!is_array($_val)) { $extra .= \\\' \\\'.$_key.\\\'="\\\'.smarty_function_escape_special_chars($_val).\\\'"\\\'; } else { $smarty->trigger_error("html_image: extra attribute \\\'$_key\\\' cannot be an array", E_USER_NOTICE); } break; } } if (empty($file)) { $smarty->trigger_error("html_image: missing \\\'file\\\' parameter", E_USER_NOTICE); return; } if (substr($file,0,1) == \\\'/\\\') { $_image_path = $basedir . $file; } else { $_image_path = $file; } if(!isset($params[\\\'width\\\']) || !isset($params[\\\'height\\\'])) { if(!$_image_data = @getimagesize($_image_path)) { if(!file_exists($_image_path)) { $smarty->trigger_error("html_image: unable to find \\\'$_image_path\\\'", E_USER_NOTICE); return; } else if(!is_readable($_image_path)) { $smarty->trigger_error("html_image: unable to read \\\'$_image_path\\\'", E_USER_NOTICE); return; } else { $smarty->trigger_error("html_image: \\\'$_image_path\\\' is not a valid image file", E_USER_NOTICE); return; } } $_params = array(\\\'resource_type\\\' => \\\'file\\\', \\\'resource_name\\\' => $_image_path); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.is_secure.php\\\'); if(!$smarty->security && !smarty_core_is_secure($_params, $smarty)) { $smarty->trigger_error("html_image: (secure) \\\'$_image_path\\\' not in secure directory", E_USER_NOTICE); return; } if(!isset($params[\\\'width\\\'])) { $width = $_image_data[0]; } if(!isset($params[\\\'height\\\'])) { $height = $_image_data[1]; } } if(isset($params[\\\'dpi\\\'])) { $_resize = $dpi_default/$params[\\\'dpi\\\']; $width = round($width * $_resize); $height = round($height * $_resize); } return $prefix . \\\'\\\'.$alt.\\\'\\\' . $suffix; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.html_options.php\' => \' * Name: html_options
* Input:
* - name (optional) - string default "select" * - values (required if no options supplied) - array * - options (required if no values supplied) - associative array * - selected (optional) - string default not set * - output (required if not options supplied) - array * Purpose: Prints the list of \\\' . "\\\\n"; } else { $_html_result = smarty_function_html_options_optgroup($key, $value, $selected); } return $_html_result; } function smarty_function_html_options_optgroup($key, $values, $selected) { $optgroup_html = \\\'\\\' . "\\\\n"; foreach ($values as $key => $value) { $optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected); } $optgroup_html .= "\\\\n"; return $optgroup_html; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.html_radios.php\' => \' * Type: function
* Name: html_radios
* Date: 24.Feb.2003
* Purpose: Prints out a list of radio input types
* Input:
* - name (optional) - string default "radio" * - values (required) - array * - options (optional) - associative array * - checked (optional) - array default not set * - separator (optional) - ie
or   * - output (optional) - without this one the buttons don\\\'t have names * Examples: *
 * {html_radios values=$ids output=$names}
 * {html_radios values=$ids name=\\\'box\\\' separator=\\\'
\\\' output=$names} * {html_radios values=$ids checked=$checked separator=\\\'
\\\' output=$names} *
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} * (Smarty online manual) * @author Christopher Kvarme * @author credits to Monte Ohrt * @version 1.0 * @param array * @param Smarty * @return string * @uses smarty_function_escape_special_chars() */ function smarty_function_html_radios($params, &$smarty) { require_once $smarty->_get_plugin_filepath(\\\'shared\\\',\\\'escape_special_chars\\\'); $name = \\\'radio\\\'; $values = null; $options = null; $selected = null; $separator = \\\'\\\'; $labels = true; $output = null; $extra = \\\'\\\'; foreach($params as $_key => $_val) { switch($_key) { case \\\'name\\\': case \\\'separator\\\': $$_key = (string)$_val; break; case \\\'checked\\\': case \\\'selected\\\': if(is_array($_val)) { $smarty->trigger_error(\\\'html_radios: the "\\\' . $_key . \\\'" attribute cannot be an array\\\', E_USER_WARNING); } else { $selected = (string)$_val; } break; case \\\'labels\\\': $$_key = (bool)$_val; break; case \\\'options\\\': $$_key = (array)$_val; break; case \\\'values\\\': case \\\'output\\\': $$_key = array_values((array)$_val); break; case \\\'radios\\\': $smarty->trigger_error(\\\'html_radios: the use of the "radios" attribute is deprecated, use "options" instead\\\', E_USER_WARNING); $options = (array)$_val; break; default: if(!is_array($_val)) { $extra .= \\\' \\\'.$_key.\\\'="\\\'.smarty_function_escape_special_chars($_val).\\\'"\\\'; } else { $smarty->trigger_error("html_radios: extra attribute \\\'$_key\\\' cannot be an array", E_USER_NOTICE); } break; } } if (!isset($options) && !isset($values)) return \\\'\\\'; /* raise error here? */ $_html_result = \\\'\\\'; if (isset($options) && is_array($options)) { foreach ((array)$options as $_key=>$_val) $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels); } else { foreach ((array)$values as $_i=>$_key) { $_val = isset($output[$_i]) ? $output[$_i] : \\\'\\\'; $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels); } } return $_html_result; } function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) { $_output = \\\'\\\'; if ($labels) $_output .= \\\'\\\'; $_output .= $separator . "\\\\n"; return $_output; } ?> \', \'~core/classes/smarty/plugins/function.html_select_date.php\' => \' * Name: html_select_date
* Purpose: Prints the dropdowns for date selection. * * ChangeLog:
* - 1.0 initial release * - 1.1 added support for +/- N syntax for begin * and end year values. (Monte) * - 1.2 added support for yyyy-mm-dd syntax for * time value. (Jan Rosier) * - 1.3 added support for choosing format for * month values (Gary Loescher) * - 1.3.1 added support for choosing format for * day values (Marcus Bointon) * @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date} * (Smarty online manual) * @version 1.3 * @author Andrei Zmievski * @param array * @param Smarty * @return string */ function smarty_function_html_select_date($params, &$smarty) { require_once $smarty->_get_plugin_filepath(\\\'shared\\\',\\\'make_timestamp\\\'); require_once $smarty->_get_plugin_filepath(\\\'function\\\',\\\'html_options\\\'); /* Default values. */ $prefix = "Date_"; $start_year = strftime("%Y"); $end_year = $start_year; $display_days = true; $display_months = true; $display_years = true; $month_format = "%B"; /* Write months as numbers by default GL */ $month_value_format = "%m"; $day_format = "%02d"; /* Write day values using this format MB */ $day_value_format = "%d"; $year_as_text = false; /* Display years in reverse order? Ie. 2000,1999,.... */ $reverse_years = false; /* Should the select boxes be part of an array when returned from PHP? e.g. setting it to "birthday", would create "birthday[Day]", "birthday[Month]" & "birthday[Year]". Can be combined with prefix */ $field_array = null; /* tags. If not set, uses default dropdown. */ $day_size = null; $month_size = null; $year_size = null; /* Unparsed attributes common to *ALL* the tags. An example might be in the template: all_extra =\\\'class ="foo"\\\'. */ $all_extra = null; /* Separate attributes for the tags. */ $day_extra = null; $month_extra = null; $year_extra = null; /* Order in which to display the fields. "D" -> day, "M" -> month, "Y" -> year. */ $field_order = \\\'MDY\\\'; /* String printed between the different fields. */ $field_separator = "\\\\n"; $time = time(); extract($params); // If $time is not in format yyyy-mm-dd if (!preg_match(\\\'/^\\\\d{4}-\\\\d{2}-\\\\d{2}$/\\\', $time)) { // then $time is empty or unix timestamp or mysql timestamp // using smarty_make_timestamp to get an unix timestamp and // strftime to make yyyy-mm-dd $time = strftime(\\\'%Y-%m-%d\\\', smarty_make_timestamp($time)); } // Now split this in pieces, which later can be used to set the select $time = explode("-", $time); // make syntax "+N" or "-N" work with start_year and end_year if (preg_match(\\\'!^(\\\\+|\\\\-)\\\\s*(\\\\d+)$!\\\', $end_year, $match)) { if ($match[1] == \\\'+\\\') { $end_year = strftime(\\\'%Y\\\') + $match[2]; } else { $end_year = strftime(\\\'%Y\\\') - $match[2]; } } if (preg_match(\\\'!^(\\\\+|\\\\-)\\\\s*(\\\\d+)$!\\\', $start_year, $match)) { if ($match[1] == \\\'+\\\') { $start_year = strftime(\\\'%Y\\\') + $match[2]; } else { $start_year = strftime(\\\'%Y\\\') - $match[2]; } } $field_order = strtoupper($field_order); $html_result = $month_result = $day_result = $year_result = ""; if ($display_months) { $month_names = array(); $month_values = array(); for ($i = 1; $i <= 12; $i++) { $month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000)); $month_values[] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000)); } $month_result .= \\\'\\\'; } if ($display_days) { $days = array(); for ($i = 1; $i <= 31; $i++) { $days[] = sprintf($day_format, $i); $day_values[] = sprintf($day_value_format, $i); } $day_result .= \\\'\\\'; } if ($display_years) { if (null !== $field_array){ $year_name = $field_array . \\\'[\\\' . $prefix . \\\'Year]\\\'; } else { $year_name = $prefix . \\\'Year\\\'; } if ($year_as_text) { $year_result .= \\\'\\\'; } else { $years = range((int)$start_year, (int)$end_year); if ($reverse_years) { rsort($years, SORT_NUMERIC); } $year_result .= \\\'\\\'; } } // Loop thru the field_order field for ($i = 0; $i <= 2; $i++){ $c = substr($field_order, $i, 1); switch ($c){ case \\\'D\\\': $html_result .= $day_result; break; case \\\'M\\\': $html_result .= $month_result; break; case \\\'Y\\\': $html_result .= $year_result; break; } // Add the field seperator if($i != 2) { $html_result .= $field_separator; } } return $html_result; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.html_select_time.php\' => \' * Name: html_select_time
* Purpose: Prints the dropdowns for time selection * @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time} * (Smarty online manual) * @param array * @param Smarty * @return string * @uses smarty_make_timestamp() */ function smarty_function_html_select_time($params, &$smarty) { require_once $smarty->_get_plugin_filepath(\\\'shared\\\',\\\'make_timestamp\\\'); require_once $smarty->_get_plugin_filepath(\\\'function\\\',\\\'html_options\\\'); /* Default values. */ $prefix = "Time_"; $time = time(); $display_hours = true; $display_minutes = true; $display_seconds = true; $display_meridian = true; $use_24_hours = true; $minute_interval = 1; $second_interval = 1; /* Should the select boxes be part of an array when returned from PHP? e.g. setting it to "birthday", would create "birthday[Hour]", "birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]". Can be combined with prefix. */ $field_array = null; $all_extra = null; $hour_extra = null; $minute_extra = null; $second_extra = null; $meridian_extra = null; extract($params); $time = smarty_make_timestamp($time); $html_result = \\\'\\\'; if ($display_hours) { $hours = $use_24_hours ? range(0, 23) : range(1, 12); $hour_fmt = $use_24_hours ? \\\'%H\\\' : \\\'%I\\\'; for ($i = 0, $for_max = count($hours); $i < $for_max; $i++) $hours[$i] = sprintf(\\\'%02d\\\', $hours[$i]); $html_result .= \\\'\\\\n"; } if ($display_minutes) { $all_minutes = range(0, 59); for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval) $minutes[] = sprintf(\\\'%02d\\\', $all_minutes[$i]); $selected = intval(floor(strftime(\\\'%M\\\', $time) / $minute_interval) * $minute_interval); $html_result .= \\\'\\\\n"; } if ($display_seconds) { $all_seconds = range(0, 59); for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval) $seconds[] = sprintf(\\\'%02d\\\', $all_seconds[$i]); $selected = intval(floor(strftime(\\\'%S\\\', $time) / $second_interval) * $second_interval); $html_result .= \\\'\\\\n"; } if ($display_meridian && !$use_24_hours) { $html_result .= \\\'\\\\n"; } return $html_result; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.html_subtheme_select.php\' => \'DB->Host, $GLOBALS[\\\'Conf\\\']->DB->User, $GLOBALS[\\\'Conf\\\']->DB->Password ); mysql_select_db( $GLOBALS[\\\'Conf\\\']->DB->DataBase ); $rs=mysql_query(\\\' SELECT category.id AS category_id, category.frendlytitle AS category_frendlytitle, theme.id AS theme_id, theme.title AS theme_title, subtheme.id AS subtheme_id, subtheme.title AS subtheme_title FROM category INNER JOIN theme ON category.id = theme.category_id INNER JOIN subtheme ON subtheme.theme_id = theme.id WHERE category.visible = \\\'.VISIBLE.\\\' AND theme.visible = \\\'.VISIBLE.\\\' AND subtheme.visible = \\\'.VISIBLE.\\\' ORDER BY category.title, theme.title, subtheme.title \\\'); print << END; mysql_free_result($rs); mysql_close(); return $res; } ?> \', \'~core/classes/smarty/plugins/function.html_table.php\' => \' * Name: html_table
* Date: Feb 17, 2003
* Purpose: make an html table from an array of data
* Input:
* - loop = array to loop through * - cols = number of columns * - rows = number of rows * - table_attr = table attributes * - tr_attr = table row attributes (arrays are cycled) * - td_attr = table cell attributes (arrays are cycled) * - trailpad = value to pad trailing cells with * - vdir = vertical direction (default: "down", means top-to-bottom) * - hdir = horizontal direction (default: "right", means left-to-right) * - inner = inner loop (default "cols": print $loop line by line, * $loop will be printed column by column otherwise) * * * Examples: *
 * {table loop=$data}
 * {table loop=$data cols=4 tr_attr=\\\'"bgcolor=red"\\\'}
 * {table loop=$data cols=4 tr_attr=$colors}
 * 
* @author Monte Ohrt * @version 1.0 * @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table} * (Smarty online manual) * @param array * @param Smarty * @return string */ function smarty_function_html_table($params, &$smarty) { $table_attr = \\\'border="1"\\\'; $tr_attr = \\\'\\\'; $td_attr = \\\'\\\'; $cols = 3; $rows = 3; $trailpad = \\\' \\\'; $vdir = \\\'down\\\'; $hdir = \\\'right\\\'; $inner = \\\'cols\\\'; extract($params); if (!isset($loop)) { $smarty->trigger_error("html_table: missing \\\'loop\\\' parameter"); return; } $loop_count = count($loop); if (empty($params[\\\'rows\\\'])) { /* no rows specified */ $rows = ceil($loop_count/$cols); } elseif (empty($params[\\\'cols\\\'])) { if (!empty($params[\\\'rows\\\'])) { /* no cols specified, but rows */ $cols = ceil($loop_count/$rows); } } $output = "\\\\n"; for ($r=0; $r<$rows; $r++) { $output .= "\\\\n"; $rx = ($vdir == \\\'down\\\') ? $r*$cols : ($rows-1-$r)*$cols; for ($c=0; $c<$cols; $c++) { $x = ($hdir == \\\'right\\\') ? $rx+$c : $rx+$cols-1-$c; if ($inner!=\\\'cols\\\') { /* shuffle x to loop over rows*/ $x = floor($x/$cols) + ($x%$cols)*$rows; } if ($x<$loop_count) { $output .= "" . $loop[$x] . "\\\\n"; } else { $output .= "$trailpad\\\\n"; } } $output .= "\\\\n"; } $output .= "
\\\\n"; return $output; } function smarty_function_html_table_cycle($name, $var, $no) { if(!is_array($var)) { $ret = $var; } else { $ret = $var[$no % count($var)]; } return ($ret) ? \\\' \\\'.$ret : \\\'\\\'; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.item_count.php\' => \'DB->Host, $GLOBALS[\\\'Conf\\\']->DB->User, $GLOBALS[\\\'Conf\\\']->DB->Password ); mysql_select_db( $GLOBALS[\\\'Conf\\\']->DB->DataBase ); if (isset($params[\\\'subtheme_title\\\']) && $params[\\\'subtheme_title\\\'] != \\\'\\\') { $rs=mysql_query(\\\' SELECT COUNT(*) FROM category INNER JOIN theme ON category.id = theme.category_id INNER JOIN subtheme ON subtheme.theme_id = theme.id INNER JOIN item ON item.subtheme_id = subtheme.id WHERE category.title = \\\\\\\'\\\'.title_decode($params[\\\'category_title\\\']).\\\'\\\\\\\' AND theme.title = \\\\\\\'\\\'.title_decode($params[\\\'theme_title\\\']).\\\'\\\\\\\' AND subtheme.title = \\\\\\\'\\\'.title_decode($params[\\\'subtheme_title\\\']).\\\'\\\\\\\' AND category.visible = \\\'.VISIBLE.\\\' AND theme.visible = \\\'.VISIBLE.\\\' AND subtheme.visible = \\\'.VISIBLE.\\\' AND item.status = \\\'.ITEM_VISIBLE.\\\' \\\'); } else { $rs=mysql_query(\\\' SELECT COUNT(*) FROM category INNER JOIN theme ON category.id = theme.category_id INNER JOIN subtheme ON subtheme.theme_id = theme.id INNER JOIN item ON item.subtheme_id = subtheme.id WHERE category.title = \\\\\\\'\\\'.title_decode($params[\\\'category_title\\\']).\\\'\\\\\\\' AND theme.title = \\\\\\\'\\\'.title_decode($params[\\\'theme_title\\\']).\\\'\\\\\\\' AND category.visible = \\\'.VISIBLE.\\\' AND theme.visible = \\\'.VISIBLE.\\\' AND item.status = \\\'.ITEM_VISIBLE.\\\' \\\'); } $res = mysql_result($rs, 0, 0); echo mysql_error(); $GLOBALS[\\\'sql_count\\\'] ++; mysql_free_result($rs); mysql_close(); return $res; } ?> \', \'~core/classes/smarty/plugins/function.links_themes.php\' => \'DB->Host, $GLOBALS[\\\'Conf\\\']->DB->User, $GLOBALS[\\\'Conf\\\']->DB->Password ); mysql_select_db( $GLOBALS[\\\'Conf\\\']->DB->DataBase ); $rs=mysql_query(\\\' SELECT id, title FROM theme WHERE category_id = \\\'.$params[\\\'category_id\\\'].\\\' ORDER BY pos, title \\\'); $GLOBALS[\\\'sql_count\\\'] ++; $theme = array(); while ($row = mysql_fetch_assoc($rs)) $theme[] = $row; $smarty->assign( \\\'themes\\\', $theme ); mysql_free_result($rs); mysql_close(); } ?> \', \'~core/classes/smarty/plugins/function.loop_init.php\' => \' \', \'~core/classes/smarty/plugins/function.loop_proceed.php\' => \'assign("__smarty_loop", $__smarty_loop); } ?> \', \'~core/classes/smarty/plugins/function.mailto.php\' => \' * Name: mailto
* Date: May 21, 2002 * Purpose: automate mailto address link creation, and optionally * encode them.
* Input:
* - address = e-mail address * - text = (optional) text to display, default is address * - encode = (optional) can be one of: * * none : no encoding (default) * * javascript : encode with javascript * * hex : encode with hexidecimal (no javascript) * - cc = (optional) address(es) to carbon copy * - bcc = (optional) address(es) to blind carbon copy * - subject = (optional) e-mail subject * - newsgroups = (optional) newsgroup(s) to post to * - followupto = (optional) address(es) to follow up to * - extra = (optional) extra tags for the href link * * Examples: *
 * {mailto address="me@domain.com"}
 * {mailto address="me@domain.com" encode="javascript"}
 * {mailto address="me@domain.com" encode="hex"}
 * {mailto address="me@domain.com" subject="Hello to you!"}
 * {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
 * {mailto address="me@domain.com" extra=\\\'class="mailto"\\\'}
 * 
* @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto} * (Smarty online manual) * @version 1.2 * @author Monte Ohrt * @author credits to Jason Sweat (added cc, bcc and subject functionality) * @param array * @param Smarty * @return string */ function smarty_function_mailto($params, &$smarty) { $extra = \\\'\\\'; extract($params); if (empty($address)) { $smarty->trigger_error("mailto: missing \\\'address\\\' parameter"); return; } if (empty($text)) { $text = $address; } // netscape and mozilla do not decode %40 (@) in BCC field (bug?) // so, don\\\'t encode it. $mail_parms = array(); if (!empty($cc)) { $mail_parms[] = \\\'cc=\\\'.str_replace(\\\'%40\\\',\\\'@\\\',rawurlencode($cc)); } if (!empty($bcc)) { $mail_parms[] = \\\'bcc=\\\'.str_replace(\\\'%40\\\',\\\'@\\\',rawurlencode($bcc)); } if (!empty($subject)) { $mail_parms[] = \\\'subject=\\\'.rawurlencode($subject); } if (!empty($newsgroups)) { $mail_parms[] = \\\'newsgroups=\\\'.rawurlencode($newsgroups); } if (!empty($followupto)) { $mail_parms[] = \\\'followupto=\\\'.str_replace(\\\'%40\\\',\\\'@\\\',rawurlencode($followupto)); } $mail_parm_vals = \\\'\\\'; for ($i=0; $itrigger_error("mailto: \\\'encode\\\' parameter must be none, javascript or hex"); return; } if ($encode == \\\'javascript\\\' ) { $string = \\\'document.write(\\\\\\\'\\\'.$text.\\\'\\\\\\\');\\\'; for ($x=0; $x < strlen($string); $x++) { $js_encode .= \\\'%\\\' . bin2hex($string[$x]); } return \\\'\\\'; } elseif ($encode == \\\'hex\\\') { preg_match(\\\'!^(.*)(\\\\?.*)$!\\\',$address,$match); if(!empty($match[2])) { $smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript."); return; } for ($x=0; $x < strlen($address); $x++) { if(preg_match(\\\'!\\\\w!\\\',$address[$x])) { $address_encode .= \\\'%\\\' . bin2hex($address[$x]); } else { $address_encode .= $address[$x]; } } for ($x=0; $x < strlen($text); $x++) { $text_encode .= \\\'&#x\\\' . bin2hex($text[$x]).\\\';\\\'; } return \\\'\\\'.$text_encode.\\\'\\\'; } else { // no encoding return \\\'\\\'.$text.\\\'\\\'; } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.math.php\' => \' * Name: math
* Purpose: handle math computations in template
* @link http://smarty.php.net/manual/en/language.function.math.php {math} * (Smarty online manual) * @param array * @param Smarty * @return string */ function smarty_function_math($params, &$smarty) { // be sure equation parameter is present if (empty($params[\\\'equation\\\'])) { $smarty->trigger_error("math: missing equation parameter"); return; } $equation = $params[\\\'equation\\\']; // make sure parenthesis are balanced if (substr_count($equation,"(") != substr_count($equation,")")) { $smarty->trigger_error("math: unbalanced parenthesis"); return; } // match all vars in equation, make sure all are passed preg_match_all("!\\\\!(0x)([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match); $allowed_funcs = array(\\\'int\\\',\\\'abs\\\',\\\'ceil\\\',\\\'cos\\\',\\\'exp\\\',\\\'floor\\\',\\\'log\\\',\\\'log10\\\', \\\'max\\\',\\\'min\\\',\\\'pi\\\',\\\'pow\\\',\\\'rand\\\',\\\'round\\\',\\\'sin\\\',\\\'sqrt\\\',\\\'srand\\\',\\\'tan\\\'); foreach($match[2] as $curr_var) { if (!in_array($curr_var,array_keys($params)) && !in_array($curr_var, $allowed_funcs)) { $smarty->trigger_error("math: parameter $curr_var not passed as argument"); return; } } foreach($params as $key => $val) { if ($key != "equation" && $key != "format" && $key != "assign") { // make sure value is not empty if (strlen($val)==0) { $smarty->trigger_error("math: parameter $key is empty"); return; } if (!is_numeric($val)) { $smarty->trigger_error("math: parameter $key: is not numeric"); return; } $equation = preg_replace("/\\\\b$key\\\\b/",$val, $equation); } } eval("\\\\$smarty_math_result = ".$equation.";"); if (empty($params[\\\'format\\\'])) { if (empty($params[\\\'assign\\\'])) { return $smarty_math_result; } else { $smarty->assign($params[\\\'assign\\\'],$smarty_math_result); } } else { if (empty($params[\\\'assign\\\'])){ printf($params[\\\'format\\\'],$smarty_math_result); } else { $smarty->assign($params[\\\'assign\\\'],sprintf($params[\\\'format\\\'],$smarty_math_result)); } } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.popup.php\' => \' * Name: popup
* Purpose: make text pop up in windows via overlib * @link http://smarty.php.net/manual/en/language.function.popup.php {popup} * (Smarty online manual) * @param array * @param Smarty * @return string */ function smarty_function_popup($params, &$smarty) { extract($params); if (empty($text) && !isset($inarray) && empty($function)) { $smarty->trigger_error("overlib: attribute \\\'text\\\' or \\\'inarray\\\' or \\\'function\\\' required"); return false; } if (empty($trigger)) { $trigger = "onmouseover"; } $retval = $trigger . \\\'="return overlib(\\\\\\\'\\\'.preg_replace(array("!\\\'!","![\\\\r\\\\n]!"),array("\\\\\\\'",\\\'\\\\r\\\'),$text).\\\'\\\\\\\'\\\'; if ($sticky) { $retval .= ",STICKY"; } if (!empty($caption)) { $retval .= ",CAPTION,\\\'".str_replace("\\\'","\\\\\\\'",$caption)."\\\'"; } if (!empty($fgcolor)) { $retval .= ",FGCOLOR,\\\'$fgcolor\\\'"; } if (!empty($bgcolor)) { $retval .= ",BGCOLOR,\\\'$bgcolor\\\'"; } if (!empty($textcolor)) { $retval .= ",TEXTCOLOR,\\\'$textcolor\\\'"; } if (!empty($capcolor)) { $retval .= ",CAPCOLOR,\\\'$capcolor\\\'"; } if (!empty($closecolor)) { $retval .= ",CLOSECOLOR,\\\'$closecolor\\\'"; } if (!empty($textfont)) { $retval .= ",TEXTFONT,\\\'$textfont\\\'"; } if (!empty($captionfont)) { $retval .= ",CAPTIONFONT,\\\'$captionfont\\\'"; } if (!empty($closefont)) { $retval .= ",CLOSEFONT,\\\'$closefont\\\'"; } if (!empty($textsize)) { $retval .= ",TEXTSIZE,$textsize"; } if (!empty($captionsize)) { $retval .= ",CAPTIONSIZE,$captionsize"; } if (!empty($closesize)) { $retval .= ",CLOSESIZE,$closesize"; } if (!empty($width)) { $retval .= ",WIDTH,$width"; } if (!empty($height)) { $retval .= ",HEIGHT,$height"; } if (!empty($left)) { $retval .= ",LEFT"; } if (!empty($right)) { $retval .= ",RIGHT"; } if (!empty($center)) { $retval .= ",CENTER"; } if (!empty($above)) { $retval .= ",ABOVE"; } if (!empty($below)) { $retval .= ",BELOW"; } if (isset($border)) { $retval .= ",BORDER,$border"; } if (isset($offsetx)) { $retval .= ",OFFSETX,$offsetx"; } if (isset($offsety)) { $retval .= ",OFFSETY,$offsety"; } if (!empty($fgbackground)) { $retval .= ",FGBACKGROUND,\\\'$fgbackground\\\'"; } if (!empty($bgbackground)) { $retval .= ",BGBACKGROUND,\\\'$bgbackground\\\'"; } if (!empty($closetext)) { $retval .= ",CLOSETEXT,\\\'".str_replace("\\\'","\\\\\\\'",$closetext)."\\\'"; } if (!empty($noclose)) { $retval .= ",NOCLOSE"; } if (!empty($status)) { $retval .= ",STATUS,\\\'".str_replace("\\\'","\\\\\\\'",$status)."\\\'"; } if (!empty($autostatus)) { $retval .= ",AUTOSTATUS"; } if (!empty($autostatuscap)) { $retval .= ",AUTOSTATUSCAP"; } if (isset($inarray)) { $retval .= ",INARRAY,\\\'$inarray\\\'"; } if (isset($caparray)) { $retval .= ",CAPARRAY,\\\'$caparray\\\'"; } if (!empty($capicon)) { $retval .= ",CAPICON,\\\'$capicon\\\'"; } if (!empty($snapx)) { $retval .= ",SNAPX,$snapx"; } if (!empty($snapy)) { $retval .= ",SNAPY,$snapy"; } if (isset($fixx)) { $retval .= ",FIXX,$fixx"; } if (isset($fixy)) { $retval .= ",FIXY,$fixy"; } if (!empty($background)) { $retval .= ",BACKGROUND,\\\'$background\\\'"; } if (!empty($padx)) { $retval .= ",PADX,$padx"; } if (!empty($pady)) { $retval .= ",PADY,$pady"; } if (!empty($fullhtml)) { $retval .= ",FULLHTML"; } if (!empty($frame)) { $retval .= ",FRAME,\\\'$frame\\\'"; } if (isset($timeout)) { $retval .= ",TIMEOUT,$timeout"; } if (!empty($function)) { $retval .= ",FUNCTION,\\\'$function\\\'"; } if (isset($delay)) { $retval .= ",DELAY,$delay"; } if (!empty($hauto)) { $retval .= ",HAUTO"; } if (!empty($vauto)) { $retval .= ",VAUTO"; } $retval .= \\\');" onmouseout="nd();"\\\'; return $retval; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.popup_init.php\' => \' * Name: popup_init
* Purpose: initialize overlib * @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init} * (Smarty online manual) * @param array * @param Smarty * @return string */ function smarty_function_popup_init($params, &$smarty) { $zindex = 1000; if (!empty($params[\\\'zindex\\\'])) { $zindex = $params[\\\'zindex\\\']; } if (!empty($params[\\\'src\\\'])) { return \\\'\\\' . "\\\\n" . \\\'\\\' . "\\\\n"; } else { $smarty->trigger_error("popup_init: missing src parameter"); } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/function.rating.php\' => \' 5) $rating_fill = 5; $smarty->assign(\\\'rating_fill\\\', $rating_fill); $smarty->assign(\\\'rating_empty\\\', $rating_empty); } ?> \', \'~core/classes/smarty/plugins/function.spacer.php\' => \'"; } ?> \', \'~core/classes/smarty/plugins/function.validate.php\' => \'get_template_vars(\\\'fields\\\'); $field = $field[ $params[\\\'field\\\'] ]; if ($field[\\\'required\\\']) $rez .= \\\' IsRequired="True" RequiredMessage="\\\'.str_replace(\\\'"\\\', \\\'\\\\\\\'\\\', str_replace( \\\'{{NAME}}\\\', $field[\\\'title\\\'], $GLOBALS[\\\'Conf\\\']->Text->Error->Empty)).\\\'" \\\'; if (isset($field[\\\'regexp\\\'])) { eval(\\\'$msg = $GLOBALS[\\\\\\\'Conf\\\\\\\']->Text->Error->\\\'.$field[\\\'regexp\\\'].\\\';\\\'); eval(\\\'$regexp = $GLOBALS[\\\\\\\'Conf\\\\\\\']->RegExp->\\\'.$field[\\\'regexp\\\'].\\\';\\\'); $msg = str_replace(\\\'"\\\', \\\'\\\\\\\'\\\', str_replace( \\\'{{NAME}}\\\', $field[\\\'title\\\'], $msg)); $regexp = str_replace(\\\'"\\\', \\\'\\\\\\\'\\\', $regexp); $rez .= \\\' FormatRegExp="\\\'.$regexp.\\\'" NotFormatMessage="\\\'.$msg.\\\'" \\\'; } return $rez; } ?> \', \'~core/classes/smarty/plugins/modifier.capitalize.php\' => \' * Name: capitalize
* Purpose: capitalize words in the string * @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE * capitalize (Smarty online manual) * @param string * @return string */ function smarty_modifier_capitalize($string) { return ucwords($string); } ?> \', \'~core/classes/smarty/plugins/modifier.cat.php\' => \' * Name: cat
* Date: Feb 24, 2003 * Purpose: catenate a value to a variable * Input: string to catenate * Example: {$var|cat:"foo"} * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat * (Smarty online manual) * @author Monte Ohrt * @version 1.0 * @param string * @param string * @return string */ function smarty_modifier_cat($string, $cat) { return $string . $cat; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.count_characters.php\' => \' * Name: count_characteres
* Purpose: count the number of characters in a text * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php * count_characters (Smarty online manual) * @param string * @param boolean include whitespace in the character count * @return integer */ function smarty_modifier_count_characters($string, $include_spaces = false) { if ($include_spaces) return(strlen($string)); return preg_match_all("/[^\\\\s]/",$string, $match); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.count_paragraphs.php\' => \' * Name: count_paragraphs
* Purpose: count the number of paragraphs in a text * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php * count_paragraphs (Smarty online manual) * @param string * @return integer */ function smarty_modifier_count_paragraphs($string) { // count \\\\r or \\\\n characters return count(preg_split(\\\'/[\\\\r\\\\n]+/\\\', $string)); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.count_sentences.php\' => \' * Name: count_sentences * Purpose: count the number of sentences in a text * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php * count_sentences (Smarty online manual) * @param string * @return integer */ function smarty_modifier_count_sentences($string) { // find periods with a word before but not after. return preg_match_all(\\\'/[^\\\\s]\\\\.(?!\\\\w)/\\\', $string, $match); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.count_words.php\' => \' * Name: count_words
* Purpose: count the number of words in a text * @link http://smarty.php.net/manual/en/language.modifier.count.words.php * count_words (Smarty online manual) * @param string * @return integer */ function smarty_modifier_count_words($string) { // split text by \\\' \\\',\\\\r,\\\\n,\\\\f,\\\\t $split_array = preg_split(\\\'/\\\\s+/\\\',$string); // count matches that contain alphanumerics $word_count = preg_grep(\\\'/[a-zA-Z0-9\\\\\\\\x80-\\\\\\\\xff]/\\\', $split_array); return count($word_count); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.date_format.php\' => \'_get_plugin_filepath(\\\'shared\\\',\\\'make_timestamp\\\'); /** * Smarty date_format modifier plugin * * Type: modifier
* Name: date_format
* Purpose: format datestamps via strftime
* Input:
* - string: input date string * - format: strftime format for output * - default_date: default date if $string is empty * @link http://smarty.php.net/manual/en/language.modifier.date.format.php * date_format (Smarty online manual) * @param string * @param string * @param string * @return string|void * @uses smarty_make_timestamp() */ function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null) { if($string != \\\'\\\') { return strftime($format, smarty_make_timestamp($string)); } elseif (isset($default_date) && $default_date != \\\'\\\') { return strftime($format, smarty_make_timestamp($default_date)); } else { return; } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.debug_print_var.php\' => \' * Name: debug_print_var
* Purpose: formats variable contents for display in the console * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php * debug_print_var (Smarty online manual) * @param array|object * @param integer * @param integer * @return string */ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) { $_replace = array("\\\\n"=>\\\'\n\\\', "\\\\r"=>\\\'\r\\\', "\\\\t"=>\\\'\t\\\'); if (is_array($var)) { $results = "Array (".count($var).")"; foreach ($var as $curr_key => $curr_val) { $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); $results .= "
".str_repeat(\\\' \\\', $depth*2)."".strtr($curr_key, $_replace)." => $return"; } return $results; } else if (is_object($var)) { $object_vars = get_object_vars($var); $results = "".get_class($var)." Object (".count($object_vars).")"; foreach ($object_vars as $curr_key => $curr_val) { $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); $results .= "
".str_repeat(\\\' \\\', $depth*2)."$curr_key => $return"; } return $results; } else { if (empty($var) && $var != "0") { return \\\'empty\\\'; } if (strlen($var) > $length ) { $results = substr($var, 0, $length-3).\\\'...\\\'; } else { $results = $var; } $results = htmlspecialchars($results); $results = strtr($results, $_replace); return $results; } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.default.php\' => \' * Name: default
* Purpose: designate default value for empty variables * @link http://smarty.php.net/manual/en/language.modifier.default.php * default (Smarty online manual) * @param string * @param string * @return string */ function smarty_modifier_default($string, $default = \\\'\\\') { if (!isset($string) || $string === \\\'\\\') return $default; else return $string; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.deletelastchar.php\' => \' \', \'~core/classes/smarty/plugins/modifier.escape.php\' => \' * Name: escape
* Purpose: Escape the string according to escapement type * @link http://smarty.php.net/manual/en/language.modifier.escape.php * escape (Smarty online manual) * @param string * @param html|htmlall|url|quotes|hex|hexentity|javascript * @return string */ function smarty_modifier_escape($string, $esc_type = \\\'html\\\') { switch ($esc_type) { case \\\'html\\\': return htmlspecialchars($string, ENT_QUOTES); case \\\'htmlall\\\': return htmlentities($string, ENT_QUOTES); case \\\'url\\\': return urlencode($string); case \\\'quotes\\\': // escape unescaped single quotes return preg_replace("%(?\\\'\\\\\\\\\\\\\\\\\\\',"\\\'"=>"\\\\\\\\\\\'",\\\'"\\\'=>\\\'\\\\\\\\"\\\',"\\\\r"=>\\\'\\\\\\\\r\\\',"\\\\n"=>\\\'\\\\\\\\n\\\')); default: return $string; } } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.fsize_format.php\' => \' 123.45 B|KB|MB|GB|TB or {$filesize|fsize_format:"MB"} => 123.45 MB or {$filesize|fsize_format:"TB":4} => 0.0012 TB * Params: int size the filesize in bytes string format the format, the output shall be: B, KB, MB, GB or TB int precision the rounding precision * Install: Drop into the plugin directory * ------------------------------------------------------------- */ function smarty_modifier_fsize_format($size,$format = \\\'\\\',$precision = 2) { //~ file measurements, could be calculated on the fly, but its faster like that $sizes = array(); $sizes["TB"] = 1099511627776; $sizes["GB"] = 1073741824; $sizes["MB"] = 1048576; $sizes["KB"] = 1024; $sizes["B"] = 1; //~ get "human" filesize foreach($sizes AS $unit => $bytes) { if($size > $bytes || $unit == strtoupper($format)) { //~ return formatted size return number_format($size / $bytes,$precision)." ".$unit; } //~ end if } //~ end foreach } //~ end function ?> \', \'~core/classes/smarty/plugins/modifier.indent.php\' => \' * Name: indent
* Purpose: indent lines of text * @link http://smarty.php.net/manual/en/language.modifier.indent.php * indent (Smarty online manual) * @param string * @param integer * @param string * @return string */ function smarty_modifier_indent($string,$chars=4,$char=" ") { return preg_replace(\\\'!^!m\\\',str_repeat($char,$chars),$string); } ?> \', \'~core/classes/smarty/plugins/modifier.lower.php\' => \' * Name: lower
* Purpose: convert string to lowercase * @link http://smarty.php.net/manual/en/language.modifier.lower.php * lower (Smarty online manual) * @param string * @return string */ function smarty_modifier_lower($string) { return strtolower($string); } ?> \', \'~core/classes/smarty/plugins/modifier.math.php\' => \'trigger_error("math: function $curr_var not allowed"); return; } } $str = \\\'$res = \\\' . preg_replace(\\\'/(? \', \'~core/classes/smarty/plugins/modifier.nl2br.php\' => \' * Name: nl2br
* Date: Feb 26, 2003 * Purpose: convert \\\\r\\\\n, \\\\r or \\\\n to <
> * Input:
* - contents = contents to replace * - preceed_test = if true, includes preceeding break tags * in replacement * Example: {$text|nl2br} * @link http://smarty.php.net/manual/en/language.modifier.nl2br.php * nl2br (Smarty online manual) * @version 1.0 * @author Monte Ohrt * @param string * @return string */ function smarty_modifier_nl2br($string) { return nl2br($string); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.regex_replace.php\' => \' * Name: regex_replace
* Purpose: regular epxression search/replace * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php * regex_replace (Smarty online manual) * @param string * @param string|array * @param string|array * @return string */ function smarty_modifier_regex_replace($string, $search, $replace) { return preg_replace($search, $replace, $string); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.replace.php\' => \' * Name: replace
* Purpose: simple search/replace * @link http://smarty.php.net/manual/en/language.modifier.replace.php * replace (Smarty online manual) * @param string * @param string * @param string * @return string */ function smarty_modifier_replace($string, $search, $replace) { return str_replace($search, $replace, $string); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.spacify.php\' => \' * Name: spacify
* Purpose: add spaces between characters in a string * @link http://smarty.php.net/manual/en/language.modifier.spacify.php * spacify (Smarty online manual) * @param string * @param string * @return string */ function smarty_modifier_spacify($string, $spacify_char = \\\' \\\') { return implode($spacify_char, preg_split(\\\'//\\\', $string, -1, PREG_SPLIT_NO_EMPTY)); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.string_format.php\' => \' * Name: string_format
* Purpose: format strings via sprintf * @link http://smarty.php.net/manual/en/language.modifier.string.format.php * string_format (Smarty online manual) * @param string * @param string * @return string */ function smarty_modifier_string_format($string, $format) { return sprintf($format, $string); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.strip.php\' => \' * Name: strip
* Purpose: Replace all repeated spaces, newlines, tabs * with a single space or supplied replacement string.
* Example: {$var|strip} {$var|strip:" "} * Date: September 25th, 2002 * @link http://smarty.php.net/manual/en/language.modifier.strip.php * strip (Smarty online manual) * @author Monte Ohrt * @version 1.0 * @param string * @param string * @return string */ function smarty_modifier_strip($text, $replace = \\\' \\\') { return preg_replace(\\\'!\\\\s+!\\\', $replace, $text); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.strip_tags.php\' => \' * Name: strip_tags
* Purpose: strip html tags from text * @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php * strip_tags (Smarty online manual) * @param string * @param boolean * @return string */ function smarty_modifier_strip_tags($string, $replace_with_space = true) { if ($replace_with_space) return preg_replace(\\\'!<[^>]*?>!\\\', \\\' \\\', $string); else return strip_tags($string); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.title_encode.php\' => \' \', \'~core/classes/smarty/plugins/modifier.truncate.php\' => \' * Name: truncate
* Purpose: Truncate a string to a certain length if necessary, * optionally splitting in the middle of a word, and * appending the $etc string. * @link http://smarty.php.net/manual/en/language.modifier.truncate.php * truncate (Smarty online manual) * @param string * @param integer * @param string * @param boolean * @return string */ function smarty_modifier_truncate($string, $length = 80, $etc = \\\'...\\\', $break_words = false) { if ($length == 0) return \\\'\\\'; if (strlen($string) > $length) { $length -= strlen($etc); if (!$break_words) $string = preg_replace(\\\'/\\\\s+?(\\\\S+)?$/\\\', \\\'\\\', substr($string, 0, $length+1)); return substr($string, 0, $length).$etc; } else return $string; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/modifier.upper.php\' => \' * Name: upper
* Purpose: convert string to uppercase * @link http://smarty.php.net/manual/en/language.modifier.upper.php * upper (Smarty online manual) * @param string * @return string */ function smarty_modifier_upper($string) { return strtoupper($string); } ?> \', \'~core/classes/smarty/plugins/modifier.wordwrap.php\' => \' * Name: wordwrap
* Purpose: wrap a string of text at a given length * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php * wordwrap (Smarty online manual) * @param string * @param integer * @param string * @param boolean * @return string */ function smarty_modifier_wordwrap($string,$length=80,$break="\\\\n",$cut=false) { return wordwrap($string,$length,$break,$cut); } ?> \', \'~core/classes/smarty/plugins/outputfilter.trimwhitespace.php\' => \' * Type: outputfilter
* Name: trimwhitespace
* Date: Jan 25, 2003
* Purpose: trim leading white space and blank lines from * template source after it gets interpreted, cleaning * up code and saving bandwidth. Does not affect * <
>
and blocks.
* Install: Drop into the plugin directory, call * $smarty->load_filter(\\\'output\\\',\\\'trimwhitespace\\\'); * from application. * @author Monte Ohrt * @author Contributions from Lars Noschinski * @version 1.3 * @param string * @param Smarty */ function smarty_outputfilter_trimwhitespace($source, &$smarty) { // Pull out the script blocks preg_match_all("!]+>.*?!is", $source, $match); $_script_blocks = $match[0]; $source = preg_replace("!]+>.*?!is", \\\'@@@SMARTY:TRIM:SCRIPT@@@\\\', $source); // Pull out the pre blocks preg_match_all("!
.*?
!is", $source, $match); $_pre_blocks = $match[0]; $source = preg_replace("!
.*?
!is", \\\'@@@SMARTY:TRIM:PRE@@@\\\', $source); // Pull out the textarea blocks preg_match_all("!]+>.*?!is", $source, $match); $_textarea_blocks = $match[0]; $source = preg_replace("!]+>.*?!is", \\\'@@@SMARTY:TRIM:TEXTAREA@@@\\\', $source); // remove all leading spaces, tabs and carriage returns NOT // preceeded by a php close tag. $source = trim(preg_replace(\\\'/((?)\\\\n)[\\\\s]+/m\\\', \\\'\\\\1\\\', $source)); // replace script blocks smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); // replace pre blocks smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); // replace textarea blocks smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); return $source; } function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) { $_len = strlen($search_str); $_pos = 0; for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) if (($_pos=strpos($subject, $search_str, $_pos))!==false) $subject = substr_replace($subject, $replace[$_i], $_pos, $_len); else break; } ?> \', \'~core/classes/smarty/plugins/prefilter.path.php\' => \'Site->Domain.\\\'/design/images/\\\', $GLOBALS[\\\'Conf\\\']->Site->Domain.\\\'/design/styles/\\\', $GLOBALS[\\\'Conf\\\']->Site->Domain.\\\'/design/scripts/\\\', $GLOBALS[\\\'Conf\\\']->Site->Domain.\\\'/\\\', $_SERVER[\\\'DOCUMENT_ROOT\\\'].\\\'/design/pages/\\\' ), $source); } ?>\', \'~core/classes/smarty/plugins/shared.escape_special_chars.php\' => \' * Purpose: used by other smarty functions to escape * special chars except for already escaped ones * @param string * @return string */ function smarty_function_escape_special_chars($string) { if(!is_array($string)) { $string = preg_replace(\\\'!&(#?\\\\w+);!\\\', \\\'%%%SMARTY_START%%%\\\\\\\\1%%%SMARTY_END%%%\\\', $string); $string = htmlspecialchars($string); $string = str_replace(array(\\\'%%%SMARTY_START%%%\\\',\\\'%%%SMARTY_END%%%\\\'), array(\\\'&\\\',\\\';\\\'), $string); } return $string; } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/plugins/shared.make_timestamp.php\' => \' * Purpose: used by other smarty functions to make a timestamp * from a string. * @param string * @return string */ function smarty_make_timestamp($string) { if(empty($string)) { $string = "now"; } $time = strtotime($string); if (is_numeric($time) && $time != -1) return $time; // is mysql timestamp format of YYYYMMDDHHMMSS? if (preg_match(\\\'/^\\\\d{14}$/\\\', $string)) { $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2), substr($string,4,2),substr($string,6,2),substr($string,0,4)); return $time; } // couldn\\\'t recognize it, try to return a time $time = (int) $string; if ($time > 0) return $time; else return time(); } /* vim: set expandtab: */ ?> \', \'~core/classes/smarty/smarty.class.php\' => \' * @author Andrei Zmievski * @package Smarty * @version 2.6.0 */ /* $Id: Smarty.class.php,v 1.459 2003/11/19 20:26:29 mohrt Exp $ */ /** * DIR_SEP isn\\\'t used anymore, but third party apps might */ if(!defined(\\\'DIR_SEP\\\')) { define(\\\'DIR_SEP\\\', DIRECTORY_SEPARATOR); } /** * set SMARTY_DIR to absolute path to Smarty library files. * if not defined, include_path will be used. Sets SMARTY_DIR only if user * application has not already defined it. */ if (!defined(\\\'SMARTY_DIR\\\')) { define(\\\'SMARTY_DIR\\\', dirname(__FILE__) . DIRECTORY_SEPARATOR); } define(\\\'SMARTY_PHP_PASSTHRU\\\', 0); define(\\\'SMARTY_PHP_QUOTE\\\', 1); define(\\\'SMARTY_PHP_REMOVE\\\', 2); define(\\\'SMARTY_PHP_ALLOW\\\', 3); /** * @package Smarty */ class Smarty { /**#@+ * Smarty Configuration Section */ /** * The name of the directory where templates are located. * * @var string */ var $template_dir = \\\'templates\\\'; /** * The directory where compiled templates are located. * * @var string */ var $compile_dir = \\\'templates_c\\\'; /** * The directory where config files are located. * * @var string */ var $config_dir = \\\'configs\\\'; /** * An array of directories searched for plugins. * * @var array */ var $plugins_dir = array(\\\'plugins\\\'); /** * If debugging is enabled, a debug console window will display * when the page loads (make sure your browser allows unrequested * popup windows) * * @var boolean */ var $debugging = false; /** * This is the path to the debug console template. If not set, * the default one will be used. * * @var string */ var $debug_tpl = \\\'\\\'; /** * This determines if debugging is enable-able from the browser. *
    *
  • NONE => no debugging control allowed
  • *
  • URL => enable debugging when SMARTY_DEBUG is found in the URL.
  • *
* @link http://www.foo.dom/index.php?SMARTY_DEBUG * @var string */ var $debugging_ctrl = \\\'NONE\\\'; /** * This tells Smarty whether to check for recompiling or not. Recompiling * does not need to happen unless a template or config file is changed. * Typically you enable this during development, and disable for * production. * * @var boolean */ var $compile_check = true; /** * This forces templates to compile every time. Useful for development * or debugging. * * @var boolean */ var $force_compile = false; /** * This enables template caching. *
    *
  • 0 = no caching
  • *
  • 1 = use class cache_lifetime value
  • *
  • 2 = use cache_lifetime in cache file
  • *
* @var integer */ var $caching = 0; /** * The name of the directory for cache files. * * @var string */ var $cache_dir = \\\'cache\\\'; /** * This is the number of seconds cached content will persist. *
    *
  • 0 = always regenerate cache
  • *
  • -1 = never expires
  • *
* * @var integer */ var $cache_lifetime = 3600; /** * Only used when $caching is enabled. If true, then If-Modified-Since headers * are respected with cached content, and appropriate HTTP headers are sent. * This way repeated hits to a cached page do not send the entire page to the * client every time. * * @var boolean */ var $cache_modified_check = false; /** * This determines how Smarty handles "" tags in templates. * possible values: *
    *
  • SMARTY_PHP_PASSTHRU -> print tags as plain text
  • *
  • SMARTY_PHP_QUOTE -> escape tags as entities
  • *
  • SMARTY_PHP_REMOVE -> remove php tags
  • *
  • SMARTY_PHP_ALLOW -> execute php tags
  • *
* * @var integer */ var $php_handling = SMARTY_PHP_PASSTHRU; /** * This enables template security. When enabled, many things are restricted * in the templates that normally would go unchecked. This is useful when * untrusted parties are editing templates and you want a reasonable level * of security. (no direct execution of PHP in templates for example) * * @var boolean */ var $security = false; /** * This is the list of template directories that are considered secure. This * is used only if {@link $security} is enabled. One directory per array * element. {@link $template_dir} is in this list implicitly. * * @var array */ var $secure_dir = array(); /** * These are the security settings for Smarty. They are used only when * {@link $security} is enabled. * * @var array */ var $security_settings = array( \\\'PHP_HANDLING\\\' => false, \\\'IF_FUNCS\\\' => array(\\\'array\\\', \\\'list\\\', \\\'isset\\\', \\\'empty\\\', \\\'count\\\', \\\'sizeof\\\', \\\'in_array\\\', \\\'is_array\\\', \\\'true\\\',\\\'false\\\'), \\\'INCLUDE_ANY\\\' => false, \\\'PHP_TAGS\\\' => false, \\\'MODIFIER_FUNCS\\\' => array(\\\'count\\\'), \\\'ALLOW_CONSTANTS\\\' => false ); /** * This is an array of directories where trusted php scripts reside. * {@link $security} is disabled during their inclusion/execution. * * @var array */ var $trusted_dir = array(); /** * The left delimiter used for the template tags. * * @var string */ var $left_delimiter = \\\'{\\\'; /** * The right delimiter used for the template tags. * * @var string */ var $right_delimiter = \\\'}\\\'; /** * The order in which request variables are registered, similar to * variables_order in php.ini E = Environment, G = GET, P = POST, * C = Cookies, S = Server * * @var string */ var $request_vars_order = "EGPCS"; /** * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false) * are uses as request-vars or $_*[]-vars. note: if * request_use_auto_globals is true, then $request_vars_order has * no effect, but the php-ini-value "gpc_order" * * @var boolean */ var $request_use_auto_globals = false; /** * Set this if you want different sets of compiled files for the same * templates. This is useful for things like different languages. * Instead of creating separate sets of templates per language, you * set different compile_ids like \\\'en\\\' and \\\'de\\\'. * * @var string */ var $compile_id = null; /** * This tells Smarty whether or not to use sub dirs in the cache/ and * templates_c/ directories. sub directories better organized, but * may not work well with PHP safe mode enabled. * * @var boolean * */ var $use_sub_dirs = true; /** * This is a list of the modifiers to apply to all template variables. * Put each modifier in a separate array element in the order you want * them applied. example: array(\\\'escape:"htmlall"\\\'); * * @var array */ var $default_modifiers = array(); /** * This is the resource type to be used when not specified * at the beginning of the resource path. examples: * $smarty->display(\\\'file:index.tpl\\\'); * $smarty->display(\\\'db:index.tpl\\\'); * $smarty->display(\\\'index.tpl\\\'); // will use default resource type * {include file="file:index.tpl"} * {include file="db:index.tpl"} * {include file="index.tpl"} {* will use default resource type *} * * @var array */ var $default_resource_type = \\\'file\\\'; /** * The function used for cache file handling. If not set, built-in caching is used. * * @var null|string function name */ var $cache_handler_func = null; /** * These are the variables from the globals array that are * assigned to all templates automatically. This isn\\\'t really * necessary any more, you can use the $smarty var to access them * directly. * * @var array */ var $global_assign = array(\\\'HTTP_SERVER_VARS\\\' => array(\\\'SCRIPT_NAME\\\')); /** * The value of "undefined". Leave it alone :-) * * @var null */ var $undefined = null; /** * This indicates which filters are automatically loaded into Smarty. * * @var array array of filter names */ var $autoload_filters = array(); /**#@+ * @var boolean */ /** * This tells if config file vars of the same name overwrite each other or not. * if disabled, same name variables are accumulated in an array. */ var $config_overwrite = true; /** * This tells whether or not to automatically booleanize config file variables. * If enabled, then the strings "on", "true", and "yes" are treated as boolean * true, and "off", "false" and "no" are treated as boolean false. */ var $config_booleanize = true; /** * This tells whether hidden sections [.foobar] are readable from the * tempalates or not. Normally you would never allow this since that is * the point behind hidden sections: the application can access them, but * the templates cannot. */ var $config_read_hidden = false; /** * This tells whether or not automatically fix newlines in config files. * It basically converts \\\\r (mac) or \\\\r\\\\n (dos) to \\\\n */ var $config_fix_newlines = true; /**#@-*/ /** * If a template cannot be found, this PHP function will be executed. * Useful for creating templates on-the-fly or other special action. * * @var string function name */ var $default_template_handler_func = \\\'\\\'; /** * The file that contains the compiler class. This can a full * pathname, or relative to the php_include path. * * @var string */ var $compiler_file = \\\'smarty_compiler.class.php\\\'; /** * The class used for compiling templates. * * @var string */ var $compiler_class = \\\'smarty_compiler\\\'; /** * The class used to load config vars. * * @var string */ var $config_class = \\\'config_file\\\'; /**#@+ * END Smarty Configuration Section * There should be no need to touch anything below this line. * @access private */ /** * error messages. true/false * * @var boolean */ var $_error_msg = false; /** * where assigned template vars are kept * * @var array */ var $_tpl_vars = array(); /** * stores run-time $smarty.* vars * * @var null|array */ var $_smarty_vars = null; /** * keeps track of sections * * @var array */ var $_sections = array(); /** * keeps track of foreach blocks * * @var array */ var $_foreach = array(); /** * keeps track of tag hierarchy * * @var array */ var $_tag_stack = array(); /** * configuration object * * @var Config_file */ var $_conf_obj = null; /** * loaded configuration settings * * @var array */ var $_config = array(array(\\\'vars\\\' => array(), \\\'files\\\' => array())); /** * md5 checksum of the string \\\'Smarty\\\' * * @var string */ var $_smarty_md5 = \\\'f8d698aea36fcbead2b9d5359ffca76f\\\'; /** * Smarty version number * * @var string */ var $_version = \\\'2.6.0\\\'; /** * current template inclusion depth * * @var integer */ var $_inclusion_depth = 0; /** * for different compiled templates * * @var string */ var $_compile_id = null; /** * text in URL to enable debug mode * * @var string */ var $_smarty_debug_id = \\\'SMARTY_DEBUG\\\'; /** * debugging information for debug console * * @var array */ var $_smarty_debug_info = array(); /** * info that makes up a cache file * * @var array */ var $_cache_info = array(); /** * default file permissions * * @var integer */ var $_file_perms = 0644; /** * default dir permissions * * @var integer */ var $_dir_perms = 0771; /** * registered objects * * @var array */ var $_reg_objects = array(); /** * table keeping track of plugins * * @var array */ var $_plugins = array( \\\'modifier\\\' => array(), \\\'function\\\' => array(), \\\'block\\\' => array(), \\\'compiler\\\' => array(), \\\'prefilter\\\' => array(), \\\'postfilter\\\' => array(), \\\'outputfilter\\\' => array(), \\\'resource\\\' => array(), \\\'insert\\\' => array()); /** * cache serials * * @var array */ var $_cache_serials = array(); /** * name of optional cache include file * * @var string */ var $_cache_include = null; /** * indicate if the current code is used in a compiled * include * * @var string */ var $_cache_including = false; /**#@-*/ /** * The class constructor. * * @uses $global_assign uses {@link assign()} to assign each corresponding * value from $GLOBALS to the template vars */ function Smarty() { foreach ($this->global_assign as $key => $var_name) { if (is_array($var_name)) { foreach ($var_name as $var) { if (isset($GLOBALS[$key][$var])) { $this->assign($var, $GLOBALS[$key][$var]); } else { $this->assign($var, $this->undefined); } } } else { if (isset($GLOBALS[$var_name])) { $this->assign($var_name, $GLOBALS[$var_name]); } else { $this->assign($var_name, $this->undefined); } } } } /** * assigns values to template variables * * @param array|string $tpl_var the template variable name(s) * @param mixed $value the value to assign */ function assign($tpl_var, $value = null) { if (is_array($tpl_var)){ foreach ($tpl_var as $key => $val) { if ($key != \\\'\\\') { $this->_tpl_vars[$key] = $val; } } } else { if ($tpl_var != \\\'\\\') $this->_tpl_vars[$tpl_var] = $value; } } /** * assigns values to template variables by reference * * @param string $tpl_var the template variable name * @param mixed $value the referenced value to assign */ function assign_by_ref($tpl_var, &$value) { if ($tpl_var != \\\'\\\') $this->_tpl_vars[$tpl_var] = &$value; } /** * appends values to template variables * * @param array|string $tpl_var the template variable name(s) * @param mixed $value the value to append */ function append($tpl_var, $value=null, $merge=false) { if (is_array($tpl_var)) { // $tpl_var is an array, ignore $value foreach ($tpl_var as $_key => $_val) { if ($_key != \\\'\\\') { if(!@is_array($this->_tpl_vars[$_key])) { settype($this->_tpl_vars[$_key],\\\'array\\\'); } if($merge && is_array($_val)) { foreach($_val as $_mkey => $_mval) { $this->_tpl_vars[$_key][$_mkey] = $_mval; } } else { $this->_tpl_vars[$_key][] = $_val; } } } } else { if ($tpl_var != \\\'\\\' && isset($value)) { if(!@is_array($this->_tpl_vars[$tpl_var])) { settype($this->_tpl_vars[$tpl_var],\\\'array\\\'); } if($merge && is_array($value)) { foreach($value as $_mkey => $_mval) { $this->_tpl_vars[$tpl_var][$_mkey] = $_mval; } } else { $this->_tpl_vars[$tpl_var][] = $value; } } } } /** * appends values to template variables by reference * * @param string $tpl_var the template variable name * @param mixed $value the referenced value to append */ function append_by_ref($tpl_var, &$value, $merge=false) { if ($tpl_var != \\\'\\\' && isset($value)) { if(!@is_array($this->_tpl_vars[$tpl_var])) { settype($this->_tpl_vars[$tpl_var],\\\'array\\\'); } if ($merge && is_array($value)) { foreach($value as $_key => $_val) { $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key]; } } else { $this->_tpl_vars[$tpl_var][] = &$value; } } } /** * clear the given assigned template variable. * * @param string $tpl_var the template variable to clear */ function clear_assign($tpl_var) { if (is_array($tpl_var)) foreach ($tpl_var as $curr_var) unset($this->_tpl_vars[$curr_var]); else unset($this->_tpl_vars[$tpl_var]); } /** * Registers custom function to be used in templates * * @param string $function the name of the template function * @param string $function_impl the name of the PHP function to register */ function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null) { $this->_plugins[\\\'function\\\'][$function] = array($function_impl, null, null, false, $cacheable, $cache_attrs); } /** * Unregisters custom function * * @param string $function name of template function */ function unregister_function($function) { unset($this->_plugins[\\\'function\\\'][$function]); } /** * Registers object to be used in templates * * @param string $object name of template object * @param object &$object_impl the referenced PHP object to register * @param null|array $allowed list of allowed methods (empty = all) * @param boolean $smarty_args smarty argument format, else traditional * @param null|array $block_functs list of methods that are block format */ function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) { settype($allowed, \\\'array\\\'); settype($smarty_args, \\\'boolean\\\'); $this->_reg_objects[$object] = array(&$object_impl, $allowed, $smarty_args, $block_methods); } /** * Unregisters object * * @param string $object name of template object */ function unregister_object($object) { unset($this->_reg_objects[$object]); } /** * Registers block function to be used in templates * * @param string $block name of template block * @param string $block_impl PHP function to register */ function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null) { $this->_plugins[\\\'block\\\'][$block] = array($block_impl, null, null, false, $cacheable, $cache_attrs); } /** * Unregisters block function * * @param string $block name of template function */ function unregister_block($block) { unset($this->_plugins[\\\'block\\\'][$block]); } /** * Registers compiler function * * @param string $function name of template function * @param string $function_impl name of PHP function to register */ function register_compiler_function($function, $function_impl, $cacheable=true) { $this->_plugins[\\\'compiler\\\'][$function] = array($function_impl, null, null, false, $cacheable); } /** * Unregisters compiler function * * @param string $function name of template function */ function unregister_compiler_function($function) { unset($this->_plugins[\\\'compiler\\\'][$function]); } /** * Registers modifier to be used in templates * * @param string $modifier name of template modifier * @param string $modifier_impl name of PHP function to register */ function register_modifier($modifier, $modifier_impl) { $this->_plugins[\\\'modifier\\\'][$modifier] = array($modifier_impl, null, null, false); } /** * Unregisters modifier * * @param string $modifier name of template modifier */ function unregister_modifier($modifier) { unset($this->_plugins[\\\'modifier\\\'][$modifier]); } /** * Registers a resource to fetch a template * * @param string $type name of resource * @param array $functions array of functions to handle resource */ function register_resource($type, $functions) { if (count($functions)==4) { $this->_plugins[\\\'resource\\\'][$type] = array($functions, false); } elseif (count($functions)==5) { $this->_plugins[\\\'resource\\\'][$type] = array(array(array(&$functions[0], $functions[1]) ,array(&$functions[0], $functions[2]) ,array(&$functions[0], $functions[3]) ,array(&$functions[0], $functions[4])) ,false); } else { $this->trigger_error("malformed function-list for \\\'$type\\\' in register_resource"); } } /** * Unregisters a resource * * @param string $type name of resource */ function unregister_resource($type) { unset($this->_plugins[\\\'resource\\\'][$type]); } /** * Registers a prefilter function to apply * to a template before compiling * * @param string $function name of PHP function to register */ function register_prefilter($function) { $_name = (is_array($function)) ? $function[1] : $function; $this->_plugins[\\\'prefilter\\\'][$_name] = array($function, null, null, false); } /** * Unregisters a prefilter function * * @param string $function name of PHP function */ function unregister_prefilter($function) { unset($this->_plugins[\\\'prefilter\\\'][$function]); } /** * Registers a postfilter function to apply * to a compiled template after compilation * * @param string $function name of PHP function to register */ function register_postfilter($function) { $_name = (is_array($function)) ? $function[1] : $function; $this->_plugins[\\\'postfilter\\\'][$_name] = array($function, null, null, false); } /** * Unregisters a postfilter function * * @param string $function name of PHP function */ function unregister_postfilter($function) { unset($this->_plugins[\\\'postfilter\\\'][$function]); } /** * Registers an output filter function to apply * to a template output * * @param string $function name of PHP function */ function register_outputfilter($function) { $_name = (is_array($function)) ? $function[1] : $function; $this->_plugins[\\\'outputfilter\\\'][$_name] = array($function, null, null, false); } /** * Unregisters an outputfilter function * * @param string $function name of PHP function */ function unregister_outputfilter($function) { unset($this->_plugins[\\\'outputfilter\\\'][$function]); } /** * load a filter of specified type and name * * @param string $type filter type * @param string $name filter name */ function load_filter($type, $name) { switch ($type) { case \\\'output\\\': $_params = array(\\\'plugins\\\' => array(array($type . \\\'filter\\\', $name, null, null, false))); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.load_plugins.php\\\'); smarty_core_load_plugins($_params, $this); break; case \\\'pre\\\': case \\\'post\\\': if (!isset($this->_plugins[$type . \\\'filter\\\'][$name])) $this->_plugins[$type . \\\'filter\\\'][$name] = false; break; } } /** * clear cached content for the given template and cache id * * @param string $tpl_file name of template file * @param string $cache_id name of cache_id * @param string $compile_id name of compile_id * @param string $exp_time expiration time * @return boolean */ function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) { if (!isset($compile_id)) $compile_id = $this->compile_id; if (!isset($tpl_file)) $compile_id = null; $_auto_id = $this->_get_auto_id($cache_id, $compile_id); if (!empty($this->cache_handler_func)) { return call_user_func_array($this->cache_handler_func, array(\\\'clear\\\', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time)); } else { $_params = array(\\\'auto_base\\\' => $this->cache_dir, \\\'auto_source\\\' => $tpl_file, \\\'auto_id\\\' => $_auto_id, \\\'exp_time\\\' => $exp_time); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.rm_auto.php\\\'); return smarty_core_rm_auto($_params, $this); } } /** * clear the entire contents of cache (all templates) * * @param string $exp_time expire time * @return boolean results of {@link smarty_core_rm_auto()} */ function clear_all_cache($exp_time = null) { if (!empty($this->cache_handler_func)) { $dummy = null; call_user_func_array($this->cache_handler_func, array(\\\'clear\\\', &$this, &$dummy, null, null, null, $exp_time)); } else { $_params = array(\\\'auto_base\\\' => $this->cache_dir, \\\'auto_source\\\' => null, \\\'auto_id\\\' => null, \\\'exp_time\\\' => $exp_time); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.rm_auto.php\\\'); return smarty_core_rm_auto($_params, $this); } } /** * test to see if valid cache exists for this template * * @param string $tpl_file name of template file * @param string $cache_id * @param string $compile_id * @return string|false results of {@link _read_cache_file()} */ function is_cached($tpl_file, $cache_id = null, $compile_id = null) { if (!$this->caching) return false; if (!isset($compile_id)) $compile_id = $this->compile_id; $_params = array( \\\'tpl_file\\\' => $tpl_file, \\\'cache_id\\\' => $cache_id, \\\'compile_id\\\' => $compile_id ); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.read_cache_file.php\\\'); return smarty_core_read_cache_file($_params, $this); } /** * clear all the assigned template variables. * */ function clear_all_assign() { $this->_tpl_vars = array(); } /** * clears compiled version of specified template resource, * or all compiled template files if one is not specified. * This function is for advanced use only, not normally needed. * * @param string $tpl_file * @param string $compile_id * @param string $exp_time * @return boolean results of {@link smarty_core_rm_auto()} */ function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) { if (!isset($compile_id)) { $compile_id = $this->compile_id; } $_params = array(\\\'auto_base\\\' => $this->compile_dir, \\\'auto_source\\\' => $tpl_file, \\\'auto_id\\\' => $compile_id, \\\'exp_time\\\' => $exp_time, \\\'extensions\\\' => array(\\\'.inc\\\', \\\'.php\\\')); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.rm_auto.php\\\'); return smarty_core_rm_auto($_params, $this); } /** * Checks whether requested template exists. * * @param string $tpl_file * @return boolean */ function template_exists($tpl_file) { $_params = array(\\\'resource_name\\\' => $tpl_file, \\\'quiet\\\'=>true, \\\'get_source\\\'=>false); return $this->_fetch_resource_info($_params); } /** * Returns an array containing template variables * * @param string $name * @param string $type * @return array */ function &get_template_vars($name=null) { if(!isset($name)) { return $this->_tpl_vars; } if(isset($this->_tpl_vars[$name])) { return $this->_tpl_vars[$name]; } } /** * Returns an array containing config variables * * @param string $name * @param string $type * @return array */ function &get_config_vars($name=null) { if(!isset($name) && is_array($this->_config[0])) { return $this->_config[0][\\\'vars\\\']; } else if(isset($this->_config[0][\\\'vars\\\'][$name])) { return $this->_config[0][\\\'vars\\\'][$name]; } } /** * trigger Smarty error * * @param string $error_msg * @param integer $error_type */ function trigger_error($error_msg, $error_type = E_USER_WARNING) { trigger_error("Smarty error: $error_msg", $error_type); } /** * executes & displays the template results * * @param string $resource_name * @param string $cache_id * @param string $compile_id */ function display($resource_name, $cache_id = null, $compile_id = null) { $this->fetch($resource_name, $cache_id, $compile_id, true); } /** * executes & returns or displays the template results * * @param string $resource_name * @param string $cache_id * @param string $compile_id * @param boolean $display */ function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false) { static $_cache_info = array(); $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(error_reporting() & ~E_NOTICE); if (!$this->debugging && $this->debugging_ctrl == \\\'URL\\\' && @strstr($GLOBALS[\\\'HTTP_SERVER_VARS\\\'][\\\'QUERY_STRING\\\'], $this->_smarty_debug_id)) { // enable debugging from URL $this->debugging = true; } if ($this->debugging) { // capture time for debugging info $_params = array(); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.get_microtime.php\\\'); $_debug_start_time = smarty_core_get_microtime($_params, $this); $this->_smarty_debug_info[] = array(\\\'type\\\' => \\\'template\\\', \\\'filename\\\' => $resource_name, \\\'depth\\\' => 0); $_included_tpls_idx = count($this->_smarty_debug_info) - 1; } if (!isset($compile_id)) { $compile_id = $this->compile_id; } $this->_compile_id = $compile_id; $this->_inclusion_depth = 0; if ($this->caching) { // save old cache_info, initialize cache_info array_push($_cache_info, $this->_cache_info); $this->_cache_info = array(); $_params = array( \\\'tpl_file\\\' => $resource_name, \\\'cache_id\\\' => $cache_id, \\\'compile_id\\\' => $compile_id, \\\'results\\\' => null ); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.read_cache_file.php\\\'); if (smarty_core_read_cache_file($_params, $this)) { $_smarty_results = $_params[\\\'results\\\']; if (@count($this->_cache_info[\\\'insert_tags\\\'])) { $_params = array(\\\'plugins\\\' => $this->_cache_info[\\\'insert_tags\\\']); require_once(SMARTY_DIR . \\\'core\\\' . DIRECTORY_SEPARATOR . \\\'core.load_plugins.php\\\'); smarty_core_load_plugins($_params, $this); $_params = array(\\\'results\\\' => $_smarty_results); require_once(SMARTY_DIR . \\\'c