Jump to content

deadonarrival

Members
  • Posts

    284
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://tminusten.com/

Profile Information

  • Gender
    Not Telling

deadonarrival's Achievements

Member

Member (2/5)

0

Reputation

  1. Okay, I've mostly solved it... With the above, the url cleanly redirects to index.php with the variables easily accessible. The obvious problem being that EVERYTHING gets redirected, and I need to ignore certain files. I made a simple regex to ignore .png etc, but with the mod_rewrite then any image in the site with a relative path eg img/pic.png is being rewritten to http://site.com/a/b/c/img/pic.png rather than http://site.com/img/pic.png I can solve this by adding / to the start of images, but this is a bit counter-intuitive as I'd have to remember to do it every time: that's fine for now while it's just me working on it, but in 6 months I'll forget that and be scratching my head again. I've come up with the following which is "nearly there". It works if the url is site.com/ or site.com/a but not if it goes any further eg site.com/a/ or site.com/a/b. Can anybody spot where I'm going wrong? ^(/.*/)*(/.*\.(png|css|jpg|jpeg|gif|js)+)$ I think what I need to do is use regex to split it into three sections, but 2 is turning out to be tricky 1) /a/b/c/d/e/....ad infinitum 2) = /img/ subfolder (possibly optional, things can be in root) 3) = file.png My other option is to write some PHP functions for images in order to remove anything after the base site path and write the URL there - ie get the location of /site/index.php, strip anything after site/ and add image.png after that. The problem here is as before, in 6 months I'll forget that I have to use the function.
  2. Aha, got it. I found an old post on here documenting when I got it right first time round, back in 2008 http://forums.phpfreaks.com/index.php?topic=198062.msg894306#msg894306 First up I had to set the Rewrite Base RewriteBase /path/to/site/ Then the rule I used was RewriteRule ^/?(.+)$ index.php?values=$1 [L,QSA] Which takes http://site.com/a/b/c/ and gives a $_GET['values'] variable which looks like a/b/c/ and can then be parsed by splitting. PHPFreaks, helping me to help myself.
  3. Hey guys I had a perfect setup for this years ago but lost it in a hard drive crash (it wasn't part of a project, just a test). What I'm trying to do is the standard http://website.com/seo/friendly/urls/ but can't quite get it right I seem to remember that my system just redirected everything to index.php (invisibly) and PHP did some parsing of the URL to put values into arrays So first up, I need some .htaccess to redirect everything to index.php I have #Rewrite on RewriteEngine On #If the URL points to a real file/directory, don't redirect RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #Send site.com/a/b/c/ to site.com/index.php RewriteRule ^/?(.+)$ http://site.com/~user/sitename/index.php?values=$1 [L] This works in terms of it gets the values to index.php but has problems: 1) I have to use a full URL (including http://site.com) because if I just put index.php?values=$1 or /index.php?values=$1 I get 404 errors - this means I can't just move straight over to the production server 2) It's not invisible - the URL bar no longer shows http://site.com/a/b/c/, it shows http://site.com/index.php?values=a/b/c/ So I think I'm doing something wrong, and I can't for the life of me remember how I did it last time. I know it's possible, because I definitely remember the end results being that I took it a stage further and had something like http://site.com/page/a.b/1.2/ mapping to index.php and including page.php within that, with $values[a] = 'b' and [1] = [2] Any hints/tips/"look here"s/fully working code snippets/"you're an idiot, it's this"s are gratefully accepted
  4. Yes. ALWAYS escape user input before putting into your database. Read this
  5. http://uk2.php.net/str_replace str_replace() might work better if you just run it on the one character field. No regex needed. $var = str_replace("{char}","{full text}",$var);
  6. Either Javascript, or a meta tag with a redirect after x seconds would do the job too. The advantage being that you don't need javascriptThe downside being that you can only redirect after a set number of seconds; rather than on a user action and that it's x seconds after the meta loads, rather than the page completion.
  7. Well I've temporarly and partially solved the problem by putting a stat analyser on wordpress; it's the only thing on the server right now anyway. When I add more I'll have to look at activeperl - does it not need a webserver on the computer? ie it runs with just activeperl and awstats?
  8. First, apologies if this is in the wrong place - nowhere quite seems to fit. Okay, basically I need a raw stat/log analyser that I can run on my home PC after downloading the logs. My host only lets AWStats run once per day, which is useless to me at the moment. They won't increase it, so my only option is to try and get an analyser to run off-server. Any suggestions? Thanks ~Jon
  9. Netbeans looks okay, but they need to get it into an all-in-one package instead of sending me off to install bits of java runtime environments and development kits. If I cared about Java, I wouldn't be coding in PHP would I?
  10. No, you can store any timestamp, and just convert it to the date. If you need the due date to be in the format 0000-00-00 just use the date("Y-m-d",$timestamp) where $timestamp is the value from the database. If you need to change the value in the database by using a string, just use $timestamp = strtotime("0000-00-00"); Which will return the timestamp for a given date. You can also enter things like 01 Jan 2008 etc. But if you specify 0000-00-00 it has to be in the format YYYY-MM-DD.
  11. Whoops, looked at the w3schools (first google result for stristr) instead of php.net I think that's perfect, thankyou!
  12. Hmm, never seen that before - nice suggestion. But if I need to use it as if(function(regex,$str)){} will it still return true? Since it returns the remainder of the string?
  13. 448191 - it sums it up, assuming you know and understand the terms "Encapsulation" and "Static coupling"
  14. I need it to find the word, but be case-insensitive and find the word within other words aswell. Is it just a case of using substr() on the second argument and using /\bword\b/i ?
×
×
  • 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.