[PHP] Re: restricting acces to files

2003-02-04 Thread Goetz Lohmann
Shams schrieb:
> Hi,
> 
> i've written a secure PHP login script which will allow users to login to a
> directory such as this:
> 
> smezone.com/members/index.php
> 
> however, how do I restrict people from accessing HTML files in that
> directory (which they can easily do so by typing the URL into their
> browser), such as:
> 
> smezone.com/members/document1.html
> 
> ?
> 
> Since its a regular HTML files (and we have lots), I can't check whether the
> user has a valid session as I would do in a PHP file.
> 

if you are using linux & apache ... just use a .htaccess file like the one below

AuthUserFile /usr/home/.htpasswd
AuthName "Secret Area"
AuthType Basic

  require valid-user


with this you restrict access only to users listet in the /usr/home/.htpasswd
files which look like

user1:668c1d6Hc6yCg
test:85FRBo8cHrAZc

the code after ":" is a MD5 key
the FilesMatch mean that all files ending with .gif,.html,.. is restricted and
.php is not.

in a php file you now can read the authentications from a user and compare it
with the /usr/home/.htpasswd entrys.

Your Login is OK";
?>
...
wrong login !";
}
  }
?>

note that the the /usr/home/.htpasswd file must include all usernames and
passwords as MD5. You can create a line of this file with:



maybe you also can use "mod_auth_db" ... but this is apache specific so
take a look at http://httpd.apache.org/docs/mod/core.html



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: How to check for refresh in PHP

2003-02-04 Thread Goetz Lohmann
Pag schrieb:
> 
> Hi,
> 
> I have a news site where i want to track how many "visits" or reads
> each individual news has. I have a main list with all the titles, then
> clicking on them shows the details of the specific news, only then the
> counter for that particular news is increased. The problem is, if the
> user does a refresh while at the details, the counter is increased
> again. How can i prevent this from happening?
> 
> I thought it would be something like a unique counter problem, but
> its like having a "counter problem" for each news i have. :-P
> 
> What would be nice, if it exists, is to check if the user is doing a
> refresh or coming from somewhere else. If its a refresh, the counter
> would simply not increase. That would be sufficient to keep the
> i-want-my-news-to-have-the-higher-number-of-visitors author, from having
> his way.
> 

maybe store the counter in a mysql database including the IP of the viewer
and the timestamp when he visited this page. If he shows the news the first
time store the IP with timestamp and the viewd news in the database.
If he view it again first check if this IP viewed this news lately.
Remove all IP which been older than maybe 8 hours afterwards.

Another option is to store this info in cookies or sessions ...

-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: restricting acces to files

2003-02-04 Thread Goetz Lohmann
Goetz Lohmann schrieb:
> Shams schrieb:
> 
>>Hi,
>>
>>i've written a secure PHP login script which will allow users to login to a
>>directory such as this:
>>
>>smezone.com/members/index.php
>>
>>however, how do I restrict people from accessing HTML files in that
>>directory (which they can easily do so by typing the URL into their
>>browser), such as:
>>
>>smezone.com/members/document1.html
>>
>>?
>>
>>Since its a regular HTML files (and we have lots), I can't check whether the
>>user has a valid session as I would do in a PHP file.
>>
> 

maybe take a look at:

http://hotwired.lycos.com/webmonkey/00/05/index2a_page3.html?tw=programming

but note that normaly $PHP_AUTH_PW is the password in clear text, but the
.htaccess file stores it as a md5 key!



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Problem with include PHP 4.3.0

2003-02-04 Thread Goetz Lohmann
Jean-Pierre Gallou schrieb:
> Hi,
> 
> I have problems with relative paths and 4.3.0. Include() do not seem to
> work the same way in 4.3.0 and 4.2.1. Consider this test:
> 
> test/
>  |- testinclude.php   
>  |- inc/
> |- inc1.php   
> |- inc2.php   OK
> 
> With PHP 4.2.1,  works OK.
> With 4.3.0, I get:
>   Failed opening '/inc/inc2.php' for inclusion \
>include_path='.:..:/usr/local/php-4.3.0/lib/php') in \
>/usr/local/www/htdocs/tests/inc/inc1.php on line 1
> 
> With a modified inc1.php:
>   
> this test is OK with 4.3.0, but gives an error with 4.2.1.
> 
> It appears that paths are relative
> - to the main script in 4.2.1,
> - to the including script in 4.3.0
>(but .. in include_path does not work).
> 
> I can't seem to be able to write something OK for both versions (except
>  if giving full pathnames). By the way, this is on Solaris, and
> safe_mode if off.
> 
> Any suggestion?
> 

Failed opening '/inc/inc2.php'

looks like that he try an absolute path from the root / ... maybe try something
like

include('./inc/inc1.php');
 ^^

instead. The "include_path" tells PHP only where to look for the file

.   = same directory
..  = parent directory

if it is a single file or relativ path, but '/inc/inc2.php' is an absolute path
from the root ...


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Variable objects?

2003-02-04 Thread Goetz Lohmann
Leif K-Brooks schrieb:
> I'm planning to use variable objects in a new project I'm working on.
> The problem is, I can't find one page of documentation on them, so I
> can't be sure if I'm going to be using an accidential feature that will
> disappear.  As an example of them working, the following outputs "In
> a_class.":
>  class a_class{
>function a_class(){
>echo 'In a_class.';
>}
> }
> $foo = 'a_class';
> new $foo();
> ?>
> 

