\n"; $bOk = false; } // $sTour = htmlspecialchars( $_POST["route"] ); //get the tour $sTour = str_replace( array( "\r\n", "\r", "\n" ), //replace all kinds of "", $sTour ); // newlines with "nothing" if( strlen( $sTour ) < 4 ) //is no tour given? { // no, then... echo "\n"; $bOk = false; } // /* $sPass = htmlspecialchars( $_POST["pass"] ); //get the password if( true === $bOk ) //all data ok? { // yes, then... $sPassword = getPassword( $sCsvFile ); // get the password if( $sPassword != $sPass ) // password match? { // no, then... echo "\n"; $bOk = false; // set error } } */ // if( true === $bOk ) //any error? { // no, then... $fFile = fopen( $sCsvFile, "a" ); // open csv file if( false !== $fFile ) // csv file open? { // yes, then... fputs( $fFile, $sDate.";" ); // make entry fputs( $fFile, htmlspecialchars( $_POST["bike"] ).";" ); fputs( $fFile, $sTour.";" ); fputs( $fFile, htmlspecialchars( $_POST["alt"] ).";" ); fputs( $fFile, htmlspecialchars( $_POST["km"] ).";" ); fputs( $fFile, $nPicIdxBeg.";" ); fputs( $fFile, $nPicIdxEnd.";" ); fputs( $fFile, "\n" ); fclose( $fFile ); // close open file } else // csv file is NOT open! { // then... echo "\n"; $bOk = false; // output an error } } return $bOk; } /** * This function returns the * @param $sPagePlusDatabase page * @return only the page title without database */ function getPageTitle( $sPagePlusDatabase, $nGerman ) { $sSearch = array( 'ue', 'oe', 'ae' ); $sReplace = array( 'ü', 'ö', 'ä' ); $aParts = explode( "|", $sPagePlusDatabase ); $sTitle = $aParts[0]; if( $nGerman != 0 ) { $sTitle = str_replace( $sSearch, $sReplace, $aParts[0] ); } return $sTitle; } /** * This function adds an entry to the * running log-book. */ function addRunEntry() { global $_FILES; //global variables global $max_file_size; global $aCsv; // $bOk = true; //ok flag $sDate = ""; //date $sTour = ""; //tour data $nPicIdxBeg = 0; //picture begin index $nPicIdxEnd = 0; //picture end index $sCsvFile = $aCsv["run"]; //setup csv filename // //28. Jul. 13;RR;Arberradmarathon TourC;1200;126; $sDate = htmlspecialchars( $_POST["date_day"] ); $sDate .= "."; $sDate .= htmlspecialchars( $_POST["date_mon"] ); $sDate .= "."; $sDate .= htmlspecialchars( $_POST["date_year"] ); if( ( strlen( $sDate ) < 8 ) || //is the date ( strlen( $sDate ) > 10 ) ) // okay? { // no, then... echo "\n"; $bOk = false; } // $sShoe = htmlspecialchars( $_POST["shoe"] ); //get the shoe // $sTour = htmlspecialchars( $_POST["route"] ); //get the tour $sTour = str_replace( array( "\r\n", "\r", "\n" ), //replace all kinds of "", $sTour ); // newlines with "nothing" // /* $sPass = htmlspecialchars( $_POST["pass"] ); //get the password if( true === $bOk ) //all data ok? { // yes, then... $sPassword = getPassword( $sCsvFile ); // get the password if( $sPassword != $sPass ) // password match? { // no, then... echo "\n"; $bOk = false; // set error } } */ // if( true === $bOk ) //any error? { // no, then... $fFile = fopen( $sCsvFile, "a" ); // open csv file if( false !== $fFile ) // csv file open? { // yes, then... fputs( $fFile, $sDate.";" ); // make entry fputs( $fFile, $sShoe.";" ); fputs( $fFile, $sTour.";" ); fputs( $fFile, htmlspecialchars( $_POST["km"] ).";" ); fputs( $fFile, $nPicIdxBeg.";" ); fputs( $fFile, $nPicIdxEnd.";" ); fputs( $fFile, "\n" ); fclose( $fFile ); // close open file } else // csv file is NOT open! { // then... echo "\n"; $bOk = false; // output an error } } return $bOk; } /* * This method writes the page * @param $nActivePage number of active page * @param $aPages array of the names of the available pages */ function writePage( $nActivePage, $aPages ) { global $aUser; global $aCsv; // $sPage = $aPages[$nActivePage]; // echo "\n"; echo " \n"; echo " ".$aUser["title"]."\n"; echo " \n"; echo " \n"; // echo "\n"; echo "\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; // $sFile = getPageTitle( $aPages[$nActivePage], 0 ).".html"; if( file_exists ( $sFile ) ) { readfile( $sFile ); } else { echo "

