[PHP] Set the background color of an image with GD

2003-10-30 Thread Cranky
Hello,
I have a stranger behaviour of the function imagecolorallocate.
Normally, this function is used to create a color for an image and the 
first call to this function set the background color of the image.

So here is my code :
?php
[snip]...[/snip]
$im = imagecreate(15, 15);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
[snip]...[/snip]
?

And when I display the page, some times the background of the generated 
image is not white.
The color is the same as the color of the background of the page 
(defined in the body tag), as if the image was transparent.

Have you also this problem ?
Why isn't the background white as expected ?
Something more strange is that if I replace the line :
$white = imagecolorallocate($im, 255, 255, 255);
by this line :
$white = imagecolorallocate($im, 255, 255, 254);
This works fine and the background of the image is well white.

Thanks for your help

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Change text size with GD

2003-10-27 Thread Cranky
Hello,
I would like to draw text in a rectangle on an image.
The text must take all the place in the rectangle.
The trouble is that with imagestring(), there are only 5 fonts (1, 2, 3, 
4, 5) and the bigger (5) is still too smaller for my rectangle.

Is there another way to change the size of the text ?

Thanks a lot

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Image created with GD does not appear

2003-10-27 Thread Cranky
Hello,
I generate an image with GD in the file generate_image.php
?php
// generate_image.php
require('config.php')
require('functions.php');
require('secure.php');
header('Content-Type: image/png');

$im = imagecreate(15, 15);

// generation of the image
// ...
imagepng($im);
imagedestroy($im);
?

But when I call this page in an image tag like this :
img src=generate_image.php border=0
The image is not found (I have the small red cross).

If I drop the 3 lines (require) at the beginning of the page then it 
works fine. The image is well displayed.
So I tought it was a problem with the headers, but I have verified, the 
3 included files doesn't send any header.

That's very strange because if I have the 3 includes files in the code 
and then I go direct to the location of the file generate_file.php (and 
so I don't call it with a tag), then the image is well displayed.

Did you have an idea why the imaeg is not displayed when I call it with 
an img tag ?

Thanks a lot

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Change text size with GD

2003-10-27 Thread Cranky
Thanks for your reply.
With this function is it possible to specify the size of the text with 
width and height and not only with an integer ?

Because the size of the rectangle on which I want to draw the text is 
various (I receive the size of the rectangle by parameter).

And other thing, I try to load a font to retrieve the width and height 
with imagefontwidth and imagefontheight.
My code is like that :

?php
$arial = imageloadfont('arial.ttf');
echo 'brWF : '.imagefontwidth($arial);
echo 'brHF : '.imagefontheight($arial);
?
And the file arial.ttf is in the same directory as this script

But when I load the page, I have this error message :
Warning: ImageFontLoad: error reading font in
Thanks for your help

Chris Neale wrote:

I use the function imageTTFtext allows you to specify a string with a font
and a font point size.
Hope that helps.

Chris

-Original Message-
From: Cranky [mailto:[EMAIL PROTECTED]
Sent: 27 October 2003 10:16
To: [EMAIL PROTECTED]
Subject: [PHP] Change text size with GD
Hello,
I would like to draw text in a rectangle on an image.
The text must take all the place in the rectangle.
The trouble is that with imagestring(), there are only 5 fonts (1, 2, 3, 
4, 5) and the bigger (5) is still too smaller for my rectangle.

Is there another way to change the size of the text ?

Thanks a lot

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Lifetime with cookie-less sessions

2003-09-24 Thread Cranky
Hello,
Is it possible to determine a lifetime for the session in the case of a 
cookie-less sessions ?

Thanks for your help.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Lifetime with cookie-less sessions

2003-09-24 Thread Cranky
I just come to do some test this afternoon and here are the results.

page_1.php
?php
session_start();
$bar = 'hello';
$now = date('H:i:s');
$_SESSION['foo'] = $bar;
$_SESSION['begin'] = $now;
header('Location: page_2.php?'.SID);
exit;
?
page_2.php
?php
session_start();
print_r($_SESSION);
echo 'brNow : '.date('H:i:s');
?
a href=page_2.php??php echo SID; ?Reload/a
And here are the results :
Config
session.use_cookie = 0;
session.gc_maxlifetime = 30; // 30 seconds
session.gc_probability = 100; // 100% = the gc is always called
On page 2, I have :
Array ( [begin] = 16:34:22, [foo] = hello )
Now : xx:xx:xx
I have this at the beginning and when I reload the page with the link, 
these information are the same (only = Now : xx:xx:xx changes as 
expected).
But after a little bit more that 30 seconds (never exactly 30 seconds) 
the gc is called and I have :
Array ()
Now : xx:xx:xx

And I do the same test with this config :
Config
session.use_cookie = 0;
session.gc_maxlifetime = 1440; // 24 minutes
session.gc_probability = 1; // 1% = the gc is called 1 time on 100
And here at the beginning all is correct, I refresh the page 2 every 15 
minutes and here, the session is destroyed randomly after 1h20, 1h50...

So it seems that the lifetime on a cookie_less session is determined by 
the gc.max_lifetime.

Thanks for your help

Raquel Rice wrote:

In my sessions I set an expire time, which is the current time
(unix timestamp) plus the number of seconds I want a session to
last.  Each new page examines the current timestamp against the
expire time.  If the current time is less than the expire time, then
the expire time is advanced again.  Otherwise, the session is wiped
out and the user sent to an error page.

$defExpireTime = 3600;
if ($_SESSION['expire'] = (time() + $this-defExpireTime) {
$_SESSION['expire'] = time() + $this-defExpireTime;
# go ahead with session
} else {
$_SESSION = array();
# send the user to an error page
}
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: mysql_close();

2003-03-21 Thread Cranky
?php
if ($connection = @mysql_connect($host, $username, $password)){
 @mysql_close($connection);
}
?

By this way, you always reopne a new connection at the end of all of your
page

You just have to use somthing like this...
if($connection)
@mysql_close($connection);

But as it was said, you are not *obliged* to close the connection, PHP will
close it himself.
But you can also close your connection manually on each page just after you
send your last request.

Shaun [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 hi,

 I include a file called bottom.php which goes at the bottom of all my
pages
 and looks like this:

 tdnbsp;/td
   /tr
  /table
 /body
 /html
 ?php
 if ($connection = @mysql_connect($host, $username, $password)){
  @mysql_close($connection);
 }
 ?

 I use this to make sure that I haven't left a connection open
accidentally,
 however I sometimes get an error message even though I am using the @
 symbol:


 Warning: mysql_close(): no MySQL-Link resource supplied in
 /home/w/o/workmanagement/public_html/authenticate_user.php on line 51

 How can this be?





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] register_variables

2003-03-18 Thread Cranky Kong
The problem must certainly come from the register_global turn to off
Check this value in your php.ini file


Samug [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 No it's not.
 It's a script called LinksCaffe
 http://www.hotscripts.com/cgi-bin/dload.cgi?ID=15062.
 In file catadd.php


 Leif K-Brooks [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Is it inside of a function?
 
  samug wrote:
 
  I'm trying to run a script which uses variables passed via a form, like
  this:
  
  if($lcat_name)
  {
  $sql_query = INSERT into category VALUES ('','$lcat_name');
  $result = mysql_query($sql_query);
  echo You add next categoryfont color=greenb
$lcat_name/b/font;
  }
  
  but the variable $lcat_name is empty unless I do this:
  $lcat_name = $_REQUEST['lcat_name'];
  
  Why?
  
  I have the variable register_globals on.
  
  
  
  
  
  
 
  --
  The above message is encrypted with double rot13 encoding.  Any
 unauthorized attempt to decrypt it will be prosecuted to the full extent
of
 the law.
 
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP url variables

2003-03-14 Thread Cranky Kong
Have a look at the parameter register_global in your php.ini
By default in the recent version of PHP, this parameter is set by default to
off for security reason.
So if you want to use $id, you just have to set this parameter to on


Stephen [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 Hi

 I have just installed PHP 4 and Apache 2 but when I pass a variable in a
url
 eg ?id=1
 I can't get the variable value by $id, I have to use $_GET['id'] or
 $_POST['id']

 Is there a setting I need to change to allow me to use the $id? If there
is
 it will save a lot of additional coding.

 Thanks,

 Stephen





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] javascript

2003-03-07 Thread Cranky Kong
And what are you doing if the javascript is not enabled in the browser of
the client ???
There will be no verification and the user can enter what he want in the
field of your form
And it's a bit dangerous for your DB if your insert data in a DB...


Marek Kilimajer [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 Not bothering the user to wait till the next page loads

 Liam Gibbs wrote:

 If you want to validate form data before sending it, javascript is the
 choise.
 
 
 
 Yeah, before sending it. Just wondering what the advantage is in
validating
 before sending.
 
 
 
 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] javascript

2003-03-07 Thread Cranky Kong
I always test the data server side, never on the client.
The set up of the browser can be changed by the client and so a guy whi want
to create problem can disable JS.

On the server, the visitor of your site can not changed the set up...
So you can also check both client side and server side but personnaly I only
test on server side.
A test doesn't take a lot of ressource and it's very quick so...


James E Hicks III [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
  And what are you doing if the javascript is not enabled in the browser
of
  the client ???
  There will be no verification and the user can enter what he want in the
  field of your form
  And it's a bit dangerous for your DB if your insert data in a DB...

 Wow, the only safe way to insure data integrity is validating it on the
 server side. Does this means that javascript validations only effect is
 to doubles the developers work?






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] javascript

2003-03-07 Thread Cranky Kong
Yes but if the fields are well filled, you will check all 2 times, the first
time on the client side to know that the fields are filled.
And a second time on server side to check the data before inserting them in
a DB for examples...
So why make 2 tests, if only one is good.

The reloading of the page is very fast.


Marek Kilimajer [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
If the user is disabled, the user will be bothered to wait till the page
reloads, sure there MUST be server side check

Cranky Kong wrote:

And what are you doing if the javascript is not enabled in the browser of
the client ???
There will be no verification and the user can enter what he want in the
field of your form
And it's a bit dangerous for your DB if your insert data in a DB...


Marek Kilimajer [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]


Not bothering the user to wait till the next page loads

Liam Gibbs wrote:



If you want to validate form data before sending it, javascript is the
choise.




Yeah, before sending it. Just wondering what the advantage is in


validating


before sending.














-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] global var or passing a parameter in classes ?

2003-03-05 Thread Cranky Kong
Hello,
here is my problem :
I have a class A and I instanciate this class at the beginninf of my script.
I have another class B and in some functions of this class B, I need to
access the instance of the class A.

So in the functions of the class B, to access the class A, is it better to
receive a reference of the class A in the contructor of the class B and then
store the reference into a variable of the class B
OR
is it better to declare global $foo; at the beginning of the functions of
the class B where I need to access the instance of the class A
($foo is the name of the instance of my class A)

???

Thanks a lot



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php as php3 perhaps with htaccess

2003-03-03 Thread Cranky
Hello,
I have a website and all my files are *.php3

I would like to change the extensions of all files to *.php

My problem is for the search engine and links to my site.
Because the site is well referenced in the search engine with files liek
*.php3

So if I rename all files in .php, the links in the search engine will be
broken

So I would like to know if there is a way perhaps with a .htaccess file to
say that the file .php3 must be redirect to the same file but in *.php

So when I try to access this page :
http://www.my-site.com/page.php3?param=value

I will access this page :
http://www.my-site.com/page.php?param=value

Thanks a lot



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php as php3 perhaps with htaccess

2003-03-03 Thread Cranky
Thanks for this reply.
But I can not use the mod-rewrite because my site is on a shared hosting.

Another idea ?

Thanks


Ernest E Vogelsinger [EMAIL PROTECTED] a écrit dans le message de
news: [EMAIL PROTECTED]
 At 10:21 03.03.2003, Cranky said:
 [snip]
 I have a website and all my files are *.php3
 I would like to change the extensions of all files to *.php
 
 So I would like to know if there is a way perhaps with a .htaccess file
to
 say that the file .php3 must be redirect to the same file but in *.php
 
 So when I try to access this page :
 http://www.my-site.com/page.php3?param=value
 
 I will access this page :
 http://www.my-site.com/page.php?param=value
 [snip]

 If you have the ability to use mod-rewrite, you can do

 RewriteEngine On
 RewriteCond %{REQUEST_URI}  ^.*\.php3.*$ [NC]
 RewriteRule ^(.*)\.php3(.*)$  $1.php$2 [L]

 This can be done either in the general configuration, within
VirtualHost,
 or within Directory.

 I am using exactly this stuff to allow legacy links to a site that has
been
 developed in Python (*.py) to access the same URLs as PHP files.


 --
O Ernest E. Vogelsinger
(\)ICQ #13394035
 ^ http://www.vogelsinger.at/





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Variables VS constantes

2003-02-28 Thread Cranky
Hello,
I would like to know if in a config file for
example, if it was better to use variables or
constantes ?
Is it a big difference of performance or in
memory used ?

And the same question about the translation of
a site.
I would like to translate my site in many
langages.
So I want to create one file per langage to put
in the text translated in it.
Is it better to use variables, associatives arrays
or constantes ?

Thanks a lot for your reply



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php