Location: PHPKode > projects > Modular Site Manager > htdocs/inc/codedb.inc.php
<?php
/*
 * I'll add this later maybe.
 */
 global $mysql;
 switch(strtolower($_GET['subsec']))
 {
 	case 'view':
 		if(!isset($_GET['id']))
 		{
 			$sel = $mysql->select(PRE.'config', "section='codedb'", "id");
 			$res = mysql_fetch_assoc($sel);
 			$set1 = explode("~", $res['setting']);
 			$set2 = explode("~", $res['setting2']);
 			$comb = array_combine($set1, $set2);
 			echo '<ul>';
 			foreach($comb as $name => $url)
 			{
 				$no = mysql_num_rows($mysql->select(PRE."codedb", "cat='".$url."' AND public='yes'", "id"));
 				echo '<li><a href="CodeDB/View/'.$url.'/">'.$name.' ('.$no.')</a></li>'."\n";
 			}
 			echo '</ul>';
 		} else {
 			if(!isset($_GET['sid']))
 			{
 				$sel = $mysql->select(PRE.'config', "section='codedb'", "id");
 				$res = mysql_fetch_assoc($sel);
 				$set1 = explode("~", $res['setting']);
 				$set2 = explode("~", $res['setting2']);
 				$comb = array_combine($set1, $set2);
 				echo '<div style="text-align: center">';
 				foreach($comb as $name => $url)
 				{
 					echo '<a href="CodeDB/View/'.$url.'/">'.$name.'</a> &brvbar; ';
 				}
 				echo '<a href="CodeDB/View/">View Categories</a> &brvbar; <a href="CodeDB/Submit/">Submit Code</a></div><hr />';

 				$cat = $_GET['id'];
 				$sel = $mysql->select(PRE."codedb", "cat='".$_GET['id']."'", "id");
 				echo '<table class="codedb">
 				<tr>
 					<td>Title</td><td>User</td><td>Date</td>
 				</tr>';
 				$count = mysql_num_rows($sel);
 				for($i=0;$i<$count;$i++)
 				{
 					$allowed = explode(', ', $a['allowedids']);
 					if($a['public'] == 'no' && !in_array($_COOKIE['mid'], $allowed))
 					{
 						echo '';
 					} else {
 						if($i % 2)
 						{
 							$style = "row1";
 						} else {
 							$style = "row2";
	 					}
 						$a = mysql_fetch_assoc($sel);
 						echo '<tr class="'.$style.'">
 						<td><a href="CodeDB/View/'.$a['cat'].'/'.$a["id"].'/">'.$a["name"].'</a></td><td>'.getuserinfoid("username", $a['userid']).'</td><td>'.date(DATE.' g:i A',timeoffset($a['date'])).'</td>
	 					</tr>';
	 				}
	 			}
	 			echo '</table>';
	 		} else {
	 			$sel = $mysql->select(PRE.'config', "section='codedb'", "id");
 				$res = mysql_fetch_assoc($sel);
 				$set1 = explode("~", $res['setting']);
 				$set2 = explode("~", $res['setting2']);
 				$comb = array_combine($set1, $set2);
 				echo '<div style="text-align: center">';
 				foreach($comb as $name => $url)
 				{
 					echo '<a href="CodeDB/View/'.$url.'/">'.$name.'</a> &brvbar; ';
 				}
 				echo '<a href="CodeDB/View/">View Categories</a> &brvbar; <a href="CodeDB/Submit/">Submit Code</a></div><hr />';

	 			$sel = $mysql->select(PRE."codedb", "cat='".$_GET['id']."' AND id='".$_GET['sid']."'", "id");
	 			$a = mysql_fetch_assoc($sel);
	 			echo '<div class="formtext" style="padding-top: 0;">Submitter:</div><div class="formdiv" style="font-weight: bold">'.getuserinfoid("username", $a['userid']).'</div>

	 			<div class="buttondiv" style="text-align: left;">';
	 			xhtml_highlight($a['code']);
	 			echo '</div>';
			}
 		}
 	break;
 	case "submit":
 		if(isset($_COOKIE['mid']))
 		{
 			echo '<form action="misc/codedb.submit.php" method="post">
 			<div class="formtext">Small Description:</div>
 			<div class="formdiv"><input type="text" name="desc" /></div>
 			<div class="formtext">Allowed Users*</div>
 			<div class="formdiv"><input type="text" name="allowedids" /></div>
 			<div class="formtext">Category:</div>
 			<div class="formdiv"><select name="cat">';
 			$sel = $mysql->select(PRE.'config', "section='codedb'", "id");
 			$res = mysql_fetch_assoc($sel);
 			$set1 = explode("~", $res['setting']);
 			$set2 = explode("~", $res['setting2']);
 			$comb = array_combine($set1, $set2);
 			foreach($comb as $name => $url)
 			{
 				echo '<option value="'.$url.'">'.$name.'</option>';
 			}
 			echo '</select></div>
 			<div class="formtext">Public?</div>
 			<div class="formdiv"><input type="checkbox" checked="checked" name="public" /></div>
 			<div class="buttondiv">Code</div>
 			<div class="buttondiv"><textarea rows="15" cols="40" name="code"></textarea></div>
 			<div class="buttondiv"><input type="submit" name="submit" value="Submit" /><br />
 			*: Seperate via commas IE: User1, User2, User3<br />
 			Make sure you add the space, or else it will think it\'s one user.<br />
 			Only used if you uncheck public.</div>
 			</form>';
 		}
 	break;
 	case 'edit':
 		echo '<form action="misc/codedb.edit.php"';
 	break;
 	default:
 	case '':
 		echo '<ul>
 		<li><a href="CodeDB/View/">View Categories</li>
 		<li><a href="CodeDB/Submit/">Submit Code</li>
 		</ul>';
 	break;
 }
?>
Return current item: Modular Site Manager