<?php
session_start();
include("./functions.php");
include("./header.php");

echo "<script type=\"text/javascript\">
function CSB(){
if (document.mform.all.checked){
xxx = true;
} else {
xxx = false;
}
for (i = 0; i < document.forms['mform'].length; i++) {
document.forms['mform'].elements[i].checked = xxx
}
}
</script>\n";

if($_REQUEST['submit'] == "Create New Profile") {
	if($_REQUEST['profile_name'] == ""){
		$_REQUEST['profile_name'] = "Unknown";
	}

	mysql_query("INSERT INTO autoposter_meta_profiles SET profile_name='".$_REQUEST['profile_name']."', meta_keywords='".$_REQUEST['meta_keywords']."', meta_description='".$_REQUEST['meta_description']."', mt_keywords='".$_REQUEST['mt_keywords']."'");

	echo "<big><b>New Profile Created!</b></big><br /><br />";
}

if($_REQUEST['submit'] == "Delete All Selected") {

	foreach($_REQUEST['selchk'] AS $checked) {
		mysql_query("delete from autoposter_meta_profiles where id='$checked'");
	}

}

//echo("<script src=\"pop.js\" type=\"text/javascript\" language=\"javascript\"></script><table width=\"100%\"><tr><td align=\"right\"><a href=\"javascript:OpenWin('pop_help/manage_wp_projects.html', 'help', 380, 400);\"><img src=\"images/q.gif\" width=\"16\" height=\"16\" border=0 hspace=\"4\"><small>Help</small></a>&nbsp;&nbsp;</td></tr></table><br>");

echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"5\" border=\"0\" bordercolor=\"#000000\" align=\"center\">";
echo "<tr><td colspan=\"2\" bgcolor=\"#C0C0C0\" align=\"center\"><font face=verdana, arial>Manage Meta Elements (Tags, Keywords & Description)</td></tr>";
echo "</table><br />";

echo '<table bgcolor="#c0c0c0" cellpadding="5" cellspacing="1" border=0 align=center>
<form NAME=mform action="manage_meta.php" method="post"><font face=verdana, arial>

<tr><td bgcolor="#eeeeee">Profile Name:</td><td bgcolor="#eeeeee"><input name="profile_name" type="text" value=""></td></tr>
<tr><td bgcolor="#eeeeee">Meta Keywords (separate with commas):</td><td bgcolor="#eeeeee"><input name="meta_keywords" type="text" size="75" value=""></td></tr>
<tr><td bgcolor="#eeeeee">Meta Description:</td><td bgcolor="#eeeeee"><textarea name="meta_description" rows="2" cols="75" wrap="on" class="mceNoEditor"></textarea></td></tr>
<tr><td bgcolor="#eeeeee">Tags<br>(separate with commas, must use space after comma)<br />i.e tag1, tag2:</td><td bgcolor="#eeeeee"><input name="mt_keywords" type="text" size="75" value=""></td></tr>
<tr><td bgcolor="#eeeeee">&nbsp;</td><td bgcolor="#eeeeee"><input type="submit" name="submit" value="Create New Profile"></td></tr>
</form></table>

<br /><br />';

echo '<table bgcolor="#c0c0c0" cellpadding="5" cellspacing="1" border=0 align=center><font face=verdana, arial>
<tr><td bgcolor="#eeeeee" align="center">ID</font></td><td bgcolor="#eeeeee"><font face=verdana, arial>&nbsp;PROFILE TITLE</font></td><td align=center><input type=checkbox onClick=\'return CSB()\' name=all></td></tr>';

$lim = $Config->PROJECTS_PER_PAGE;
$s = $_REQUEST['s'];
if (!isset($s) || $s < 1 || !is_numeric($s)) {
$s = 1;
}
$start = ($s - 1) * $lim;
$fquery = "select * from autoposter_meta_profiles";
$countpages = $fquery;
$fquery = $fquery . " order by id desc limit $start, $lim";
$res = mysql_query($fquery);
$pages = ceil(mysql_num_rows(mysql_query($countpages)) / $lim);
if ($pages > 0) {
	echo("<p align=center style=\"font-size: 85%\">");
	for ($i = 1; $i <= $pages; $i++) {
		echo("[");
		if ($i == $s) {echo("<b>");}
		else {echo("<a href=?s=$i>");}
		echo("Page $i");
		if ($i == $s) {echo("</b>");}
		else {echo("</a>");}
		echo("]  ");
	}

	echo("</p><br />");

   	for ($i = 0; $i < mysql_num_rows($res); $i++) {
       	$id = mysql_result($res, $i, "id");
       	$profile_name = mysql_result($res, $i, "profile_name");
       	$metakeywords = mysql_result($res, $i, "meta_keywords");
       	$metadescription = mysql_result($res, $i, "meta_description");
       	$tags = mysql_result($res, $i, "mt_keywords");

		echo '<tr><td align="center" bgcolor="#eeeeee">&nbsp;<a href="edit_meta.php?id='.$id.'">'.$id.'</a></td><td align="left" bgcolor="#eeeeee"><font face=verdana, arial>&nbsp;<a href="edit_meta.php?id='.$id.'">'.$profile_name.'</a></td><td align="center"><font face=verdana, arial><input type=checkbox name=selchk[] value='.$id.'></td></tr>';
	}
}

echo '<tr><td colspan="7" align="right" bgcolor="#eeeeee"><font face=verdana, arial><input type=submit name=submit value="Delete All Selected" onclick="return confirm(\'Are you sure?\')" style="color: #000000; font-size: 8pt; font-weight: bold; border: 1px ridge #000000; background-color: #E1EBFB"></td></tr></table>';

include("./footer.php");
?>