-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Given that we don't know what the value of the "DOWNLOADS" is, Maybe?
-
If PHP is timing out then there should be an error logged to that effect. Maybe you don't have your logging set up yet? Or the error_reporting level is too low. Not sure what to say beyond you confirming that it's PHP terminating. set_time_limit() should totally work.
-
Preg Replace Callback Function Replacing Content Twice
requinix replied to ShoeLace1291's topic in PHP Coding Help
I figure the markup looks like [quote message_id=123]This is another test. This is only another test.[/quote]Right? When you replace the opening -
array_reduce and array_merge: array_reduce($array, "array_merge", array())
-
Why not just make yourself a test user account, with the settings applied, and see if you can make a script that gets around the restriction. You can save yourself some work by simply verifying that the setting is there and correct and assume that PHP will enforce it.
- 2 replies
-
- php
- open_basedir
-
(and 3 more)
Tagged with:
-
Your getfile.php has to tell the browser what type of content it is returning, otherwise it'll just be the default text/html. Looking at the file extension should be enough to decide. For example, .mp4 is video/mp4. header("Content-Type: video/mp4");
-
While you're learning, take a look at empty too. It's very similar to isset(); empty($var) !isset($var) || $var == "" || $var === "0"(I think that's precise) Note that a "0" is considered empty; sometimes that's alright, but sometimes it isn't.
-
isset() tells you if the field was submitted with the form. It doesn't give you the value, just that "yes or no" if it's there. Use isset() to check that the value is accessible. If so then you can get to it normally without those warnings. if (!isset($_POST["password"]) || $_POST["password"] == "") { // not present OR empty $passwordIsEmpty = true; } if (!isset($_POST["password2"]) || $_POST["password2"] == "") { // not present OR empty $password2IsEmpty = true; } // here you'd have to do more isset()s, but the variables above already know about that if (!$passwordIsEmpty && !$password2IsEmpty // only check if the passwords match if they were given at all && $_POST["password"] != $_POST["password2"]) { $passwordIsValid = false; }
-
Well, your is still named "mchk" and not "mchk[]" as you have in the selector...
-
I don't see the problem in there. Can you post the whole file?
-
Keep removing the &s until they're all gone. You're aware that the function definitions do need to use &s, right? Like function stats_count($forumID, &$array, $bool) { That's something completely different. What is the code from lines 250 to 300 (for a start)?
-
I don't have a /etc/php.ini, is it a problem?
requinix replied to renatov's topic in PHP Installation and Configuration
That's totally normal, leave it be: the OpenSUSE folks deliberately set up PHP to be like that so it'll work just fine. The idea is that you can run PHP three different ways (Apache module, command-line, and using FastCGI) so it can help to have three different configurations.- 7 replies
-
- php.ini
- installation
-
(and 2 more)
Tagged with:
-
Don't use MD5 for passwords. Not salted, not repeatedly hashed, not anything using MD5. Or SHA1. Neither of them are secure enough to use with passwords, and haven't been for years now. Upgrade to PHP 5.5 if you can: it has functions like password_hash so you don't have to worry about password hashing. If you can't, there's a PHP version of it you can download and use.
-
Hiring programmers, are there copyright laws?
requinix replied to paddy_fields's topic in Miscellaneous
An NDA will scare people away - especially the kinds of seasoned programmers you'd want to get to look at the code. With that said, probably the best answer anyone here can give is to talk to a lawyer. -
English to Metric Converter Class Object?
requinix replied to dennis-fedco's topic in PHP Coding Help
Wouldn't it be easier to just make all the conversions work with the same units everywhere? I'm inclined to just hardcoding the multiplication/division operation when needed. The numbers aren't going to change anytime soon, and if any of the underlying code changes units you still have to spelunk into your code to change the conversion logic. But if you really want a more complicated solution then it depends how complicated you want to get: #3 is simple while #2 is more flexible. I suggest you don't go too far because all it seems you need to do is convert a handful of units from SI to Imperial in a few places, and while an OOP solution is cool and all, you're adding a lot more overhead and complexity without gaining much in return. The more flexible-type solutions vary based on needs. One easy way to describe is to maintain a mapping of factors (or maybe functions in case of conversions like Fahrenheit/Celsius) and call a function using the labels. array( "length" => array( // picking m as the base unit "ft" => 0.3048, "m" => 1 ) ) convert("length", "ft", "m", $myObject->getValue()); // value * 0.3048 / 1 convert("length", "m", "ft", $myObject->getValue()); // value * 1 / 0.3048You can OOP that bya) Passing "length" to a constructor and converting any unit to any other unit, or b) Passing all three arguments and converting a value "to" or "from" (which sounds closer to your needs) -
It's under "My Profile". This link should take you to the editing page.
-
Best Password Storing/Retrieval Method
requinix replied to carlosmoreeira's topic in PHP Coding Help
Your client is stupid.- 7 replies
-
- password
- encryption
-
(and 3 more)
Tagged with:
-
can you combine these three preg_replace into one?
requinix replied to lfernando's topic in Regex Help
Speaking of DOM... It's definitely longer but it's more flexible than string matching. It's also a matter of principle: avoid using regular expressions on HTML. $html = <<<HTML ... <ul> <li id="5691_3" value="pass"> Some text here</li> <li id="5691_4" value="pass"> Some text here</li> <li id="5691_6"> Some text here</li> <li id="5691_7" value="fail"> Some text here</li> </ul> ... HTML; $dom = new DOMDocument(); $dom->loadHTML($html); $lis = $dom->getElementsByTagName("li"); for ($i = 0; $i < $lis->length; ) { // no $i++ $li = $lis->item($i); $parent = $li->parentNode; if ($li->getAttribute("value") == "pass") { $text = "You passed!"; } else if ($li->getAttribute("value") == "fail") { $text = "You failed!"; } else { $text = "It's blank!"; // $parent->removeChild($li); // continue; } $id = $li->getAttribute("id"); $text = "Result for id={$id} - {$text}{$li->nodeValue}"; $textnode = $dom->createTextNode($text); $parent->replaceChild($textnode, $li); $parent->insertBefore($dom->createElement("br"), $textnode); } echo $dom->saveHTML();Regarding $i: when removing nodes, like with removeChild() or replaceChild(), the node you had will be removed from everywhere. That includes $lis. So $i shouldn't advance beyond 0 because it'll always want to look at the first item in the list....unless you decide that a node shouldn't be removed, for whatever reason, in which case you $i++ and then continue. -
Dynamically indicate a path for onMouseOver
requinix replied to saturday79's topic in Javascript Help
$p1 = $picMetadata['id']; $p2 = $picMetadata['folder']; $p3 = $picMetadata['filename']; $p4 = $picMetadata['thumbname']; $p5 = $picMetadata['blurb']; $p6 = $picMetadata['date']; $a="P"; $b="lease, "; $c="p"; $d="do"; $e="n't "; $e=" that"; echo $a, $b, $c, $b, $d, $e, $d, $e; // use $picMetadata, or at least reasonable variable names This is a job for CSS, not Javascript. <!-- stuff inside this may show or hide depending if the user is hovering over it --> <span class="thumbnail-hover"> <!-- visible only when hovering --> <img class="normal" src="/path/to/normal/image.jpg" ...> <!-- visible only when not hovering --> <img class="thumbnail" src="/path/to/thumbnail/image.jpg" ...> </span> /* hide the normal image when not hovering */ .thumbnail-hover img.normal { display: none; } /* show the normal image when hovering */ .thumbnail-hover:hover img.normal { display: inline; } /* hide the thumbnail image when hovering */ .thumbnail-hover:hover img.thumbnail { display: none; } -
Wat?
-
It would be so much easier if you just attached a "conversation ID" to each message. Which you know when the messages are created: creating a new message is a new conversation, while hitting Reply would be continuing an existing conversation. That ID can very easily be just the ID of the original message; when you make a new message in the conversation you copy the ID from the message being replied to, if present, or use that message's own ID, if not.
-
Clever trick, trying to deflect blame by implying it's someone else doing that. Very clever.
-
explanation needed for gd - to get alpha value directly
requinix replied to murfy's topic in PHP Coding Help
You're asking if there's a way to get what you want except for the way you're supposed to use? imagecolorat() tells you the full RGBA value (truecolor) or color index (palette). imagecolorsforindex() converts both of those into a single r,g,b,a array without you having to care whether the image is truecolor or palette. $color = imagecolorat($im, $x, $y); $colorarray = imagecolorsforindex($im, $color); $alpha = $colorarray['alpha'];The imagecolorsforindex() call should be very fast: either it decomposes the AARRGGBB value (simple bit math = constant time) or it looks up the RGBA values in the image's color palette (array offset = constant time). -
Having issues with restricting pages if not logged in
requinix replied to Tassadar's topic in PHP Coding Help
You don't have to "echo" it for the same reason you don't have to do that now: you simply drop into and out of PHP mode just about whenever you want. Really, it's exactly how I posted. -
Having issues with restricting pages if not logged in
requinix replied to Tassadar's topic in PHP Coding Help
Which "the rest of the page"? That HTML stuff you have after the PHP code? Yeah, that will execute because you made a decision to show either the message or the safe.php - says nothing about the HTML below. If you want to hide that too either put it in safe.php or make sure it's included inside the else clause }else{ include("safe.php"); ?> (HTML code goes in after this) <?php }