Jump to content

Php Script Help??!!


crazyeyes

Recommended Posts

First off I should indicate that I am new here. Second, I don't have much experience with php.

 

Heres whats up...

I had a guy do some work for me awhile ago with php/mysql. My SQL server crashed and I lost all of the databases, and the guy is nowhere to be found.

 

I have like 17 php scripts that I need databases for... here is just one:

 

<?php
session_start();
session_register('passw');

if($sub=="in"){$passw=$pass;}

echo '

<html>
<head><title>Schedule Admin</title></head>
<body>
<center>
';
$rightnow = time();
$dbh=mysql_connect ("localhost", "vwtvorg_vwtv", "34vw43") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("vwtvorg_vwtv");

//$delq = mysql_query("DELETE FROM sched WHERE (timein + runtime) < $rightnow AND runtime > 0;",$dbh);

$passq = mysql_query("SELECT value FROM vars WHERE name = 'password'",$dbh);
$passa = mysql_fetch_row($passq);
print (mysql_error()); 
$schedq = mysql_query("SELECT `name`,`timein`,`runtime`,`entry_num` FROM sched WHERE 1=1 ORDER BY timein,'order' ASC;");


if($passw==$passa[0]){
switch($act){

case 'ev':
	$editq = mysql_query("SELECT * FROM sched WHERE `entry_num` = '$edite';");

	echo "<table bgcolor=gray border=1 bordercolor=0 width=350>";
	echo "<tr><td colspan=4 align=center><form action='?act=e' method=post><br>";
	if(mysql_num_rows($editq)==0){
		echo "Couldnt locate entry to edit...";
	}else{
		$edita = mysql_fetch_row($editq);
		$timeval = strftime("%m/%d/%y %I:%M %p",$edita[2]);
		echo "Show Name:  <input type=text name=showname value='$edita[0]'><br><br>";
		echo "Sort Code:  <input type=text name=showsort value='$edita[4]'><br><br>";
		echo "Start Time:  <input type=text name=showstart value='$timeval' size='30'><br><br>";
		echo "Running Length:  ";
	echo "<select name=showrun>";
	echo "<option value=$edita[3]>Dont change...";
	echo "<option value=900>15 Minutes";
	echo "<option value=1800>30 Minutes";
	echo "<option value=3600>1 Hour";
	echo "<option value=5400>1 Hour 30 Minutes";
	echo "<option value=7200>2 Hours";
	echo "<option value=9000>2 Hours 30 Minutes";
	echo "<option value=10800>3 Hours";
	echo "<option value=12600>3 Hours 30 Minutes";
	echo "<option value=14400>4 Hours";
	echo "<option value=-1>FOREVER!!";
	echo "</select><br><br>";

		echo "Source:  ";
	echo "<select name=showsrc>";
	echo "<option value=$edita[1]>Dont change...";
		$DocRoot = './';
		$dir = "../library";
		$dh  = opendir($dir);
		while (false !== ($filename = readdir($dh))) {
    				if(strpos($filename,".")===FALSE){echo "<option value=$filename>$filename";}
		}

	echo "</select><br><br>";
		echo "<input type=hidden name=edite value=$edite>";
	}
	echo "<input type=submit value=Edit></form></td></tr>";
	echo "</table>";
break;

case 'av':
	$timeval = strftime("%m/%d/%y %I:%M %p",$rightnow);
	echo "<table bgcolor=gray border=1 bordercolor=0 width=350>";
	echo "<tr><td colspan=4 align=center><form action='?act=a' method=post><br>";
		echo "Show Name:  <input type=text name=showname value=''><br><br>";
		echo "Sort Code:  <input type=text name=showsort value=''><br><br>";
		echo "Start Time:  <input type=text name=showstart value='$timeval' size='30'><br><br>";
		echo "Running Length:  ";
	echo "<select name=showrun>";
	echo "<option value=900>15 Minutes";
	echo "<option value=1800>30 Minutes";
	echo "<option value=3600>1 Hour";
	echo "<option value=5400>1 Hour 30 Minutes";
	echo "<option value=7200>2 Hours";
	echo "<option value=9000>2 Hours 30 Minutes";
	echo "<option value=10800>3 Hours";
	echo "<option value=12600>3 Hours 30 Minutes";
	echo "<option value=14400>4 Hours";
	echo "<option value=-1>FOREVER!!";
	echo "</select><br><br>";

		echo "Source:  ";
	echo "<select name=showsrc>";
		$DocRoot = './';
		$dir = "../library";
		$dh  = opendir($dir);
		while (false !== ($filename = readdir($dh))) {
    				if(strpos($filename,".")===FALSE){echo "<option value=$filename>$filename";}
		}

	echo "</select><br><br>";

	echo "<input type=submit value='Add Entry'></form></td></tr>";
	echo "</table>";
break;

case 'e':
	if($showstart!="0"){$showstart = strtotime($showstart);}
	$cqs = "UPDATE `sched` SET `name` = '$showname', `src` = '$showsrc',`timein` = '$showstart',`runtime` = '$showrun', `order` = '$showsort' WHERE `entry_num` = '$edite';";
	//$cqs;
	$changeq = mysql_query($cqs,$dbh);
	if(!$changeq){
		echo "Change failed. <a href='?'>Click Here</a>";
	}else{
		echo "Made changes. <a href='?'>Click Here</a>";
	}
break;

case 'a':
	if($showstart!="0"){$showstart = strtotime($showstart);}
	$showrun = intval($showrun);
	$iqs = "INSERT INTO sched VALUES('$showname','$showsrc','$showstart','$showrun','$showsort','')";
	//echo $iqs;
	$insertq = mysql_query($iqs,$dbh);
	//echo mysql_error();
	if(!$insertq){
		echo "Add failed. <a href='?'>Click Here</a>";
	}else{
		echo "Added entry. <a href='?'>Click Here</a>";
	}
break;

case 'd':
	$sdelq = mysql_query("DELETE FROM sched WHERE `entry_num` = '$dwhat';",$dbh);
	if(!$sdelq){
		echo "Delete failed. <a href='?'>Click Here</a>";
	}else{
		echo "Deleted entry. <a href='?'>Click Here</a>";
	}
break;

default:
	echo "<table bgcolor=gray border=1 bordercolor=0>";
	echo "<tr> <td><b>Show</b></td> <td><b>Start Time</b></td> <td><b>Run Length</b></td> <td><b>Options</b></td> </tr>";
		if(mysql_num_rows($schedq)==0){
			echo "<tr><td colspan=4 align=center><h4>No Scheduled Shows</h4></td></tr>";
		}else{
			while($scheda = mysql_fetch_row($schedq)){
				$highlight = "gray";
				if($scheda[1] < $rightnow){
					if(($puresched + $scheda[2]) > $puretime||($puresched < $puretime && $sched[2]=-1)){
						$highlight = "red";
					}	
				}
				$scheda[3] = "<a href='?act=ev&edite=$scheda[3]'>Edit</a> <a href='?act=d&dwhat=$scheda[3]'>Delete</a>";

				if ($scheda[1]==0){
					$scheda[1] = "N/A";
				}else{
					$scheda[1] = strftime("%m/%d/%y %I:%M %p",$scheda[1]);
				}
				if($scheda[2]==-1){
					$scheda[2] = "Never";
				}else{
					$scheda[2] = ($scheda[2] / 60) / 60;
					$scheda[2] = $scheda[2] . " hour(s).";
				}
				echo "<tr>";
					foreach($scheda as $sched_e){
						echo "<td bgcolor=$highlight><b>$sched_e</b></td>";
					}
				echo "</tr>";
			}
		}
	$rightnow = strftime("%m/%d/%y %I:%M %p",$rightnow);
	echo "</table><br><br>The time is: $rightnow<br><h5>Red indicates the show is now in the rotation, all other shows are scheduled to enter the rotation.</h5><br>";
	echo "<a href='?act=av'>Add A New Entry...</a>";
break;
}
}else{
echo "<form method=post action=?>";
echo "<h3>Please Log In:</h3><br>";
echo "<h4>Password:</h4><input type=password name=pass><br>";
echo "<input type=hidden name=sub value=in>";
echo "<input type=submit value=Login><br>";
echo "</form>";
}

?>
</center>
</body>
</html>

 

I know the db name... could someone explain what the rows, fields, and datatypes are for each field so I can attempt to get this show on the road?

 

Any help would be greatly appreciated.

 

 

-TW

Link to comment
https://forums.phpfreaks.com/topic/124273-php-script-help/
Share on other sites

It would be time consuming. Just go through, look at the FROM.. After the FROM is the name of the table. After the SELECT there may be column names. As for the types, you would need to assume. I don't think anyone would have the time to go through and tell you all the table names etc.

Link to comment
https://forums.phpfreaks.com/topic/124273-php-script-help/#findComment-641777
Share on other sites

Well ProjectFear is right that would be your best way, but I would suggest continuely trying to get in contact with the guy that did the programming for you, also something you probably should have done... Database backups.... just mentioning for future reference this way if you have anymore problems with your database crashing you won't have to worry about having to re-assume the entire database again.

Link to comment
https://forums.phpfreaks.com/topic/124273-php-script-help/#findComment-642485
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.