|
Super 3 posted:php_value max_execution_time X Super 3 posted:I was wondering if anyone could point me to a php progress bar script of some kind. I need it to be able to display sales for about 12 different entities on one page. I've been digging around quite a few sites to no avail.
|
# ¿ Mar 21, 2008 06:49 |
|
|
# ¿ Apr 29, 2024 10:46 |
|
admiraldennis posted:I agree, though delete() isn't even a built-in function... I tend to shy away from reusing built-in functions because it makes the syntax highlighting in my editor look odd. All built-in functions are highlighted in blue, and all others are in grey, so it looks kinda strange to see one of my functions in blue. This usually isn't a problem as I use a camelCase naming convention, so overlap is very rare.
|
# ¿ Mar 28, 2008 06:33 |
|
Or just use exec() or something to run diff directly (assuming your host is running Linux). diff is a pretty clever program, I wouldn't want to be re-inventing that unless I absolutely needed to.
|
# ¿ Mar 31, 2008 10:54 |
|
Are you using double back slashes? If not, then the actual string will be "cd c:pathWithSVN". Try using single quotes. Edit: Also, the "cd blah" thing is never going to work, the scope is limited to that exec call only. Use chdir as brae suggests. Also, use escapeshellarg() to ensure that your command line parameters get passed correctly.
|
# ¿ Apr 3, 2008 01:18 |
|
I'm with Bonus, sanitize when you need to. If you sanitize before you write to the DB it means that: - You can present the user with exactly what they wrote if they go back to edit it. We have a comment system that you can enter HTML into, and we use HTMLtidy to clean it and sanitize it. The guy who implemented the system made it so that the data was always cleaned before writing, and so we get users confused as to why their post has tags inserted into it that they didn't write themselves. - As a coder you can get a false sense of security by assuming that all DB data is clean.
|
# ¿ Apr 5, 2008 10:54 |
|
nbv4 posted:I have this one class which is getting so huge, it's almost 2000 lines. I want to split it up into smaller text files to make editing easier, but I'm having trouble doing so. Apparently you can't just do: This is where C#'s "partial class" definitions feature would come in handy. But we don't have that, so here's what I do with my 18000 line class that contains all the DB schema upgrades we've made since version 1: php:<? class DBUpgraderBase { function upgrade_version_1() { ... } function upgrade_version_2() { ... } ... function upgrade_version_99() { ... } } ?> php:<? class DBUpgraderBase1 extends DBUpgraderBase { function upgrade_version_100() { ... } ... function upgrade_version_199() { ... } } ?> php:<? class DBUpgrader extends DBUpgraderBase6 { function upgrade_version_700() { ... } } ?>
|
# ¿ Apr 8, 2008 05:47 |
|
Safety Shaun posted:I'm looking to stop image leeching on my server by using a fancypants URL hiding script. The easiest is just to check the Referrer header with mod_rewrite and redirect the user to a 404 page if it's not your site. However some browsers/proxy servers don't send the Referrer header 100% of the time so its presence or absence alone is not enough - the best and easiest thing to do here is to only let the image be displayed if the Referrer header is present and points at your site, OR isn't present at all. I believe this is what Waffleimages does. A more accurate solution would be to set a cookie when someone visits your site, and then check for the presence of that cookie when serving the images. Anyone leeching won't have the cookie and thus won't get the image. This can probably be done with mod_rewrite (but I don't know for sure). If not then use a PHP script to check for it. If the cookie is present, then just do: php:<? header('Content-type: image/jpeg'); $path_to_file = $_GET['file_name']; ... //validate and sanitize $path_to_file here http_send_file($path_to_file); exit; ?>
|
# ¿ Apr 14, 2008 04:56 |
|
Safety Shaun posted:Ahh yes of course, thank you.
|
# ¿ Apr 17, 2008 05:24 |
|
You cannot "break" out of an if statement. break is for loops and switch statements.
|
# ¿ May 9, 2008 03:32 |
|
Kaluza-Klein posted:Why does this only work for the "The " value? If the string starts with "A " or "An " it doesn't catch it.
|
# ¿ May 19, 2008 03:28 |
|
Lankiveil posted:I'm looking at implementing my own RSS feed generator, which will work off of a series of existing tables in my database. I had planned to simply write a PHP script that output the required XML straight to the client, but most of the tutorials that I've seen on the web do it by generating a flat text file at a regular interval and having that serve as the feed. This optimization works very well for blogs and the like, which are updated probably a couple of times a day at most, and have feeds that are not customized for any particular reader. But it breaks down when feeds need to be customized, because customization goes against the grain of cachability. The most custom something is, the less effective caching techniques will work. The easiest way to implement a customized feed is just to generate it from scratch every time and return it, i.e. don't cache it to a flat file on the disc. But this won't scale well. So you could cache each custom feed in a file, but then that'll mean you need a file for each customized feed. This is more complex to manage, needs more disc space, and you'll need a cronjob or something to clean up stale feeds. Depending on the number of clients I was expecting to see, I might try caching the feeds with memcached or something. The way it'd work is that the PHP script would generate a unique key based on the custom feed parameters, and check to see if that feed was present in memcache. If it is, return it. If not, generate it, stick it in memcache, and then return it. This way you can cache a very large number of feeds, and not have to worry about cleanup of the flat files.
|
# ¿ Jun 2, 2008 08:18 |
|
drcru posted:What's the best or easiest way to add language support? By language support I mean we can display an error message in English or maybe French rather than just English. Pick the language based on the HTTP request "Accept-Language" header, but always allow the user to override it by setting a cookie or something.
|
# ¿ Jun 3, 2008 03:25 |
|
mcbuttbutt posted:It works for smaller files, but larger files (>50 megs) are always incomplete. Any idea why this is happening? Thanks!
|
# ¿ Jun 11, 2008 18:43 |
|
Try adding "while(@ob_end_clean());" before you start outputting data.
|
# ¿ Jun 11, 2008 19:33 |
|
iamstinky posted:I am trying to implement a reversible sort a 2d array by an arbitrary key in the second level function. php:<? /** * sortMultiArray * * Input: a 2-dimensional array, where the all the 2nd-dimension elements have a common field name (e.g. 'name') * It will sort the array based on a specific field name. * E.g. if the array contains many arrays like ('name'=>..., 'address'=>...) * then calling sortMultiArray($arr, 'name') will return the array sorted by name. * The key of the main array is not retained. * * @param array $arr - Array to sort * @param string $field - field name to sort on * @param boolean $reverse - Reverse sort order. false (default) - ascending, true - descending * @param string $function - name of the sorting function. (strnatcasecmp is default). To pass in a static class * method (a non-static class method is not permitted), use the form 'StaticClass::methodname'. * @return array - the sorted array. */ function sortMultiArray($arr, $field, $reverse=false, $function=null) { $rev = ''; if($reverse) { $rev = '-'; } if(!$function) { $function = 'strnatcasecmp'; } $function_def = 'return '.$rev.$function.'($a[\''.$field.'\'],$b[\''.$field.'\']);'; $function = create_function('&$a,&$b',$function_def); usort($arr, $function); return $arr; } ?>
|
# ¿ Jun 16, 2008 22:40 |
|
illamint posted:How do you guys deal with really long SQL queries in your PHP code? do this: php:<? $query = "SELECT ... FROM ... ORDER BY ... "; ?> Edit: Also, a pro-tip: When putting comma-separated things onto separate lines, put the commas at the start and line them up. That way you can easily see when a comma is missing, which is harder to do when commas go at the end. Plus, it's easier to add new lines to the end and not miss putting the comma in. Example: php:<? $sql = "CREATE TABLE foo ( bar integer , baz string , wiz float , waz integer , PRIMARY KEY (bar) ) "; ?> minato fucked around with this message at 18:40 on Jun 19, 2008 |
# ¿ Jun 19, 2008 18:37 |
|
Use gettext. Looks like this: php:<? $some_string = _("Welcome to our site");?> code:
You'll need to write a script to extract the strings from your code. The xgettext tool already supports extracting them from PHP, but you may need something custom for Smarty.
|
# ¿ Jul 30, 2008 21:12 |
|
Munkeymon posted:Anyone know what it means when mb_detect_encoding returns an empty string? Clearly it's failing at detecting the encoding, but the drat thing has to have some encoding (and it should be UTF-8). I've found it really hard to reliably detect an encoding. And it doesn't help that some people seem to equate Windows-2352 with ISO-8859-1.
|
# ¿ Aug 1, 2008 18:12 |
|
|
# ¿ Apr 29, 2024 10:46 |
|
I use a complicated system that involves throwing the text out to this little application that's used in Firefox's test harness. The app's job is to help test the encoding detection of Firefox, you just send it some text via stdin and it tells you what it thinks the encoding is. But apart from requiring the app to shell out to an external program, it requires building Firefox from source with all the test stuff enabled which is a horrible process. Thankfully I don't have to do it very often - just when trying to parse NNTP/mail posts from Outlook which breaks standards by not including the encoding.
|
# ¿ Aug 1, 2008 23:01 |