Welcome, Guest. Please login or register.

Login with username, password and session length
Pages: [1]   Go Down
Print
Topic: Run .jpg extension as .php  (Read 829 times)
« on: June 08, 2009, 10:58:39 AM »
madar1985 Offline
Newbie

View Profile
*
Posts: 3



Hey Guys,

I want my php code to run with the file type extension of .jpg.

By this i mean I save my php script with a jpg extension.

I have added this code to my .htaccess file

Code:
<Files spacer.jpg>
ForceType application/x-httpd-php
</Files>

But it didn't work. Is the code right? I wonder if my host could be blocking this perhaps?

Any help would be greatly appreciated.

Thanks,
Logged

 
« Reply #1 on: June 14, 2009, 05:39:23 PM »
schank Offline
Newbie

View Profile
*
Posts: 45



it may not work for already uploaded files, you might have to re-upload files, but i'm not too experienced with .htaccess, though...
Logged
« Reply #2 on: June 22, 2009, 06:04:25 AM »
n1tr0b Offline
Newbie

View Profile
*
Posts: 11



um you mean some pictures from captcha having this code??

<img src="captcha.php" alt="">

Here is the code for the captcha
<?php
session_start
();
$width 140;
$height 70;
$im imagecreate($width$height);
$bg imagecolorallocate($im000);

// generate random string
$len 5;
$chars 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$string '';
for (
$i 0$i $len$i++) {
    
$pos rand(0strlen($chars)-1);
    
$string .= $chars{$pos};
}
$_SESSION['captcha'] = md5($string);

// grid
$grid_color imagecolorallocate($im17500);
$number_to_loop ceil($width 20);
for(
$i 0$i $number_to_loop$i++) {
    
$x = ($i 1) * 20;
    
imageline($im$x0$x$height$grid_color);
}
$number_to_loop ceil($height 10);
for(
$i 0$i $number_to_loop$i++) {
    
$y = ($i 1) * 10;
    
imageline($im0$y$width$y$grid_color);
}

// random lines
$line_color imagecolorallocate($im13000);
for(
$i 0$i 30$i++) {
    
$rand_x_1 rand(0$width 1);
    
$rand_x_2 rand(0$width 1);
    
$rand_y_1 rand(0$height 1);
    
$rand_y_2 rand(0$height 1);
    
imageline($im$rand_x_1$rand_y_1$rand_x_2$rand_y_2$line_color);
}

// write the text
$text_color imagecolorallocate($im25500);
$rand_x rand(0$width 50);
$rand_y rand(0$height 15);
imagestring($im10$rand_x$rand_y$string$text_color);


header ("Content-type: image/png");
imagepng($im);
?> 
Logged
 
Pages: [1]   Go Up
Print
Jump to: