SimpleSEF 2.0 (SMF 1.1.x and SMF 2.0)

Started by SlammedDime, December 05, 2009, 10:08:40 PM

Previous topic - Next topic

feline

I see that url's with a user id don't work on all situation .. specially I fond that on
action=reminder;sa=setpassword;u=31;code=xxxxxxxxx
This url is formed as:
/reminder/setpassword/user_31/code,xxxxxxxxx
But that not work, run in a error in the reminder service.

I have changed all the u=## to /u,## and all works correct.
changes:

$query_parts['user'] = getUserName($params['u']);

to:

$query_parts['u'] = getUserName($params['u']);


in the getUserName($id) change twice:

return 'user' . $modSettings['simplesef_space'] . $id;

to:

    return 'u,'. $id;


Also we have developed a mod, to get SSEF 1.0.2 to work with PortaMx v0.971-2

Fel

pokerullz

#261
Quote from: SlammedDime on January 18, 2010, 08:16:34 PM
Are there any errors in your error log?

Can you check the settings table in the database and find this variable and make sure it's value points to the right file...
integrate_pre_include

or run this query in phpMyAdmin if you have it...
SELECT variable, value FROM smf_settings WHERE variable = "integrate_pre_include" LIMIT 1

The value should be the full path to SimpleSEF.php inside your Source directory.

I went into my database and found the variable.
It shows like this :

integrate_pre_include     D:Hosting323969html/Sources/SimpleSEF.php

This should show right?
Hmm..should I reinstall the mod?
--- i did---- ...no luck

SlammedDime

That path isn't correct... it's missing some slashes which is probably the heart of the issue.  If you look at your Settings.php file, how is $sourcedir formatted?

It should have slashes like the following...
c:\\inetpub\\wwwroot\\smf\\simplesef (this is MY setup... i'm just wanting to point out the double backslashes)
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

SlammedDime

Quote from: feline on January 18, 2010, 08:18:28 PM
I see that url's with a user id don't work on all situation .. specially I fond that on
action=reminder;sa=setpassword;u=31;code=xxxxxxxxx
This url is formed as:
/reminder/setpassword/user_31/code,xxxxxxxxx
But that not work, run in a error in the reminder service.

I have changed all the u=## to /u,## and all works correct.
changes:

$query_parts['user'] = getUserName($params['u']);

to:

$query_parts['u'] = getUserName($params['u']);


in the getUserName($id) change twice:

return 'user' . $modSettings['simplesef_space'] . $id;

to:

    return 'u,'. $id;


Also we have developed a mod, to get SSEF 1.0.2 to work with PortaMx v0.971-2

Fel

Code changes shouldn't be\aren't necessary... simply adding 'setpassword' to the user_action list might/should resolve the issue.  Looking at the admin panel now though, I forgot to include that new array with a change I made to SimpleSEF.php, so the next version will have that extra list in the admin center.  While I respect you trying to make the two mods work together, if you don't understand the code flow, please don't try to suggest changes that could only make more issues.  On top of that, you're code changes above work only because you're running SimpleSEF in 'Simple' Mode... those changes would still cause the mod to fail in 'Normal' mode.

You of all people should know that the idea is that modular coding is the ideal way to go... don't do special cases, make generalizations that work for a number of things and code around that, which is exactly what keeps the code compact here.  Everything you keep suggesting is making more and more special cases which really don't need to be done.  Knowing so much about OOP, you should know this.

As for the issue you are having with dynamic theme and language support that you had mentioned on your site... the issue only occurs because of the way you've chosen to implement changing those items via your portal, so it is hardly fair to call it a bug in this mod, which it isn't.  Since it isn't a bug in this mod, might I suggest some code changes for your javascript and PHP to make it work, not only with this mod, but with any future change that others might make to code.

In your changing function, rather than echoing the php $scripturl variable, you can (should) use the javascript variable "smf_scripturl", which is declared in the head of the page.  Using this will prevent SimpleSEF from changing the URL.  This will cause a 301 redirect however.  You mentioned that you can't use a 301 because you are using POST data to transfer the referring URL.  IMO, this is a poor way to go about that.  Three better alternatives are
1) checking the $_SESSION['old_url'] variable that SMF sets that should contain the URL anyway, so there is no need to even transport it in the POST request or
2) Change for form method from POST to GET, and use the appropriate variables in your PHP code, or
3) Base 64 encode the URL in the javascript and call window.location to change the page url to change the language/theme, then decode it in the PHP source and redirect accordingly, rather than submitting a form, as form submission isn't really required here.

If it was a valid bug in this mod, I would be happy to address it, however it isn't.

