Google

NukeCoder


View next topic
View previous topic
Post new topic   Reply to topic
Author Message
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Sat Mar 17, 2007 2:53 pm
Reply with quote

This will show you how to get forum topic titles into your Google Tapped links. The rewrites are based on the last GT-nextgen release and may need modification for other versions. Backup your files before making any changes.

Files to edit: 4
Difficulty: Easy

Open -> modules/Forums/nukebb.php

Find:
php:
 include("header.php"); 


After, ADD on a new line:
php:
 function gt_url($url_in)
{
  
$url_in trim(str_replace(array('exec''union''.'), ''$url_in));
  
$url_out preg_replace('/[^a-z0-9_\-\.]/i''_'$url_in);
  unset(
$url_in);
  return 
preg_replace('/[_]{2,}/''_'$url_out);


End -> modules/Forums/nukebb.php
_______________________________________

Open -> modules/Forums/viewforum.php

Find:
php:
 $goto_page .= '<a href="' append_sid("viewtopic.$phpEx?" POST_TOPIC_URL "=" $topic_id "&start=$j") . '">' $times '</a>'


Change to:
php:
 $goto_page .= '<a href="' append_sid("viewtopic.$phpEx?" POST_TOPIC_URL "=" $topic_id "&start=$j&title=".gt_url($topic_rowset[$i]['topic_title'])) . '">' $times '</a>'



Find:
php:
 $view_topic_url append_sid("viewtopic.$phpEx?" POST_TOPIC_URL "=$topic_id"); 


Change to:
php:
 $view_topic_url append_sid("viewtopic.$phpEx?" POST_TOPIC_URL "=$topic_id&title=".gt_url($topic_rowset[$i]['topic_title']) ); 



Find:
php:
 $last_post_url '<a href="' append_sid("viewtopic.$phpEx?"  POST_POST_URL '=' $topic_rowset[$i]['topic_last_post_id']) . '#' $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' $images['icon_latest_reply'] . '" alt="' $lang['View_latest_post'] . '" title="' $lang['View_latest_post'] . '" border="0" /></a>'


Change to:
php:
 $last_post_url '<a href="' append_sid("viewtopic.$phpEx?"  POST_POST_URL '=' $topic_rowset[$i]['topic_last_post_id']) .'&title='.gt_url($topic_rowset[$i]['topic_title']) . '#' $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' $images['icon_latest_reply'] . '" alt="' $lang['View_latest_post'] . '" title="' $lang['View_latest_post'] . '" border="0" /></a>'


End -> modules/Forums/viewforum.php
_______________________________________

Open -> .htaccess

Add the following 3 rewrite rules to your forum section:
Code:

RewriteRule ^ftopic-([0-9]*)-([0-9]*)-([A-Za-z0-9_-]*).html modules.php?name=Forums&file=viewtopic&t=$1&start=$2&title=$3 [L]
RewriteRule ^ftopic(t|p)-([0-9]*)-([A-Za-z0-9_-]*).html modules.php?name=Forums&file=viewtopic&$1=$2&title=$3 [L]
RewriteRule ^ftopic(t|p)-([0-9]*)-([A-Za-z0-9_-]*).html#([0-9]*) modules.php?name=Forums&file=viewtopic&$1=$2&title=$3#$4 [L]


End -> .htaccess
_______________________________________

Open -> GoogleTap/GT-Forums.php

Insert the lines marked in the code below:
This is only part of the $urlin array...
php:
 $urlin = array(
"'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&start=([0-9]*)&postdays=([0-9]*)&postorder=(desc|asc)&highlight=([A-Za-z0-9_-]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&postdays=([0-9]*)&postorder=(desc|asc)&start=([0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&start=([0-9]*)&title=([a-zA-Z0-9-_]*)'",//add#1
"'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&start=([0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&view=(previous|next)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&(t|p)=([0-9]*)&highlight=([A-Za-z0-9_-]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&(watch|unwatch)=topic&start=([0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&(t|p)=([0-9]*)((\")|(&sid=[a-zA-Z0-9]*))'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&(t|p)=([0-9]*)#([0-9]*)((\")|(&sid=[a-zA-Z0-9]*))'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&(t|p)=([0-9]*)&title=([a-zA-Z0-9-_]*)((\")|(&sid=[a-zA-Z0-9]*))'"// add#2
"'(?<!/)modules.php\?name=Forums&file=viewtopic&(t|p)=([0-9]*)&title=([a-zA-Z0-9-_]*)#([0-9]*)((\")|(&sid=[a-zA-Z0-9]*))'"// add#3
"'(?<!/)modules.php\?name=Forums&file=profile&mode=editprofile'",
"'(?<!/)modules.php\?name=Forums&file=profile&mode=viewprofile&u=([0-9]*)'"


This is only part of the $urlout array...
php:
 $urlout = array(
"ftopic-\\1-\\2-days\\3-order\\4-\\5.html",
"ftopic-\\1-days\\2-order\\3-\\4.html",
"ftopic-\\1-\\2-\\3.html",//add#1
"ftopic-\\1-\\2.html",
"ftopic-\\1-\\2.html",
"ftopic\\1-\\2-\\3.html",
"ftopic-\\1-\\2-\\3.html",
"ftopic\\1-\\2.html\\3",
"ftopic\\1-\\2.html#\\3\\4",
"ftopic\\1-\\2-\\3.html\\4",//add#2
"ftopic\\1-\\2-\\3.html#\\4\\5",//add#3
"forum-editprofile.html",
"forum-userprofile-\\1.html"


Save and close all files.
End Mod.

Check out this post to find out how to get the forum name into the url:
http://nukecoder.com/ftopict-367-Forum_Name_in_URL_with_Google_Tap.html
 
View user's profile Send private message Visit poster's website
floppy




Joined: Nov 29, 2006
Posts: 85
Location: Jackson, Mississippi

PostPosted: Sun Jan 25, 2009 4:43 pm
Reply with quote

Here is an updated copy of your gt_url function. Mainly the improvements are the stripping of special characters and such. Maybe a better way to do it, but this one worked for me.

php:
 function gt_url($url_in)
{
    
$code_entities_match = array(' ','--','---','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',&quot;'",',','.','/','*','+','~','`','=');
    
$code_entities_replace = array('-','-','-','','','','','','','','','','','','','','','','','','','','','','','','');
    
$url_in = str_replace($code_entities_match$code_entities_replace$url_in);
    
$url_in = trim(str_replace(array('exec', 'union', '.'), '', $url_in));
    
$url_out = preg_replace('/[^a-z0-9_\-\.]/i', '-', $url_in);
    unset(
$url_in);
    return strtolower(preg_replace('/[_]{2,}/', '-', 
$url_out));
 
View user's profile Send private message Visit poster's website MSN Messenger
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Mon Jan 26, 2009 7:38 pm
Reply with quote

I don't see why you have that big str_replace function when the following line gets rid of any funky characters...

php:
 $url_out preg_replace('/[^a-z0-9_\-\.]/i''-'$url_in); 


Also note that floppy's function is not compatable with my edits above as his uses - instead of _
 
View user's profile Send private message Visit poster's website
floppy




Joined: Nov 29, 2006
Posts: 85
Location: Jackson, Mississippi

PostPosted: Mon Jan 26, 2009 7:45 pm
Reply with quote

Well your right in a way, I took the long way around. I couldn't figure a better way to do it off the top of my head. So that is some old google'd code.

the title is
Bbcode on nuke news story?

It was all about one - too lmao, I wanted
http://www.clan-themes.co.uk/ftopict-4801-bbcode-on-nuke-news-story-.html

To be
http://www.clan-themes.co.uk/ftopict-4801-bbcode-on-nuke-news-story.html

In retrospect, maybe an easier way without the complicated str_replace.
 
View user's profile Send private message Visit poster's website MSN Messenger
floppy




Joined: Nov 29, 2006
Posts: 85
Location: Jackson, Mississippi

PostPosted: Mon Jan 26, 2009 7:49 pm
Reply with quote

php:
 function gt_url($url_in)
{
$url_in preg_replace('/[^a-z0-9_\-\.]/i'' '$url_in);
$url_in trim(str_replace(array('exec''union''.'), ''$url_in));
$url_out preg_replace('/[^a-z0-9_\-\.]/i''-'$url_in);
unset(
$url_in);
return 
strtolower(preg_replace('/[_]{2,}/''-'$url_out));

 


Seems to give the same result, thanks.
 
View user's profile Send private message Visit poster's website MSN Messenger
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Mon Jan 26, 2009 7:51 pm
Reply with quote

Code:
$url_in = preg_replace('/[^a-z0-9_\-\.]/i', ' ', $url_in);


is not needed.
 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 5 Hours
Forums ©