items ) { $items = get_object_vars($xml->items); foreach( $items as $item ) { if( $item->keywordFind && $item->keywordReplace ) str_replace( $item->keywordFind, $item->keywordReplace, $html ); } } } return $html; } function get_file_contents() { $_SERVER['REQUEST_URI'] = str_replace('?','__',$_SERVER['REQUEST_URI']) ; $file_path = $_SERVER['REQUEST_URI']; // if '/' means wants to output index.html if( $file_path == "/" ) $file_path = '/index.html'; elseif( substr($file_path, -1) == "/" ) $file_path .= 'index.html'; elseif( $file_path == '/index.php' ) { redirect_to_index(); exit; } // add a . before the file path $file_path = '.' . $file_path; // fix dynamic pages /* $file_path = str_replace('.php?', '.php_', $file_path); $file_path = str_replace('.asp?', '.asp_', $file_path); $file_path = str_replace('&', '&', $file_path); */ // if not file exists 301 redirect to index if( !file_exists($file_path) ) $file_path = handle_not_existing_path($file_path); elseif( is_image($file_path) ) { if( filesize($file_path) <= 0 ) $file_path = handle_not_existing_path($file_path); } else { if( !filesize($file_path) ) $file_path = handle_not_existing_path($file_path); } if( is_image($file_path) && strpos(strtolower($file_path), '.png') ) header("content-type: image/x-png"); elseif( is_image($file_path) && strpos(strtolower($file_path), '.gif') ) header('Content-Type: image/gif'); elseif( is_image($file_path) && strpos(strtolower($file_path), '.jpg') ) header('Content-Type: image/jpeg'); elseif( is_image($file_path) && strpos(strtolower($file_path), '.jpeg') ) header('Content-Type: image/jpeg'); elseif( is_css($file_path) ) header("Content-type: text/css; charset: UTF-8"); elseif( is_pdf($file_path) ) header('Content-type: application/pdf'); $file_contents = file_get_contents( $file_path ); return $file_contents; } function redirect_to_nopicture() { if( !file_exists('./404.png') ) create_404_image(); /* header("HTTP/1.1 301 Moved Permanently"); header("Location: " . get_root_url() . '/no_picture.png' );*/ header("Content-type: image/png"); readfile('./404.png'); die(); } function redirect_to_index() { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . get_root_url() ); die(); } function get_root_url() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; $pageURL .= $_SERVER["SERVER_NAME"]; return $pageURL; } function run_tracking_script() { //set POST variables $url = 'https://panel.loganix.net/bcb/receive_traffic.php'; //url-ify the data for the POST $fields_string = http_build_query($_SERVER); //do post $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); $result = curl_exec($ch); curl_close($ch); } function handle_not_existing_path($path) { if( is_image($path) ) redirect_to_nopicture(); else redirect_to_index(); } function create_404_image() { $width = rand(4, 20); $height = rand(4, 20); $text = chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)); $text_x = rand(102, $width+10); $text_y = rand(102, $height+10); $img = imagecreatetruecolor($width, $height); imagesavealpha($img, true); $color = imagecolorallocatealpha($img, 0, 0, 0, 127); $text_color = imagecolorallocate($img, 243, 243, 243); imagefill($img, 0, 0, $color); //imagestring($img, rand(1,3), $text_x, $text_y, $text, $text_color); for( $i=0; $i<=rand(1,4); $i++ ) { $color = imagecolorallocate($img, rand(0,255), rand(0,255), rand(0,255)); imagesetpixel($img, rand(0, $width),rand(0, $height), $color); } header("content-type: image/x-png"); imagepng($img, './404.png'); // Free up memory imagedestroy($img); exit; } function is_image($str) { if( strpos($str, '.jpg') || strpos($str, '.jpeg') || strpos($str, '.png') || strpos($str, '.gif') || strpos($str, '.ico') || strpos($str, '.tiff') || strpos($str, '.svg') ) { return true; } return false; } function is_css($str) { if( strpos($str, '.css') ) return true; return false; } function is_pdf($str) { if( strpos($str, '.pdf') ) return true; return false; } function change_chars() { if( $_POST['changechars'] == 1 ) { $domain = $_SERVER[HTTP_HOST]; $path = '/home/admin/web/' . $domain . '/public_html/'; $di = new RecursiveDirectoryIterator($path); echo '

Renaming files

'; $count = 0; foreach (new RecursiveIteratorIterator($di) as $filename => $file) { $filename = str_replace($path, '', $filename); $newfilename = $filename; // remove css cache $extensions = array( 'css', 'js', 'jpg', 'jpeg', 'png', 'gif' ); foreach( $extensions as $tmp ) { $search = '.' . $tmp . '_'; if( strpos($newfilename,$search) ) { $newfilename = explode($search, $newfilename); $newfilename = $newfilename[0] . '.' . $tmp; } } if( ltrim($newfilename, '_') != $newfilename ) $newfilename = str_replace_first('_', '?', $newfilename); $newfilename = str_replace('%3F', '?', $newfilename); $newfilename = str_replace('&', '&', $newfilename); $newfilename = str_replace('.php_', '.php?', $newfilename); $newfilename = str_replace('.asp_', '.asp?', $newfilename); if( $newfilename != $filename ) { $count++; echo $newfilename . '
'; rename($path . $filename, $path . $newfilename ); } } echo '

' . $count . ' Files renamed

'; die(); } } function str_replace_first($from, $to, $subject) { $from = '/'.preg_quote($from, '/').'/'; return preg_replace($from, $to, $subject, 1); }