Also, I gave Arantor an example last night of how your implementation of the "." in the URL is semantically incorrect. 
You do a preg_match_all to capture the data from the URL and then use $match[0][0] if it exists to find the page to go to.  If you look at your small block of code that sets $match[0][0], you'll notice the following issue: You do two 'unset' calls to unset the REQUEST and GET parameters.  Here is the issue with it... you're possibly unsetting variables that don't even exist.  If the page I am calling is my.cat, then you set your $PageReq variable to my.cat ($match[0][0]), then you try to unset($_REQUEST[$match[0][0]]).  In reality, you're trying to unset $_REQUEST['my.cat'], but in practice you want to unset$_REQUEST(and $_GET)['my_cat'], as PHP transforms the '.' into '_'.  Herein likes the issue.  Say I make a PHP block that accepts a GET parameter or my_cat to do something.  So my URL would be formatted as so:
index.php?my.cat&my_cat=4
So lets assume you make a change above to properly unset $_REQUEST/$_GET['my_cat'], well if you unset my_cat (because remember, my.cat does not exist in the GET or REQUEST arrays, it is my_cat because of what PHP does), you've just unset my my_cat variable and now my block fails because the variable is no longer there, thus a a bug in PortaMX.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

feline

Well .. a log story  ;) I will get a shorter answer ..

1.. the reminder function
in this case a 'user' don't work, while the function setPassword2() make a GET['u'], the result is a 'no access' error and a error_log entry 'unknown index u'. And .. the modify from 'user_##' to 'u,##' works in 'Normal' mode as membername_##. But I will test the adding of 'setpassword' to the user_action.

2.. for the dynamic theme / language change we need no modification on SSEF, that is handled in the block code itself. Only the action 'theme' and area 'language' must be removed from SSEF settings.

3.. the modification we have made, do follow:
  a) skiped not own url parsing (while this fills the apache error log extensive)
  b) added conversion of existing SMF-sef urls in messages
  c) added (simple) handling for PortaMx page request

A version with all these changes runs on our site without any error or problems.
You mod in not bad .. but it's need small fixes/changes. Best way to test is that what I do .. run on a productive site and check all the logs in cyles of 2 hours. And so I don't understand your reaction on my postings  :(

If you need more detailed information, let us known.

Feline

hartiberlin

Many many thanks to Feline and SlammedDime to make this compatible !
You 2 are really great programmers !


Many thanks again.

Regards, Stefan.

alblove

i have a problem with comments in aeva media gallery.
i can't add coments.

http://www.zeriyt.info/media.html;sa=comment;in=5641 (link with seo4smf - smf 1.1.11) work good
http://www.alblove.com/media/item/in,5648/ ( with simplesef - smf 2.0 RC2) dont work it redirect me in te gallery index.
pls how can i fix it ?

SlammedDime

#267
feline, can you please explain and elaborate on 3a and 3b

alblove - I'll have to test with the media gallery when I have some more free time
Edit: I just followed your second link above and it loads a pictures of a beautiful young lady in a black bathing suit... I don't see any issues, looks like it is working exactly as it should.
Edit2: After browsing around your site even more, I'm quite pleased at how well SMG/Aeva works with this mod.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

Afro

QuoteDo you actually have a real folder named articles?  If so, that'll be the problem... you'll need to either rename the the action in the code, or rename the folder and change any code/html that points to it./quote]

i am still on this.. what should i rename the folder to and where do i make the necessary changes to that effect ?

SlammedDime

Rename the folder to anything but articles.  And then rename anything points to it to point to the new name... that's all outside the scope of this mod though.

The way SimpleSEF works... when an URL is passed to your SMF directory, the .htaccess checks if that is a real path/folder or a real file... if so, that real folder or file is returned, otherwise, the entire URL is passed to SMF for SimpleSEF to parse.  If you have an action=articles and a folder also named articles, the folder takes precedence.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

Afro

LOL SLIME...

Please speak English.

lets say i changed the articles folder to news..

lets also assume that i have not posted any article there ,

where else needs to be renamed... ?

SlammedDime

SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

Afro

Ok i changed the folder to news and the articles seems to be working..that easy ?

i will be checking on it.... thanks Slamm

SlammedDime

SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

alblove

yes it works very good but  i can't add comments to pictures
i you want i cancrate a test user for you to try ...

feline

Quote from: SlammedDime on January 19, 2010, 03:38:26 AM
feline, can you please explain and elaborate on 3a and 3b
3a) skipped not own urls
find:

// Parse the url
$url_parts = parse_url(str_replace($boardurl, '', $_SERVER['REQUEST_URL']));

