function write_error($log,$error){ // this function opens up the log file and inserts the new error $nofile = 0; // lets first make sure the log file is there // if not will create a new one if(!is_file(ROOT_SITE_DIR . 'LOGS/' . $log . '.LOG')){ $nofile = 1; $goNew = fopen(ROOT_SITE_DIR . 'LOGS/' . $log . '.LOG',"w+"); $pubNew = fwrite(''); fclose($goNew); chmod(ROOT_SITE_DIR . 'LOGS/' . $log . '.LOG',0775); } $fOpen = fopen(ROOT_SITE_DIR . 'LOGS/' . $log . '.LOG',"r+b"); if(!$fOpen){ /* Ok there is an error opening up the error log file. */ }else{ /* ok now we have the error log open, we have to read the current data and insert the new error after it all */ if(!$nofile){ $errCont = fread($fOpen,filesize(ROOT_SITE_DIR . 'LOGS/' . $log . '.LOG')); if(!$errCont){ // error with reading the content from the log // need to figure out what to do with this error. }else{ // ok have our error data now will add our new error $errCont . $errCont . '\n\r ' . $error; $fWrite = fwrite($fOpen,$errCont); if(!$fWrite){ // ok there was an error with adding the new error // need to figure out what todo with this error }else{ fclose($fOpen); } } }else{ // ok the file is new we will just write our error $fWrite = fwrite($fOpen,$error); if(!$fWrite){ // error with writing to new file }else{ fclose($fOpen); } } } }