ignace
Moderators-
Posts
6,457 -
Joined
-
Last visited
-
Days Won
26
Everything posted by ignace
-
I said: <?php if(!$ses_user && !$ses_pass){ echo "You need to be logged in to view this page."; } ?> <?php ob_start(); session_start(); Does this look like the VERY TOP to you?
-
Like gizmola already mentioned I would just store their timezone and simply set date_default_timezone_set() to their timezone instead of simply UTC and all your dates will be automatically adjusted. Or use DateTime with a DateTimeZone object but that seems more work IMO. When working with dates I use github:Carbon.
-
Stop trying to program and LEARN! It should be pretty obvious from the comments that it should come before ANY OUTPUT. echo 'output'; header('Location: doesnotwork.php'); This does not work because there is output. The same goes for: <html>This is output</html> <?php header('Location: doesnotwork.php'); ?> This WILL work when you enable output buffering. This means putting ob_start() at the very top (right after <?php ) of your script. <?php ob_start(); // first line ?> <html>you can't see this output because you are being redirected unless you have crappy/no internet or your browser ignores Location headers!</html> <?php header('Location: working-as-intended.php'); ?> ob_start() enables output buffering, that means it keeps everything in a buffer before sending it to the browser, thus headers can still be manipulated and php does not throw warnings/errors. If you want to use sessions make sure you call session_start() also at the very top (right after <?php ) of your script, it does not need to be at the same place where you use $_SESSION. session_start() simply populates $_SESSION. <?php ob_start(); session_start(); // first line ?> <html>you can't see this output because you are being redirected unless you have crappy/no internet or your browser ignores Location headers!</html> <?php header('Location: working-as-intended.php'); ?> I hope this helps!
-
How to add a specific function to a provided php code?
ignace replied to Creative26's topic in PHP Coding Help
You are looking for a key logger either as a standalone app or as a browser plugin. This is an application running in the background that captures all key presses and optionally sends them to a specified address, the same exists for browsers as a plugin. As you can imagine this is a serious privacy violation. So I wonder, what do you want to do with it? -
class User class SignupService class AuthService class Photo class UploadService class LikeService There you have them. I doubt they are any good to you since you have a vague idea on OOP.
-
Which is why you should read it...
-
That won't work as you may think it will. The pass_phrase will change on every page request. The correct would be: // $_POST user_phrase if (isset($_POST['answer'])) { $user_pass_phrase = sha1($_POST['answer']); // if a member or if the $user_phrase is correct if ($_SESSION['pass_phrase'] == $user_pass_phrase) { echo "Correct!"; } } $a = rand(1, 10); $b = rand(1, 10); $c = $a + $b; $_SESSION['pass_phrase'] = SHA1($c); Now the pass_phrase is not overwritten when you submit the form, so that you can actually validate it. Is the pass phrase not correct then you are presented with a new one.
-
That's what Zend has to say about it: http://framework.zend.com/download/subversion
-
No. Actually, when you use a framework and you are not a good programmer to begin with, you will end up with a bigger ball of mud than what you would have had if you hadn't used it.
-
Correction:
-
@White_Lily You should escape your inputs before putting them into the SQL query. You avoid a user from actually logging in (' OR 1 --) by double checking the username and password but he might break your query or even break out of it and writing PHP code (". eval('<?php echo 'foo'; ?>') .", won't actually execute but still).
-
Little help on refactoring or simplifying my code
ignace replied to spertuit's topic in PHP Coding Help
It was not meant to offend you, simply to show the OP that it's harder than that because the structure of _FILES changes when you upload multiple files. -
There are a few online tools that do this for you, but they are not 100% accurate since they only process 1 page... There are also a few payed services that crawl all your pages and tell you based off that which CSS is not used. Maybe there are browser extensions that can do this for you? Anyway I think Google is your friend! FF extension: https://addons.mozilla.org/en-US/firefox/addon/dust-me-selectors/ Lots of resources: http://stackoverflow.com/questions/135657/tool-to-identify-unused-css-definitions Online payed service (more than 1 page): http://unused-css.com/
-
Little help on refactoring or simplifying my code
ignace replied to spertuit's topic in PHP Coding Help
Nope, as per the manual: foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; move_uploaded_file($tmp_name, "data/$name"); } } -
Little help on refactoring or simplifying my code
ignace replied to spertuit's topic in PHP Coding Help
There is an SPL class specific for this use-case: $photos = new MultipleIterator(MIT_NEED_ALL|MIT_KEYS_ASSOC); $photos->attachIterator(new ArrayIterator(array($_FILES['photo']['tmp_name'],$_FILES['photo2']['tmp_name'],$_FILES['photo3']['tmp_name'],$_FILES['photo4']['tmp_name'],$_FILES['photo5']['tmp_name'])), 'source'); $photos->attachIterator(new ArrayIterator(array($target,$target2,$target3,$target4,$target5)), 'target'); foreach ($photos as $photo) { if (mv($photo['source'], $photo['target'])) { // success } else { // failure } } function mv($src, $dest, $mode = 0664) { return move_uploaded_file($src, $dest) && chmod($target, $mode); } -
https://github.com/ai/visibility.js#readme More interesting libraries can be found at: http://cdnjs.com/
-
mysql driver is not currently installed
ignace replied to OAFC_Rob's topic in PHP Installation and Configuration
No idea. I don't use yum on Windows. -
mysql driver is not currently installed
ignace replied to OAFC_Rob's topic in PHP Installation and Configuration
Yes you can use mysqli with a mysql database. The i stands for improved. It allows for preparing queries, and variable binding and the like. Check first if php_mysql.dll exists in your ext/ directory. If not and you have PHP 5.3+, download it from: http://dev.mysql.com/downloads/connector/php-mysqlnd/ Then add it to your php.ini. -
I use the PSR standard.
-
mysql driver is not currently installed
ignace replied to OAFC_Rob's topic in PHP Installation and Configuration
You enabled the MySQL PDO extension. Which is something entirely different. You need to uncomment this line: ;extension=php_mysql.dll That said mysql_* is deprecated and you should use mysqli instead which is almost the same as mysql except your functions start with mysqli_* and the $dblink is required and the first parameter to a function. -
Sorry I could no longer edit my original post but that should be: SELECT game_id, interest_level FROM follows WHERE user_id = ? and SELECT foo, bar, baz FROM events WHERE (game_id = ? AND interest_level >= ?) OR (..) ORDER BY newsworthiness DESC
-
I don't see the issue here. We have tables with 25M rows and increasing as we speak, it's size is in the GB's and queries return their results really fast, I believe that last time I checked it was something along the lines of (min: 0.016ms avg: 0.032ms max: 0.078ms) if my memory serves me well, could be something entirely differently though. What I would do is when the user signs in grab all games he is interested in and cache it in his session variable (or a cookie that persists even if the user is no longer signed in, so that you can still display game news, though you will have to regularly sync this whenever he starts following a new game or unfollows one). SELECT game_id FROM follows WHERE user_id = ? Then when you want to grab all news: SELECT foo, bar, baz FROM events WHERE game_id IN(?) Both queries should run really fast even if both have 25M rows and more. Even if your write/read operations become to heavy you can still replicate your data in a master-slave setup. Where the master receives all writes and you read from the slaves. The master regularly updates the slaves with batch queries.
-
Yup. You can have an iframe, an image gallery, inline content, ajax loaded content, .. all on one page.
-
Shuffling a deck of cards in as few queries as possible
ignace replied to Jessica's topic in MySQL Help
Use a procedure/function to shuffle the cards for you in the DB. I don't see anything particular difficult in your function that may be hard to port to a procedure/function. -
I checked out leanModal. It appears you can't. You can however if you use fancyBox. Your HTML code would look like: <a href="lineup.php?id=45" data-fancybox-type="iframe" class="fancybox">Show Lineup</span> JS code: $('.fancybox').fancybox();