take a look at
http://www.php.net/manual/en/ref.classobj.php

;-)

-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Converting links in strings

2003-02-04 Thread Goetz Lohmann
Randum Ian schrieb:
> Hi all,
> 
> Please can someone direct me to the correct function that changes 
> http://www.foo.com to http://www.foo.com";>http://www.foo.com 
> for any occurence in a string.
> 
> Cheers, Ian.
> 

do you wish convert a string in a link ??? try:

$string1";
?>

or a link in a string ?



with

$string[1]; // protocol type (http,https,ftp)
$string[2]; // hostname (domain)
$string[3]; // port if available like 80 for http

... please be more precise in your question !



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: include_path problem on RH 8

2003-02-04 Thread Goetz Lohmann
Paul schrieb:
> Using RH 8, php 4.2.2, Apache 2.0, I'm getting (from phpinfo) a reported include 
>path of .:/usr/share/pear no matter what I put in the include_path in php.ini. The 
>info also says it's using /etc/php.ini as the config file.
> 
> And, yes, I've restarted Apache many times. I've tried many variations on the path 
>syntax, and settled on the simplest possibility, but it still doesn't pick it up. At 
>the moment, /usr/share/pear is not in that statement.
> 
> Anybody got any good ideas?
> 
> TIA,
> Paul


don't panic ... the last part "/usr/share/pear" is the path where the command
line version of PHP resists and is always there also without an include_path
entry of php.ini


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Getting key of value added to array with []?

2003-02-04 Thread Goetz Lohmann
Leif K-Brooks schrieb:
> Is there any way to get the key of an element added to an array with []?
> I need to use this for a reference to it.  The only idea I can think of
> is to foreach through the array and use the last key looped through, but
> that seems very dirty.
> 

$foo[]='bar';

will insert 'bar' as the last item of the array $foo. To get this you might
use

$erg = key($foo); // the key of the current element

or

$erg = pos($foo); // the value of the current element

maybe if something happend between the insertion first head to the last item

$erg = end($foo); // get the last element of array $foo

instead of foreach you can also use array_walk($arr, 'func');




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: mail function

2003-02-04 Thread Goetz Lohmann
Dale schrieb:
> I am trying to configure the php.ini file so that I can use the mail
> function in my code. The problem I am facing is that I get the following
> error message when I try to run my code:
> 
> Warning: mail() [function.mail]: SMTP server response: 550 Relaying is
> prohibited
> 

this is an error of sendmail not from PHP ! ... take a look at the
/etc/mail/sendmail.cf or /etc/mail/access of your box and enable
relaying for maybe localhost ...


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: include_path problem on RH 8

2003-02-04 Thread Goetz Lohmann
Paul schrieb:
> Thanks for the info. But I notice that I didn't really state the essence of my 
>problem, which is that I can't get PHP to locate any include directory I put in the 
>php.ini, thus no files I want to include get included.
> 
> Paul schrieb:
> 
> 
>>>Using RH 8, php 4.2.2, Apache 2.0, I'm getting (from phpinfo) a reported include 
>path of .:/usr/share/pear no matter what I put in the include_path in php.ini. The 
>info also says it's using /etc/php.ini as the config file.
>>>
>>>And, yes, I've restarted Apache many times. I've tried many variations on the path 
>syntax, and settled on the simplest possibility, but it still doesn't pick it up. At 
>the moment, /usr/share/pear is not in that statement.
>>>
>>>Anybody got any good ideas?
>>>
>>>TIA,
>>>Paul
> 


include_path = ".:..:/mydir"

using "" around or left the ; infront ? No I don't think you are stupid but
sometimes someone don't realize the easyest things ...

what is in the error log of apache reported, enable the error_log in php.ini and
take a look at that ... is there any information when apache/php is started ?

maybe did you changed "/etc/php.ini" or something else ?

are there two lines in "/etc/php.ini" with include_path ?

at command line type
$> vim /etc/php.ini

search for include_path with
:/include_path/

search twice with
://

quit with
:q



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Problem with include PHP 4.3.0

2003-02-04 Thread Goetz Lohmann
Jean-Pierre Gallou schrieb:
> Thank you for your reply. Goetz Lohmann wrote :
> 
>> Failed opening '/inc/inc2.php'
> 
> 
> Yes, I don't understand the reason of the leading slash in the error
> message.
> 
>> ... maybe try something like
>>
>> include('./inc/inc1.php');
>>  ^^
> 
> 
> same thing: Failed opening './inc/inc2.php' for inclusion
> 


mhhh ... wait ... don't you wrote

test/
 |- testinclude.php   
 |- inc/
|- inc1.php   
|- inc2.php   OK

wich means that "testinclude.php" includes "inc/inc1.php"
and "inc/inc1.php" includes "inc/inc2.php" ?

the include is like a copy of the code from
"inc/inc1.php" into "testinclude.php" so that in the
first sighth it might be correct to call "inc/inc2.php"
instead of "inc2.php".

But maybe the parser of PHP 4.3.0 is rewritten so that it
now parse it bottom up. That means that first the inclusion
of "inc/inc2.php" into "inc/inc1.php" will happen which
fails cause its in the same directory.

... I tried it on my server ... all went Ok ... strange ...

insert something like into inc1.php and inc2.php:

\n";
   echo "\n";
   $folder=dir('inc');
   // print out folder "inc"
   while($datei = $folder->read()) {
  echo "$datei\n";
   }
   $folder->close();
   echo "\n";
?>

maybe did it head anywhere else or did it show something like

inc included
inc included

.
..
inc1.php
inc2.php


.
..
inc1.php
inc2.php


???


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] authentication

2003-02-04 Thread Goetz Lohmann
[EMAIL PROTECTED] schrieb:
> I don't think the process is an extra step at all. In fact, it's just a
> trade off using one or the other. You can either login using php and a
> database backend or just authenticate using .htaccess directives.
> 



> On Mon, 3 Feb 2003, Chris Shiflett wrote:
> 
> 
>>>There is a way to supposedly do this by authenticating
>>>a username and password through php first through such
>>>methods as database lookups and then passing the
>>>username and password through $PHP_AUTH_USER and
>>>$PHP_AUTH_PW using the header() command to point to the
>>>URL of the .htaccess protected directory but I have
>>>never gotten it to work myself.
>>
>>The variables $PHP_AUTH_USER and $PHP_AUTH_PW are available
>>to you when the user authenticates via HTTP basic
>>authentication. Thus, the user has already had to type in
>>the username and password into a separate window, which is
>>what the original poster is trying to avoid.
>>
>>To then send the user to another URL and supply the
>>authentication credentials in the URL itself just creates
>>an unnecessary step.
>>
>>


In fact you could combine .htaccess AND $PHP_AUTH cause its
all depending on apache. Apache is looking for the variables
AUTH_USER and AUTH_PW ... not PHP ... PHP just send this via
header() and the Apache result is copyd to PHP_AUTH.

That way you could use an PHP file to build the login page
and an .htacces file to define the restrictions

use something like


  require valid-user


to restrict access to the specified files and note that the
data of the .htpasswd must be the same as the user/password
definitions of the database. Maybe you might use mod_auth_db
instead of mod_auth.
With  instead of  you only protect files
not the way/method how to get them. With the line above
all .html files are protected and .php files are not.
In combination with  you could also make a
special definition range ...

you only have to beware of the MD5 password ... use



to generate a password valid for an .htacces file



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: restricting acces to files

2003-02-04 Thread Goetz Lohmann
Goetz Lohmann schrieb:
> Shams schrieb:
> 
>>Hi,
>>
>>i've written a secure PHP login script which will allow users to login to a
>>directory such as this:
>>
>>smezone.com/members/index.php
>>
>>however, how do I restrict people from accessing HTML files in that
>>directory (which they can easily do so by typing the URL into their
>>browser), such as:
>>
>>smezone.com/members/document1.html
>>
>>?
>>
>>Since its a regular HTML files (and we have lots), I can't check whether the
>>user has a valid session as I would do in a PHP file.
>>
> 
> 
> if you are using linux & apache ... just use a .htaccess file like the one below
> 
> AuthUserFile /usr/home/.htpasswd
> AuthName "Secret Area"
> AuthType Basic
> 
>   require valid-user
> 
> 
> with this you restrict access only to users listet in the /usr/home/.htpasswd
> files which look like
> 
> user1:668c1d6Hc6yCg
> test:85FRBo8cHrAZc
> 
> the code after ":" is a MD5 key
> the FilesMatch mean that all files ending with .gif,.html,.. is restricted and
> .php is not.
> 
> in a php file you now can read the authentications from a user and compare it
> with the /usr/home/.htpasswd entrys.
> 
>...
>   if (!isset($PHP_AUTH_USER)) {
> // $PHP_AUTH_USER is empty ... no login
> header('WWW-Authenticate: Basic realm="My Private Stuff"');
> header('HTTP/1.0 401 Unauthorized');
> echo 'Authorization Required.';
> exit;
>   }
>   // If not empty, check authentication ...
>   else {
> if ($PHP_AUTH_USER==$username && $PHP_AUTH_PW==$mypasswd) {
>   echo "Your Login is OK";
> ?>
> ...
>  } else {
>   echo "wrong login !";
> }
>   }
> ?>
> 
> note that the the /usr/home/.htpasswd file must include all usernames and
> passwords as MD5. You can create a line of this file with:
> 
>echo "$username:".md5($mypasswd);
> ?>
> 
> maybe you also can use "mod_auth_db" ... but this is apache specific so
> take a look at http://httpd.apache.org/docs/mod/core.html


ups ... dont use the default md5() function cause it is not equal to that of
linux in .htpasswd files, use instead:



to generate a MD5 password


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] authentication

