//run hook //add http reffer to session to prevent errors with some browsers ! if (isset($_GET['filename'])) { $_SESSION['HTTP_REFERER'] = $config['siteurl'] . ($config['mod_writer'] ? "downloadf" . $fname . ".html" : "do.php?filename=" . $fname); } else { $_SESSION['HTTP_REFERER'] = $config['siteurl'] . ($config['mod_writer'] ? "download" . $id . ".html" : "do.php?id=" . $id); } // show style ... Saaheader($title); echo $tpl->display($sty); Saafooter(); } else { if (isset($_GET['down']) || isset($_GET['downf']) || isset($_GET['img']) || isset($_GET['thmb']) || isset($_GET['imgf']) || isset($_GET['thmbf']) || isset($_GET['downex']) || isset($_GET['downexf'])) { ($hook = kleeja_run_hook('begin_down_go_page')) ? eval($hook) : null; //run hook kleeja_log('downloading file start - (' . implode(', ', $_GET) . ') -> ' . $_SERVER['HTTP_REFERER']); //must know from where he came ! and stop him if not image //todo: if it's download manger, let's pass this if ((isset($_GET['down']) || isset($_GET['downf'])) && !defined('DEV_STAGE')) { if (!isset($_SERVER['HTTP_REFERER']) || empty($_SERVER['HTTP_REFERER'])) { if (function_exists('getenv')) { $_SERVER['HTTP_REFERER'] = getenv('HTTP_REFERER') ? getenv('HTTP_REFERER') : null; } if (!isset($_SERVER['HTTP_REFERER']) || empty($_SERVER['HTTP_REFERER'])) { if (isset($_SESSION['HTTP_REFERER'])) { $_SERVER['HTTP_REFERER'] = $_SESSION['HTTP_REFERER']; unset($_SESSION['HTTP_REFERER']); } } } //if not from our site and the waiting page
function error_msg($msg) { global $dbprefix; if (!$this->show_errors) { return false; } $error_no = mysql_errno(); $error_msg = mysql_error(); $error_sql = @current($this->debugr[$this->query_num + 1]); //some ppl want hide their table names, not in develoment stage if (!defined('DEV_STAGE')) { $error_sql = preg_replace("#\\s{1,3}`*{$dbprefix}([a-z0-9]+)`*\\s{1,3}#e", "' <span style=\"color:blue\">' . substr('\$1', 0, 1) . '</span> '", $error_sql); $error_msg = preg_replace("#{$this->db_name}.{$dbprefix}([a-z0-9]+)#e", "' <span style=\"color:blue\">' . substr('\$1', 0, 1) . '</span> '", $error_msg); $error_sql = preg_replace("#\\s{1,3}(from|update|into)\\s{1,3}([a-z0-9]+)\\s{1,3}#ie", "' \$1 <span style=\"color:blue\">' . substr('\$2', 0, 1) . '</span> '", $error_sql); $error_msg = preg_replace("#\\s{1,3}(from|update|into)\\s{1,3}([a-z0-9]+)\\s{1,3}#ie", "' \$1 <span style=\"color:blue\">' . substr('\$2', 0, 1) . '</span> '", $error_msg); $error_msg = preg_replace("#\\s'([^']+)'@'([^']+)'#ie", "' <span style=\"color:blue\">hidden</span>@\$2 '", $error_msg); $error_sql = preg_replace("#password\\s*=\\s*'[^']+'#i", "password='******'", $error_sql); } echo "<html><head><title>ERROR IM MYSQL</title>"; echo "<style>BODY{FONT-FAMILY:tahoma;FONT-SIZE:12px;}.error {}</style></head><body>"; echo '<br />'; echo '<div class="error">'; echo " <a href='#' onclick='window.location.reload( false );'>click to Refresh this page ...</a><br />"; echo "<h2>Sorry , There is an error in mysql " . ($msg != '' ? ", error : {$msg}" : "") . "</h2>"; if ($error_sql != '') { echo "<br />--[query]-------------------------- <br />{$error_sql}<br />---------------------------------<br /><br />"; } echo "[{$error_no} : {$error_msg}] <br />"; echo "<br /><br /><strong>Script: Kleeja <br /><a href='http://www.kleeja.com'>Kleeja Website</a></strong>"; echo '</b></div>'; echo '</body></html>'; #loggin -> error kleeja_log('[SQL ERROR] : "' . $error_no . ' : ' . $error_msg . '" ' . $this->connect_id); @$this->close(); exit; }
function _write($filepath, $content) { #is this file exists ? well let see $chmod_dir = false; if (!file_exists($this->_fixpath($filepath))) { kleeja_log('1. not exsist: ' . $this->_fixpath($filepath)); if (!is_writable(dirname($this->_fixpath($filepath)))) { kleeja_log('2. not writable: ' . dirname($this->_fixpath($filepath))); #chmod is not a good boy. it doesnt help sometime .. $chmod_dir = $this->_chmod(dirname($this->_fixpath($filepath)), 0777); } } else { kleeja_log('3. exsist: ' . $this->_fixpath($filepath)); #file isnt writable? chmod it .. if (!is_writable($this->_fixpath($filepath))) { kleeja_log('4. not wriable : ' . $this->_fixpath($filepath)); #chmod is not a good boy. it doesnt help sometime .. $this->_chmod($this->_fixpath($filepath), 0666); } } #now write in a simple way .. $filename = @fopen($this->_fixpath($filepath), 'w'); $fw = fwrite($filename, $content); @fclose($filename); #fwrite return false if it can not write .. if ($fw === false) { kleeja_log('5 . fw === false : ' . $this->_fixpath($filepath)); $fw = $this->f->_write($this->_fixpath($filepath), $content); } #re chmode it to 644 for the file, and 755 for the folder $this->_chmod($this->_fixpath($filepath), 0666); if ($chmod_dir) { $this->_chmod(dirname($this->_fixpath($filepath)), 0755); } return $fw; }