|
Found this in the backend for our CMS:php:<? $current_event_id = ""; if(file_exists("../site/config/config.txt")){ $config_file_lines = file("config/config.txt"); foreach( $config_file_lines as $config_file_line ){ if( trim($config_file_line) != "" ){ $current_event_id = trim($config_file_line); } } }?> This was written by the dudes who manage my work's servers. Those same guys also wouldn't give me the source code to something they wrote (just so I figure out which objects it was referencing and replicate easily) because they didn't want me stealing their code. And the way these files our laid out that bit of code actually gets called like 4 times per page. And then there's this gem on the same file as above (this is the way they had it formatted as well): php:<? if( $row['field_options'] != "" ){ $field_item['field_options'] = array(); $field_item['field_options'] = explode("|", trim($row['field_options'])); }?> Optimus Prime Ribs fucked around with this message at 22:37 on Oct 17, 2011 |
# ¿ Oct 17, 2011 22:33 |
|
|
# ¿ Apr 26, 2024 20:19 |
|
Doc Hawkins posted:Or claim you think you can optimize the site if some overtime will get approved. Remove 10-20% of the blank lines, goof off for the rest of the time, collect money, repeat as needed. Too bad I can't pull that ruse. I get paid by the year. I'll just stick to fixing up all this horrible code I've been running in to.
|
# ¿ Oct 18, 2011 20:45 |
|
nielsm posted:VC10 still has a compiler option to allow that broken scoping Why would you want to do this?
|
# ¿ Oct 18, 2011 22:40 |
|
tractor fanatic posted:well you HAD to do that in VC6.0 since Well isn't that cute.
|
# ¿ Oct 18, 2011 23:38 |
|
rjmccall posted:There is a camp that claims that modifying const objects should be okay as long as you put them back the way you found them. It's not completely irrational, but it's obviously something to be very careful about, and it's still not a great idea. Why would someone make something const if the value isn't constant? What purpose could that possibly serve? Seems pretty stupid to me.
|
# ¿ Oct 21, 2011 17:11 |
|
BP posted:It would allow you to modify the memory storing the object, as long as you can reverse the changes, rather than making a copy of the memory and mutating the copy. This could lead to some memory savings in some cases. Makes sense and all but from a practical stand-point I just don't get why someone would want to write their code that way. Whenever I use const it's for things which I know will never change (e.g. if I wanted to store pi in a variable for some reason). Oh well. People will always be doin' dumb things. vv
|
# ¿ Oct 21, 2011 21:13 |
|
I'm not really sure what this was supposed to be used for. Written by some dude a year ago, who left where I work before I got there. This is all that was in the file. php:<? $gConfig = array(); require "../../../config/config.php"; $db_connection_str = "host=" . $gConfig['db']['event']['host'] . " dbname=" . $gConfig['db']['event']['name'] . " user=" . $gConfig['db']['event']['user'] . " password=" . $gConfig['db']['event']['password']; $db_connection = pg_pconnect($db_connection_str); $stmt = "select * from _event where event_id = " . $_POST['event_id']; $result = pg_query($db_connection, $stmt); if( pg_num_rows($result) > 0 ){ $handle = fopen("../site/config/config.txt", "w"); fwrite($handle, $_POST['event_id']); fclose($handle); $url = "index.php"; } else{ $url = "index.php?error=event_id_error&&event_id=" . $_POST['event_id']; } header( "Location: $url" ); ?>
|
# ¿ Oct 27, 2011 00:33 |
|
SlightlyMadman posted:How quickly you forget! Clearly it's there to write out this config file: Well I know what it's doing. I just don't know what purpose it serves. Maybe the dude really badly wanted to assign an event id to the text file using POST data, and do literally nothing else. Makes me wonder why he didn't just use a GET variable in the URL for the id.
|
# ¿ Oct 27, 2011 18:01 |
|
Why not just respond with "It sure is" and then call it a day.
|
# ¿ Oct 31, 2011 14:26 |
|
quote:Sometimes you want to know both the value of a variable being passed to a function and its name. php:<?php $theVarStem="emailName"; $theVarValue=eval("return \$$theVarStem;"); ?> php:<?php myFunction(compact("emailName")) function myFunction($theInfo) { $theVarStem=key($theInfo); $theVarValue=current($theInfo); //... } ?>
|
# ¿ Oct 31, 2011 21:07 |
|
OriginalPseudonym posted:It boils down to people coding and not knowing what a key => value hash looks like. These are probably the same people that will do something like this: php:<? $myVar1 = 1; $myVar2 = 2; $myVar3 = 4; //;) ?> But I don't really want to think about coding like that. e: Boy do I wish I could look at the source code for my work's CMS. One of our clients decided that they were going to write their own PHP/JavaScript for their pages and then give all that to us and we'd plug it into our system. It turns out if you escape a string when inserting into our SQL database it causes our reports to display incorrectly. So whoever wrote that beast didn't bother with small things like preventing SQL injections. Optimus Prime Ribs fucked around with this message at 23:06 on Oct 31, 2011 |
# ¿ Oct 31, 2011 23:03 |
|
OriginalPseudonym posted:Who uses PDO, anyways. Real PHP coders roll strings into mysql_query. The PHP version on our server doesn't even support PDOs.
|
# ¿ Nov 1, 2011 00:37 |
|
NotShadowStar posted:Yep, you can still do that. mysql_* has an implicit, invisible connection if you don't specify a connection handler on mysql_connect. Ramsus Lerdorf, stealing a bunch of poo poo from Perl but didn't really understand what Perl was doing. I have to wonder: is Ramsus just a gigantic meat-head or is PHP an elaborate troll?
|
# ¿ Nov 3, 2011 21:23 |
|
Rasmus Lerdof posted:I'm not a real programmer. I throw together things until it works then I move on. The real programmers will say "Yeah it works but you're leaking memory everywhere. Perhaps we should fix that." I’ll just restart Apache every 10 requests. Did he seriously say this?
|
# ¿ Nov 3, 2011 22:33 |
|
For better or worse.
|
# ¿ Nov 4, 2011 01:36 |
|
code:
Does this make as little sense as I think it does?
|
# ¿ Nov 25, 2011 23:05 |
|
Well that certainly is something.
|
# ¿ Nov 26, 2011 00:32 |
|
mjau posted:Can you center vertically with that? "margin-top: auto; margin-bottom: auto;" doesn't seem to do anything. The margin:0px auto trick only works for horizontal centering, and in my experience vertical centering can be a bitch. The best way I've found to do it, where the containing element's height is not known, is: display:table-cell; vertical-align:middle;. I feel dirty every time I use that though.
|
# ¿ Dec 8, 2011 17:22 |
|
Hammerite posted:Here's an entertaining one: Assigning values inside an array (yes I know that PHP + Stack Overflow is the lowest of low-hanging fruit). I've never seen that goofy "more than one dollar sign" poo poo in PHP before, but just what the hell is it supposed to do? Like, this makes no sense: http://codepad.org/tMhOK1dO http://codepad.org/3xDgPwrA http://codepad.org/1IxeJDDO
|
# ¿ Feb 13, 2012 18:51 |
|
Look Around You posted:Apparently they are "variable variables": Ah, that makes sense. I just had the perfect storm of variable names for extra confusion. Not surprising at all that this feature exists in PHP though.
|
# ¿ Feb 13, 2012 19:01 |
|
Hammerite posted:But on thinking about it, it is consistent with PHP's treatment of unknown bare words in other contexts, so I'm not sure why I was surprised. Every time I learn a new horror regarding PHP I am amazed for a few seconds and then remember that it's PHP.
|
# ¿ Feb 14, 2012 00:43 |
|
pigdog posted:Correct me if I'm wrong (I never actually got around to learning C), but isn't the answer "either way you like"? I've never heard "pass by value" be referred to as "pass by copy" before, but yes. In C and C++ you could pass an int (for example) by value by doing void foo(int butts), or by reference by doing void bar(int& boobs). You could even pass a pointer! void baz(int* ohgod)
|
# ¿ Feb 14, 2012 16:30 |
|
Look Around You posted:There's no references in C. Oh derp. Well I'm not a C programmer, so there you go.
|
# ¿ Feb 14, 2012 16:49 |
|
Right now my work has our servers hosted by absolutely incompetent morons. Case in point: over 3 weeks ago we requested to have an SQL database created for us, so that I can create some new tools to make my job easier. They're charging $500.00 for this, and so far haven't done anything. Don't ask me why we're with them; I do not know. Well, unsurprisingly, the PHP scripts that they wrote for us (these were written before I started working here) don't work very well. I was having issues with one script that generates ASX meta-info so that Windows Media Player and Silverlight players can dynamically load streams. Of course said script is hosted on a part of the FTP that I do not have access to. Our server host has stated that we don't have access because they do not want us stealing their code. Turns out that they didn't bother setting any CHMOD permissions, since I was able to use the PHP copy() function to copy the PHP scripts into the part of the FTP that I do have access, and what I found was a sight to behold. This is what I had waiting for me: http://codepad.org/4rquhM3M This is the code that they were afraid I was going to steal. Seriously, who the gently caress thought this was a good idea: php:<? $event_res = $db->Query(sprintf( $stmt, "/" . $gConfig['module']['data'], $event_id, $event_id, "/" . $gConfig['module']['data'], "/" . $gConfig['module']['data'], $event_id, $event_id, $event_id, $event_id, $event_id, $event_id, $event_id, $event_id, $event_id, $event_id, "/" . $gConfig['module']['data'], "/" . $gConfig['module']['data'], "/" . $gConfig['module']['data'], $event_id, $event_id ));?> The ASX generating script that wasn't working is including like 4 other files. I'm afraid to look at them. Optimus Prime Ribs fucked around with this message at 18:23 on Feb 15, 2012 |
# ¿ Feb 15, 2012 18:20 |
|
darthbob88 posted:in a final product that would, he assures me, make us zillions of dollars if I just do the backend work for him. He wanted you to work for free, and only compensate you after its success, didn't he?
|
# ¿ Feb 20, 2012 19:42 |
|
yaoi prophet posted:php is the worst loving language oh my god What version of PHP causes this? I tried that here, and it works as it should: http://ideone.com/OaHC4 http://codepad.org/HfFKOjed Then I tried the it on my work's server (PHP 5.3.3, newer than Ideone's PHP 5.2.11), and it got the same, incorrect, 4/6.5/757 crap. The hell is going on here?
|
# ¿ Feb 21, 2012 20:50 |
|
Saw this posted on a different message board:code:
|
# ¿ Mar 23, 2012 19:47 |
|
senrath posted:Those comments make me wonder if it was auto-generated code. I want to believe that a person didn't willingly type that out. But I'm too cynical.
|
# ¿ Mar 23, 2012 20:12 |
|
Strong Sauce posted:Do you think those programmers ever wonder, "drat I wish there was an easier way to do this. If only there were some sort of thingy that can hold all these similar items!" Funny thing is that in AS2 (which that is written in) the _root variable is essentially an array. He could have written that like this: code:
|
# ¿ Mar 23, 2012 20:48 |
|
Carthag posted:^^^ I'd start with success = false though, much cleaner that way. ^^^ I definitely agree with that, but then the for loop would need something like this: code:
Not that it matters since this is a coding horror no matter how you write it.
|
# ¿ Mar 23, 2012 21:07 |
|
yaoi prophet posted:I've never even touched PHP, what's the proper way to do this? The only horror that I can see is that the input fields are being named field_1, field_2, field_3, field_4, et cetera. Though doing this: code:
code:
code:
|
# ¿ Mar 23, 2012 21:31 |
|
AlsoD posted:In one of my first year programming courses we lost marks if we didn't comment each of our closing braces. Needless to say I saw a lot of Wonder what would have happened if you did this: code:
We had to create a variable instead: code:
code:
|
# ¿ Mar 24, 2012 02:15 |
|
shrughes posted:If you had to deal with all the stupid poo poo mistakes students would make, you'd have those rules too. That is a fair argument, but I didn't like writing code a way that I wouldn't have normally without being given a reason as to why I should.
|
# ¿ Mar 24, 2012 02:24 |
|
baquerd posted:Come on, I bet you have at least one little thing that doesn't effect functionality that you greater prefer. Braces style? White space? Variable or function name convention? Everyone has their preferred way to write code. But why should I be penalised for not conforming to the professor's preference?
|
# ¿ Mar 24, 2012 21:39 |
|
feedmegin posted:In the real world, whether open source or commercial, you'll generally be expected to conform to the existing style of any large body of code to which you contribute. Doing otherwise is aggressively antisocial. I suggest you get used to it. Admittedly I had not thought of that perspective when I made my post, but I don't think my frustration over the situation is entirely unreasonable. For what it's worth if I am writing code for a project that is not entirely my own I completely conform to the style of said project.
|
# ¿ Mar 25, 2012 00:14 |
|
Strong Sauce posted:The fact that it chugs on a x120e while seemingly not doing anything processor/graphic intensive is pretty frustrating. I always found it pretty funny that Minecraft runs worse on my computer than Skyrim does. Not sure how Notch pulled that one off, but he found a way.
|
# ¿ Apr 8, 2012 09:09 |
|
As much as I hate having to work with PHP, I love learning about the dumb poo poo that it does. It's the gift that keeps on giving.
|
# ¿ Apr 10, 2012 19:58 |
|
code:
|
# ¿ Apr 30, 2012 19:42 |
|
Well I got tasked with figuring out how code (which was written by a guy who doesn't work here anymore) works. This is what some of it looks like (formatting preserved): code:
|
# ¿ May 8, 2012 21:09 |
|
|
# ¿ Apr 26, 2024 20:19 |
|
Zombywuf posted:idgi Maybe I'm missing something, but: code:
|
# ¿ May 25, 2012 02:08 |