Jump to content

Dragen

Members
  • Posts

    1,154
  • Joined

  • Last visited

    Never

About Dragen

  • Birthday 05/22/1988

Contact Methods

  • Website URL
    http://www.gimppro.co.uk/

Profile Information

  • Gender
    Male
  • Location
    UK

Dragen's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  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
×
×
  • 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.