tomcatuk Posted July 13, 2008 Share Posted July 13, 2008 Hi first time here and I know nothing about php script files... duh! So I'm after a bit of help.... Trying to use a script file that is for searching a log file but it don't work for me :-( Somebody pointed out that it is because I am using php v5 and its made for older versions. Could somebody please have a look at it for me and see if there is anything obvious? It's going to be used for searching a log of amateur radio call signs but nothing seems to happen... Not sure if I should upload the script here so before I do...... if anyone could help? Many thanks in advance... Steve Quote Link to comment Share on other sites More sharing options...
teynon Posted July 13, 2008 Share Posted July 13, 2008 Just paste it using the tags. Quote Link to comment Share on other sites More sharing options...
tomcatuk Posted July 14, 2008 Author Share Posted July 14, 2008 Just paste it using the tags. [/quote] Hope this is correct... I had a friend try this on his own server with the same problem it never worked, so he thinks it's to do with only working for earlier versions of php I'm using 5.2.5 <?php function show_entry_form($file_index, $mycall) { echo "<form action=".$file_index."?cmd=search method=post>\n"; ?> <table border=0 cellpadding=4 cellspacing=2> <tr> <td colspan=2 bgcolor="#333366"><font face='Verdana, Arial, Helvetica, sans-serif' size=3 color="#FFFFFF"><b> Online Log Search for <select name='mycall'> <option value='DA0A'>DA0A</option> <option value='DA0B'>DA0B</option> </select></b></font></td> </tr> <tr> <td bgcolor="#CCCCCC"><b><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color="#333366">Your call sign: <input type="text" name="callsign" size=20 maxlength=12> <input type="submit" name="submit" value="Search"> <input type="reset" value="Clear" name="reset"></td> </tr> </table> </form> <? } function search_log($file_index, $mycall, $callsign) { ?> <HTML> <HEAD> <TITLE><?=$mycall?> Log Search Results</TITLE> </HEAD> <BODY bgcolor=#FFFFFF link=#003399 vlink=#003399 alink=#FF0000 text=#333366> <? $number_of_bands = 9; $number_of_modes = 2; $bands = array ("160", "80", "40", "30", "20", "17", "15", "12", "10"); $modes = array ("CW", "SSB"); $bandmodes = array ( "160" => array ("CW"=>"-", "SSB"=>"-"), "80" => array ("CW"=>"-", "SSB"=>"-"), "40" => array ("CW"=>"-", "SSB"=>"-"), "30" => array ("CW"=>"-", "SSB"=>"-"), "20" => array ("CW"=>"-", "SSB"=>"-"), "17" => array ("CW"=>"-", "SSB"=>"-"), "15" => array ("CW"=>"-", "SSB"=>"-"), "12" => array ("CW"=>"-", "SSB"=>"-"), "10" => array ("CW"=>"-", "SSB"=>"-")); $callsign = strtoupper($callsign); $callsign = trim($callsign); $callsign = strtr($callsign, chr(32), ""); $search = "$callsign "; $qsos = 0; $total_qsos = 0; $first_date = ""; $log_date = ""; $first_log_time = ""; $last_log_time = ""; $log_time = "0000"; $last_date = ""; global $data_file; $data_file = strtolower(strtr($mycall, "/", "_")); $data_file = strtolower(strtr($mycall, " ", "_")); $data_file = "../_logs/$data_file.log"; $r_data_file = fopen($data_file, "r"); while (!feof($r_data_file)) { $string = chop(fgets($r_data_file, 1000)); if ($string != "") { // Find his_call if (eregi($search, $string)) { list ($call, $band, $mode, $time) = split('[ ]', $string); if ($call == $callsign) { if ($mode == "C") { $mode = "CW"; } elseif ($mode == "S") { $mode = "SSB"; } elseif ($mode == "R") { $mode = "RTTY"; } elseif ($mode == "P") { $mode = "PSK31"; } elseif ($mode == "T") { $mode = "SSTV"; } elseif ($mode == "F") { $mode = "FM"; } $bandmodes[$band][$mode] = "X"; if ($qsos == 0) { echo "<table border=0 cellpadding=4 cellspacing=0>\n"; echo "<tr><td colspan=2><font face='Verdana, Arial, Helvetica, sans-serif' size=4 color=#333366><b> ".$mycall." Log Search Results for ".$callsign."</b></font></td></tr>\n"; echo "<tr>\n"; echo "<td valign=top>\n"; echo "<table border=1 cellpadding=2 cellspacing=0 bordercolor=#333366>\n"; echo "<tr>\n"; echo "<td bgcolor=#333366><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#FFFFFF><b>Callsign </b></font></td>\n"; echo "<td width=50 bgcolor=#333366><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#FFFFFF><b>Band</b></font></td>\n"; echo "<td width=50 bgcolor=#333366><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#FFFFFF><b>Mode</b></font></td>\n"; echo "</tr>\n"; } echo "<tr>\n"; echo "<td bgcolor='#FFFFFF'><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#333366><b>".$call."</b></font></td>\n"; echo "<td width=50 bgcolor='#FFFFFF'><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#333366><b>".$band.""; if ($band != "SAT") { echo "m"; } echo "</b></font></td>\n"; echo "<td width=50 bgcolor='#FFFFFF'><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#333366><b>".$mode."</b></font></td>\n"; echo "</tr>\n"; $qsos++; } } } } fclose($r_data_file); if ($qsos == 0) { ?> <table border="0" width="500" cellspacing="0" cellpadding="4"> <tr> <td><font face='Verdana, Arial, Helvetica, sans-serif' size=4 color=#333366><b><?=$mycall?> Log Search Results</b></font></td> </tr> <tr> <td><b><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#333366>Sorry, no QSOs found for <?=$callsign?> !</font></b></td> </tr> <tr> <td><b><font face='Verdana, Arial, Helvetica, sans-serif' size=2><a href="javascript:history.go(-1)">Return</a></font></b></td> </tr> </table> <? } else { echo "</table>\n"; echo "</td>\n"; echo "<td valign=top>\n"; // Header Band/Mode Table if ($qsos != 0) { echo "<table border=1 cellpadding=2 cellspacing=0 bordercolor=#333366>\n"; echo "<tr>\n"; echo "<td align=center bgcolor=#333366 width=50><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#FFFFFF> </font></td>\n"; for ($m=0; $m<$number_of_modes; $m++) { echo "<td align=center bgcolor=#333366 width=50><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#FFFFFF><b>".$modes[$m]."</b></font></td>\n"; } echo "</tr>\n"; for ($b=0; $b<$number_of_bands; $b++) { echo "<tr>\n"; echo "<td align=center bgcolor=#333366 width=50><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#FFFFFF><b>".$bands[$b].""; if ($band != "SAT") { echo "m"; } echo "</b></font></td>\n"; for ($m=0; $m<$number_of_modes; $m++) { echo "<td align=center bgcolor='#FFFFFF' width=50><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#333366><b>".$bandmodes[$bands[$b]][$modes[$m]]."</b></font></td>\n"; } echo "</tr>\n"; } echo "</table>\n"; } echo "</td>\n"; echo "</tr>\n"; echo "<tr>\n"; if ($qsos == 0) { //echo "<td bgcolor=#333366 colspan=2><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#FFFFFF><b>Sorry, no QSO(s) found for ".$callsign."!</b></font></td>\n"; } else { echo "<td colspan=2><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#333366><b>Number of QSO(s) found: ".$qsos."</b></font></td>\n"; } echo "</tr>\n"; echo "<tr>\n"; echo "<td><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#333366><b><a href=\"javascript:history.go(-1)\">Return</a></b></font></td>\n"; echo "<td align='right'><font face='Verdana, Arial, Helvetica, sans-serif' size=2 color=#333366><b>Log Search provided by <a href=\"http://www.df3cb.com\" target=\"_parent\">DF3CB</a></b></font></td>\n"; echo "</tr>\n"; echo "</table>\n"; } echo "</BODY>\n"; echo "</HTML>\n"; } // choose command function execute_commands() { global $file_index, $cmd, $mycall, $callsign; if ($cmd == "search") { search_log($file_index, $mycall, $callsign); } else { show_entry_form($file_index, $mycall); } } // Start Commands // Name of the Log File $file_index="logsearch.php"; // Execute commands execute_commands(); ?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 14, 2008 Share Posted July 14, 2008 The problem is that your script relies on register_globals being turned on(see here for a description of register_globals), which isn't a good thing. This setting was turned off by default in PHP 5. You'll need to extract the variables from their relevant superglobal array. Change execute_commands and the call to the function (at the bottom of the script) to: function execute_commands($file_index, $cmd, $mycall, $callsign) { if ($cmd == "search") { search_log($file_index, $mycall, $callsign); } else { show_entry_form($file_index, $mycall); } } // Start Commands // Name of the Log File $file_index="logsearch.php"; // Execute commands execute_commands($file_index,$_GET['cmd'],$_POST['mycall'],$_POST['callsign']); Quote Link to comment Share on other sites More sharing options...
tomcatuk Posted July 14, 2008 Author Share Posted July 14, 2008 Phew that was a quick reply.... I'll have to get my friend to look at this as unfortunately I know nothing about php and the bit about "relevant superglobal array...." just about scared the life out of me... Thanks for your help.... Steve Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 14, 2008 Share Posted July 14, 2008 Erm, well i actually showed you what to change too. Quote Link to comment Share on other sites More sharing options...
tomcatuk Posted July 15, 2008 Author Share Posted July 15, 2008 Erm, well i actually showed you what to change too. Oppssss sorry never read it your reply correctly.... will report back as just off to work... Thanks once again for your help... Steve Quote Link to comment Share on other sites More sharing options...
tomcatuk Posted July 16, 2008 Author Share Posted July 16, 2008 Hi... brilliant it works a treat, many many thanks for your help.... Steve Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.