2003-02-04 Thread Goetz Lohmann
Goetz Lohmann schrieb:
> [EMAIL PROTECTED] schrieb:
> 
>>I don't think the process is an extra step at all. In fact, it's just a
>>trade off using one or the other. You can either login using php and a
>>database backend or just authenticate using .htaccess directives.
>>
> 
> 
> 
> 
>>On Mon, 3 Feb 2003, Chris Shiflett wrote:
>>
>>
>>
>>>>There is a way to supposedly do this by authenticating
>>>>a username and password through php first through such
>>>>methods as database lookups and then passing the
>>>>username and password through $PHP_AUTH_USER and
>>>>$PHP_AUTH_PW using the header() command to point to the
>>>>URL of the .htaccess protected directory but I have
>>>>never gotten it to work myself.
>>>
>>>The variables $PHP_AUTH_USER and $PHP_AUTH_PW are available
>>>to you when the user authenticates via HTTP basic
>>>authentication. Thus, the user has already had to type in
>>>the username and password into a separate window, which is
>>>what the original poster is trying to avoid.
>>>
>>>To then send the user to another URL and supply the
>>>authentication credentials in the URL itself just creates
>>>an unnecessary step.
>>>
>>>
> 
> 
> 
> In fact you could combine .htaccess AND $PHP_AUTH cause its
> all depending on apache. Apache is looking for the variables
> AUTH_USER and AUTH_PW ... not PHP ... PHP just send this via
> header() and the Apache result is copyd to PHP_AUTH.
> 
> That way you could use an PHP file to build the login page
> and an .htacces file to define the restrictions
> 
> use something like
> 
> 
>   require valid-user
> 
> 
> to restrict access to the specified files and note that the
> data of the .htpasswd must be the same as the user/password
> definitions of the database. Maybe you might use mod_auth_db
> instead of mod_auth.
> With  instead of  you only protect files
> not the way/method how to get them. With the line above
> all .html files are protected and .php files are not.
> In combination with  you could also make a
> special definition range ...
> 
> you only have to beware of the MD5 password ... use
> 
>$password=crypt($PHP_AUTH_PW,substr($PHP_AUTH_PW,0,2));
> ?>
> 
> to generate a password valid for an .htacces file


maybe take a look at

http://www.diegonet.com/support/mod_auth_mysql.shtml

;-)


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: restricting acces to files

2003-02-04 Thread Goetz Lohmann
Goetz Lohmann schrieb:
> Goetz Lohmann schrieb:
> 
>>Shams schrieb:
>>
>>
>>>Hi,
>>>
>>>i've written a secure PHP login script which will allow users to login to a
>>>directory such as this:
>>>
>>>smezone.com/members/index.php
>>>
>>>however, how do I restrict people from accessing HTML files in that
>>>directory (which they can easily do so by typing the URL into their
>>>browser), such as:
>>>
>>>smezone.com/members/document1.html
>>>
>>>?
>>>
>>>Since its a regular HTML files (and we have lots), I can't check whether the
>>>user has a valid session as I would do in a PHP file.
>>>
>>
>>
>>if you are using linux & apache ... just use a .htaccess file like the one below
>>
>>AuthUserFile /usr/home/.htpasswd
>>AuthName "Secret Area"
>>AuthType Basic
>>
>>  require valid-user
>>
>>
>>with this you restrict access only to users listet in the /usr/home/.htpasswd
>>files which look like
>>
>>user1:668c1d6Hc6yCg
>>test:85FRBo8cHrAZc
>>
>>the code after ":" is a MD5 key
>>the FilesMatch mean that all files ending with .gif,.html,.. is restricted and
>>.php is not.
>>
>>in a php file you now can read the authentications from a user and compare it
>>with the /usr/home/.htpasswd entrys.
>>
>>>  ...
>>  if (!isset($PHP_AUTH_USER)) {
>>// $PHP_AUTH_USER is empty ... no login
>>header('WWW-Authenticate: Basic realm="My Private Stuff"');
>>header('HTTP/1.0 401 Unauthorized');
>>echo 'Authorization Required.';
>>exit;
>>  }
>>  // If not empty, check authentication ...
>>  else {
>>if ($PHP_AUTH_USER==$username && $PHP_AUTH_PW==$mypasswd) {
>>  echo "Your Login is OK";
>>?>
>>...
>>>} else {
>>  echo "wrong login !";
>>}
>>  }
>>?>
>>
>>note that the the /usr/home/.htpasswd file must include all usernames and
>>passwords as MD5. You can create a line of this file with:
>>
>>>  echo "$username:".md5($mypasswd);
>>?>
>>
>>maybe you also can use "mod_auth_db" ... but this is apache specific so
>>take a look at http://httpd.apache.org/docs/mod/core.html
> 
> 
> 
> ups ... dont use the default md5() function cause it is not equal to that of
> linux in .htpasswd files, use instead:
> 
>$password=crypt($PHP_AUTH_PW,substr($PHP_AUTH_PW,0,2));
> ?>
> 
> to generate a MD5 password

maybe take a look at

http://www.diegonet.com/support/mod_auth_mysql.shtml

;-)


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] Which link was selected?

2003-02-04 Thread Goetz Lohmann
Leonard Burton schrieb:
> Good Catch,
> 
> Be just as an advisement besure to escape those quotes with a backslash \"
> 
> Leonard.
> 
> 

yes, you are right, but I also prefer the way of


  


instead of

";
  echo "";
  // do something here
?>

cause its easyer to change HTML code afterwards without hacking \" everywhere
and you could preview styles in browser if you looking for a file but that's
just freaky to discuss which one might be better ...

;-)




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Problem with include PHP 4.3.0

2003-02-04 Thread Goetz Lohmann
Jean-Pierre Gallou schrieb:
> Goetz Lohmann wrote :
> 
>> wich means that "testinclude.php" includes "inc/inc1.php"
>> and "inc/inc1.php" includes "inc/inc2.php" ?
> 
> 
> Right. I'm sorry, I didn't modify testinclude.php as you suggested, but
> inc1.php. With a modified testinclude.php:
>   
> I get:
>   Failed opening './inc/inc1.php' for inclusion \
>(include_path='.:..:/usr/local/php-4.3.0/lib/php')
> 
> Seems it doesn't like './' ("inc/inc1.php" is OK). I think that since
> the name begins with '.', PHP tries to find a file in the working dir,
> which is null (see below).

