473,241 Members | 1,627 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

GD Library Problem

The web site was on another server i switch to a new one but this server hav
now PHP Safe Mode to ON so i get error when creating thumbnail. I cant put
PHP Safe mode to OFF. is ther any thing i can do so it will be able to
create the thumbnail again ?
site: www.jfl-media.com

Thanks

J-F
her is the script:

<?php

/*

Main functions and login
@author Terje Torkelsen

@version 1.0.0.0

@date 16.10.2002

*/

include_once('./phplib/var-main.php');

include_once('./phplib/cl-Database.php');

include_once('./phplib/cl-User.php');

// Checking if a user has logged in, should be an easyier way yo do this

$headfile = "index";

session_set_cookie_params( 60 * 60 * 2 );

session_start();

if( session_is_registered( "User" ) ) { // A user is logged in

if( $User->type == TELECOMUTER ) $headfile = "tele";

elseif( $User->type == ADMIN ) $headfile = "admin";

if( md5( $User->ID . $timestamp ) != $login[id] || $timestamp !=
$login[time] || $login[type] != $User->type ) {

$headfile = "index";

session_destroy();

header( "Location: index.php" );

exit;

}

}

if( !session_is_registered( "timestamp" ) ) {

session_register( "timestamp" );

$timestamp = microtime();

}

// End checking

if( !isset( $blang ) ) $blang = 'eng'; // Too be sure...

include_once("lang_$blang/language.php");

// Login thru the upper login menu

$login_error = "";

