<?php
/* Submit.php */
include("config.php");
include("mysql.php");
$SQL = new SQL;
function newlink()
{
global $config;
echo "<html>
<head>
<title>".$config['title']." :: Submitting Link</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
</head>
<body>
<form method=\"post\" action=\"?action=submit_link\">
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" class=\"form\">
<tr>
<td width=\"50%\">
Title:
</td>
<td width=\"50%\">
<input type=\"text\" name=\"title\" size=\"20\">
</td>
</tr>
<tr>
<td width=\"50%\">
Url:
</td>
<td width=\"50%\">
<input type=\"text\" name=\"url\" size=\"20\">
</td>
</tr>
<tr>
<td width=\"50%\">
Description:
</td>
<td width=\"50%\">
<textarea name=\"description\" rows=\"7\" cols=\"25\"></textarea>
</td>
</tr>
</table>
<input type=\"submit\" value=\"Submit\">
</form>
</body>
</html>";
}
function submit_link()
{
global $config,$SQL,$title,$url,$description,$posted_on;
if (!$title | !$url | !$description)
{
echo "<html>
<head>
<title>".$config['title']." :: Error</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
</head>
<body>
<font class=\"error\">
You must fill out the <b>Title</b>, <b>Url</b>, and <b>Description</b> fields! <a href=\"?act=newlink\">Try Again</a>
</font>
</body>
</html>";
die();
}
else
{
$urlpro=str_replace("http://",'',$url);
$urlpro=str_replace("www.",'',$urlpro);
$SQL->Connect($config['sql_host'],$config['sql_user'],$config['sql_pass'],$config['sql_database']);
$check = $SQL->Query("SELECT * FROM `pm_search` WHERE url LIKE '%$urlpro%'");
$result=mysql_query($check);
$num=mysql_num_rows($result);
if ($num>0)
{
echo "<html>
<head>
<title>".$config['title']." :: Error</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
</head>
<body>
<font class=\"error\">
Има вече такъв URL.
</font>
</body>
</html>";
die();
}
$SQL->Connect($config['sql_host'],$config['sql_user'],$config['sql_pass'],$config['sql_database']);
$posted_on = time();
$add_link = $SQL->Query("INSERT INTO `pm_search` (id, title, url, description, posted_on)". "VALUES ('NULL','$title','$url','$description','$posted_on')");
if (!$add_link)
{
echo "<html>
<head>
<title>".$config['title']." :: Error</title>
<link rel=\"stylesheet\" type=\"Text/css\" href=\"style.css\">
</head>
<body>
<font class=\"error\">
We are sorry, but we could not add your link. <a href=\"?act=newlink\">Try Again</a>
</font>
</body>
</html>";
die();
}
else
{
echo "<html>
<head>
<title>".$config['title']." :: Link Submitted</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
</head>
<body>
<font class=\"confirm\">
You link has been added with success! <a href=\"?act=newlink\">Add New Link</a>
</font>
</body>
</html>";
}
}
}
if ($_GET[action] == "newlink")
newlink();
else
if ($_GET[action] == "submit_link")
submit_link();
else
newlink();
?>