Pixelpost Forum

Pixelpost Forum (http://www.pixelpost.org/forum/index.php)
-   Hacks and Modifications (http://www.pixelpost.org/forum/forumdisplay.php?f=16)
-   -   http:// in comment url field (http://www.pixelpost.org/forum/showthread.php?t=2942)

tinyblob 12-19-2005 09:30 AM

http:// in comment url field
 
Want your comment template to have "http://" as it's starting value when new commenters look at the form? This encourages them to type well formed urls, instead of urls starting with "www." which breaks some addons.
This is easily accomplished with a hack.

Open up your index.php file in Notepad, or a similar plain text editor (Wordpad or MS Word are not suitable).

Look for line 639. You should find the following:

PHP Code:

if(isset($_COOKIE['visitorinfo']))    list($vinfo_name,$vinfo_url,$vinfo_email) = split("%",$_COOKIE['visitorinfo']); 

If you're using Notepad or something which doesn't show line numbers, just use the find function with the code above.

What that line does is check to see if visitors have opted to save their details previously, and if they have, it uses the values they have stored in a cookie.

We want to alter it, so that if no cookie exists, we're filling in the form field with "http://", so lets do that.

Change the line to this:

PHP Code:

if(isset($_COOKIE['visitorinfo'])) {
  list(
$vinfo_name,$vinfo_url,$vinfo_email) = split("%",$_COOKIE['visitorinfo']);
} else {
  
$vinfo_url "http://";


Yes, that's a total of 5 lines there to paste.

What we're doing now is just adding a statement which says, if there's no cookie, use this value instead..

That's done the job, the form field will now have a default setting of "http://".

But there's a problem, now if someone doesn't fill in the field their url gets saved as "http://". We can't have that!

Further down the file we have a section for saving comments, which starts at line 914 (it was line 911 before you made the previous changes).

If you want, use the find function with the text "// $url".

You'll find this section:

PHP Code:

// $url     
$url = isset($_POST['url']) ? $_POST['url'] : "";
if (
eregi("\r",$url) || eregi("\n",$url)){  die("No intrusion! ?? :(");}
$url clean($url); 

Add this line to the end:

PHP Code:

if ($url == "http://"){$url "";} 

All that does is checks to see if the url is set to just "http://" (meaning it hasn't been filled in), and if that's the case, resets it to nothing.


And we're done!

By the way.. the reason this is a hack, not an addon, is because it will be included in 1.5 final ;)

steff 12-20-2005 07:30 PM

great!
 
BTW in 1.4.3 the code is near line 430 :)

moreover, the // $url section can't be found in 1.4.3

thank you anyway! :)

tinyblob 12-20-2005 07:32 PM

heh, sorry, i haven't used 1.4.3 in quite some time ;)


All times are GMT. The time now is 03:18 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.