problema validacion duplicado

oscar
10 de Mayo del 2006
Hola,
Tengo un script (php list directory) que lo que hace es armar un directorio de sitios webs. Segun este script, no puede haber 2 direcciones webs iguales y yo necesito sacar eso, probe de todas formas y no pude editarlo.
En donde dice true, puse false y todo pero no funciona por lo que no entiendo el motivo, les paso el php, si alguien puede darme una mano sera muy bien recibida

Saludos

Diego.


<?
require_once("config.php");
require_once("include.php");
require_once("template_add_url.php");
$c *= 1;
if ($c == 0){
header("Location: {$dir}");
exit();
};
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
mysql_select_db($mysql_database, $bd);
require_once("include_banned.php");
$sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c");
$current_category = mysql_fetch_array($sql, MYSQL_ASSOC);
if (($c > 1) & !$current_category["name"]){
mysql_close();
header("Location: {$dir}");
exit();
};
if (!$current_category["name"]) $current_category["name"] = "Free PHP Directory Script";
if (!$current_category["description"]) $current_category["description"] = $current_category["name"]." ".$current_category["title"];

$replace = array("[CATEGORY_NAME]" => $current_category["name"], "[CATEGORY_TITLE]" => $current_category["title"], "[CATEGORY_DESCRIPTION]" => $current_category["description"]);
echo strtr($TEMPLATE["HEADING"],$replace);
flush();
$last_category = false;
$ref = $c;
while(!$last_category){
$n_parent_categories += 1;
$sql = mysql_query("SELECT id, name, ref FROM {$prefix}categories WHERE id = $ref");
$parent_categories[$n_parent_categories-1] = mysql_fetch_array($sql, MYSQL_ASSOC);
if ($parent_categories[$n_parent_categories-1]["ref"] == 0){
$last_category = true;
}else{
$ref = $parent_categories[$n_parent_categories-1]["ref"];
};
};
echo $TEMPLATE["PATH"]["HEADING"];
for ($x = $n_parent_categories-1; $x >= 0; $x--){
if ($x != $n_parent_categories-1) echo $TEMPLATE["PATH"]["SEPARATOR"];
if ($parent_categories[$x]["id"] > 1){
$category_url = $dir.'index.php?c='.$parent_categories[$x]["id"];
}else{
$category_url = $dir;
};
$replace = array("[CATEGORY_NAME]" => $parent_categories[$x]["name"], "[CATEGORY_URL]" => $category_url);
echo strtr($TEMPLATE["PATH"]["CATEGORY"],$replace);
};
echo $TEMPLATE["PATH"]["FOOTER"];
flush();
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$url = convert_url($url);
$keywords = convert_keywords($keywords);
$url = parse_input($url);
$title = parse_input($title);
$description = parse_input($description);
$keywords = parse_input($keywords);
$sql = mysql_query("SELECT * FROM {$prefix}pages WHERE url = '$url'");
if (mysql_num_rows($sql) > 0){
$error_duplication = true;
}else{
if (strlen($title) < 5 || strlen($title) > 100) { $error_variables = true; $errors["title"] = true; };
if (strlen($description) < 50 || strlen($description) > 200) { $error_variables = true; $errors["description"] = true; };
if (strlen($keywords) < 20 || strlen($keywords) > 200) { $error_variables = true; $errors["keywords"] = true; };
if (strlen($url) < 10) { $error_variables = true; $errors["url"] = true; };
if (!$error_variables){
mysql_query("INSERT INTO {$prefix}pages (url,title,description,keywords,accepted,ip,category) VALUES ('$url','$title','$description','$keywords','n','".$_SERVER["REMOTE_ADDR"]."',$c)");
};
};
};
mysql_close();
if ($_SERVER["REQUEST_METHOD"] == "POST"){
if ($error_duplication){
echo $TEMPLATE["DUPLICATED_SUBMISSION"];
}elseif ($error_variables){
echo $TEMPLATE["ERROR_FORM"]["HEADING"];
$field = ($errors["url"])? $TEMPLATE["ERROR_FORM"]["ERROR_FIELD"] : $TEMPLATE["ERROR_FORM"]["FIELD"];
$replace = array("[FIELD_NAME]" => "url", "[FIELD_VALUE]" => $url, "[FIELD_MAXLENGTH]" => 100, "[FIELD_DESCRIPTION]" => $TEMPLATE["FORM"]["FIELDS"]["URL"]);
echo strtr($field,$replace);
$field = ($errors["title"])? $TEMPLATE["ERROR_FORM"]["ERROR_FIELD"] : $TEMPLATE["ERROR_FORM"]["FIELD"];
$replace = array("[FIELD_NAME]" => "title", "[FIELD_VALUE]" => $title, "[FIELD_MAXLENGTH]" => 100, "[FIELD_DESCRIPTION]" => $TEMPLATE["FORM"]["FIELDS"]["TITLE"]);
echo strtr($field,$replace);
$field = ($errors["description"])? $TEMPLATE["ERROR_FORM"]["ERROR_FIELD"] : $TEMPLATE["ERROR_FORM"]["FIELD"];
$replace = array("[FIELD_NAME]" => "description", "[FIELD_VALUE]" => $description, "[FIELD_MAXLENGTH]" => 200, "[FIELD_DESCRIPTION]" => $TEMPLATE["FORM"]["FIELDS"]["DESCRIPTION"]);
echo strtr($field,$replace);
$field = ($errors["keywords"])? $TEMPLATE["ERROR_FORM"]["ERROR_FIELD"] : $TEMPLATE["ERROR_FORM"]["FIELD"];
$replace = array("[FIELD_NAME]" => "keywords", "[FIELD_VALUE]" => $keywords, "[FIELD_MAXLENGTH]" => 200, "[FIELD_DESCRIPTION]" => $TEMPLATE["FORM"]["FIELDS"]["KEYWORDS"]);
echo strtr($field,$replace);
echo '<INPUT TYPE="hidden" NAME="c" VALUE="'.$c.'">'."rn";
echo $TEMPLATE["ERROR_FORM"]["FOOTER"];
}else{
echo $TEMPLATE["CORRECT_SUBMISSION"];
};
}else{
echo $TEMPLATE["FORM"]["HEADING"];
$replace = array("[FIELD_NAME]" => "url", "[FIELD_VALUE]" => "http://www.zonaoestecomercial.com.ar", "[FIELD_MAXLENGTH]" => 100, "[FIELD_DESCRIPTION]" => $TEMPLATE["FORM"]["FIELDS"]["URL"]);
echo strtr($TEMPLATE["FORM"]["FIELD"],$replace);
$replace = array("[FIELD_NAME]" => "title", "[FIELD_VALUE]" => "", "[FIELD_MAXLENGTH]" => 100, "[FIELD_DESCRIPTION]" => $TEMPLATE["FORM"]["FIELDS"]["TITLE"]);
echo strtr($TEMPLATE["FORM"]["FIELD"],$replace);
$replace = array("[FIELD_NAME]" => "description", "[FIELD_VALUE]" => "", "[FIELD_MAXLENGTH]" => 200, "[FIELD_DESCRIPTION]" => $TEMPLATE["FORM"]["FIELDS"]["DESCRIPTION"]);
echo strtr($TEMPLATE["FORM"]["FIELD"],$replace);
$replace = array("[FIELD_NAME]" => "keywords", "[FIELD_VALUE]" => "", "[FIELD_MAXLENGTH]" => 200, "[FIELD_DESCRIPTION]" => $TEMPLATE["FORM"]["FIELDS"]["KEYWORDS"]);
echo strtr($TEMPLATE["FORM"]["FIELD"],$replace);
echo '<INPUT TYPE="hidden" NAME="c" VALUE="'.$c.'">'."rn";
echo $TEMPLATE["FORM"]["FOOTER"];
};
echo $TEMPLATE["FOOTER"];
?>