this is very strange cause I got it working with "./inc/inc1.php" and with
"inc/inc1.php" ... "/inc/inc1.php" fail cause its searching the file in the
server root ... also "inc1.php" will fail cause it searches it in the
working dir of testinclude.php ... did you set

doc_root = /usr/local/www/htdocs

than maybe leave this blank !

>> insert something like into inc1.php and inc2.php:
>>
>> >echo "inc included\n";
>>echo "\n";
>>$folder=dir('inc');
>>// print out folder "inc"
>>while($datei = $folder->read()) {
>>   echo "$datei\n";
>>}
>>$folder->close();
>>echo "\n";
>> ?>
> 
> 
> Unfortunately, this gives nothing. I guess this is because pathnames of
> files are relative to the working dir.

yes if the path not start with "/"

> There are only two variables,
> PATH and TZ in the environment of my Apache server, but nothing about a
> working dir: cwd() returns an empty string, and so does `pwd` or `ls`.
> Relative pathnames of included files are apparently resolved through a
> special way, unless they begin with '.' or '..'. But this is not clearly
> described in the documentation, and it's a bit confusing.

if a file is parsed, all include files a relativ to this parsed file.
with phpinfo() you could read the document root in the "PHP Variables"
section which might look like

PHP_SELF   /phpinfo.php
_SERVER["DOCUMENT_ROOT"]   /usr/local/www/htdocs
...
_SERVER["SCRIPT_FILENAME"] /usr/local/www/htdocs/phpinfo.php
_SERVER["SCRIPT_URI"]  http://www.yourdomain.com/phpinfo.php
...
_SERVER["PATH_TRANSLATED"] /usr/local/www/htdocs/phpinfo.php
...

a "." mean working dir and ".." mean parent dir

echo exec('ls');

should print out not a empty string but

testinclude.php

and

echo exec('pwd');

should print "/usr/local/www/htdocs/tests"




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Is there a way to retrieve an entire source code from a php file?

2003-02-04 Thread Goetz Lohmann
The New Source schrieb:
> What I want to know is if it is possible to retrieve a source code from a url, with 
>a php file.
> 
> Something like this:
> 
> There is a php file that retrieve the source code from the url www.url.com and this 
>source is treated and you get content from this file and show it on the response page.
> 
> Is this possible? Can anyone show me the right direction?
> 
> Rodrigo.
> 

if you wish to sniff other peoples code from their web site ... no way by
default ... and thats quite good, cause sometimes there are passwords
stored in plaintext.



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: iframes and php

2003-02-04 Thread Goetz Lohmann
Edward Peloke schrieb:
> there is a php page that uses an iframe...when I view the page at home, I
> see all of the contents of the iframe...when I view it at work some of the
> contents are wrapped...both of my screen resolutions are the same.  Why
> would this be?
> 
> Thanks,
> Eddie
> 

this depends on your browser ... cause PHP will always do the same thing if
you call it ... maybe you got another charset, another browser version,
another character style at work ... but thats not the fault of PHP ;-)

-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: HTML if no PHP

2003-02-04 Thread Goetz Lohmann
Bob Lockie schrieb:
> 
> I want to display an HTML page if PHP can't load an include file or
> otherwise has an error or just doesn't work.
> How do I do this?


if you using apache you could do this with an ErrorDocument line
which also is usefull to prevent the 404 error page.

take a look at:

http://httpd.apache.org/docs/mod/core.html#errordocument


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Help Needed

2003-02-04 Thread Goetz Lohmann
Pushpinder Singh Garcha schrieb:
> Hello All:
> 
> My question is related to authentication. I have made a login system
> using PHP Sessions and MySQL. Once the user gets authenticated on the
> website I want to be able to allow him to see some html pages on the
> website. Only users who have logged in are able to see such a files. I
> have asked this question before , but still I have some doubts.
> 
> My code will check for:
> 
> 
>   if (session_is_registered($valid_user))
> {
>   /// display the reqd page
> }
> 
> 
> else {
> 
> DISPLAY ERROR MESSAGE and ASK USER TO LOGIN
> }
> 
> 
> How should I display the page ... the page has a lot of html code and
> trying to write echo "   blah  blah blah . ";
> will not be a an option. Please suggest a way out .

you could include every page into a php script using



this mean, that this page is like being copyed in the php file

also instead of



you always can do


   bla bla bla





-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: How to get a certain line from a file

2003-02-04 Thread Goetz Lohmann
The New Source schrieb:
> How can I get a certain line from a file?
> 
> If I get a file in this way:
> 
> $f = fopen("http://www.url.com/index.htm","r";); 
> 
> How can I get a certain line of the file index.htm?
> 
> I would need to get the line number 232, or lines from 232 to 238. How can I get 
>this content?
> 
> Thanx.
> 
> Rodrigo
> 

http://www.url.com/index.htm";, "r");
  // go to line 232
  fseek($fp, $fromline);
  // how many lines to read ?
  $numlines=$tillline-$fromline;
  $i=0
  // read the lines
  while (!feof($fp) && $i<$numlines) {
$str[$i]=fgets($fp, $maxlength); // read line into Array
$i++; // next line
  }
  // now all lines from 232 till 238 are in the array $str[]
  ...
?>



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Question on PHP

