Jump to content

Dragen

Members
  • Posts

    1,154
  • Joined

  • Last visited

    Never

Everything posted by Dragen

  1. Hi, I have a sub-domain set up, which links to a folder in the root directory of my main domain: main_root/sub_domain/ What I am trying (and failing) to do is to create a .htaccess entry in the root directory of the main domain (main_root), where the main domain website is, to stop users accessing the sub-domain via the relative path (ie; mydomain.com/sub_domain/) and instead only allowing access if they access it like so; sub_domain.mydomain.com Is this possible? I would preferably send them a 404 not found, rather than 403 or anything else. At the moment I have resorted to detecting the host, from within a .htaccess file in the sub-directory and if it is that of the main domain, then re-direct to the index page of the main domain, but I really need to be able to do this without editing the .htaccess of the sub-domain. Just for reference, the code I'm using in my sub-domain is as follows: RewriteCond %{HTTP_HOST} !^(www.)?sub_domain.maindomain.com [NC] RewriteRule ^(.*)$ / [R,L] Any help would be more than appreciated! Thanks.
  2. Does anyone have an answer for this? I need to be able to use getimagesize on he php script that outputs the image, without having to use a direct url. Thanks.
  3. Sorry, but your response didn't make much sense... What do you mean by: Also, the images are just stored in a folder in the root directory. The script just reads the images, scales them down and outputs them in the page. It doesn't save the thumbnailed image anywhere. Thanks.
  4. Okay, an update. After finding this forum topic on stack overflow: http://stackoverflow.com/questions/2430478/php-problem-with-getimagesize I tried using the full url: http://www.mydomain.com/incudes/resize.php?width=50&height=70&img=logo.jpg And it works. I'm not sure quite why this makes a difference, but is there any way around it? I quite need to be able to use relative paths. Regards.
  5. Hi, It's been a while since I've been on here... I've got a script that takes an image url and resizes it, then outputs it to the screen (using image headers etc). I've then got a htaccess file that changes my nice url, such as: 'images/thumb/50-70/logo.jpg' to: 'incudes/resize.php?width=50&height=70&img=logo.jpg' Which is the resize script, so I can use a nice url in img tags. The width and height are just the maximum allowed, so sometime the image will be smaller. Now, this all works correctly, but I am now trying to find out the width and height of the thumbnailed image, from outside of the resize.php script. I thought that I could use getimagesize, but this doesn't seem to work... I first tried it using the 'nice' url: '/images/thumb/50-70/logo.jpg' Thinking that .htaccess would re-direct, but no. I then tried a direct link to the resize file: '/incudes/resize.php?width=50&height=70&img=logo.jpg' But that returns a file not found error... Although I can access the file directly. Trying the direct url without the get variables, however, successfully finds the file, but it doesn't seem to be able to detect the image dimensions. I just get a blank result.. Is PHP able to recognise htaccess re-directs? Is PHP able to parse a php file that outputs as an image? (I have all the correct headers etc set!) Thanks
  6. Thank you so much! I feel rather silly now, as I'd never actually looked into how large a number a tinyint could hold and it didn't even cross my mind.. I've changed it to an int now and it works fine. Thanks again!
  7. Hi, I'm having a strange problem when I try to add something to a table in my database. MYSQL server: 5.1.32 & 5.0.77 (I've tried both) I have a table called store_items, which as an id Primary Key, which auto increments. I have been using it and adding/removing rows from it with no problem, but it now seems that the auto_increment value is 'stuck'. I've just added a 127th row and when I try and add another it throws up this error: SQL Query: INSERT INTO `daisymoon`.`store_items` ( `id` , `name` , `price` , `qty` , `cat_id` , `keywords` , `description` , `weight` , `i_date` , `live` ) VALUES ( NULL , 'test', '1.00', '1', '1', '', '', '', '2010-03-16 13:54:20', '1' ) MySQL Said: #1062 - Duplicate entry '127' for key 'PRIMARY' But as you can see, I'm not entering an id :/ I've also tried setting the id to 128 in the SQL statement, which still brought up the same error. I then tried changing the auto_increment value on the 'Operations' page in MyAdmin.. same problem. Does anyone have any advice? Surely there's no limit to the auto_increment value?? I can't think what would cause this to happen. Kind regards.
  8. I'm still looking for a solutio to this problem, if anyone has any ideas?
  9. Okay, Sorry for the tripple post, but I've found the solution. The problem was that my web page was using charset UTF-8 whereas it appears this doesn't understand the pound symbol properly? I've now changed it to charset ISO-8859-15, which seems to have fixed the problem!
  10. I found this, which appears to be the same, or similar, problem: http://bugs.php.net/bug.php?id=39075 Although I don't understand what the answer means?
  11. hm, strange. It's all on a British server and also the same on my local server. The input is the following (taken directly from a textarea in thet form): WE ARE DELIGHTED TO OFFER FREE SHIPPING ON ALL ORDERS OVER £20.00! (UK ONLY) And here's part of the code that processes it: $var = html_entity_decode(trim($var)); echo $var.'<br />'; $var = htmlentities($var, ENT_COMPAT, 'ISO-8859-15'); echo 'htmlentities: '.$var.'<br />'; return $var; I use entity decode to ensure that when I encode, I'm not double encoding (ending up with things like &amp;) The first echo statement outputs the text correctly (although the pound sign is not encoded as £, obviously). After the htmlentities, I echo again, but now the output is as follows: WE ARE DELIGHTED TO OFFER FREE SHIPPING ON ALL ORDERS OVER £20.00! (UK ONLY) That's taken from the source view. Strangely it appears to have encoded the pound AND added the  which has also been encoded..
  12. If you have one column for each colour, red, blue, green, any, then I would suggest having them all as BOOLEAN type. That way you can simply store true, if they are checked or false if not.
  13. Hi, Can anyone tell me why, when I use htmlentities on the pound symbol (£), instead of converting it to £ as expected, it changes it to £? I have a form in which users can enter information and I am using htmlentities on it and when it is output it returns all of the pound signs as above. Any ides? Thanks.
  14. Okay, thanks for the replies! Its working fine now, the problem was on my end. I'd missed out a call to a function so it wasn't doing everything... The code I had below works perfectly. Thanks!
  15. Thanks for that, but I'm getting some strange results. Here's my code: /** * Creates a base image from the img url and returns it. */ private function createBase(){ $src_img = NULL; switch($this->getType()){ case 'png': $src_img = imagecreatefrompng($this->getImage()); break; case 'gif': $src_img = imagecreatefromgif($this->getImage()); break; default: $src_img = imagecreatefromjpeg($this->getImage()); break; } return $src_img; } /** * Creates the resampled image that will be used */ private static function resampleImage($src_img, $dimg){ $w = imagesx($src_img); $h = imagesy($src_img); imagecopyresampled($dimg, $src_img, 0, 0, 0, 0, $w, $h, $w, $h); } private function replaceImage(){ if($this->getType() == 'png'){ return true; }else{ //checks images exists and creates the base source image if($this->imageExists() && ($src_img = $this->createBase())){ $dimg = imagecreatetruecolor(imagesx($src_img), imagesy($src_img)); imagealphablending($dimg, false); $colorTransparent = imagecolorallocatealpha($dimg, 0, 0, 0, 127); imagefill($dimg, 0, 0, $colorTransparent); imagesavealpha($dimg, true); //resamples the image $this->resampleImage($src_img, $dimg); //getImageNoType gets the image path, without the filetype, so I can add .png to the end if(imagepng($dimg, $this->getImageNoType() . '.png')){ @imagedestroy($dimg); @imagedestroy($src_img); unlink($this->getImage()); return true; } } return false; } } At first glance this appears to work, as it successfully creates the image, with a .png extension, but when trying to access it through PHP GD library, using imagecreatefrompng(), it throws up the following error: Warning: imagecreatefrompng() [function.imagecreatefrompng]: 'C:/Program Files/wamp/www/images/links/2_5.png' is not a valid PNG file in C:\Program Files\wamp\www\incs\thumbs.php on line 60 So it appears that it has saved the file, but not encoded it as a png. EDIT: In fact, checking it in firefox, pageinfo, it states the filetype is .jpg
  16. Hi, I've got a form which uploads an image to the server. Is it possible to change the image type during the upload? I want the user to be able to upload images that are .gif .jpg or .png, but when uploaded, if they are .gif or .jpg, have been changed to .png. Is this possible?
  17. One way of doing it would be to use mod_rewrite to set the vars as GET variables: RewriteRule ^page/([a-z0-9]+)/([a-z0-9]+)/?$ index.php?page=$1$extra=$2 [NC]
  18. RewriteRule /search/([a-z0-9]+)/? /siteengine/search.php?cx=008406457722762222407%3Azeakjf5um_o&cof=FORID%3A9&ie=UTF-8&q=$1&sa=Search
  19. Thanks for the response. The [OR] bit was actually put in recently whilst I was just throwing about random code to get it to work.. so I'll remove that. And yes, my code probably could be optimised a lot. I'm not brilliant at htaccess though, but if yuo have any tips they'll be more than welcome! Yes, if I remove the line: RewriteRule ^([a-z0-9]+)/$ $1.php [NC] It sees to work fine, so I put it down to something like apache doesn't pick up the 404 because of the rewrite.. I don't know. Also, if I try and access a non-existent .php file with the filetype, like this: mydomain.co.uk/nofile.php then the rewrite doesn't come into it, but it tries to download the .php file. If you download it the content is blank. Yet another strange happening!
  20. surely just: href="/article/' . $display_category['category_id'] . '" would suffice?
  21. To be honest I've never used RedirectMatch before, I'd use this: RewriteRule ^^/cake-photo-pages/.*$ http://www.cake-photos.com/ [R=301,NC] Although I don't know which one is better. And yes it will also re-direct googlebot. I think you can specify not to re-direct for certain bots or ip addresses, but I haven't looked into it.
  22. Probably something like: RewriteRule ^folder-a/?(.+)?$ / [R,NC]
  23. No, but it's the only part that seems to be effecting the 404 page. Here's the rest, although I've removed a few bits that have no relevance: ErrorDocument 404 /errors/404.php RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\. [NC,OR] RewriteCond %{HTTP_HOST} daisymoondesign.co.uk [NC,OR] RewriteCond %{HTTP_HOST} daisymoondesigns.com [NC] RewriteRule (.*) http://daisymoondesigns.co.uk/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^maillist(/([a-z\-\ ]+)/?)$ maillist.php?action=$2&%{QUERY_STRING} [NC] RewriteRule ^policies(/([a-z\-\ ]+)/?)$ policies.php?policy=$2&%{QUERY_STRING} [NC] RewriteRule ^([a-z0-9]+)$ $1/ [R,NC] RewriteRule ^([a-z0-9]+)/$ $1.php [NC] RewriteRule ^register/([a-z\-\ ]+)/?$ register.php?action=$1&%{QUERY_STRING} [NC] RewriteRule ^basket/([a-z\-\ ]+)/?$ basket.php?action=$1&%{QUERY_STRING} [NC] RewriteRule ^checkout/([a-z\-\ ]+)/?$ checkout.php?action=$1&%{QUERY_STRING} [NC] RewriteRule ^thumbs/(([a-z0-9\_\ /]+)/)?(([0-9]+)-([0-9]+))/(([a-z0-9\_]+)\.(jpg|gif|png))$ incs/thumbs.php?dir=$2&width=$4&height=$5&img=$6 [NC] RewriteRule ^images/?(([0-9]+)-([0-9]+))/captcha\.(jpg|gif|png)$ incs/captcha.php?getimage=true&width=$2&height=$3 [NC] RewriteRule ^store/([a-z0-9\&\-\/\_\ ]+)+(/(.+?).itm)?$ index.php?c=$1&i=$3&%{QUERY_STRING} [NC,L]
  24. Hi, I'm using mod-rewrite to change all urls like this: mydomain.co.uk/thispage/ to this: mydomain.co.uk/thispage.php Which is working perfectly, but it's stopped any 404 erros from displaying correctly. If I try and access a non-existent .html file it works fine, but when I access a 'folder' (i.e; mydomain/nofile/) file which doesn't exist it simply brings up a blank screen and returns a header of: HTTP/0.9 200 OK Although trying to access a non-existent .php file directly (i.e; mydomain/nofile.php) causes firefox to try and download a blank php file. If I remove the re-write code from my .htaccess file it works, so I'm putting it down to apache re-writing the url so it skips the file not found error check..? The code is as follows: RewriteRule ^([a-z0-9]*)/$ $1.php [NC] If anyone can help it would be greatly appreciated! I've just spent the last couple of hours trying to find a solution. Regards, Lee
×
×
  • 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.