Location: PHPKode > projects > Modular Site Manager > htdocs/lk/admin.inc.php
<?
if(!isset($_GET['sect']))
{
	echo "Welcome to the Vouksh.info V5 Admin, ".$_COOKIE['user'].". Use the links to the left to get to the various sections";
} else {
	switch($_GET['sect'])
	{
		case "tuts":
			switch($_GET['page'])
			{
				case "approve":
					//$mysql = new mysql(DB_MAIN);
					$sel = $mysql->select(PRE."tutorials", "approved='no'", "id", "ASC");
					if(mysql_num_rows($sel) < "1")
					{
						echo "There are no tutorials to approve";
					} else {
						while($a = mysql_fetch_assoc($sel))
						{
							echo '<div style="float: left; text-align:right; width: 15%;">Tutorial name:</div>
							<div style="float: right; text-align:left; width: 80%;"><a href="/tutorials/'.$a['cat'].'/'.$a['id'].'.php">'.$a['name'].'</a></div>
							<div style="float: left; text-align:right; width: 15%;">Link:</div>
							<div style="float: right; text-align:left; width: 80%;">&nbsp;'.$a['link'].'</div>
							<div style="float: left; text-align:right; width: 15%;">Author:</div>
							<div style="float: right; text-align:left; width: 80%;">'.$a['author'].'</div>
							<div style="float: left; text-align:right; width: 15%;">Category:</div>
							<div style="float: right; text-align:left; width: 80%;">'.$a['cat'].'</div>
							<div style="float: left; text-align:left; width: 60%;margin-bottom: 20px; margin-left: 150px;">
							<fieldset>
							<form action="lk/approve-tut.php" method="post">
							<input type="hidden" name="id" value="'.$a['id'].'" />
							<input type="submit" value="Approve" name="submit" />
							</form>
							</fieldset>
							</div>';
						}
					}
				break;
				case "edit":
					//$mysql = new mysql(DB_MAIN);
					$sel = $mysql->select(PRE."tutorials", NULL, "id", "ASC");
					if(mysql_num_rows($sel) < "1")
					{
						echo "There are no tutorials to edit.. weird..";
					} else {
						if(!isset($_GET['id']))
						{
							while($a = mysql_fetch_assoc($sel))
							{
								echo '<div style="margin-bottom: 20px; width: 100%;">
								<div style="float: left; text-align:right; width: 15%;">Tutorial name:</div>
								<div style="float: right; text-align:left; width: 80%;"><a href="admin.php?sect=tuts&amp;page=edit&amp;id='.$a['id'].'&amp;cat='.$a['cat'].'">'.$a['name'].'</a></div>
								<div style="float: left; text-align:right; width: 15%;">Link:</div>
								<div style="float: right; text-align:left; width: 80%;">&nbsp;'.$a['link'].'</div>
								<div style="float: left; text-align:right; width: 15%;">Author:</div>
								<div style="float: right; text-align:left; width: 80%;">'.$a['author'].'</div>
								<div style="float: left; text-align:right; width: 15%;margin-bottom: 20px;">Category:</div>
								<div style="float: right; text-align:left; width: 80%;margin-bottom: 20px;">'.$a['cat'].'</div>
								<br /><br /></div>';
							}
						} else {
							$sel = $mysql->select(PRE."tutorials", "id='".$_GET['id']."'", "id", "DESC", "1");
							$a = mysql_fetch_assoc($sel);
							$cats = listcats("tutorials");
							echo '<fieldset><form action="lk/tutorials.edit.php" method="post">
							<div class="formtext">Author:</div><div class="formdiv"><input type="text" name="author" value="'.$a['author'].'" /></div>
							<div class="formtext">Category:</div><div class="formdiv"><select name="cat">';
							foreach($cats as $cat => $disp)
							{
								if($cat == $a['cat'])
								{
									echo "<option value=\"".$cat."\" selected=\"selected\">".$disp."</option>";
								} else {
									echo "<option value=\"".$cat."\">".$disp."</option>";
								}
							}
							echo '</select></div>
							<div class="buttondiv">-Tutorial-</div>
							<div class="buttondiv">
							<textarea rows="30" cols="100" name="tutorial">
							'.stripslashes(
							htmlspecialchars(
							file_get_contents(
							SITE_PATH."tutorials/".$a['cat']."/".$_GET['id'].".php"
							))).'
							</textarea>
							</div>
							<div class="buttondiv"><input type="submit" name="submit" value="Edit" /></div></form></fieldset>';
						}
					}
					//$mysql->close();
				break;
				case "cats":
					//$mysql = new mysql(DB_MAIN);
					//$cats = listcats("tutorials");
					$sel = $mysql->select(PRE."config", "section='tutorials'", "id", "DESC", "1");
					$a = mysql_fetch_assoc($sel);
					$arr1 = explode("~", $a['setting']);
					$arr2 = explode("~", $a['setting2']);
					$cats = array_combine($arr1, $arr2);
					echo '<fieldset><form action="lk/tutcats.php" method="post">
					<div class="formtext">Categories</div><div class="formdiv"><textarea rows="20" cols="60" name="cats">';
					foreach($cats as $cat => $disp)
					{
						echo $cat." - ".$disp."\n";
					}
					echo '</textarea></div>
					<div class="buttondiv"><input type="submit" name="submit" value="submit" /></div>
					</form></fieldset>';
				break;
			}
		break;
		case "dls":
			switch($_GET['page'])
			{
				case "cats":
					//$mysql = new mysql(DB_MAIN);
					//$cats = listcats("tutorials");
					$sel = $mysql->select(PRE."config", "section='downloads'", "id", "DESC", "1");
					$a = mysql_fetch_assoc($sel);
					$arr1 = explode("~", $a['setting']);
					$arr2 = explode("~", $a['setting2']);
					$cats = array_combine($arr1, $arr2);
					echo '<fieldset><form action="lk/tutcats.php" method="post">
					<div class="formtext">Categories</div><div class="formdiv"><textarea rows="20" cols="60" name="cats">';
					foreach($cats as $cat => $disp)
					{
						echo $cat." - ".$disp."\n";
					}
					echo '</textarea></div>
					<div class="buttondiv"><input type="submit" name="submit" value="submit" /></div>
					</form></fieldset>';
				break;
			}
		break;
		case "affs":
			include SITE_PATH."lk/aff.inc.php";
		break;
		case "news":
			switch($_GET['page'])
			{
				case "new":
					echo '<form action="lk/news-post.php" method="post">
					<div class="formtext">Subject:</div><div class="formdiv"><input type="text" name="subject" /></div>
					<div class="buttondiv">News:</div>
					<div class="buttondiv"><textarea rows="50" cols="150" name="message" class="wysiwyg"></textarea></div>
					<div class="buttondiv"><input type="submit" name="submit" value="Submit" /></div>
					</form>';
				break;
				case 'edit':
					if(!isset($_GET['id']))
					{
						$sel = $mysql->select(PRE.'news', NULL, 'id', "DESC");
						while($l = mysql_fetch_assoc($sel))
						{
							echo '<a href="admin.php?sect=news&amp;page=edit&amp;id='.$l["id"].'">Edit '.$l['subject'].' ('.$l['id'].')</a><br />';
						}
					} else {
						$sel = $mysql->select(PRE.'news', "id='".$_GET['id']."'", 'id', "DESC");
						while($l = mysql_fetch_assoc($sel))
						{
							echo '<form action="lk/news.edit.php" method="post">
							<div class="formtext">Subject:</div>
							<div class="formdiv">
							<input type="text" name="subject" value="'.$l["subject"].'" />
							</div>
							<div class="buttondiv">
							<textarea name="news" rows="30" cols="80" class="wysiwyg">
							'.$l['submission'].'
							</textarea></div>
							<div class="buttondiv">
							<input type="hidden" name="id" value="'.$l["id"].'" />
							<input type="submit" name="submit" value="Edit It" />
							</div>';
						}
					}
				break;
			}
		break;
		case "members":
			switch($_GET['page'])
			{
				case "newsletter":
					echo '<form action="lk/members-newsletter.php" method="post">
					<div class="formtext">Subject:</div>
					<div class="formdiv"><input type="text" name="subject" /></div>
					<div class="formtext">Override newsletter option?</div>
					<div class="formdiv"><input type="checkbox" name="override" /></div>
					<div class="formtext">Message:</div>
					<div class="formdiv"><textarea rows="25" cols="75" name="message"></textarea></div>
					<div class="buttondiv"><input type="submit" name="submit" value="Send it" />
					</form>';
				break;
			}
		break;
		case 'content':
			switch($_GET['page'])
			{
				case 'addtopnav':
					$sel = $mysql->select(PRE.'config', "section='topnav'", 'id');
					$a = mysql_fetch_assoc($sel);
					echo '<form action="lk/content-topnav.php" method="post">
					<div class="buttondiv"><textarea rows="20" cols="40" name="opts">';
					$a1 = explode('~', $a['setting']);
					$a2 = explode('~', $a['setting2']);
					$b = array_combine($a1, $a2);
					foreach($b as $opt => $setting)
					{
						echo $opt.' - '.$setting."\n";
					}
					echo '</textarea></div>
					<div class="buttondiv"><input type="submit" name="submit" value="Submit" /></div>
					</form>';
				break;
				case 'addmainnav':
					$sel = $mysql->select(PRE.'config', "section='navigation-test'", 'id');
					$a = mysql_fetch_assoc($sel);
					echo '<form action="lk/content-mainnav.php" method="post">
					<div class="buttondiv"><textarea rows="20" cols="40" name="opts">';
					$a1 = explode('~', $a['setting']);
					$a2 = explode('~', $a['setting2']);
					$b = array_combine($a1, $a2);
					foreach($b as $opt => $setting)
					{
						echo $opt.' - '.$setting."\n";
					}
					echo '</textarea></div>
					<div class="buttondiv"><input type="submit" name="submit" value="Submit" /></div>
					</form>';
				break;
				case 'edit':
					$dir = opendir(SITE_PATH."content/");
					while($rd = readdir($dir))
					{
						if($rd !== '.' && $rd !== '..' && $rd !== "error_log" && $rd !== 'null.php')
						{
							echo '<a href="admin.php?sect=content&amp;page=edit&amp;id='.$rd.'">Edit '.$rd.'</a><br />';
						}
					}
					closedir($dir);
					if(isset($_GET['id']))
					{
						$fp = fopen(SITE_PATH.'content/'.$_GET['id'], 'r');
						echo '<form action="lk/content.edit.php" method="post">
						<div class="buttondiv">
						<textarea name="content" rows="30" cols="80">';
						echo stripslashes(fread($fp, filesize(SITE_PATH.'content/'.$_GET['id'])));
						echo '</textarea></div>
						<div class="buttondiv">
							<input type="hidden" name="file" value="'.SITE_PATH.'content/'.$_GET['id'].'" />
							<input type="submit" name="submit" value="Change" />
						</div>
						</form>';
					}
				break;
				case 'new':
					echo '<form action="lk/content.add.php" method="post">
					<div class="formtext">Filename:</div>
					<div class="formdiv"><input type="text" name="fname" value="filename.php" /></div>
					<div class="buttondiv"><textarea rows="30" cols="80" name="content"></textarea></div>
					<div class="buttondiv">
					<input type="submit" name="submit" value="Add It!" /><br />
					Make sure  you add it to the main navigation, using the form v5/&lt;filename (minus .php)&gt;/ </div>
					</form>';
				break;
				case 'delete':
					$dir = opendir(SITE_PATH."content/");
					while($rd = readdir($dir))
					{
						if($rd !== '.' && $rd !== '..' && $rd !== "error_log" && $rd !== 'null.php')
						{
							echo '<a href="lk/content.delete.php?id='.$rd.'">Delete '.$rd.'</a><br />';
						}
					}
					closedir($dir);
				break;
			}
		break;
	}
}
?>
Return current item: Modular Site Manager