Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. You may be able to put random nonsense in your .htaccess, and after the ErrorDocument if you had to add one in there. Or definitely in the .htaccess of a subdirectory. FYI PHP only triggers 500s in certain installations.
  2. The Unix timestamp is a very simple way of expressing times that is not affected by timezones. You can easily subtract timestamps like Luke showed to get the elapsed time* between them. Naturally you can also add elapsed times to that without needing special logic about converting between units or dealing with leap years... at least not until you convert it back to a date string. The downside is that it can require large numbers (see the Y2K38 bug), there was iffy support for negative timestamps (pre-1970), and there still is iffy support for fractional timestamps (like precision milliseconds). There's also a lot of debate about when it's better to use a Unix timestamp or a date string, especially when it comes to databases. * Note elapsed time. With daylight savings, adding 86400 seconds (one day) may not give you the same HH:MM:SS time as you started with.
  3. If you're concerned about cookies being disabled, and you're right that they'd see an infinite loop, then you will need to be able to vary the URL the splash page redirects to. 1. As I posted. 2. Make the splash page check for a cookie. If set then all is good and you let things happen normally. 3. If not then the cookie was rejected. Change the URL to the index page so that you can avoid another redirect; with code you'd check $_GET and with mod_rewrite you could RewriteCond %{HTTP_COOKIE} !(^|;\s*)nosplash=yes RewriteCond %{QUERY_STRING} !nosplash RewriteRule ^index.php$ /misc.php?page=welcome [CO=nosplash:yes:.domain.com,L,R=307](and you would redirect to /index.php?nosplash) Problem is that a] anyone could bypass the splash page and b] if you ever link to the index page you'd have to worry about needing to add that ?nosplash (lest they be sent back to the splash page again). So before you start on that, find out if you need to worry about not supporting cookies. Often Javascript and cookies will be disabled at the same time, but that's certainly not something you could rely upon. If you do need to worry then that's one more nail in the coffin of the splash page...
  4. It looks like you're on the right track. Put the generated numbers into the form as hidden inputs. Then in code get the value from the form (if it was submitted) or generate new ones (if not).
  5. Yeah, that makes much more sense. It's also more inline with how splash pages normally work. It's much easier to do the splash page stuff in code. You have your index page check for a cookie that's only set once they've seen the splash page. If it's not set you set it and redirect to that page. When they come back the cookie is set, and it will remain set for however long you want it to. If you have to do it with mod_rewrite you can replicate that exact same logic with RewriteCond/%{HTTP_COOKIE} and RewriteRule/the CO flag. Untested but I think you get the gist. RewriteCond %{HTTP_COOKIE} !(^|;\s*)nosplash=yes RewriteRule ^index.php$ /misc.php?page=welcome [CO=nosplash:yes:.domain.com,L,R=307]
  6. cpd is a member here. He posted in this thread. Didn't you see it? Scroll up.
  7. Just to be clear: the method you're going for makes the splash page essentially the homepage, and that also means /index.php is not accessible (because it always sends you to the splash page). That's how it's supposed to work?
  8. Read cpd's reply. He told you exactly what the problem is.
  9. Neater? I don't see how that's neater. But after reading the code I wouldn't suggest using array_unique() anyways - wrong tool for the job. What you have is a bit... off. The main problem is how you're doing the randomization. It's a very inefficient approach and there's something much better. Try if (in_array($module, array('all', 'sem1', 'sem2'))) { $modulearray = array( 1 => 'Endocrine', 2 => 'Renal', 3 => 'Genetics', 4 => 'GI', 5 => 'Neuro', 6 => 'EPISTATS' ); switch ($module) { case 'all': $modules = array(1, 2, 3, 4, 5, 6); break; case 'sem1': $modules = array(4, 5, 6); break; case 'sem2': $modules = array(1, 2, 3); break; } shuffle($modules); $randommodulearray = array(); foreach ($modules as $m) { $randommodulearray[] = $modulearray[$m]; } }But to answer the question, while (count($randommodulearray) == $numberofmodules)Think about exactly what's happening there. What will happen after $randommodulearray has its first item?
  10. That is the error cpd was talking about.
  11. Does array_unique suit your needs better than writing something yourself?
  12. I don't know because I can't see what you're working with. All you've described are "paragraphs" and "sentences" in a "book". We need something more concrete. I assume you have some kind of code already. What is it, and what are the values of the variables you have so far?
  13. Alright, let's just do away with the relative directories entirely as they seem to be the problem over and over again. I should have said that at the start. Unless you're doing something weird with directories, the /images folder is directly under the DOCUMENT_ROOT. files = glob($_SERVER['DOCUMENT_ROOT'] . '/images/gallery/*.{jpg,png,gif}', GLOB_BRACE);Using an absolute path like that means it'llwork regardless of where the code is executing. Same way using /images in the URL makes it work regardless of URL rewriting.
  14. Ah, I didn't notice: $files = glob('/images/gallery/*.{jpg,png,gif}', GLOB_BRACE);There are two types of file paths: one for the filesystem and hard drive(s), one for URLs. They are often the same simply because that's easier, but technically speaking they are two different things. The URL for the images should have leading slashes. The filesystem path for the images should not. In fact if you do then PHP is going to think you mean to find a "/images" folder at the very root of the drive. But that's not where it is. <?php $files = glob('../images/gallery/*.{jpg,png,gif}', GLOB_BRACE); // filesystem path with ../ foreach($files as $file) { echo ('<img src="/images/gallery/' . basename($file) . '">'); // URL path with / } ?>
  15. Looks right to me. What's the source HTML of the page that's not working and what is the URL the image(s) should be pointing to?
  16. You might want to point out to them that splash pages kill SEO.
  17. But only the &s. If you use htmlentities() or htmlspecialchars() then you'll be double-encoding some characters. http://stackoverflow.com/questions/552957/rationale-behind-simplexmlelements-handling-of-text-values-in-addchild-and-adda http://www.php.net/manual/en/simplexmlelement.addchild.php#112204 imen, are you sure you posted the right code? The error message talks about the value given to addChild() but the only time you call that you don't provide the value.
  18. @-suppress mail() and check its return value. Oh, and Trying to trick us into solving your problem by phrasing it as some sort of "contest" is insulting. There's nothing wrong with asking people for help if you don't know the answer.
  19. Nothing as in an empty filename? $_POST is for forms with $_GET is for URLs. That's the one you want to use.
  20. You can't use variables in literal HTML and just expect PHP to know that you want it replaced. You have to use PHP code for it.
  21. Besides the gratuitous use of heredocs the only problem I see is the extra spaces at the end of them. print <<< HERE <h2>$bName and $gName<br />Went up the hill<br /></h2> To Fetch a $device of water<br /> $bName fell down and broke his $bPart <br /> And $gName came tumbling after. </h2> \n HERE; print <<< HERE <h3>Please fill in the blanks below, and I will tell you a story</h3> ... </form> HERE;When ending heredocs the "HERE" (or whatever) must be the absolute only thing on the line except a possible semicolon. No leading spaces, no trailing spaces, and no indentation. [edit] Find your php.ini and make sure you have error_reporting = -1 display_errors = onThen restart the web server. With those set you would have seen the error message from PHP about an "unexpected $end".
  22. So it is
  23. The designs? Like layouts and themes and whatnot?
  24. And what is "run correctly" supposed to mean?
  25. Not only does that not look like what I posted, what I posted had nothing to do with $files.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.