Calculators

Error: No sitefolder given.
"; exit( $content ); } $filenamedirTEMP = explode( "/" ,$filename ); $filenamedir = ''; for ( $ii = 0; $ii < count( $filenamedirTEMP ) - 1; $ii++ ) { $filenamedir .= $filenamedirTEMP[ $ii ] . '/'; } $filename = $filenamedirTEMP[ count( $filenamedirTEMP ) - 1 ]; //$sitefolder = "aceMoore"; $fileexists = 0; $filesize = 0; $filefound = "$filenamedir$filename"; $dirfound = "$filenamedir"; //*/ LOAD HTML TEMPLATE FILE $usingTemplate = 0; if ( file_exists( "$sitefolder/$htmlfilenameToLoadInto.htm" ) ) { $usingTemplate = 1; $htmlhandle = fopen( "$sitefolder/$htmlfilenameToLoadInto.htm", "rb" ); if ( $htmlhandle ) { // READ FILE $htmltemplate = fread( $htmlhandle, filesize( "$sitefolder/$htmlfilenameToLoadInto.htm" ) ); } else { // COULD NOT OPEN FILE $content .= "Error: Could not open up html template file.
"; exit( $content ); } fclose( $htmlhandle ); } //*/ // SEE IF REQUESTED FILE EXISTS if ( $filename != "Local.htm" ) { if ( $debug ) { $content .= "Sitefolder: \"" . htmlspecialchars( $sitefolder ) . "\".
"; $content .= "FileDir: \"" . htmlspecialchars( $filenamedir ) . "\".
"; $content .= "Filename: \"" . htmlspecialchars( $filename ) . "\".
"; } if ( file_exists( "$newsletterfolder$filenamedir$filename" ) ) { if ( $debug ) $content .= "File Exists.
"; $fileexists = 1; $filefound = "$filenamedir$filename"; $dirfound = "$filenamedir"; } else { $found = 0; foreach ( $foldersToTry as $somefolder ) { if ( $fileexists != 1 ) { if ( file_exists( "$newsletterfolder$somefolder$filename" ) ) { if ( $debug ) $content .= "FOUND ELSEWHERE, but File Exists.
"; $fileexists = 1; $filefound = "$somefolder$filename"; $dirfound = "$somefolder"; } } } } if ( $fileexists != 1 ) { if ( $debug ) $content .= "Couldn't find file, loading default page to load.
"; $filefound = "$defaultDir$defaultFile"; $dirfound = "$defaultDir"; } if ( $debug ) { $content .= "Dir Found: $dirfound
"; $content .= "File Found: $filefound
"; } $filesize = filesize( "$newsletterfolder$filefound" ); if ( $debug ) $content .= "Filesize: " . $filesize . ".
"; if ( $debug ) $content .= "


"; // LOAD FILE $fhandle = fopen( "$newsletterfolder$filefound", "rb" ); if ( $fhandle ) { // READ FILE $filecontents = fread( $fhandle, $filesize ); } else { // COULD NOT OPEN FILE $content .= "Error: Could not open up requested file.
"; exit( $content ); } fclose( $fhandle ); } else { // LOAD FILE $fhandle = fopen( "$sitefolder/Local.htm", "rb" ); if ( $fhandle ) { // READ FILE $filecontents = fread( $fhandle, filesize( "$sitefolder/Local.htm" ) ); } else { // COULD NOT OPEN FILE $content .= "Error: Could not open up requested file.
"; exit( $content ); } fclose( $fhandle ); exit( $filecontents ); } // CHANGE ALL LINKS $filecontents = ereg_replace( "href=\"([%A-Za-z0-9./]*)\"", "href=\"https://draketechnologies.com/$thisphpfilename?r=$sitefolder&f=$dirfound\\1&l=$htmlfilenameToLoadInto\" onMouseOver=\"(window.status='\\1'); return true\" onMouseOut=\"(window.status=''); return true\" ", $filecontents ); // CHANGE ALL IMAGES $filecontents = ereg_replace( "([_A-Za-z0-9.]+(\.gif))", "https://draketechnologies.com/$newsletterfolderForImages\\1", $filecontents ); $filecontents = ereg_replace( "([_A-Za-z0-9.]+(\.jpg))", "https://draketechnologies.com/$newsletterfolderForImages\\1", $filecontents ); $filecontents = str_replace( "src=\"../", "src=\"", $filecontents ); $filecontents = str_replace( "src=\"../", "src=\"", $filecontents ); $filecontents = str_replace( "|../", "|", $filecontents ); $filecontents = str_replace( "|../", "|", $filecontents ); foreach ( $customImages as $someimg) { if ( file_exists( "$sitefolder/customImages/$someimg" ) ) { $filecontents = str_replace( "https://draketechnologies.com/$newsletterfolderForImages$someimg", "https://draketechnologies.com/" . $sitefolder . "/customImages/$someimg", $filecontents ); } } $filecontents = ereg_replace( "src=\"([/.:A-Za-z0-9]+)http://", "src=\"https://", $filecontents ); $filecontents = ereg_replace( "href=\"([/.=&?:A-Za-z0-9]+)http://", "href=\"https://", $filecontents ); $filecontents = ereg_replace( "background=\"([/.:A-Za-z0-9]+)http://", "background=\"https://", $filecontents ); //*/ // QUICK FIX FOR JAVA APPLETS $filecontents = ereg_replace( "\\|([/A-Za-z0-9]+(\\.htm))\\|", "|https://draketechnologies.com/$thisphpfilename?r=$sitefolder&f=$dirfound\\1&l=$htmlfilenameToLoadInto|", $filecontents ); // SPIT IT OUT $content .= $filecontents; if ( $usingTemplate ) { echo str_replace( "CONTENT_GOES_HERE", $content, $htmltemplate ); } else { echo $content; } ?>