Results 11 to 20 of 42
-
29th Jun 2012, 11:34 AM #11(1only)Website's:
BarakaDesigns.com Amodity.com IMGFlare.comDay 2 and ready for another post
Anyhow this is something i done awhile back for vBulletin. For those whom use cyb - chatbox may see this useful its only the gist of things to make custom commands since cyb lacks on itAnyhow here is a /ban one limited to 15 lines so this is gist
PHP Code:$vbulletin->GPC['ccb_newmessage'] = str_replace('/ban ', "".'', $vbulletin->GPC['ccb_newmessage']);
$banuserthis = $vbulletin->db->query_read("SELECT user.username, user.usergroupid, user.displaygroupid,user.userid FROM ".TABLE_PREFIX."user WHERE user.username = '".$banusername."' AND user.userid !='".$banusername."'");
$banuserthisone = $db->fetch_array($banuserthis);
$lists = explode(',',$vbulletin->options['cybchatbox_excluded_users']);
$userid = $banuserthisone['userid'];
$cybcb_banuser = $vbulletin->options['cybchatbox_excluded_users'].','.$cybcb_usertoban;
$cybcb_banuser = str_replace(',,',',',$cybcb_banuser);
$cybcb_banuser = trim($cybcb_banuser, ',');
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "setting SET value = '".$cybcb_banuser."' WHERE varname = 'cybchatbox_excluded_users' ");
I done this off the top of my head
(I may post the full code not sure though)
-
29th Jun 2012, 04:40 PM #12(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comInteresting, but i do prefer my own implementation of such functionality.
Actually, it is in use on KWWH right now, handles several commands in a generic fashion, meaning none of the main code needs to be altered when adding new ones.
I actually replaced a huge amount of the original code when modifying KWWH's copy. Deleted most of the code and reimplemented it myself because the original was inadequate and inefficient.Projects:
WCDDL - The Professional DDL Script
Top Secret Project: In Development - ZOMG
ImgTrack - Never Have Dead Images Again!
-
29th Jun 2012, 04:42 PM #13OPRespected DeveloperWebsite's:
X4B.orgJmZ but thats the vBulliten way. Its also the way you can tell vbulliten code appart.
My snippet, an example of when SQL is better than a query builder/prepared statements/ORM.
PHP Code:function swap($inc){
if($inc>=0) $inc = '+'.$inc;
$sql = 'UPDATE '.self::TABLE.' t1, '.self::TABLE.' t2
SET
t1.cr_order=(@temp:=t1.cr_order),
t1.cr_order = t2.cr_order ,
t2.cr_order = @temp
WHERE
t1.cr_id='.$this->id.' and
(t2.lease_id='.$this->getLease()->getId().' AND t2.cr_order=t1.cr_order'.$inc.')';
\DB::Q($sql);
}
$inc would be +1 to move up or -1 to move down.
-
29th Jun 2012, 05:10 PM #14(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comNah splitice you misunderstood.
Of course it'd be the "vbulletin way" either way. I was merely stating that I preferred my code as it has a generic (and secure) handler for commands, allowing for easy addition to the selection.
I re-coded half of the mod because I found the original code to be insufficient and inefficient. It was very procedural and repetative, very specific to the default features, meaning it didn't allow easy modification/extension.
Basically I didn't like the code, it wasn't up to standard, so I deleted most of it and wrote it myself.
The resulting code was still the 'vbulletin way', so I have absolutely no idea why you thought otherwise, lol.Projects:
WCDDL - The Professional DDL Script
Top Secret Project: In Development - ZOMG
ImgTrack - Never Have Dead Images Again!
-
29th Jun 2012, 05:15 PM #15OPRespected DeveloperWebsite's:
X4B.orgDidnt say your new comment, just stating that repeated code, repeated SQL and long functions / scopes is how vbulliten is written (as apposed to normal programming practices).
I cant speculate as to your 'new' code as I havent seen it. My observations are based on my own experience and in response to 1only's sample.
-
29th Jun 2012, 05:23 PM #16(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comHow vB is written, probably, but plugins may be written in any way you wish as long as they work.
Most recent vb releases use classes for the data managers and what not anyway, pretty useful if you're coding plugins.
Anyway, a snippet:
PHP Code:m = re.findall('^(?:(?:(?:(?:(SELECT) ([\w, ]+) FROM ([\w]+))|(?:(DELETE) FROM ([\w]+))|(?:(UPDATE) ([\w]+) SET ([\w,= ]+)))(?:(?: WHERE ([\w=>< ,]+))?))|(?:(INSERT) INTO ([\w]+) VALUES ([\w, \(\)]+)))$', query)[0]
Basically I got bored one day so I made a small python app. It parsed SQL queries and performed their actions on dictionaries. So I essentially wrote an SQL interpreter to interface with python dictionaries (a standard python data type, like arrays).
It has absolutely no use really, the most pointless thing ever. Ridiculous idea, but I was bored and felt like coding something crazy.Projects:
WCDDL - The Professional DDL Script
Top Secret Project: In Development - ZOMG
ImgTrack - Never Have Dead Images Again!
-
29th Jun 2012, 05:41 PM #17OPRespected DeveloperWebsite's:
X4B.orgI like it, Ive toyed with the idea of a SQL parser class in my framework for the purpose of running only on development/testing servers for advanced debugging (also things like efficiency scores). Although I wouldnt do in regex (prefering an objective parser, utilising the same parse tree as mysql).
Still a nice regex, certainly thorough.
-
30th Jun 2012, 11:24 AM #18(1only)Website's:
BarakaDesigns.com Amodity.com IMGFlare.comPHP Code:public function saltGenerator($limitChars=8) {
$symb = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-=_+[]{}\\|;:'\",./<>?~`";//letters,numbers,& symbols
$saltv = '';
for ($i = 0; $i < $limitChars; $i++)
$saltv .= $symb[rand(0, strlen($symb) - 1)];
return $saltv;
}
PHP Code:$saltv = $saltv ?: $this->saltGenerator();
$phash = md5(md5($saltv) . md5($pass));
$sql->password = $phash;
$sql->salt = $saltv;
-
30th Jun 2012, 12:53 PM #19
-
30th Jun 2012, 03:31 PM #20OPRespected DeveloperWebsite's:
X4B.orgAsk and ye shall receive.
PHP Code:function saltGenerator($limitChars=8) {
$saltv = '';
for (; $limitChars; --$limitChars)
$saltv .= chr(rand(33,126));
return $saltv;
}
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Plz Help To Add A Php Snippet Into My DLE Index !
By JoomlaZ in forum Web Development AreaReplies: 0Last Post: 7th Jul 2011, 01:18 PM -
[C#] Tiny Web Server (snippet)
By Hyperz in forum Web Development AreaReplies: 6Last Post: 24th Jun 2010, 01:19 PM -
Image Upload in php. Code snippet #2
By SplitIce in forum Tutorials and GuidesReplies: 5Last Post: 31st Oct 2009, 07:40 AM -
See real OOP (Snippet from Litewarez V2) Webmasters CP
By litewarez in forum Tutorials and GuidesReplies: 21Last Post: 19th Sep 2009, 03:59 PM -
A Snippet from my latest project
By litewarez in forum Tutorials and GuidesReplies: 19Last Post: 21st Jun 2009, 05:17 PM
themaCreator - create posts from...
Version 3.47 released. Open older version (or...