2003-02-06 Thread Goetz Lohmann
Karthikeyan.Balasubramanian schrieb:
> Hi,
> 
>   I would like put this question directly to Rasmus creator of this
> wonderful server side scripting language.
> 
>   Is there a possibility with the future release of PHP to add extension in
> a easier manner.  For every feature client wants there is a recompile
> involved.
> 
>   Wouldn't this be much easier if we just compile the appropriate library
> and just point the directory through php.ini.
> 
>   In that way most of the hosting provider would have update to date
> version.
> 
>   I also like features of gefionsoftware's LiteWebServer wherein they
> provide an admin screen and it allows us to update to the latest version
> without
> pain.
> 
>   Here I am talking about both upgrading to latest version as well as adding
> extensions.
> 
>   Have a great day.
> 
> Karthikeyan B


that's ain't such easy as it seem cause every little linux box is a bit
different ... SUSE, Red Hat, FreeBSD ... but maybe you could use RPM
package to update your system which also tell you which modul is used
by another ... after all note

"never change a running system !"

if there are no needs (security bug) to be always near the developement
branch.


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] Client Side PHP

2003-02-06 Thread Goetz Lohmann
Php schrieb:
> PHP codes gets executed at the server (server side), so I wonder how you can
> make it to work at the client side?
> 
> But good thinking :)
> 
> huzz


Client Side PHP ? ... maybe you could ;-) ... you only have to install PHP on
your box. PHP is too mighty and huge to implement in the browser like JavaScript
or VBscript nor will M$ ever wan't to replace VB with PHP. But you have to use
a PHP system ruuning on your box to interpret the code. That way everybody who
want to use Client-Side PHP have to get the hole PHP system ... that's not the
point it will ever go so this is a dead end. And who realy needs it ?
The browsers and HTML lacks on other problems than on possibilys to manage
somethin with a good scripting tool.

;-)


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Config problems

2003-02-06 Thread Goetz Lohmann
Brian V Bonini schrieb:
> Been using PHP for some time but never have actually compiled my own,
> the version my provider compiled always sufficed, anyway, I
> I'm having some issues.

NOTE: once compiled, this PHP package runs without the include files,
cause they are "included" to the package. So you provider had freetype
version 2 and xpm installed, you might not have this.

> config fails here:
> 
> checking for GD support... yes
> checking for the location of libjpeg... yes
> checking for the location of libpng... yes
> checking for the location of libXpm... yes
> checking for FreeType 1.x support... yes
> checking for FreeType 2... yes
> checking for T1lib support... yes
> checking whether to enable truetype string function in GD... yes
> checking for jpeg_read_header in -ljpeg... yes
> checking for png_write_image in -lpng... yes
> If configure fails try --with-xpm-dir=
> configure: error: freetype2 not found!

... PHP is looking for freetype 2 (if realy needed ???)
^ note the version !

> %locate freetype
> /usr/local/include/freetype
> /usr/local/include/freetype/freetype.h
> /usr/local/include/freetype/fterrid.h
> /usr/local/include/freetype/ftnameid.h
> /usr/local/include/freetype/ftxcmap.h
> /usr/local/include/freetype/ftxerr18.h
> /usr/local/include/freetype/ftxgasp.h
> /usr/local/include/freetype/ftxgdef.h
> /usr/local/include/freetype/ftxgpos.h
> /usr/local/include/freetype/ftxgsub.h
> /usr/local/include/freetype/ftxkern.h
> /usr/local/include/freetype/ftxopen.h
> /usr/local/include/freetype/ftxpost.h
> /usr/local/include/freetype/ftxsbit.h
> /usr/local/include/freetype/ftxwidth.h
> /usr/local/include/freetype.h
> /var/db/pkg/freetype-1.3.1
> /var/db/pkg/freetype-1.3.1/+COMMENT
> /var/db/pkg/freetype-1.3.1/+CONTENTS
> /var/db/pkg/freetype-1.3.1/+DESC
> /var/db/pkg/freetype-1.3.1/+REQUIRED_BY

this is freetype version 1.3.1 !
if you relay need it you might get it from
http://www.rpmfind.net/linux/rpm2html/search.php?query=freetype2

> %locate xpm
> /usr/X11R6/bin/cxpm
> /usr/X11R6/bin/sxpm
> /usr/X11R6/include/X11/xpm.h
> /usr/X11R6/man/man1/cxpm.1.gz
> /usr/X11R6/man/man1/sxpm.1.gz
> /usr/share/man/man3/expm1.3.gz
> /usr/share/man/man3/expm1f.3.gz
> /var/db/pkg/xpm-3.4k
> /var/db/pkg/xpm-3.4k/+COMMENT
> /var/db/pkg/xpm-3.4k/+CONTENTS
> /var/db/pkg/xpm-3.4k/+DESC

that's not the xpm he is looking for ... try
%> locate Xpm
  ^ note the big X
and it should find something like:
/usr/X11R6/lib/libXpm.so
/usr/X11R6/lib/libXpm.so.4
/usr/X11R6/lib/libXpm.so.4.10
/usr/i386-glibc20-linux/lib/libXpm.so
/usr/i386-glibc20-linux/lib/libXpm.so.4
/usr/i386-glibc20-linux/lib/libXpm.so.4.10

if you haven't it but think you realy need it get it from:
http://www.rpmfind.net/linux/rpm2html/search.php?query=xpm

> Currently installed module (4.0.6) was configures with:
> 
>  './configure' '--with-apxs=/usr/local/www/bin/apxs'
> '--with-config-file-path=/usr/local/www/etc' '--enable-versioning'
> '--with-system-regex' '--disable-debug' '--enable-track-vars'
> '--with-gd=/usr/local' '--with-freetype-dir=/usr/local'
> '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-zlib'
> '--with-imap=/usr/local' '--with-mysql=/usr/local'
> '--with-imap=/usr/local' '--prefix=/usr/local/www' 'i386--freebsd4.4'
> 
> which is exactly what I'm trying to duplicate with the new install
> (4.3.0)
> 
> 
> Not sure what to do here...

Note: to compile he needs the .h (example "png.h" for PNG suppport)
from /usr/local/include (or whatever you told him) and the .so
modul like "libpng.so" out of /usr/lib (or whatever you told him) !

regards


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: upgrade issues

2003-02-06 Thread Goetz Lohmann
Brian V Bonini schrieb:
> What's wrong with this snippet of code that would make it stop working
> after upgrading from 4.0.6 to 4.3.0
> 
> 
>  
> if (!$id) {
> include "pagetop.inc.php";
> }
> if ($id == 1) {
> $title = "xxx";
> include "pagetop.inc.php";
> ?>
> Stuff
> 
> 
> 

look at http://www.php.net/manual/en/tutorial.oldcode.php

it is cause $id isn't set to the value of your uri anymore !
set "register_globals on" in your PHP.INI or use $_GET['id']


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: AYUDA..Actualizar txt

2003-02-06 Thread Goetz Lohmann
Rot Alvarez schrieb:
> Necesito saber como limpiar o actualizar txt . Resulta q he creado un chat en flash 
>y php, pero almacena los user y los comentarios en txt, lo malo es que tengo q 
>limpiarlos desde el server.q hago.
> 
> _
> Registra gratis tu cuenta email en http://www.exploraiquique.cl
> 
> _
> Select your own custom email address for FREE! Get [EMAIL PROTECTED] w/No Ads, 6MB, 
>POP & more! http://www.everyone.net/selectmail?campaign=tag

please post english and please wrap your lines at 80 characters !!!

-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] Re: Config problems

2003-02-06 Thread Goetz Lohmann
Brian V Bonini schrieb:
> On Thu, 2003-02-06 at 10:03, Goetz Lohmann wrote:
> 
>>Brian V Bonini schrieb:
>>
>>>Been using PHP for some time but never have actually compiled my own,
>>>the version my provider compiled always sufficed, anyway, I
>>>I'm having some issues.
>>
>>NOTE: once compiled, this PHP package runs without the include files,
>>cause they are "included" to the package. So you provider had freetype
>>version 2 and xpm installed, you might not have this.
>>
> 
> 
> I got it, thanks... I was just being lazy and did not want to have to
> install a newer freetype which also meant having to install GNU make
> because BSD make will not work to install freetype. Unfortunately after
> upgrading all my PHP sites stopped working, I suspect due to a change in
> syntax or perhaps just poor coding practices in the past
> 

everytime nice to help someone ;-)

the major change from 4.2.x to 4.3.x might be some security issues which
normaly prevent

http://my.domain.com/test.php?id=123


to work, which was most common in the past !
instead you have to use $_GET['id'] to go through but take a look at:

http://www.php.net/manual/en/tutorial.oldcode.php




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Stupid question, sorry...

2003-02-06 Thread Goetz Lohmann
Chris Boget schrieb:
> Why is it that \n gets translated to a _new line_ when in
> double quotes whereas it's displayed as the literal when
> in single quotes?  I checked out the docs but couldn't 
> come up with a definitive answer.  If someone could point
> me to the right page in the docs that explains this, I'd be
> ever so appreciative!
> 
> thnx,
> Chris
> 


all inside of "" will be interpreted instead of things
between '' will be as is ... and as "\n" means "New Line"
it will do this. If you wish to print out a "\n" then you
have to write it like "\\n".

This is true for all special characters like:
\n   - new line
\r   - carriage return
\t   - tab
\- escape sign for the special characters
\\   - backslash itself


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Solutions need for resizing images (Thumbnail) on the fly..

2003-02-06 Thread Goetz Lohmann
Geckodeep schrieb:
> Hi there I have this problem wondering how to define the size of my images.
> I have this page that has 9 images coming from the database. These images
> are uploaded into a folder and the names are referenced in the DB.
> I pull the image through these tags
>  src=\"$folder/$image1\">" ?>
> and it's ok if the images are rectangular with size 104 x 70,but how will I
> reduce the size of the image having the opposite size 70 x 104 rectangular
> but shorter in length.
> 
> Hard coding the size is not the solution for me as these images are coming
> straight from the DB with their actual size.
> 
> Having decided the sizes to be either 104 x 70 or 70 x 104, now the trouble
> is how to assignee these values dynamically judging the format of the image.
> 
> I've seen different script in resizing the images on the fly but couldn't
> adapt to my needs, as I've 9 image variables ($image1, $image2,..)already
> assigned and I am looking for scripts or solutions in resizing the images on
> the fly by assigning my 9image variables to the resize function.
> 
> Thanks once again.

its just mathematic ;-)