add before:

// skip external urls
if(strpos($_SERVER['REQUEST_URL'], $boardurl) === false)
return;


3b) conversion of existing SMF-sef urls in messages
find:

$url_parts = parse_url(str_replace(array(',', '&', ';'), array('=', '&', '&'), $url));

replace:

// handle exist SMF-sef urls
$url = preg_replace('~[\d+\.]html~', '', $url);
$url_parts = parse_url(str_replace(array(',', '&', ';'), array('=', '&', '&'), str_replace($boardurl .'/index.php/', $scripturl .'?', $url)));


For the reminder problem, I have add 'reminder' to the simplesef_useractions. That worked.

Portamx page request ..
It would be very good if you can add a hook for this, so we can handle that inside pmx.
I have tested that, make fixes on Pmx and add a special call for SSF in the function create_sef_url($url)
find:

parse_str(!empty($url_parts['query']) ? $url_parts['query'] : '', $params);

replace with:

// handle PortaMx page requests
if(function_exists('portamx_ssef_parsestr'))
$params = portamx_ssef_parsestr(!empty($url_parts['query']) ? $url_parts['query'] : '');
else
parse_str(!empty($url_parts['query']) ? $url_parts['query'] : '', $params);


So all worked best I think ..
Thanks,

Fel


Afro

#276
how about sa=connect;step.

how do i add this to the sub action window ?

connect,step, or connect_step ?

also, the /pm/send

doesnt work on my forum. so i cant send messages to members. again.

i checked the action and sub action and found the corresponding words there.
what else can be done ?


my profile account settings doesnt work also...after setting and save, it doesnt change anything

SlammedDime

Fel - 3a should never happen... convertQueryString is only called from Load.php, so the SMF Script must have run so the URL must belong to this board.  That is also a less than desirable fix because it relies on the $boardurl variable, but $boardurl is not officially set in stone until Load.php's loadTheme() function which isn't called until AFTER convertQueryString due to the forum_alias_urls modSetting.  If my boardurl is http://myboard.com but I have an alias of http://yourboard.com and I navigate to http://yourboard.com/general-discussion/, then SimpleSEF will fail.

However, I just realized that I myself am using $boardurl thus a bug in SimpleSEF because it won't respect the forum_alias_urls setting... this will be fixed in the next release

3b I'll have to look at this in more detail... there should be better ways to handle this.

For portamx_ssef_parsestr - I'd like to see this function in it's entirety before making this change.  I know you have likely coded it to fix your '.' issue in URLs, and while I'm not entirely happy about supporting this because I believe it to be improper URL handling with PHP, I will entertain it under the condition that all support requests that arise from it will be directed to PortaMX and if I find that it causes other issues, I will have to remove it.




Afro, for your first question, you only add 'connect'.  'step' is neither an action, subaction or area, it's simply a URL parameter that will be handled in a different way.

For PM sending, do you get any errors?  I just tested sending a PM on my SSEF test board and it worked find with no errors.

Same thing with the profile account settings... I had no issues there either.  Please check your error log for any possible errors.





In the next verison I'll add some debugging tools that will make this a bit easier to help troubleshoot... unfortunately a lot of issues that people may experience are site specific due to server configs or mods installed, and rather than FTP'ing into lots of sites, I'll put in a few lines of code to give debug output in the forum error log under certain conditions.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

alblove

hey SlammedDime did you try to add comments in de aeva media gallery in my site ? pl is very important to fix it ...

feline

Quote from: SlammedDime on January 19, 2010, 02:41:13 PM
For portamx_ssef_parsestr - I'd like to see this function in it's entirety before making this change.  I know you have likely coded it to fix your '.' issue in URLs, and while I'm not entirely happy about supporting this because I believe it to be improper URL handling with PHP, I will entertain it under the condition that all support requests that arise from it will be directed to PortaMX and if I find that it causes other issues, I will have to remove it.
The code in PortaMx

/**
* handle SimpleSEF url's for page request
* Check the requests and return the params array.
*/
function portamx_ssef_parsestr($query)
{
$query = !empty($query) ? $query : ''; 
parse_str($query, $params);

// check page request
preg_match_all('/[a-zA-Z0-9\.\-\_]+/', $query, $match);
if(!empty($match) && count($match[0]) == 1)
{
parse_str($match[0][0], $match[0][1]);
list($match[0][1]) = array_keys($match[0][1]);
// legal page request?
if(empty($params[$match[0][0]]) && empty($params[$match[0][1]]))
{
unset($params);
$params[$query] = '';
}
}
return $params;
}


Fel

Advertisement: