<?php
include('header.php');
	if (isset($_POST['submit'])) {
		$all = serialize($_POST);
		$update = mysql_query("UPDATE setting SET social_networks='$all' WHERE id='1'");
		if ($update) {
		$message = $general->notification('success','Your Setting Is Saved Successfully');
		} else {
		$message = $general->notification('error','Error Happened');
		}
	}
	$get = mysql_query("SELECT social_networks FROM setting WHERE id='1'");
	$g = mysql_fetch_array($get);
	$row = unserialize($g['social_networks']);
	echo '<div class="page_title"><h3>Social Networks</h3></div>';
	echo '<form method="POST" action="">
	<table width="100%" cellpadding="5" cellspacing="0">';
	if (isset($message)) {
	echo '<tr>
	<td colspan="3">'.$message.'</td>
	</tr>';
	}
	echo '<tr>
	<td colspan="3" class="label_td" style="padding:20px;">Write your profile full link with <b>http://</b> in the following Social Networks fields.</td>
	</tr>';
		$social_dir = scandir('images/social_icons/');
		foreach ($social_dir AS $social) {
		if ($social === '.' or $social === '..') continue;
		echo '<tr>
			<td class="label_td" width="16"><img src="images/social_icons/'.$social.'" /></td>
			<td class="label_td" width="150"><b>'.str_replace('.png','',ucfirst(str_replace('_',' ',$social))).'</b></td>
			<td class="input_td"><input type="text" name="'.str_replace('.png','',$social).'" value="'.$row[str_replace('.png','',$social)].'" size="70" /></td>
		</tr>';
		}
	echo '<tr>
	<td colspan="3"><input type="submit" name="submit" value="Save Setting" class="inputbutton grey" /></td>
	</tr>
	</table>
	</form>';
include('footer.php');
?>