[ABD] Simple Url to Link Name before posting 1.0.8

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
User avatar
Alien_Time
Registered User
Posts: 389
Joined: Fri Dec 31, 2010 7:08 am

Re: [RC] Simlpe Url to Link Name before posting 1.0.8

Post by Alien_Time »

One more thing Porutchik. Sorry I am not trying to be picky but I am just addressing a small typo on the MOD name. It should be "Simple" instead of "Simlpe". Thats all.. its just a polite feedback. :D

Cheers.
Porutchik
I've Been Banned!
Posts: 275
Joined: Sat Dec 31, 2005 11:11 am
Location: Russia, Orenburg (Россия, Оренбург)
Name: Sergey O
Contact:

Re: [RC] Simple Url to Link Name before posting 1.0.8

Post by Porutchik »

Wow :shock: . Tnks.
My forum | Advanced Similar Topics
Excuse me please for my awful English. Thanks!. Please do not P.M., ICQ or email me for support help - you won't get any reply. If you have a question or issue, post it in the appropriate forum/topic.
User avatar
Alien_Time
Registered User
Posts: 389
Joined: Fri Dec 31, 2010 7:08 am

Re: [RC] Simple Url to Link Name before posting 1.0.8

Post by Alien_Time »

hi Porutchik, I have the advanced SEO MOD installed and I installed this MOD by adding this:

Code: Select all

		//[begin] Url to Link name by Porutchik
		if ($allow_bbcode && $allow_magic_url)
		{
			$board_url = generate_board_url();
			$firstchar = '(^|[\n\t (>.])';
			$lastchar = '([\w\#$%&~\-;:=,?@+]*)';
			$viewtopic_url = str_replace('\://', '\://(www\.)*', $firstchar . '(' . preg_quote($board_url . '/viewtopic.' . $phpEx . '?') . ')');
			$viewforum_url = str_replace('\://', '\://(www\.)*', $firstchar . '(' . preg_quote($board_url . '/viewforum.' . $phpEx . '?') . ')');
			$viewprofile_url = str_replace('\://', '\://(www\.)*', $firstchar . '(' . preg_quote($board_url . '/memberlist.' . $phpEx . '?') . 'mode=viewprofile&)');
			$forums_auth = array();
			$matches0 = array();
			preg_match_all('#' . $viewtopic_url . '(f)=([0-9]+)&(t|p)=([0-9]+)' . $lastchar . '#si', $this->message, $matches0[]);
			preg_match_all('#' . $viewtopic_url . '(p)=([0-9]+)' . $lastchar . '#si', ' ' . $this->message, $matches0[]);
			preg_match_all('#' . $viewforum_url . '(f)=([0-9]+)' . $lastchar . '#si', ' ' . $this->message, $matches0[]);
			preg_match_all('#' . $viewprofile_url . '(u)=([0-9]+)' . $lastchar . '#si', ' ' . $this->message, $matches0[]);

			$last_char_patt = '/([\),]*)$/';
			foreach ($matches0 as $matches) 
			{
				foreach ($matches[0] as $k => $str) 
				{
					if (preg_match('@(\[code(?:=([a-z]+))?\].*?)' . preg_quote($str) . '(.*?\[\/code\])@is', $this->message))
					{
						continue;
					}
					$topic_title = '';
					$topic_post_id = (int) $matches[4+1][$k];
					$type_url = $matches[3+1][$k];
					switch ($type_url)
					{
						case 'f':
							switch ($matches[5+1][$k])
							{
								case 'p':
									$topic_post_id = (int) $matches[6+1][$k];
									$type_url = 'p';
								break;
								case 't':
									$topic_post_id = (int) $matches[6+1][$k];
									$sql = 'SELECT topic_title, topic_type, forum_id
										FROM ' . TOPICS_TABLE . ' t
										WHERE t.topic_id = ' . $topic_post_id;
								break;
								default:
									$sql = 'SELECT forum_name as topic_title, forum_id
										FROM ' . FORUMS_TABLE . '
										WHERE forum_id = ' . $topic_post_id;
								break;
							}
						break;
						case 'u':
							$sql = 'SELECT username
								FROM ' . USERS_TABLE . '
								WHERE user_id = ' . $topic_post_id;
						break;
					}
					if ($type_url == 'p')
					{
						$sql = 'SELECT t.topic_title, t.topic_type, t.forum_id, p.post_subject
							FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
							WHERE p.post_id = ' . $topic_post_id . ' 
								AND p.topic_id = t.topic_id';
					}
					if (!empty($topic_post_id) && ($result = $db->sql_query($sql)))
					{
						$row = $db->sql_fetchrow($result);
						switch ($type_url)
						{
							case 'u':
								$topic_title = $row['username'];
							break;
							case 'f':
							case 't':
							case 'p':
								if (!isset($forums_auth[$row['forum_id']]))
								{
									$forums_auth[$row['forum_id']] = $auth->acl_gets('f_list', 'f_read', $row['forum_id']);
								}
								if ($forums_auth[$row['forum_id']] || $row['topic_type'] == POST_GLOBAL)
								{
									$topic_title = (!empty($row['post_subject'])) ? $row['post_subject'] : $row['topic_title'];
								}
							break;
						}
						$db->sql_freeresult($result);
					}
					if (!empty($topic_title))
					{
						$internal_url = substr($str, strlen($matches[1][$k]));
						$internal_url = preg_replace('/(&)sid=[0-9a-f]{32}/', '', $internal_url);
						if (preg_match($last_char_patt, $str, $math))
						{
							$internal_url = preg_replace($last_char_patt, '', $internal_url);
						}
						$this->message = str_replace($str, $matches[1][$k] . '[url=' . trim($internal_url) . ']' . $topic_title . '[/url]' . ((isset($math[1])) ? $math[1] : ''), ' ' . $this->message);
					}
				}
			}
		}
		//[end] Url to Link name by Porutchik
Before:

Code: Select all

		// Prepare BBcode (just prepares some tags for better parsing)
		if ($allow_bbcode && strpos($this->message, '[') !== false)
It works fine when I dont add the font color bbcode or other bbcodes like B, i, u, etc... that is wrapped around the post with URL. But it shows the following error message when I preview the post that contains URL wrapped around the bbcode:

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/includes/message_parser.php on line 1250: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 55
[phpBB Debug] PHP Warning: in file [ROOT]/includes/message_parser.php on line 1250: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 55
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4885: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3900)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4887: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3900)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4888: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3900)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4889: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3900)
The line 1250 of includes/message_parser.php is:

Code: Select all

$this->message = preg_replace("@$str@", $replacement, ' ' . $this->message);
It only happens when I preview the posts that is wrapped with bbcode that ends right after the URL link and if I remove the font bbcode or add a space between the ending of URL and the ending bbcode, it converts the url to Link name without an issue.

For example:

Something like this works (note: This has a space between the URL and ending bbcode):

Code: Select all

[color=#004000]Check out this Link: https://www.phpbb.com/community/posting.php?mode=reply&f=70&t=1257295 [/color]
But This Doesnt:

Code: Select all

[color=#004000]Check out this Link: https://www.phpbb.com/community/posting.php?mode=reply&f=70&t=1257295[/color]
After showing the above error, the post body becomes empty and it shows "Your message contains too few characters.".

I understand the simple fix is to add a space at the end of the URL, but some users having this issue are reporting it about the error.
Porutchik
I've Been Banned!
Posts: 275
Joined: Sat Dec 31, 2005 11:11 am
Location: Russia, Orenburg (Россия, Оренбург)
Name: Sergey O
Contact:

Re: [RC] Simple Url to Link Name before posting 1.0.8

Post by Porutchik »

Update for SEO-mod. Current version 1.1.3
See contrib/update_for_seo_mod_1_1_2_to_1_1_3.xml or remove old code. See contrib/install_for_seo_mod.xml

See first post for download link.
My forum | Advanced Similar Topics
Excuse me please for my awful English. Thanks!. Please do not P.M., ICQ or email me for support help - you won't get any reply. If you have a question or issue, post it in the appropriate forum/topic.
User avatar
Alien_Time
Registered User
Posts: 389
Joined: Fri Dec 31, 2010 7:08 am

Re: [RC] Simple Url to Link Name before posting 1.0.8

Post by Alien_Time »

Thanks for the update. Its great!
User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5489
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: [RC] Simple Url to Link Name before posting 1.0.8

Post by Marc »

This topic has been marked as [ABD] - Abandoned as the mod author has not been active recently. If the MOD author wishes to continue development, please PM anyone on the MOD Team to request this topic be unlocked.

Notice!
We do not recommend that a user of the phpBB software install this MOD, or any other mod that is marked as “abandoned” or “in development”, on a live forum. Doing so may cause your forum to not perform in the manner it should.


Thank you,
The phpBB Modifications Team
Locked

Return to “[3.0.x] Abandoned MODs”