Can't read file '$sFile'

\n"; } // echo "
\n"; echo " \n"; echo "
\n"; echo "\n"; } /** * This function adds an entry to the guestbook */ function addGuestbook() { global $aCsv; // $bOk = true; $sName = ""; $sEMail = ""; $sText = ""; // $sName = trim( htmlspecialchars( $_POST["guest_name"] ) ); $sEMail = trim( htmlspecialchars( $_POST["guest_email"] ) ); $sText = trim( htmlspecialchars( $_POST["guest_text"] ) ); // if( strlen( $sText ) < 2 ) //is text given? { // no, then... $bOk = false; // clear ok flag } // if( strlen( $sName ) < 2 ) //is name given? { // no, then... $bOk = false; // clear ok flag } // if( true === $bOk ) //all okay? { // yes, then... $sText = str_replace( ";", ",", $sText ); // replace " by ' $sText = str_replace( "\r\n", "
", $sText ); // replace " by ' $fFile = fopen( $aCsv["guest"], "a+" ); // open file if( false !== $fFile ) // is file open? { // yes, then... fputs( $fFile, "\"".$sName."\";" ); fputs( $fFile, "\"".$sEMail."\";" ); fputs( $fFile, "\"".$sText."\";" ); fputs( $fFile, "\n" ); fclose( $fFile ); // close open file } } return $bOk; } //_____________________________________________________________________________ // MAIN // $bEntryOk = true; $nPage = 0; //set default page#0 // // check if parameter for guestbook if( ( isset( $_POST["guest_name"] ) ) && //is guestbook entry? ( isset( $_POST["guest_email"] ) ) && ( isset( $_POST["guest_text"] ) ) ) { // yes, then... $bEntryOk = addGuestbook(); // add this to guestbook $nPage = 3; } // // check if parameters for entry if( ( isset( $_POST["date_day"] ) ) && //is page available? ( isset( $_POST["date_mon"] ) ) && ( isset( $_POST["date_year"] ) ) && ( isset( $_POST["bike"] ) ) && ( isset( $_POST["route"] ) ) && ( isset( $_POST["alt"] ) ) && ( isset( $_POST["km"] ) ) && ( isset( $_POST["type"] ) ) && ( $_POST["type"] == "bike" ) ) { // yes, then... $bEntryOk = addBikeEntry(); // add the entry if( false === $bEntryOk ) // all okay? { // NO, then... $nPage = 2; // g } else { $nPage = 1; } } // // check if parameters for entry if( ( isset( $_POST["date_day"] ) ) && //is page available? ( isset( $_POST["date_mon"] ) ) && ( isset( $_POST["date_year"] ) ) && ( isset( $_POST["route"] ) ) && ( isset( $_POST["km"] ) ) && ( isset( $_POST["shoe"] ) ) && ( isset( $_POST["type"] ) ) && ( $_POST["type"] == "run" ) ) { // yes, then... $bEntryOk = addRunEntry(); // add the entry if( false === $bEntryOk ) // all okay? { // NO, then... $nPage = 5; // g } else { $nPage = 4; } } // // check for the page if( isset( $_GET["page"] ) ) //is page available? { // yes, then... $nPage = intval( htmlspecialchars( $_GET["page"] ) ); // get the page number } writePage( $nPage, $aPages );