function redirect($url, $status = '302 Moved Temporarily', $message = '') { if (!strpos($url, ':')) { while (substr($url, 0, 2) == './') { $url = substr($url, 2); } if (substr($url, 0, 1) == '/') { $url = this_url_sans_path() . $url; } else { $url = ereg_replace('/[^/]*$', "/{$url}", this_url()); } } if (function_exists('session_save_messages')) { session_save_messages(); } header("HTTP/1.0 {$status}"); header("Location: {$url}"); echo $message; exit; }
$path = $_SERVER['SCRIPT_NAME']; $url = 'http' . ($_SERVER['HTTPS'] ? 's' : '') . '://' . $domain . $path; return ereg_replace('rss.php', '', $url); } do_update_if_needed($twitster); $tweets = Tweet::find($options); echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> <rss version="2.0"> <channel> <title><?php echo SITE_TITLE; ?> </title> <link><?php echo this_url(); ?> </link> <description><?php echo SITE_SUBTITLE; ?> </description> <language>en-us</language> <ttl>40</ttl> <?php $i = 0; foreach ($tweets as $tweet) { $tweet->tagify(); $cleantext = $tweet->message; //$tweet->clean(); echo "<item>\n";
$this_page = @mysql_fetch_array(@mysql_query("SELECT post_name, post_content FROM cnt_posts WHERE post_type = 2 and id = " . $cnt->rewrite_id)); $cnt->assign(array('page_title' => $this_page['post_name'], 'page_content' => $this_page['post_content'])); $cnt->parse('page'); $this_title = $this_page['post_name']; break; case 'faq': $list_faq = @mysql_query("SELECT * FROM cnt_faqs"); while ($faq = @mysql_fetch_array($list_faq)) { $cnt->assign(array('faq_id' => $faq['id'], 'faq_title' => $faq['faq_name'], 'lfaq_id' => $faq['id'], 'lfaq_title' => $faq['faq_name'], 'lfaq_content' => $faq['faq_content'])); $cnt->parse('faq_title'); $cnt->parse('faq_list'); } $cnt->parse('faq'); $this_title = 'Câu hỏi thường gặp'; break; case 'contact': $cnt->parse('contact'); $this_title = 'Liên hệ'; break; } if (get_option('report') == 1 && !$_COOKIE['report']) { $cnt->parse('report'); } online(); $user_on = @mysql_num_rows(@mysql_query("SELECT id FROM cnt_onlines WHERE online_user > 0")); $guest_on = @mysql_num_rows(@mysql_query("SELECT id FROM cnt_onlines WHERE online_user <= 0")); list($total_visit) = @mysql_fetch_array(@mysql_query("SELECT MAX(id) FROM cnt_onlines")); $cnt->assign(array('this_time' => formatTime(time(), 4), 'this_url' => this_url(), 'web_url' => get_option('url'), 'web_title' => $this_title, 'web_description' => get_option('description'), 'web_keywords' => get_option('keywords'), 'web_tpl' => get_option('default_tpl'), 'total_product' => @mysql_num_rows(@mysql_query("SELECT id FROM cnt_products")), 'total_visit' => $total_visit, 'user_online' => $user_on, 'guest_online' => $guest_on)); $cnt->tpl_out(); } }
function edit_url() { $url = this_url(); $url = ereg_replace('view_php=[^&]*', 'edit=yes', $url); $url = ereg_replace('download_tar=[^&]*', 'edit=yes', $url); $url = ereg_replace('/[a-z0-9_.]*\\?', '/?', $url); $url = str_replace('jasonwoof.l', 'jasonwoof.com', $url); # so that code generated on Jason's home computer will display a publically accessible link. return $url; }
function run_php($dest = false) { if ($dest) { # if it has a : it must be a full URL, redirect if (strpos($dest, ':')) { redirect($dest); exit; } # if it starts with './' then it's a relative URL, redirect if (substr($dest, 0, 2) == './') { redirect(ereg_replace('/[^/]*$', substr($dest, 1), this_url())); exit; } # otherwise, it's a normal basename, display that content $basename = $dest; } else { # no dest arg $basename = $_SERVER['REDIRECT_URL']; $basename = ereg_replace('.*/', '', $basename); $basename = ereg_replace('\\.html$', '', $basename); if ($basename == '') { $basename = 'index'; } } $html_file = "{$basename}.html"; $php_file = "{$basename}.php"; $html_exists = file_exists($html_file); $php_exists = file_exists($php_file); # cms_get can return one of: # 1) false to indicate that there's no cms content for this basename # 2) a string to request a soft/full redirect just like foo_main() # 3) a hash of key/value pairs to be added to the template if (function_exists('cms_get')) { $cms_content = cms_get($basename); if (is_string($cms_content)) { run_php($cms_content); return; } } if ($php_exists) { # files can return a basename or URL of a page to be run/displayed $other = file_run($php_file); if ($other) { run_php($other); return; } } elseif ($html_exists) { readfile($html_file); exit; } elseif (!$cms_content) { header('HTTP/1.0 404 File Not Found'); if (file_exists('404.php') || file_exists('404.html')) { run_php('404'); return; } else { echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>404</title></head><body><h1>404 File Not Found</h1></body></html>'; } } $data =& $GLOBALS['wfpl_template']; $data['basename'] = $basename; if ($cms_content) { foreach ($cms_content as $name => $value) { $data[$name] .= $value; } } if (file_exists("{$basename}.css")) { $data['css_link'] = "{$basename}.css"; } if (file_exists("template.html")) { $template = parse_template_file("template.html"); if ($html_exists) { $subs = parse_template_file($html_file); $template = merge_templates($template, $subs); } } elseif ($html_exists) { $template = parse_template_file("{$html_file}"); } if ($template) { print fill_template($data, $template); } }