Instructions on how to avoid validation of URL on submission and editing listings
Open the file ./suggest-listing.php
Find the code:
PHP Code:
/** reciprocal listing checking **/
if ($config->get('reciprocal_check') && valid_url($_POST['reciprocal']))
{
$listing['recip_valid'] = check_reciprocal($_POST['reciprocal']);
}
/** checking for correct url **/
$listing['header'] = 200;
if ($config->get('listing_check') && $valid_url)
{
$listing['header'] = get_listing_header($_POST['url']);
}
if ($config->get('listing_check') && ($listing['header'] != 200) && ($listing['header'] != 301) && ($listing['header'] != 302))
{
$error = true;
$msg = "<li>".$gDirLang['error_broken_listing']."</li>";
}
if (($config->get('reciprocal_check')) && ($listing['recip_valid'] != 1))
{
$error = true;
$msg = "<li>".$gDirLang['error_no_backlink']."</li>";
}
Replace it with:
PHP Code:
$listing['recip_valid'] = check_reciprocal($_POST['reciprocal']);
$listing['header'] = get_listing_header($_POST['url']);
Find this code:
PHP Code:
$valid_url = false;
/** check URL **/
if (!$_POST['url'] || !valid_url($_POST['url']))
{
$error = true;
$msg = "<li>".$gDirLang['error_url']."</li>";
$valid_url = true;
}
else
{
$listing['domain'] = get_domain($_POST['url']);
}
and replace it with:
PHP Code:
$listing['domain'] = get_domain($_POST['url']);
also remove this code:
PHP Code:
/** gets pagerank **/
if ($config->get('pagerank') && $valid_url)
{
$listing['pagerank'] = getPageRank($_POST['url']);
}
Open ./edit-listing.php
PHP Code:
/** check URL **/
if (!$listing['url'])
{
$error = true;
$msg .= $gDirLang['error_url'];
}
else
{
$domainIsChanged = false;
$listing['domain'] = get_domain($listing['url']);
// account has changed the domain (changing domain means also change of the url itself)
if($original_listing['domain'] != $listing['domain'])
{
$domainIsChanged = true;
}
/** check if listing already exists (and if changed whether new value for the url or domain already exists) **/
if ($domainIsChanged && $config->get('duplicate_checking'))
{
$check = ($config->get('duplicate_checking_type') == 'domain') ? $listing['domain'] : $listing['url'];
$status = $Listing->checkDuplicate(sql($check), $config->get('duplicate_checking_type'));
if ('banned' == $status)
{
$error = true;
$msg .= $gDirLang['error_banned'];
}
elseif ($status)
{
$error = true;
$msg .= $gDirLang['error_listing_present'];
}
}
}
replace with:
PHP Code:
$listing['domain'] = get_domain($listing['url']);
Open ./admin/suggest-listing.php
Find this code:
PHP Code:
$valid_url = valid_url($_POST['url']);
if($valid_url)
{
$listing['url'] = $_POST['url'];
}
if ($url_required && !$valid_url)
{
$error = true;
$msg = $gDirLang['error_url'];
}
else
{
$_POST['url'] = $listing['url'] = sql($listing['url']);
$listing['domain'] = '';
$listing['header'] = '200';
$listing['pagerank'] = -1;
$listing['recip_valid'] = 0;
/** get pagerank **/
if ($config->get('pagerank'))
{
// if local install
if(0!==strpos($_SERVER['REMOTE_ADDR'], "192.168."))
{
$listing['pagerank'] = getPageRank($_POST['url']);
}
}
/** get domain name **/
$listing['domain'] = get_domain($_POST['url']);
/** check broken url **/
$listing['header'] = 200;
if ($config->get('listing_check') && !$config->get('broken_visitors'))
{
$listing['header'] = get_listing_header($_POST['url']);
$correct_headers = explode(',', $config->get('http_headers'));
if (!in_array($listing['header'], $correct_headers))
{
$error = true;
$msg = $gDirLang['error_broken_listing'];
}
}
}
/** check reciprocal listing**/
if ($valid_url && valid_url($_POST['reciprocal']) && $config->get('reciprocal_check') && !$config->get('reciprocal_visitors'))
{
if ($config->get('reciprocal_domain'))
{
if (get_domain($_POST['reciprocal']) != get_domain($_POST['url']))
{
$error = true;
$msg = 'Reciprocal listing seems to be placed on different domain.';
}
}
$listing['recip_valid'] = check_reciprocal($_POST['reciprocal']);
if (!$listing['recip_valid'])
{
$error = true;
$msg = $gDirLang['no_backlink'];
}
else
{
$listing['reciprocal'] = $_POST['reciprocal'];
}
}
replace it with:
PHP Code:
$listing['url'] = $_POST['url'];
$_POST['url'] = $listing['url'] = sql($listing['url']);
$listing['domain'] = '';
$listing['header'] = '200';
$listing['pagerank'] = -1;
$listing['recip_valid'] = 0;
$listing['domain'] = get_domain($_POST['url']);
$listing['reciprocal'] = $_POST['reciprocal'];
Remove this code:
PHP Code:
if ($config->get('duplicate_checking') && !$config->get('duplicate_visitors'))
{
$x = $config->get('duplicate_domain');
$forcheck = '';
if($x)
{
$forcheck = $listing['domain'];
$field = 'domain';
}
elseif($valid_url)
{
$forcheck = $_POST['url'];
$field = 'url';
}
if (!empty($forcheck) && $Listing->exists("`".$field."`='".$forcheck."'"))
{
$error = true;
$msg = $gDirLang['error_listing_present'];
}
}
Open ./admin/edit-listing.php
Find this code:
PHP Code:
if (!$temp['url'] || ($temp['url'] == 'http://') || !valid_url($temp['url']))
{
$error = true;
$msg = 'Please input correct listing URL.';
}
else
{
$temp['domain'] = get_domain($temp['url']);
}
Replace with:
PHP Code:
$temp['domain'] = get_domain($temp['url']);
Open ./admin/util.php
FInd this code:
PHP Code:
function valid_url($aUrl)
{
return preg_match('/^https?:\/\/[a-z0-9-]{2,63}(?:\.[a-z0-9-]{2,})*(?::[0-9]{0,5})?(?:\/|$)\S*$/',$aUrl);
}
replace with:
PHP Code:
function valid_url($aUrl)
{
return true;
}