The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
single/double quotation problems
Hiya,
I've a couple of users who are called like Quote:
However, when I create custom code it breaks because of the single quotation in the username. How do I read the username with this in it correctly and later, insert it into the database again with the single/double quotation mark? I'd rather not do a str_replace or alike. Any thoughts? |
#2
|
||||
|
||||
Stripslashes is the function you want
|
#3
|
|||
|
|||
PHP Code:
Hmmz, I've found the problem, it was because I not only used $bbuserinfo['username'], but also the lastreplyer, I didn't do addslashes on that username as well. Thanks a bunch! |
#4
|
||||
|
||||
Why are you inserting the username into the database? Always insert the userid, it follows the normalisation rules and gets rid of redundant data. E.g. if the username changes you'll end up having to alter two tables. If you insert the userid to get the username you just do a nice LEFT JOIN
|
#5
|
|||
|
|||
Thats very true, I must say I haven't really thought about that before.
Having said that, I've seen the left joins in the default vbb-code, but I still don't quite understand how it works. |
#6
|
||||
|
||||
Take a look at this article here. Hopefully it'll explain it better. In a nutshell it allows you to join two tables together with the same key and grab fields based on where the keys are the same:
http://www.devshed.com/c/a/MySQL/MySQL-Table-Joins/ |
#7
|
|||
|
|||
Aah, thats alot better!
PHP Code:
I'll play with it a bit longer, and thanks for your help mate! |
#8
|
||||
|
||||
No problem, keep up the good work!
|
#9
|
|||
|
|||
Thanks guys!!
Searching brought me here and great info!! While I agree, adding username and/or adding a filename twice in a database is senseless for most cases .... let me explain my case and maybe some people can share their thoughts with me?? My hack's main purpose is to keep a history of file downloads. Most importantly, my goal is to keep info that might get deleted by vB. It logs username, userid, fileid, filename, dateline, ipaddress, and alt_ip for every download. Example: Private file gets leaked. Author or a Moderator gets pissed and deletes post/file. Result is the admin's don't have a filename or fileid anymore to research from to track down the file leaker. Meanwhile: The leaker gets banned, or better yet, deleted for some other reason. Now the admin's don't even have a username or userid to associate past downloads with. Question 1) Does this sound like a good reason to save the filename and username? So today someone ran into the Irish Syndrome, LOL. Single Quote in username caused DB error. After hearing that, I figure the filename error is right around the corner. Sidenote A: If your wondering about the rawurldecode, it's in response to a bugfix. http://www.vbulletin.com/forum/bugs35.php?bugid=691 Sidenote B: If your wondering about !$_GET['stc'], that is to hopefully prevent non-thumbnails from being logged .... like normal pictures in showthread .... because I find it's useless to track those since they load every thread read (when not yet cached on users pc). Question 2) Am I SAFELY coding around username and filename correctly? This is an 'attachment_complete' hook I'm wishing to use. PHP Code:
Question 4) Are IP's OK as is or do they TOO need to be handled special and if so how? OHHH, PS .... important info I suppose I should mention. All 4 variables (username, filename, ipaddress, alt_ip) are all being saved to DB as VARCHAR's (I mean that's the data type I declare for those columns in my DB create). EDITED (automerged) TO ADD..... OK, I think I just figured out that vbulletin gets rid of get_magic_quotes_gpc inside class_core.php So is this closer to what I need? Just always addslashes no matter what? Here's my modified top (the variables to be inserted): PHP Code:
I did make an O'reilly user and this last edit appears to be working so far. I downloaded a couple files and phpmyadmin is reporting that exact name in the database for my downloads. How come there's no slashes being shown to me when inspecting phpmyadmin? I mean the name is there, and it didn't kick an error this time SO OBVIOUSLY the addslashes "did something to get the data in there" ... I guess I just don't understand where the slashes went, LOL. |
#10
|
|||
|
|||
Just a follow-up....
MarcoH64 informed me of the following: Quote:
So for anyone interested or searching like I was, here's what my previous code eventually turned into. PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|