|
Imminent posted:Might want to mention these two frameworks: There's also these, which I have tried...
|
# ¿ Mar 20, 2008 00:15 |
|
|
# ¿ Apr 29, 2024 16:57 |
|
Mashi posted:Careful there. There is no such type in PHP as 'nothing', that use of return with no value actually returns NULL, and NULL, 0, and false are all equal to "".
|
# ¿ Mar 24, 2008 16:55 |
|
Gary the Llama posted:I've just playing with CodeIgniter and have already ran into a problem. I'm trying to load a model from my controller and I'm getting this error:
|
# ¿ Mar 25, 2008 03:41 |
|
Evil Angry Cat posted:When this is absolutely neccesary I go with ${$variable} = "whatever"; . I'd have to see a bigger section of your code to see if there was an easier/cleaner way around it (which there usually is).
|
# ¿ Apr 4, 2008 14:03 |
|
Bonus posted:Incidentally, does anyone else think that the interface for mysqli is loving terrible? Especially the bind_param method. First you have to prepare the statement, then you have to bind parameters to it by giving it variables and strings like "sssd", then execute, bind results to variable, then fetch the data and then loop and output the variables that have the results binded to them repeatedly.
|
# ¿ Apr 7, 2008 00:41 |
|
drcru posted:Can I assume that #\n# will find all new lines?
|
# ¿ Apr 9, 2008 05:43 |
|
stack posted:Is there a way to catch 'Ctrl-C' in a PHP CLI script running in Windows? PCNTL isn't available for Windows so I can't easily use it to catch the signal for it. Google only turns up one post on php.net where a guy made a custom build of PHP to include PCTNL and that won't work for my situation.
|
# ¿ Apr 11, 2008 06:11 |
|
Inquisitus posted:Or just readfile it: code:
|
# ¿ Apr 14, 2008 23:08 |
|
Also suggesting use of glob() instead of the opendir crap.
|
# ¿ Apr 16, 2008 21:18 |
|
mr. why posted:The best thing I came up with is this:
|
# ¿ Jun 6, 2008 09:37 |
|
mcbuttbutt posted:I'm trying to implement a simple URL hiding script that retrieves a zip file from the server filesystem. It's pretty basic and could surely be much better. Something like this... Don't do silly things like this. Use readfile(). Also, I don't know if that is only a snippet of the code, but please:
gibbed fucked around with this message at 06:49 on Jun 12, 2008 |
# ¿ Jun 12, 2008 06:47 |
|
mcbuttbutt posted:Easy now, that's just a snippet. And thanks, but readfile() didn't work either... still a partial download. I've increased the memory_limit variable in my php.ini to 80M and that did nothing as well. Stumped! There is no reason why readfile() should fail unless the file is damaged somehow.
|
# ¿ Jun 13, 2008 01:08 |
|
ante posted:I need to read 8-bit alpha channels from PNGs. http://www.php.net/imagick Here's a crappy example: php:<? $image = new Imagick('image.png'); $width = $image->getImageWidth(); $height = $image->getImageHeight(); $iterator = $image->getPixelIterator(); foreach ($iterator as $y => $pixels) { foreach ($pixels as $x => $pixel) { $color = $pixel->getColor(true); // color is an array like array('r' => ..., 'g' => ..., 'b' => ..., 'a' => ...) // passing true to getColor() returns them in floats, // so to get the 'real' value you just multiply the values by 255. } $iterator->syncIterator(); }?> It's crude but it works. To answer your question about the PNG format: All IDAT blocks are joined together as one block of data, this data is compressed with zlib, after you decompress it, you'll get an amount of data depending on the image settings in the IHDR. Your understanding of this data format is correct, each scan line has a filter type associated with it, this filter type determins how the data for that scanline is stored. http://www.cs.toronto.edu/~cosmin/pngtech/optipng.html Skip down to "2.2 The PNG delta filters". gibbed fucked around with this message at 11:37 on Jun 22, 2008 |
# ¿ Jun 22, 2008 11:29 |
|
Zorilla posted:If PHP isn't configured, the web server interprets it as text/plain and just sends off the script without processing it. (beaten)
|
# ¿ Oct 12, 2008 15:08 |
|
Lankiveil posted:What is the current cool framework to use for PHP? At the moment I'm playing with CodeIgniter, but I'm happy to jump ship if there's something better out there.
|
# ¿ Nov 21, 2008 14:26 |
|
Are you creating the SoapClient from a remote WSDL file or something local? Try downloading the WSDL and pointing the SoapClient at the local WSDL file instead?
|
# ¿ Nov 30, 2008 01:33 |
|
Zorilla posted:Not even big-time CMSes have a way to secure this as far as I know. WordPress, Joomla and others just put those as plaintext in a central config file. /data/www/somesite.com/www, /data/www/somesite.com/subdomain I give access to PHP to /data/www/somesite.com I store things like configs there, or backend related code in /data/www/somesite.com/backend It saves you the hassle of people getting access to important information / code in the event your HTTP server breaks and starts serving raw content.
|
# ¿ Dec 7, 2008 01:28 |
|
duck monster posted:Sure. Let me explain.
|
# ¿ Feb 2, 2009 05:25 |
|
duck monster posted:Except that its wrong and causes serious loving headaches.
|
# ¿ Feb 2, 2009 05:30 |
|
duck monster posted:Wrong
|
# ¿ Feb 2, 2009 05:51 |
|
duck monster posted:throw an exception when attempting arithmatic in a variable that hasnt even been allocated yet. quote:Notice: Undefined variable: test in test.php on line 2 code:
|
# ¿ Feb 2, 2009 07:20 |
|
Golbez posted:... what now? How do I get an associative array out of this? Or should I care, and just learn to live with the buffered results?
|
# ¿ Feb 4, 2009 02:36 |
|
Golbez posted:Well that's just it, I'm assuming I'm missing a better way of returning results, but the best the PHP documentation will give me is a bland list of functions, rather than answering the simple question, "What methods does one use to get results from a prepared query?" I'd rather avoid PDO, since I don't need the abstraction it offers; this will be once and always on a MySQL database.
|
# ¿ Feb 4, 2009 02:44 |
|
The smart way is to put any important source files outside of webroot, period. The dumb way is to do something like, if (!defined('MY_APP_BE_RUNNIN')) { return; } in your header fine, and define('MY_APP_BE_RUNNIN', true); in any files that include it.
|
# ¿ Feb 15, 2009 02:33 |
|
Tots posted:Does anyone know how to search directories other than the current with glob? php:<?php $files = array(); $paths = array(realpath('.')); while (count($paths) > 0) { $path = array_shift($paths); $dirs = glob($path . '/*', GLOB_ONLYDIR); foreach ($dirs as $dir) { $paths[] = $dir; } $files = array_merge($files, glob($path . '/{*.jpg,*.gif,*.png}', GLOB_BRACE)); } var_dump($files); ?>
|
# ¿ Feb 25, 2009 19:06 |
|
Tots posted:The number of functions available is loving huge. Do people remember all of these?
|
# ¿ Feb 25, 2009 19:07 |
|
Tots posted:You just used 3 functions that are completely new to me. I just threw chdir() in my script and it works. Is there any advantage to doing it your way? If any of my code is confusing feel free to ask about what you are having trouble with. All my code does is build an array ($files) of absolute paths to all *.jpg/*.gif/*.png files that it finds. array_merge (merges arrays), array_shift (removes an item from the beginning of the array and returns it), realpath (resolves relative paths to absolute ones). Use the PHP manual! PHP may have lots of functions but nearly all of them are documented well enough.
|
# ¿ Feb 25, 2009 19:21 |
|
php:<?php $files = array(); $paths = array(realpath('.')); //I don't understand why you have this while statement. Won't realpath('.'); always resolve to a single pathname? ///Yes, what's happening here is that, as the inner loop runs, ///it will add more paths to the $paths array. The first loop will always ///happen of course, because I put a starting element in the ///array (realpath('.')) while (count($paths) > 0) { $path = array_shift($paths); //Here you are taking the current directory, and searching for any subfolders (I think) //Now I start to get lost. I think I'm too tired, and I've been trying to figure out too many things at once today. What exactly is the statement $paths[] = $dir doing? ///This was dumb code on my behalf, I should have just used array_merge. What I'm doing is adding ///found subdirectories to the paths array, so the while loop will search them too, this results ///in every subdirectory from the top directory is searched for files. /// ///The original code, $paths[] = $dir. '$var[] = $thing' is basically syntax magic for array_push($var, $thing). $paths = array_merge($paths, glob($path . '/*', GLOB_ONLYDIR)); //Can you break down what this merge is doing also? ///It's adding all found .jpg/.gif/.png files to the files array (array_merge combines two or more arrays into a single array) $files = array_merge($files, glob($path . '/{*.jpg,*.gif,*.png}', GLOB_BRACE)); } var_dump($files); ?>
|
# ¿ Feb 25, 2009 22:38 |
|
Zorilla posted:If you need recursive file listings like gibbed seemed to be doing, include this function and use it instead (pulled from the comments section of glob() in php.net)
|
# ¿ Feb 26, 2009 00:31 |
|
Zorilla posted:By stack limit, you mean the number of functions running simultaneously, right? One would think you'd hit the limit of the filesystem much sooner than you'd run out of recursions. I can't think of any situation where you'd go 255 directories deep looking for things (or is this limit much lower?)
|
# ¿ Feb 26, 2009 00:56 |
|
Enable curl's verbose mode to see if it's actually returning any cookies to you.
|
# ¿ Mar 2, 2009 02:50 |
|
php:<?php foreach ($urls as $url) { $content = @file_get_contents($url); // note the @ will supress error/warnings that would normally be outputted if ($content === false) { // failed to obtain content of xml } else { $xml = new SimpleXMLElement($content); $name = (string)$xml->name; // it might be $xml->user->name if user isn't the root element. // etc... } } ?>
|
# ¿ Mar 3, 2009 10:54 |
|
What the gently caress? Why are you using define that way? Edit: also your problem is probably the fact that ImageCopyResized wants an image resource not a filename. Edit 2: drop the ImagePNG and you will probably see lots of warnings/errors.
|
# ¿ Mar 10, 2009 07:02 |
|
awdio posted:I'm making constants for security reasons when I add onto the code. What exactly do you mean by image resource? Sorry for the dumb question, I just have no idea what you mean by this. ImageCopyResized Note the second argument. You're passing a string when it wants a resource, you'll want to use ImageCreateFromPNG() or equivilent to load the image you want to resize. You certainly should have gotten warnings or errors with your code, is your error reporting off? Where did you get the idea that constants somehow magically affect security?
|
# ¿ Mar 10, 2009 07:21 |
|
I have no problem with newwidth/newheight being define()s (though I personally wouldn't do that). But the image resources (thumb, source) should definitly not be constants.
|
# ¿ Mar 10, 2009 09:19 |
|
TreFitty posted:I'm learning PHP and was wondering: can you guys recommend any of the frameworks in the original post? I mean, does one completely outclass the other? Which is better for what? etc. In that regard, another good option that isn't in the OP is Agavi.
|
# ¿ Mar 11, 2009 00:29 |
|
And for the love of god use .php as the extension, not .inc, or at least .inc.php.
|
# ¿ Mar 12, 2009 05:41 |
|
http://php.net/oop4 - PHP4 http://php.net/oop5 - PHP5
|
# ¿ Mar 24, 2009 10:53 |
|
eHacked posted:I'm learning OOP from a pretty fantastic book (so far): PHP Object Oriented Solutions by David Powers.
|
# ¿ Apr 13, 2009 06:59 |
|
|
# ¿ Apr 29, 2024 16:57 |
|
What's the error? You're not giving enough information, given that there can be server settings to run other PHP code in addition to yours, etc, that would help. Edit: Oh, it's not that at all. It's your verbatim copying of the code from the guide. The “” are not properly interpreted as " by PHP, fix that and you fix the code. gibbed fucked around with this message at 11:59 on Jun 13, 2009 |
# ¿ Jun 13, 2009 11:56 |