if( isset( $x ) && ($email != "E-mail" || $password != "Password") ) {

if( is_email( $email ) ) {

$Data = new Database( true );

if( $Data->is_admin( $email, $password ) ) {

session_register( "User" );

$User = new User( ADMIN );

$Data->getuser( $email, $User, ADMIN );

$Data->close();

set_login_cookie( $User->ID, ADMIN );

header( "Location: admin-login.php" );

exit;

} elseif( $Data->get_user_f( $email, "password", TELECOMUTER ) ==
$password ) {

session_register( "User" );

$User = new User( TELECOMUTER );

$Data->getuser( $email, $User, TELECOMUTER );

$Data->query("UPDATE telecomuter SET last_login = " . time() . " WHERE
(telecomuter_ID = $User->ID);");

$Data->close();

set_login_cookie( $User->ID, TELECOMUTER );

header( "Location: tele-login.php" );

exit;

} elseif( $Data->get_user_f( $email, "password", EMPLOYER ) == $password ) {

session_register( "User" );

$User = new User( EMPLOYER );

$Data->getuser( $email, $User, EMPLOYER );

$Data->close();

set_login_cookie( $User->ID, EMPLOYER );

header( "Location: client-login.php" );

exit;

} else { $Data->close(); $login_error = $LoginFailure; }

} else $login_error = $EmailNotValid;

}

// End Login

function set_login_cookie( $userID, $type ) {

global $timestamp;

setcookie( "login[type]", $type, time() + ( 60 * 60 * 24 ), '/', '', 0 );

setcookie( "login[time]", $timestamp, time() + ( 60 * 60 * 24 ), '/', '',
0 );

setcookie( "login[id]", md5( $userID . $timestamp ), time() + ( 60 * 60 *
24 ), '/', '', 0 );

}

function cut_string( $string, $len ) {

if( strlen( $string ) <= $len ) return $string;

$in_tag = false;

$first_lt = strpos( substr( $string, $len ), '<' );

$first_gt = strpos( substr( $string, $len ), '>' );

if( $first_lt != false || $first_gt != false ) {

if( $first_lt > $first_gt ) $in_tag = true;

}

for( $i = $len; $i>0; $i-- ) {

if( $string[$i] == '<' && $in_tag ) $in_tag = false;

if( $string[$i] == '>' && !$in_tag ) $in_tag = true;

if( $in_tag ) continue;

if( $string[$i] == ' ' ) return substr( $string, 0, $i ) . '...';

}

}

function more( $id, $description, $image, $len ) {

if( strlen( $description ) <= $len ) {

$result = "$image\n";

$result .= "$description\n";

} else {

$result = "<span class=\"\" id=desc_sh_$id style=\"display: inline\">\n";

$result .= "$image\n";

$result .= cut_string( $description, $len ) . "\n";

$result .= "<a href=\"#\" onclick=\"desc_sh_$id.style.display='none';
desc_ln_$id.style.display='inline'; return false; \">\n";

$result .= "<b>more</b></a></span>\n";

$result .= "<span class=\"\" id=desc_ln_$id style=\"display: none\">\n";

$result .= "$image\n";

$result .= "$description\n";

$result .= "<a href=\"#\" onclick=\"desc_sh_$id.style.display='inline';
desc_ln_$id.style.display='none'; return false; \">\n";

$result .= "<b>short</b></a></span>\n";

}

return $result;

}

function is_phone( $phonenr ) {

return !preg_match( "/[a-zA-Z]/", $phonenr );

}

function is_email( $email ) { // Regular expression found on
www.phpbuilder.com

return
preg_match("'^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$'",
$email);

}

function valid_pw( $pass ) {

$PCODE0 = true;

$PCODE1 = ( strlen( $pass ) >= MIN_PASS_LEN );

$PCODE2 = ( preg_match("/[a-z]/", $pass ) && preg_match("/[A-Z]/",
$pass ) );

$PCODE3 = ( $PCODE2 && preg_match("/[0-9]/", $pass ) );

$PCODE4 = ( $PCODE3 && preg_match("/\W/", $pass ) );

switch( PASS_CODE ) {

case 0: return ( $PCODE0 ); break;

case 1: return ( $PCODE1 ); break;

case 2: return ( $PCODE1 && ($PCODE2 || $PCODE3 || $PCODE4) ); break;

case 3: return ( $PCODE1 && ($PCODE3 || $PCODE4) ); break;

case 4: return ( $PCODE1 && $PCODE4 ); break;

default: return false; break;

}

}

function array_contains( $array, $contain ) {

if( !is_array( $array ) ) return false;

foreach( $array as $value )

if( $value == $contain ) return true;

}

function email_type( $message ) {

if( preg_match( "/<[\/\!]*?[^<>]*?>/i", $message ) )

return 'text/html';

else

return 'text/plain';

}

// Saves the given image and makes a thumbnail of it which it saves

// with a sm- in front of the filename.

function save_image( $tmpfile, $filename, $filetype, &$user, $dirname =
'projects', $userdir = true ) {

global $PATH_TRANSLATED;

$savepath = dirname( $PATH_TRANSLATED ) . "/$dirname";

if( $userdir ) $savepath .= "/$user->ID";

if( is_file( $savepath . "/$filename" ) ) return false;

if( empty( $tmpfile ) ) return false;

if( !is_dir( $savepath ) ) mkdir( $savepath, 0777 );

chmod ($savepath, 0777);

move_uploaded_file( $tmpfile, $savepath . "/$filename" );

$im = ImageCreateFrom( $savepath . "/$filename", $filetype );

if( !$im ) return false;

$im_width = ImageSX( $im );

$im_height = ImageSY( $im );

if( $im_width <= MAX_IMAGE_X && $im_height <= MAX_IMAGE_Y ) {

ImageSave( $im, $savepath . "/thumb_$filename", $filetype );

} else {

$scale_x = MAX_IMAGE_X / $im_width;

$scale_y = MAX_IMAGE_Y / $im_height;

if( $scale_x > $scale_y )

$srcim = ImageCreate( $im_width * $scale_y, $im_height * $scale_y );

elseif( $scale_x < $scale_y )

$srcim = ImageCreate( $im_width * $scale_x, $im_height * $scale_x );

else

$srcim = ImageCreate( $im_width * $scale_x, $im_height * $scale_y );

ImageCopyResized( $srcim, $im, 0, 0, 0, 0, ImageSX( $srcim ), ImageSY(
$srcim ), $im_width, $im_height );

ImageSave( $srcim, $savepath . "/thumb_$filename", $filetype );

ImageDestroy( $srcim );

}

ImageDestroy( $im );

}

function ImageCreateFrom( $filename, $filetype ) {

if( $filetype == 'image/png' || $filetype == 'image/x-png' )

return @ImageCreateFromPNG( $filename );

elseif( $filetype == 'image/jpeg' || $filetype == 'image/pjpeg' )

return @ImageCreateFromJPEG( $filename );

/*elseif( $filetype == 'image/gif' ) ONLY SUPPORTED FOR GD LIBRARY < v1.6

return @ImageCreateFromGIF( $filename );*/

else return false;

}

function ImageSave( &$image, $filename, $filetype ) {

if( $filetype == 'image/png' || $filetype == 'image/x-png' )

ImagePNG( $image, $filename );

elseif( $filetype == 'image/jpeg' || $filetype == 'image/pjpeg' )

ImageJPEG( $image, $filename );

/*elseif( $filetype == 'image/gif' ) ONLY SUPPORTED FOR GD LIBRARY < v1.6

ImageGIF( $image, $filename );*/

}

// Returns a text cleaned for php commands and html tags

function cleantext( $text ) {

$rettext = preg_replace( "'<script[^>]*?>.*?</script>'si", "", $text );

$rettext = @strip_tags( $rettext, "<b><center><a><i><u>" );

$search = array( "'&[^#]*?;'i", "'\"'i", "'\''i", "' < 'i", "' > 'i", "'" .
chr(161) . "'i", "'" . chr(162) . "'i", "'" . chr(163) . "'i", "'" .
chr(169) . "'i" );

$replace = array( "&amp;", "&quot;", "'", " &lt; ", " &gt; ",
"&iexcl;", "&cent;", "&pound;", "&copy;" );

$rettext = preg_replace( $search, $replace, $rettext );

$rettext = nl2br( $rettext );

$rettext = preg_replace( "'[\n\r]'i", "", $rettext );

return $rettext;

}

// Returns a text opposite from the above... turns it back ( have to be done
for textareas )