$width) {
 $new_h = $maxsize; // new height
 $new_w = (int) (($maxsize * $width) / $height); // casting to int !
  } else {
 $new_w = $maxsize; // new width
 $new_h = (int) (($maxsize * $height) / $width); // casting to int !
  }
  // resize image
  ImageCopyResized($thumb,$img,0,0,0,0,$new_w,$new_h,$w,$h);
  // new thumbnail is in $thumb
?>


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] php pages broken after moving to a newer version

2003-02-06 Thread Goetz Lohmann
Chip Wiegand schrieb:
> Jason Wong <[EMAIL PROTECTED]> wrote on 02/05/2003 09:38:48 PM:
> 
> 
>>On Thursday 06 February 2003 07:13, [EMAIL PROTECTED] wrote:
>>
>>
>>>>1) Read the changelog/history/release notes of all versions of php
>>>>between the
>>>>4.0.3 and up to 4.2.3
>>>>
>>>>2) Check the php log (turn on full error reporting).
>>
>>>The log is 23 pages long and doesn't to all the way back to
>>>4.0.3. Could you perhaps give me a hint as to something else to look 
> 
> for
> 
>>>in
>>>the log?
>>
>>OK, first you need to see what PHP is choking on. Only way to do 
>>that is to do 
>>(2) above. So once you know what errors PHP is giving out you do (1) to 
> 
> see 
> 
>>whether anything has changed to cause this behaviour.
> 
> 
> Okay, so I have turned on all the error handling options in 
> /usr/local/etc/php.ini-dist. I have purposely put an error in my 
> phpinfo.php
> page, it errors out in the browser, but no error log is created. My
> index.php page does not load and does not provide any errors. I set the
> error log to go into the /tmp directory, after trying /var/log and also
> my own home directory, it just will not be created in any of them.

change php.ini NOT php.ini-dist which not will be loaded !!!
and be sure you change the php.ini which is used (maybe there might be
more than one php.ini in your system but only one is use ... find this
out with phpinfo !)

[phpinfo.php]



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Solutions need for resizing images (Thumbnail) on the fly..

2003-02-06 Thread Goetz Lohmann
Goetz Lohmann schrieb:
> Geckodeep schrieb:
> 
>>Hi there I have this problem wondering how to define the size of my images.
>>I have this page that has 9 images coming from the database. These images
>>are uploaded into a folder and the names are referenced in the DB.
>>I pull the image through these tags
>>>src=\"$folder/$image1\">" ?>
>>and it's ok if the images are rectangular with size 104 x 70,but how will I
>>reduce the size of the image having the opposite size 70 x 104 rectangular
>>but shorter in length.
>>
>>Hard coding the size is not the solution for me as these images are coming
>>straight from the DB with their actual size.
>>
>>Having decided the sizes to be either 104 x 70 or 70 x 104, now the trouble
>>is how to assignee these values dynamically judging the format of the image.
>>
>>I've seen different script in resizing the images on the fly but couldn't
>>adapt to my needs, as I've 9 image variables ($image1, $image2,..)already
>>assigned and I am looking for scripts or solutions in resizing the images on
>>the fly by assigning my 9image variables to the resize function.
>>
>>Thanks once again.
> 
> 
> its just mathematic ;-)

UPS ... sorry ...
if using $height/$h and $width/$w I should it in the whole script ...

$w) {
 $new_h = $maxsize; // new height
 $new_w = (int) (($maxsize * $w) / $h); // casting to int !
  } else {
 $new_w = $maxsize; // new width
 $new_h = (int) (($maxsize * $h) / $w); // casting to int !
  }
  // resize image
  echo "newsize: $new_w x $new_h";
  // new thumbnail is in $thumb
?>

now that should do ! ;-)


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Solutions need for resizing images (Thumbnail) on the fly..

2003-02-06 Thread Goetz Lohmann
Geckodeep schrieb:
> Thanks Goetz
> 
> But how can I apply this having:
> 
> Path to the folder is $folder='images/repor_images';   // path to the
> image.
> 
> My 9image variables are $image1, $image2, $image3,. and the code to call the
> image
> 
>  src=\"$folder/$image1\">" ?>
> 
> Thanks again.

I should do coding the whole page I gues ;-)

First of all some things to mention about:
1. Better store only filenames in the database and leave
   the images in the directory, cause you have to copy then
   to a location anyway to get it by an browser
2. Use an array of $image[] instead of numbering them
   like $image1, $image2, ... (you have to use eval to
   work with the numbers or have to write the code more
   than once !)

Ok here it goes:

$w) {
$new_h = $maxsize; // new height
$new_w = (int) (($maxsize * $w) / $h); // casting to int !
  } else {
$new_w = $maxsize; // new width
$new_h = (int) (($maxsize * $h) / $w); // casting to int !
  }
  // build dummy image
  $thumb = imagecreate ($new_w, $new_h);
  // resize old image
  ImageCopyResized($thumb,$img,0,0,0,0,$new_w,$new_h,$w,$h);
  // maybe use tempname() to generate a temporary file name or
  // create name of thumbnail file like: *.jpg ==> *.png
  $tumbnail=substr($image[$nr],0,strrpos($image[$nr],".")).".png";
  // save png image to same directory as jpg
  @imagepng ($thumb,"$folder/$tumbnail"); // hope we could write
  // leave the temporary data ...
  ImageDestroy($img);
  ImageDestroy($thumb);
  // finished work
  // ---
  // show image
  echo "";
}
$nr++; // next image
  }
?>

maybe there might better ways but thats just a fast hack to work ...



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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