<?php
include('header.php');
	if (isset($_POST['submit'])) {
		$all = serialize($_POST);
		$update = mysql_query("UPDATE setting SET general_setting='$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 general_setting FROM setting WHERE id='1'");
	$g = mysql_fetch_array($get);
	$row = unserialize($g['general_setting']);
	echo '<div class="page_title"><h3>Setting</h3></div>';
	echo '<form method="POST" action="">
	<table width="100%" cellpadding="5" cellspacing="0">';
	if (isset($message)) {
	echo '<tr>
	<td colspan="2">'.$message.'</td>
	</tr>';
	}
	echo '<tr>
	<td colspan="2" class="divider_td">Seo Setting</td>
	</tr>
	<tr>
	<td class="label_td" width="150">Profiler Url</td>
	<td class="input_td"><input type="text" name="script_url" size="60" value="'.str_replace('admin/setting.php','',current_page()).'" /></td>
	</tr>
	<tr>
	<td class="label_td" width="150">Site Title</td>
	<td class="input_td"><input type="text" name="site_title" size="60" value="'.$row['site_title'].'" /></td>
	</tr>
	<tr>
	<td class="label_td" width="150">Site Description</td>
	<td class="input_td"><textarea name="site_description" rows="3" style="width:98%;">'.$row['site_description'].'</textarea></td>
	</tr>
	<tr>
	<td class="label_td" width="150">Site Keywords</td>
	<td class="input_td"><input type="text" name="site_keywords" size="80" class="keywords" value="'.$row['site_keywords'].'" /></td>
	</tr>
	<tr>
	<td colspan="2" class="divider_td">Profile Setting</td>
	</tr>
	<tr>
	<td class="label_td" width="150">Profile Title</td>
	<td class="input_td"><input type="text" name="profile_title" size="60" value="'.$row['profile_title'].'" /></td>
	</tr>
	<tr>
	<td class="label_td" width="150">About</td>
	<td class="input_td"><textarea name="profile_about" rows="3" style="width:98%;">'.$row['profile_about'].'</textarea></td>
	</tr>
	<tr>
	<td class="label_td" width="150">Contact Information</td>
	<td class="input_td"><textarea name="contact_information" rows="3" style="width:98%;">'.$row['contact_information'].'</textarea></td>
	</tr>
	<tr>
	<td colspan="2" class="divider_td">Mail Setting</td>
	</tr>
	<tr>
	<td class="label_td" width="150" valign="top">Send Mail Method</td>
	<td class="input_td">
	<input type="radio" name="send_mail_method" value="0"'; if ($row['send_mail_method'] == 0) {echo 'CHECKED';} echo ' /> Simple PHP <code>mail()</code> Function <br />
	<input type="radio" name="send_mail_method" value="1"'; if ($row['send_mail_method'] == 1) {echo 'CHECKED';} echo ' /> SMTP <br />
	<div id="smtp"'; if ($row['send_mail_method'] == 0) {echo 'style="display:none;"';} else {echo 'style="display:block;"';} echo '>
	<div style="padding:5px;"><span style="width:150px; display:inline-block;">SMTP Host</span> <input type="text" name="smtp_host" size="40" value="'.$row['smtp_host'].'" /></div>
	<div style="padding:5px;"><span style="width:150px; display:inline-block;">SMTP Port</span> <input type="text" name="smtp_port" size="5" value="'.$row['smtp_port'].'" /></div>
	<div style="padding:5px;"><span style="width:150px; display:inline-block;">SMTP Username</span> <input type="text" name="smtp_username" size="40" value="'.$row['smtp_username'].'" /></div>
	<div style="padding:5px;"><span style="width:150px; display:inline-block;">SMTP Password</span> <input type="text" name="smtp_password" size="40" value="'.$row['smtp_password'].'" /></div>
	</div>
	<div id="php_mail"'; if ($row['send_mail_method'] == 1) {echo 'style="display:none;"';} else {echo 'style="display:block;"';} echo '>
	<div style="padding:5px;"><span style="width:150px; display:inline-block;">Sender E-Mail</span> <input type="text" name="sender_mail" size="40" value="'.$row['sender_mail'].'" /></div>
	</div>
	</td>
	</tr>
	<tr>
	<td colspan="2" class="divider_td">Template Setting</td>
	</tr>
	<tr>
		<td class="label_td" width="200">Site Theme</td>
		<td class="input_td"><select name="site_template">';
			$path = '../templates/';
			$results = scandir($path);
				foreach ($results as $result) {
					if ($result === '.' or $result === '..') continue;
					if (is_dir($path.$result)) {
						echo '<option value="'.$result.'"'; if ($result == $row['site_template']) {echo 'SELECTED';} echo '>'.$result.'</option>';
					}
				}
		echo '</select></td>
	</tr>
	<tr>
	<td colspan="2" class="divider_td">Blog RSS Setting</td>
	</tr>
	<tr>
	<td class="label_td">Blog RSS Url</td>
	<td class="input_td"><input type="text" name="blog_rss_url" size="60" value="'.$row['blog_rss_url'].'" /></td>
	</tr>
	<tr>
	<td class="label_td">Blog Posts Number</td>
	<td class="input_td"><select name="blog_posts_number">';
	for($i=3;$i<11;$i++) {
	echo '<option value="'.$i.'"'; if ($row['blog_posts_number'] == $i) {echo 'SELECTED';} echo '>'.$i.'</option>';
	}
	echo '</select></td>
	</tr>
	<tr>
	<td colspan="2" class="divider_td">Envato Marketplace Setting</td>
	</tr>
	<tr>
	<td class="label_td">Envato Api Key</td>
	<td class="input_td"><input type="text" name="envato_api_key" size="50" value="'.$row['envato_api_key'].'" /></td>
	</tr>
	<tr>
	<td class="label_td">Envato Username</td>
	<td class="input_td"><input type="text" name="envato_username" size="30" value="'.$row['envato_username'].'" /></td>
	</tr>
	<tr>
	<td class="label_td">Envato Items Number</td>
	<td class="input_td"><select name="envato_items_number">';
	for($i=1;$i<30;$i++) {
	echo '<option value="'.$i.'"'; if ($row['envato_items_number'] == $i) {echo 'SELECTED';} echo '>'.$i.'</option>';
	}
	echo '</select></td>
	</tr>
	<tr>
	<td colspan="2">
	<input type="hidden" name="copyrights" value="Profiler v1.0" />
	<input type="submit" name="submit" value="Save Setting" class="inputbutton grey" />
	</td>
	</tr>
	</table>
	</form>';
include('footer.php');
?>