function uncleantext( $text ) {

$search = array( "'’'i", "'&(quot|#34);'i", "'''i", "' &(lt|60);
'i", "' &(gt|#62); 'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i",
"'&(pound|#163);'i", "'&(copy|#169);'i", "'&(amp|#38);'i" );

$replace = array( "´", "\"", "\'", " < ", " > ", chr(161), chr(162),
chr(163), chr(169), "&" );

$rettext = preg_replace( $search, $replace, $text );

$rettext = preg_replace( "'<br>|<br />'i", "\n", $rettext );

return $rettext;

}

// Returns a string where input arrays are inserted into input string

function rstring( $str, $array ) {

if( !is_array( $array ) ) return $str;

foreach( $array as $key => $value ) {

$str = preg_replace( "/%$key%/", $value, $str );

}

return $str;

}

?>

Jul 17 '05 #1
0 2701

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Simon | last post by:
Hello. I wanna use my dynamic shared library(built with C language) with php script. (PHP version is 4.0.6) So I making a shared library(*.so) in Solaris environment(2.7) and it is successful....
5
by: Venky | last post by:
We have a strange error here. We have an application that is built in VC++ 6.0 and uses a C library built using the same. Now, we have migrated to .Net and have used the same source code to be...
3
by: Tee | last post by:
Hi guys, I have a problem with my VS project, it keeps saying COM Interop registration failed. Could not find a type library for assembly 'Class1'. If I choose to continue, everything still work...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
4
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r)...
87
by: Robert Seacord | last post by:
The SEI has published CMU/SEI-2006-TR-006 "Specifications for Managed Strings" and released a "proof-of-concept" implementation of the managed string library. The specification, source code for...
7
by: akennis | last post by:
First of all, sorry for duplicating this post. I put it up in the alt.comp.lang.learn.c-c++ mistakenly. I'm investigating a problem whereby exceptions thrown from functions in a Shared Library...
0
by: drawing in aspnet | last post by:
Question about putting the data layer in a separate class library. I keep reading that the data layer should be separated from the presentation layer and put in its own class library. I am...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.