Idiolatry Posted February 16, 2009 Share Posted February 16, 2009 Got a couple problems with this script...I'm very very new to PHP and can't read tutorials...I learn better when I mess around with actual code...Anyway...I have "DJ Status" PHP/SQL...First problem is...I can login to the admin panel just fine and add new DJs to the DB from it...But when I try to login from the DJ page it gives me password incorrect error...I know the password is fine... config.php <?php ////////////////////////////////////////////////////////////////////////////// // DJ Status v1.8.2 // // ©2005 Nathan Bolender www.nathanbolender.com // // Free to use on any website // ////////////////////////////////////////////////////////////////////////////// // Configuration // Add your information in the quotes on each line # Database $dbhost = "xxx.xxx.xxx.xxx"; // MySQL Server, Usually localhost $dbname = "TheDBName"; // MySQL database name $dbuser = "TheDBusername"; // MySQL username $dbpass = "DBpassword"; // MySQL password # Shoutcast $scdef = "Stream Name"; // Default station name to display when server or stream is down (ex: SNRadio) $scip = "xxx.xxx.xxx.xxx."; // ip or url of shoutcast server - no http:// (ex: radio.radiosite.com) $scport = "Port"; // port of shoutcast server (ex: 8000) $scpass = "Password"; // password to shoutcast server # Admin Panel $adminname = "Admin name"; // Name to display when in manual mode $adminpass = "Admin pass"; // Password for the administration panel // End configuration //////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////// Do not edit below this line ////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////// $version = "1.8.2"; $filename = "admin/install/index.php"; // Shoutcast Server Stats $scfp = @fsockopen("$scip", $scport, $errno, $errstr, 10); if(!$scfp) { $scsuccs=1; # echo'<strong>'.$scdef.' is Offline</strong><br>'; } if($scsuccs!=1){ fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: DJ Status v$version (www.nathanbolender.com) (Mozilla Compatible)\r\n\r\n"); while(!feof($scfp)) { $page .= fgets($scfp, 1000); } //define xml elements $loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "AIM", "ICQ"); $y=0; while($loop[$y]!=''){ $pageed = ereg_replace(".*<$loop[$y]>", "", $page); $scphp = strtolower($loop[$y]); $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed); if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE || $loop[$y]==AIM || $loop[$y]==ICQ) $$scphp = urldecode($$scphp); // uncomment the next line to see all variables #echo'$'.$scphp.' = '.$$scphp.'<br>'; $y++; } //end intro xml elements //get song info and history $pageed = ereg_replace(".*<SONGHISTORY>", "", $page); $pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed); $songatime = explode("<SONG>", $pageed); $r=1; while($songatime[$r]!=""){ $t=$r-1; $playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]); $playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]); $song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]); $song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]); $song[$t] = urldecode($song[$t]); $dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page); $dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed); $r++; } //end song info fclose($scfp); } if (file_exists($filename)) { $nodb = "1"; } if (isset($nodb) == FALSE) { include ("dbconnect.php"); } ?> Update page ( Login ) <?php ////////////////////////////////////////////////////////////////////////////// // DJ Status v1.8.2 // // ©2005 Nathan Bolender www.nathanbolender.com // // Free to use on any website // ////////////////////////////////////////////////////////////////////////////// include ("config.php"); if ($mode == "1") { if (!isset($dj)) { echo "<form name=\"form1\" method=\"post\" action=\"update2.php\"> <p><b>Welcome to the DJ select page. Please choose your name and input your password.</b><br> <select name=\"newdj\" id=\"newdj\"> <option>--Choose Your Name--</option>"; $query="SELECT * FROM currentdj ORDER BY `dj` ASC"; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $edj = "$row[dj]"; $ename = "$row[name]"; echo "<option value=\"$edj\">$ename</option>"; } echo "</select> <b>Password: </b> <input name=\"password\" type=\"password\" id=\"password\"> </p> <p> <input type=\"submit\" name=\"Submit\" value=\"Update DJ\"> </p> </form>"; } else { echo "<form name=\"form1\" method=\"post\" action=\"update2.php\"> <input type=\"hidden\" value=\"$dj\" name=\"olddj\"> <p><b>$name is still signed on. If you are $name, please input your password to sign off.</b><br> <b>Name: </b>$name <b>Password: </b> <input name=\"password1\" type=\"password\" id=\"password1\"><br>You may also contact $adminname for an override if needed. </p> <p> <input type=\"submit\" name=\"Submit\" value=\"Update DJ\"> </p> </form>"; } } else { echo "<b>DJ Status is currently in Automatic mode. To switch to Manual mode, have $adminname change the setting in the administration panel.</b>"; } echo "<br><br><font size=\"-1\"><strong>Powered by DJ Status v$version - ©2005 Nathan Bolender - <a href=\"http://www.nathanbolender.com\" target=\"_blank\">www.nathanbolender.com</a></strong></font>"; ?> And update2 page... <?php ////////////////////////////////////////////////////////////////////////////// // DJ Status v1.8.2 // // ©2005 Nathan Bolender www.nathanbolender.com // // Free to use on any website // ////////////////////////////////////////////////////////////////////////////// include ("config.php"); if ($mode == "1") { if (isset($dj)) { $query="SELECT * FROM currentdj WHERE dj = '$dj'"; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $pass = "$row[password]"; } $password1 = $_POST['password1']; if (("$password1" == "$pass") or ("$password1" == "$adminpass")) { $resultID = mysql_query("UPDATE currentdj SET active = '0' WHERE dj = '$dj'") or die(mysql_error()); if ($resultID == TRUE) { print "DJ $name has been set to inactive. (SUCCESSFUL)"; } else { print "DJ $name is still set to active, please try again. (NOT SUCCESSFUL)"; } } else { echo "<b>INCORRECT PASSWORD</b>"; } } else { /////////////////////////////////////////////////// $query="SELECT * FROM currentdj WHERE dj = '$newdj'"; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $pass = "$row[password]"; } $password = $_POST['password']; if (("$password" == "$pass") or ("$password" == "$adminpass")) { $resultID = mysql_query("UPDATE currentdj SET active = '1' WHERE dj = '$newdj'") or die(mysql_error()); if ($resultID == TRUE) { print "You (DJ #$newdj) have been set to active. (SUCCESSFUL)"; } else { print "You (DJ #$newdj) have NOT been set to active, please try again. (NOT SUCCESSFUL)"; } } else { echo "<b>INCORRECT PASSWORD</b>"; } } } else { echo "<b>DJ Status is currently in Automatic mode. To switch to Manual mode, have $adminname change the setting in the administration panel.</b>"; } echo "<br><br><font size=\"-1\"><strong>Powered by DJ Status v$version - ©2005 Nathan Bolender - <a href=\"http://www.nathanbolender.com\" target=\"_blank\">www.nathanbolender.com</a></strong></font>"; ?> Sorry if I'm not mentioning anything that needs to be mentioned... When I get into the DB and enter 1 instead of 0 for active...Then when I go to the login page it says "$name is still signed on. If you are $name, please input your password to sign off." ( From first update page ) and when I enter the password it logs the user out ( 1 to 0 in the DB for active )...I hope that makes sense ? Anyway...My other problem is it's not getting the stats from the stream either...I've contacted the server about fsock and they say it's open but the readme.txt for the script says that the error is caused because fsock isn't open...I've also tested with <?php $fp = fsockopen("www.mydomain.com", 8080, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } ?> And I get Warning: fsockopen() [function.fsockopen]: unable to connect to www.mydomain.com:8080 (Connection refused) in /home/content/html/testfsockopen.php on line 2 Connection refused (111) When I contacted the server they replied with I have verified that the PHP function 'fsock' can be used by the server. Unfortunately, we do not provide technical support with third-party scripting issues. We are very limited in the support we can offer for custom-written code or scripts. If there is evidence that our system is responsible for the error, please forward it to us, and we would be happy to look into the matter further. But at the moment this does not appear to be the case, so we regret we can not assist you further with this issue. Quote Link to comment https://forums.phpfreaks.com/topic/145372-dj-status/ 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.