Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #1  
Old 12-19-2005, 09:30 AM
tinyblob's Avatar
tinyblob Offline
team pixelpost
 
Join Date: Nov 2005
Location: scotland
Posts: 523
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
__________________
touchnothing.net
Reply With Quote
  #2  
Old 12-20-2005, 07:30 PM
steff Offline
pixelpost guru
 
Join Date: Feb 2005
Location: Milan, Italy
Posts: 151
Send a message via MSN to steff
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!
Reply With Quote
  #3  
Old 12-20-2005, 07:32 PM
tinyblob's Avatar
tinyblob Offline
team pixelpost
 
Join Date: Nov 2005
Location: scotland
Posts: 523
heh, sorry, i haven't used 1.4.3 in quite some time
__________________
touchnothing.net
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 11:17 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs