News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Pretty URLs

Started by SMFHacks.com Team, January 31, 2007, 10:56:43 AM

Previous topic - Next topic

viulian

Quote from: eldʌkaː on September 03, 2007, 04:21:27 AM
Hmmm, I don't see how it could restart itself. It just runs straight through once.

Or it might be some Apache configuration error - don't know, I did not configure that Apache.
As soon as I removed install.php , threads started to die (I assume each process actually tried to convert the topic names and then started another copy of itself). Then Mysql started to give out errors ("Too many connections") then the threads spawned lot quicker till the system was too loaded.

After removing install.php - it calmed down, so while I can't for sure know what the problem is, removing install.php while it happened cleaned the issue.
I will try to figure out what happened and let you know.

Minare

querystring.php gave error again , I changed the querystring.php with a new one. And it is ok now. But does anything happen to my forum because of that change ?  :D

Dannii

Which error?
You replace QueryString.php with a non-edited one? Well then the mod won't do anything.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Minare

There is no error elhamdulillah*  (thanks to god) . I just wondered if there will be because of that change.But it is ok  ;)



I just want to ask sth.

For example this is my category name : "İsimler"

But it shows like this : "simler"

That letter doesn't show : "İ"

This is because , it only supports english alphabet. What should I additionally do in order to show these as well:  Ş - Ç  - İ - Ü - Ö

Thanks, great mod

Dannii

Are you using UTF-8? I'm pretty sure I have all of those letters in the conversion table.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Minare

No I am not using UTF-8


This is my category name :  Düşünce İklimi

I am expecting this to be seen as : http://minare.net/forum/dusunce-iklimi/0/

But this is how it shows : http://minare.net/forum/dnce-klimi/0/

I dunno why this happens and how to solve   :-\

Dannii

To do the conversion it really needs to be in UTF-8. I do have it set to convert character encodings if possible, but it doesn't work very reliably.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

viulian

#647
Quote from: eldʌkaː on September 03, 2007, 04:21:27 AM
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'o-noua-provocare"), (3180, "traieste-clipa"), (3181, "sexul-a-fi-sau-a-nu-fi!"),' at line 3
File: [...]/htdocs/community/Sources/Subs-PrettyUrls.php
Line: 233
Is there anyway you can get the whole query? Check the forum's error log, it hopefully will be there.

The whole query has 138Kb :D plain text. Nothing in Error Log, had to patch up a bit Subs-PrettyUrls.php with a

                fwrite($Handle, "
                        REPLACE INTO {$db_prefix}pretty_topic_urls
                                (ID_TOPIC, pretty_url)
                        VALUES " . implode(', ', $tablePretty));
                fclose($Handle);


Please excuse the uppercase H  O:) did it with copy paste from a tutorial on how to write a file from PHP and wad too lazy to fix.


Here's more text from around what mysql thinks is an error:

3, "omul-este-condamnat-la-libertate-!!"), (3174, "jocul-de-a-relatia!"), (3175, "din-ciclul-\'oameni-in-strofe-cu-sperante-ca-rime\'"), (3177, "\'moderatoarea-si-purceii\'-sau-\'ospat-pe-cinste-(a)-celei-ce-pofteste-la-el-!\"), (3179, "o-noua-provocare"), (3180, "traieste-clipa"), (3181, "sexul-a-fi-sau-a-nu-fi!"),

Now, as the error the forum throws is not helpfull, I loaded up a local database, created a dummy table with ID_TOPIC and pretty_url, and gave it 140Kb of a single command to chew on.

It came up with a more helpful:

There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem

ERROR: Unclosed quote @ 73312
STR: '
SQL:


By looking around position 73312 (which turned out to be more like 72706), I spotted the problem:

(3177, "\'moderatoarea-si-purceii\'-sau-\'ospat-pe-cinste-(a)-celei-ce-pofteste-la-el-!\"),

It seems that instead of escaping a ', the code escaped the " character.

Searched up the forum (me did not remember the topic  O:)) turned out the title is:

"Moderatoarea si purceii" sau "Ospat pe cinste (a) ...celei ce pofteste la el !"

Hope this helps.

Dannii

"\'moderatoarea-si-purceii\'-sau-\'ospat-pe-cinste-(a)-celei-ce-pofteste-la-el-!\"Is indeed the problem... The problem is that it's being cut off at 80 characters (the maximum for pretty topics). I'll see if I can put together a patched version of 0.7 with the quotes fix.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

viulian

Phew.................................

After 2 debugging sessions (last night and this one which is about to end) I made my forum work with pretty url 0.7 (a bit patched).

What I found out and fixed:

a)

"Hacking attempt..." message comes from Subs.php method db_query. SMF checks that a user tries to overload the server with queries, and will refuse to do them.
Fix is to add the "disableQueryCheck" in {dbprefix}settings, with the value 1 - before running pretty url.

I discovered this while doing a lot of trial and error, and ending up commenting the db_query in Subs-PrettyUrls.php. Instead of "Hacking attempt...", I got a nice message that the package was installed successfully.

So then I realised that db_query is causing the issue, probably because the query is too big (mine, as I said, had 140Kb of text).
I then patched the code to something like:

// Update the database
if (count($tablePretty) > 0)
{
  $chunks = array_chunk($tablePretty, 1);
  $n = count($chunks);
  fwrite($fh, "There are " . $n . " chunks.\n");
  for($i = 0; $i < $n; $i ++)
  {
    fwrite($fh, "Running cycle " . $i . "\n");
    fwrite($fh, "
  REPLACE INTO {$db_prefix}pretty_topic_urls
(ID_TOPIC, pretty_url)
  VALUES " . implode(', ', $chunks[$i]));
  fflush($fh);
    db_query("
  REPLACE INTO {$db_prefix}pretty_topic_urls
(ID_TOPIC, pretty_url)
  VALUES " . implode(', ', $chunks[$i]), __FILE__, __LINE__);
 
  fwrite($fh, "Cycle ran.\n");
  fflush($fh);
}
  }


After rerunning the package installation, discovered that only ~30 queries are successfully ran (with chunk of size 1) and one query is actually ran with chunks of size 100.
I looked then where db_query is defined -> bingo. Time checks.

They can be disabled, like I said, by creating (my forum didn't have it) the setting disableQueryCheck to 1, using a command like:

INSERT INTO `[YOURPREFIX]_settings` (`variable`, `value`) VALUES ('disableQueryCheck', '1');

b)

A sollution to the trimming down to 80, I'm trying it now.
The current one is using '_' instead of " \\' " for ' and " chars, it works.
But a better one - I think - is to let those pesky chars unnoticed and then use mysql_real_escape_string before adding the pretty_text in the $tablePretty.

Will post back soon :)

viulian

Ok, sollution with mysql_real_escape_string works for me, I suggest it.

For example, here's how that title looks now:

http://www.lovetime.ro/community/b33/moderatoarea-si-purceii-sau-ospat-pe-cinste-(a)-celei-ce-pofteste-la-el-!/msg21601/#msg21601

There were 2 changes in the Subs-PrettyUrls.php file:

a)

Removing the line:

"\\'" => array ("'", '"', 'ﺀ', 'ع'),

(I know about the " and ' chars, did not care about the other two)

b)

Instead of:

// Update the arrays
$tablePretty[] = '(' . $row['ID_TOPIC'] . ', "' . $pretty_text . '")';


I put:

      $pretty_text = mysql_real_escape_string($pretty_text);
  // Update the arrays
$tablePretty[] = '(' . $row['ID_TOPIC'] . ', "' . $pretty_text . '")';



One more thing about the huge load:

I think it is the fact that install.php will not remove the .htaccess file it creates and if it encounters an error (such as the "Hacking attempt..." - caused by a die() after a huge query). This way, instead of redirecting back to the homepage of the forum to announce the error, it will redirect to install.php again (and another huge query); the cycle starts, and the sollution is to remove the .htaccess file in the forum folder.


But I love the package (loved it since the beginning, my first post on topic is on page 4).

:)

Dannii

QuoteThe current one is using '_' instead of " \\' " for ' and " chars, it works.
But a better one - I think - is to let those pesky chars unnoticed and then use mysql_real_escape_string before adding the pretty_text in the $tablePretty.
What I'm using in the development version of 0.8 is an unused control character. It's not printable, so I doubt it will actually ever be used in a piece of text.

QuoteI think it is the fact that install.php will not remove the .htaccess file it creates and if it encounters an error (such as the "Hacking attempt..." - caused by a die() after a huge query). This way, instead of redirecting back to the homepage of the forum to announce the error, it will redirect to install.php again (and another huge query); the cycle starts, and the sollution is to remove the .htaccess file in the forum folder.
If there's a huge error... it should just die. I'm not sure what would make it redirect. And also, the .htaccess file shouldn't redirect any .php files, it only touches files/directories without an extension.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Minare

Hello again.

Now there is another problem for me.

If url inludes " ' ", it doesn't show the topic and page gives error, doesn't open.

For example ( fake url ) : www.myforum.com/Infor'mative/0/

Or if this character is on the message, again it gives error , and page doesn't open.

Example (fake) : www.myforum.com/Informative/web'logy/0/

How can I overcome this ?

Thanks

Dannii

The quotes problem should be fixed in the next version. I can try fixing it now for you if you can post up the pretty_board_lookup and pretty_board_urls database settings (from smf_settings).
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

viulian

Ok, so for a confirmation: in the next version you're working on, the ' and " characters will disappear from the URL, right ?
[So I would know and fix the DB myself, so when I can update with no changes, when I'll have pretty url 0.8 upgraded.

And a second thing:

Just noticed that a URL looks like:

http://www.lovetime.ro/community/b14/schimbari-pe-lovetime-(explicatii-pentru-downtime-ul-din-sept-2007)/0/

I guess board names did not generate correctly ?

Dannii

No they'll still be allowed, but they'll be escaped properly so they all work.

Quotehttp://www.lovetime.ro/community/b14/schimbari-pe-lovetime-(explicatii-pentru-downtime-ul-din-sept-2007)/0/
Hmm... would it be using non-roman characters? It does have a proper url (if it was only /14/ it wouldn't), but it doesn't look like it found any valid characters.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

mladja04

I install this mod, but it dont appear in my site (still old url rewrite are in site)!

Site is www.velikibrat.us/forum

Why this happen?

viulian

mladja04, you should go to your Admin backend, hit "Features and Options" and then you'll see a checkmark on where to enable filters.

It's not enough just to install the mod, you need to activate it too.

Second, you might not see "Enable filters" (it happened to me too) - but if you scroll down in that page you'll notice that there are 1 text edit box (with your forum url in it) and below another checkmark which is not checked.

Plugin did not update my english-utf8 language I guess, so I did not see it at first. But it's there after "Max height of posted pictures (0 = disable)".

Dannii

Hmm wait... you're using english-utf8? Are you specifically using the english-utf8 files, or just UTF8 with english? I don't think I have the proper utf8 english files as I don't think they were needed.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

mladja04

I dont see that option in Settiong page.
But I go to my database and manually change "pretty_enable_filters" to "1" but and after that I dont see that anything change in my site! :(

Advertisement: