php-general Digest 25 Mar 2005 13:57:24 -0000 Issue 3358

2005-03-25 Thread php-general-digest-help

php-general Digest 25 Mar 2005 13:57:24 - Issue 3358

Topics (messages 211536 through 211561):

OR statement
211536 by: Marquez Design
211538 by: Tom Rogers
211541 by: Josh Whiting
211546 by: Philip Olson
211548 by: Joe Wollard

Re: Storing data structires in DB
211537 by: Joshua Beall

Game development approach
211539 by: Alexandre
211544 by: Robert Cummings
211545 by: Robert Restad
211558 by: maillists.morningstarcom.net

Re: Getting the process ID
211540 by: trlists.clayst.com
211542 by: Josh Whiting
211549 by: Rasmus Lerdorf

PHP4 and PHP5 in virtual Host
211543 by: Juan Pablo Herrera

rounding test fails when I try to make test
211547 by: Larry

Re: [semi OT]: Planning projects
211550 by: kamen 123

Download Link !
211551 by: AN.S
211553 by: Ken
211560 by: maillists.morningstarcom.net

Re: How can I destroy  parameters  by page
211552 by: listas.uakari.com
211554 by: Colin Ross

Re: Pagination
211555 by: Colin Ross

Where is php installed on linux
211556 by: Merlin
211557 by: Jason Wong

Re: Problem with header in an if
211559 by: Jay Blanchard

header(Location: page.php target=_parent)?
211561 by: Jacques

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
php-general@lists.php.net


--
---BeginMessage---
Hello,

I would like to first thank everyone for their help with the last few
questions I have had. I really appreciate it.

Here is my question:

 if ($audio == Cool){

Do this

}else{

Do that

}

This work fine, however, I would like to add to the criteria above. I would
like to say:

 if ($audio == Cool or junk or funky){

...

I have tried to look for something in the manual, and am still looking, but
a little help on this would be appreciated.

Thank you again,

--
Steve Marquez
---End Message---
---BeginMessage---
Hi,

Friday, March 25, 2005, 11:27:30 AM, you wrote:
MD Hello,

MD I would like to first thank everyone for their help with the last few
MD questions I have had. I really appreciate it.

MD Here is my question:

MD  if ($audio == Cool){

MD Do this

MD }else{

MD Do that

MD }

MD This work fine, however, I would like to add to the criteria above. I would
MD like to say:

MD  if ($audio == Cool or junk or funky){

MD ...

MD I have tried to look for something in the manual, and am still looking, but
MD a little help on this would be appreciated.

MD Thank you again,

MD --
MD Steve Marquez

The most easily expandable way is with a switch statement

switch($audio){
  case 'Cool':
  case 'junk':
  case 'funky':
Do this
  break;
  default:
Do that
  break;
}

-- 
regards,
Tom
---End Message---
---BeginMessage---
 This work fine, however, I would like to add to the criteria above. I would
 like to say:
 
  if ($audio == Cool or junk or funky){
 
 ...
 

if (in_array($audio,array(Cool,junk,funky))) {
...
}

not the most elegant looking but it gets the job done.

/josh w
---End Message---
---BeginMessage---
  This work fine, however, I would like to add to the criteria above. I would
  like to say:
  
   if ($audio == Cool or junk or funky){
  
  ...
  
 
 if (in_array($audio,array(Cool,junk,funky))) {
 ...
 }
 

Yes that's one way but to answer the question:

 if ($a == 'foo' OR $a == 'bar') {


Regards,
Philip
---End Message---
---BeginMessage---
This can also be done with double pipes, which is what is used in many 
other languages.
-
if($audio==Cool || $audio==junk || $audio==Funky){
Do this
} else{
Do this
}
--
As far as I can tell there are no plans to remove or reason to favor one 
method or the other, so it's just a matter of preference.

Philip Olson wrote:
This work fine, however, I would like to add to the criteria above. I would
like to say:
if ($audio == Cool or junk or funky){
...
 

if (in_array($audio,array(Cool,junk,funky))) {
...
}
   

Yes that's one way but to answer the question:
if ($a == 'foo' OR $a == 'bar') {
Regards,
Philip
 

---End Message---
---BeginMessage---
Joshua Beall [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 You should look into the WDDX functions - http://php.net/wddx/ - they give 
 you an XML document that you can edit by hand much more easily than the 
 bytestream you get from serialize.  However it is not as compact as 
 serialize, and not only that it suffers from what I consider a showstopped 
 bug.

er, make that showstopper... 
---End Message---
---BeginMessage---
Hi there,
I'm developing an online game (using PHP+MySQL, and being totally interfaced via 
web) which needs to have a game cycle running. For example, the player is 
flying a 

RE: [PHP] [semi OT]: Planning projects

2005-03-25 Thread kamen 123
Hello

For planning project I like simplistic design and scalability.
I describe business objects involved in the project and the processes
between them with plain text and schemas. Discuss them with the client. When he 
confirms these documents I write code according to this functional design/plan.

-
http://gbg.bg/search --  !

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



[PHP] Download Link !

2005-03-25 Thread [EMAIL PROTECTED]
Hello,
When I purchased a website template from templatemonster.com, they sent 
the download link to my email, this link was active for only 2 or 3 days 
then it became inactive.

Now I'm writing a script for selling website templates, the templates 
are uploaded to a certain folder, when someone buys a template a 
download link must be sent to his/her email address, and must  be active 
for only 2 or 3 days..

Anyone have an idea how to start or where to start?
Any link, any tutorial?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] How can I destroy parameters by page

2005-03-25 Thread [EMAIL PROTECTED]
Use unset()
unset($_GET['item']);
unset($_GET['ac2']);
if you want to destroy the value and its name in the same $_GET array.
or unset($item); if you want to destroy another variable, not related to 
$_GET

You can use the same with $_POST...
Devta.
IHow Can I destroy some variable that I pass by url, exmple:
http://webadmin/paginas/personalidades.php?ac2=deleteitem=18#
then when i get the varibale ac2 and item, I want to delete the value of
this variable.
how can I do?

___
Yahoo! Messenger - Nueva versión GRATIS
Super Webcam, voz, caritas animadas, y más...
http://messenger.yahoo.es
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Download Link !

2005-03-25 Thread Ken
On Fri, 25 Mar 2005 11:25:09 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] 
wrote:
 Hello,

 When I purchased a website template from templatemonster.com, they sent
 the download link to my email, this link was active for only 2 or 3 days
 then it became inactive.

 Now I'm writing a script for selling website templates, the templates
 are uploaded to a certain folder, when someone buys a template a
 download link must be sent to his/her email address, and must  be active
 for only 2 or 3 days..

 Anyone have an idea how to start or where to start?
 Any link, any tutorial?

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




A quick outline:

when a user purchases something, enter an unique string (try
md5(microtime()) although it's not completely unique) into the
database.

make a script that verifies the string...
verify.php?unique=12345user=johndoe

in verify.php you'd have something that compares $_GET['unique'] to
the database value, same with $_GET['user']

Then if that's good, send the download link. However, I would use
headers for downloads. By doing this you can place your template files
outside your web directory, which will make it more secure, obviously.

if you know how to use pear then i suggest using http_download. if you
don't, have a look at the fpassthru bit in the manual.

http://www.php.net/fpassthru

hth... it was a bit too simple but you have the general idea now :D

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



Re: [PHP] How can I destroy parameters by page

2005-03-25 Thread Colin Ross
on a side note, for devs, i don't really like how you can override the
values of the $_GET (or $_POST) array, seems like it could be a
security threat. Also, with that ability, you can never tell
(especially if you are making a mod, etc for a larger system) if what
your dealling with is the ACTUAL $_GET vars or something injected
later in the code.


On Fri, 25 Mar 2005 10:35:30 +0100, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Use unset()
 
 unset($_GET['item']);
 unset($_GET['ac2']);
 
 if you want to destroy the value and its name in the same $_GET array.
 
 or unset($item); if you want to destroy another variable, not related to
 $_GET
 
 You can use the same with $_POST...
 
 Devta.
 
 IHow Can I destroy some variable that I pass by url, exmple:
 http://webadmin/paginas/personalidades.php?ac2=deleteitem=18#
 then when i get the varibale ac2 and item, I want to delete the value of
 this variable.
 how can I do?
 
 
 ___
 
 Yahoo! Messenger - Nueva versión GRATIS
 
 Super Webcam, voz, caritas animadas, y más...
 
 http://messenger.yahoo.es
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] Pagination

2005-03-25 Thread Colin Ross
watch out for SQL injection attacks on that one though:

what if the 'user' went to page.php?start=1;SELECT * from `mysql`;


On Thu, 24 Mar 2005 22:55:01 +0100, pavel [EMAIL PROTECTED] wrote:
  I am wanting to paginate records from a MySQL Database.
  I want there to be 5 records on a page, on multiple pages.
 
 example for selecting page of records from mysql table:
 $sql=sprintf(
 SELECT SQL_CALC_FOUND_ROWS * FROM table LIMIT %d, %d,
 $position*$records,
 $records
 );
 
 after get count of all records:
 $sql='SELECT FOUND_ROWS()';
 
  (I would like there to be a next and previous.)
 
 you can use http://pear.php.net/package/Pager
 
 --
 Pavel Vrany
 http://ogi.cz/
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



[PHP] Where is php installed on linux

2005-03-25 Thread Merlin
Hi there,
I want to install Turck MMCasche. The install instructions say that the path to 
the php install has to be declared. Now I was searching the linux system for the 
php install but could not find it! It is compiled as a module and there is a 
file /usr/local/bin/php but no directory.

The instructions read:
Step 1. Compiling Turck MMCache
  export PHP_PREFIX=/usr
  $PHP_PREFIX/bin/phpize
  ./configure --enable-mmcache=shared 
--with-php-config=$PHP_PREFIX/bin/php-config
  make
You must specify the real prefix where PHP is installed in the export command. 
It may be /usr /usr/local, or something else.

Can anybody point me into the right [dir]ections?
Thank you in advance,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Where is php installed on linux

2005-03-25 Thread Jason Wong
On Friday 25 March 2005 19:03, Merlin wrote:

 I want to install Turck MMCasche. The install instructions say that the
 path to the php install has to be declared. Now I was searching the
 linux system for the php install but could not find it! It is compiled
 as a module and there is a file /usr/local/bin/php but no directory.

 The instructions read:

 Step 1. Compiling Turck MMCache

export PHP_PREFIX=/usr
$PHP_PREFIX/bin/phpize
./configure --enable-mmcache=shared
 --with-php-config=$PHP_PREFIX/bin/php-config make

 You must specify the real prefix where PHP is installed in the export
 command. It may be /usr /usr/local, or something else.

In your case you have to set PHP_PREFIX to '/usr/local', and before you 
can proceed you must make sure you have the file '/usr/local/bin/phpize'.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Game development approach

2005-03-25 Thread maillists
On Tuesday 22 March 2005 21:13, Alexandre wrote:
 Hi there,

 I'm developing an online game (using PHP+MySQL, and being totally
 interfaced via web) which needs to have a game cycle running. For
 example, the player is flying a plane, so he sets the plane speed to 10%,
 then the game cycle needs to keep moving the plane forward (i.e. updating
 position), while the player doesn't order it a full stop. The point is how
 to implement this game cycle?

 I've done some research on the web and haven't found a feasible approach to
 this idea.

 Thanks in advance for any help.

 []s
 Alex

I am no expert and someone may have already answered you.

I would try C, JavaScript, PostgreSQL (instead of MySQL), and XML along with 
your PHP

-- 
Win a Vespa Scooter or a Dell Gift Card worth $3,000.00
http://www.morningstarcom.net/raffle-contest.php

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

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



RE: [PHP] Problem with header in an if

2005-03-25 Thread Jay Blanchard
[snip]
   /* send the errors to the interface and exit*/
   if('' !== $errorsReported){
   for($i = 0; $i  count($errorsReported); $i++){
   echo $errorsReported[$i];
   }
unset($errorsReported);
print_r($errorsReported);
   } else {
   /* reload the empty interface */

a quick echo statement here to check that this block is running when
you expect it to might tell you something... but you have probably
already plastered your code with echo/print statements to determine the
flow :-)
[/snip]

Well, the array still appears, it is empty  and unset (see modified code
above) does not get rid of it. Here is how it comes back 
Array ( [0] = [1] = [2] = [3] = ) 

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



Re: [PHP] Download Link !

2005-03-25 Thread maillists
On Friday 25 March 2005 14:25, [EMAIL PROTECTED] wrote:
 Hello,

 When I purchased a website template from templatemonster.com, they sent
 the download link to my email, this link was active for only 2 or 3 days
 then it became inactive.

 Now I'm writing a script for selling website templates, the templates
 are uploaded to a certain folder, when someone buys a template a
 download link must be sent to his/her email address, and must  be active
 for only 2 or 3 days..

 Anyone have an idea how to start or where to start?
 Any link, any tutorial?

http://www.oscommerce.com has what you need.

-- 
Win a Vespa Scooter or a Dell Gift Card worth $3,000.00
http://www.morningstarcom.net/raffle-contest.php

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

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



[PHP] header(Location: page.php target=_parent)?????

2005-03-25 Thread Jacques
How should I formulate the header function to replace the current frameset 
page with a new one?  I have tried a combination of header(Location: 
page.php target=_parent); but I get an error message saying the page does 
not exist.

Also, can I save a frameset page with a .php extension?  I have tried it out 
and it seems to work.  Maybe perhaps I should not do this as there  may be 
some implications later on???

Regards

Jacques 

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



Re: [PHP] header(Location: page.php target=_parent)?????

2005-03-25 Thread maillists
On Friday 25 March 2005 08:57, Jacques wrote:
 Also, can I save a frameset page with a .php extension?  I have tried it
 out and it seems to work.  Maybe perhaps I should not do this as there  may
 be some implications later on???

I have not had any problems with .php ext frameset pages.  I have had 3 
different sites set up this way for about a year an no problems.

-- 
Win a Vespa Scooter or a Dell Gift Card worth $3,000.00
http://www.morningstarcom.net/raffle-contest.php

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

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



Re: [PHP] header(Location: page.php target=_parent)?????

2005-03-25 Thread Brian V Bonini
On Fri, 2005-03-25 at 08:57, Jacques wrote:
 How should I formulate the header function to replace the current frameset 
 page with a new one?  I have tried a combination of header(Location: 
 page.php target=_parent); but I get an error message saying the page does 
 not exist.
 
 Also, can I save a frameset page with a .php extension?  I have tried it out 
 and it seems to work.  Maybe perhaps I should not do this as there  may be 
 some implications later on???


'header' send raw http headers of which 'target' is NOT a part of. Use
plain html to do it ot post a better description of what your trying to
do. Surely there is a way to accomplish it but perhaps not along the
same lines of thought your current pursing.


-- 

s/:-[(/]/:-)/g


BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

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



Re: RES: [PHP] Game development approach

2005-03-25 Thread Alexandre
Robert Restad wrote:
I suggest you write a 'tick' engine, which i.e. games like Planetarion
use.
This should be written in C or C++, compiled... You can run this using
PHP of course, and run it from command line/shell, but PHP isnt ideal
for this. If you have a decent server and not too much players (i.e.
more than a hundred simultaneous players), then PHP will do. Any more
than this, and I doubt PHP can handle without choking the server.
Hello Robert,
First thanks for your answer and your help. I would like to explore this concept 
of using the PHP. I mean, I've already coded some small games in C++, and 
implementing a game loop is kinda easy, since you have the control of all the 
data being processed. But PHP scripts, as I currently know of, are only run when 
requested by the client, and the when they finish execution then they're gone. I 
never tried, but could it be done a game loop in PHP? I mean like a script I 
would start and it would keep running constantly, checking for new commands in a 
queue, updating objects status, can it be done or the server would kill it?

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


RE: RES: [PHP] Game development approach

2005-03-25 Thread Jay Blanchard
[snip]
First thanks for your answer and your help. I would like to explore this
concept 
of using the PHP. I mean, I've already coded some small games in C++,
and 
implementing a game loop is kinda easy, since you have the control of
all the 
data being processed. But PHP scripts, as I currently know of, are only
run when 
requested by the client, and the when they finish execution then they're
gone. I 
never tried, but could it be done a game loop in PHP? I mean like a
script I 
would start and it would keep running constantly, checking for new
commands in a 
queue, updating objects status, can it be done or the server would kill
it?
[/snip]

You can set a while(TRUE) loop. Here is an example of one that I use to
monitor a condition in a database and update an IFRAME. This has a 10
second sleep cycle.

while(TRUE){
$getNotesCount = SELECT COUNT(*) AS entries FROM test.tblTNotes
;
if(!($dbNotesCount = mysql_query($getNotesCount, $dbc))){
echo mysql_error() . \n;
exit();
}
$value = mysql_fetch_array($dbNotesCount);
$newValue = $value['entries'];
if(!(isset($currentValue)) || ($currentValue != $newValue)){
$currentValue = $newValue;
?
form name=foo action=stateTestData.php
method=POST target=bottomFrame
/form
script language=javascript
foo.submit();
/script
?php
flush();
ob_end_flush(); 
}
sleep(10);
} 

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



Re: [PHP] Game development approach

2005-03-25 Thread Alexandre
Robert Cummings wrote:

Javascript. And perhaps use XmlHttpRequest to synchronize the game cycle
with your web server from time to time. Or if the pages are being
submitted, you can just synchronize at that time.
Hi Rob, thanks for your answer. Let me see if I got it right, I would use 
javascript to be run on the client as to time the cycle and request the update 
to the server, that would run the cycle. The XMLHTTPrequest would be used to 
keep all the requests synchronized, so that one player can't get an update 
berfore the cycle time is counted, and hence all players get the updates at the 
same time. Is it so?

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


Re: RES: [PHP] Game development approach

2005-03-25 Thread Üstündað
Check PHP-CLI ( Command line interface )
You can run php script without client request. For
example :

/usr/local/bin/php -f /path_of_your_script/game.php
arg1 arg2 


--- Alexandre [EMAIL PROTECTED] wrote:
 Robert Restad wrote:
  I suggest you write a 'tick' engine, which i.e.
 games like Planetarion
  use.
  
  This should be written in C or C++, compiled...
 You can run this using
  PHP of course, and run it from command line/shell,
 but PHP isnt ideal
  for this. If you have a decent server and not too
 much players (i.e.
  more than a hundred simultaneous players), then
 PHP will do. Any more
  than this, and I doubt PHP can handle without
 choking the server.
  
 
 Hello Robert,
 
 First thanks for your answer and your help. I would
 like to explore this concept 
 of using the PHP. I mean, I've already coded some
 small games in C++, and 
 implementing a game loop is kinda easy, since you
 have the control of all the 
 data being processed. But PHP scripts, as I
 currently know of, are only run when 
 requested by the client, and the when they finish
 execution then they're gone. I 
 never tried, but could it be done a game loop in
 PHP? I mean like a script I 
 would start and it would keep running constantly,
 checking for new commands in a 
 queue, updating objects status, can it be done or
 the server would kill it?
 
 Kind regards,
 Alex
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



[PHP] Meta HTTP refresh problem

2005-03-25 Thread John Vaughan
Recently, during a rewrite of my login page, the Meta Refresh I am using 
suddenly stopped working. I've tried using it by echoing it with php and 
by just using it in HTML. I've also tried using a javascript redirect 
with no luck either. Any thoughts on how to debug and what might be 
holding me up?

Thanks for the help. -John
The code for the refresh:
echo META HTTP-EQUIV=REFRESH CONTENT=\0;URL=main_page.php\;
I know that the refresh is actually being sent to the browser because I 
can read it in the HTML source of the output page and can see the test echo.

I also know that it isn't an issue with my configuration, because I am 
using a meta http refresh on other pages that are working fine.  I am 
running php 4.3.7 on Apache 2.0.49

Here's the entire code for my login page:
?php
/*
* login.php - Authenticates user. Usernames and passwords are stored
* in a MySQL database called 'compass'. The table that contains this 
information is
* called 'users'
*
* sessionn_start(); MUST be the very first line of the program
* or else an error will be generated. This is a PHP specification.
*/
session_start();
header(Cache-control: private); //IE 6 Fix
$_SESSION['sessionUserId'] = ;

//This function simply prints out the login screen
function printLogin() {
echo centerCompass Project/center;
echo brbr;
echo center;
echo table;
echo form method=\POST\ action=\login.php\;
echo tr class=\login\;
echo td class=\login\Username: /tdtdinput type=\text\ 
name=\userName\ value=\\ size=20/td;
echo /tr;
echo tr class=\login\;
echo td class=\login\Password: /tdtdinput type=\password\ 
name=\password\ value=\\ size=20
/td;
echo /tr;
echo tr class=\login\td/tdtd align=\center\input 
type=\submit\ name=\login\ value=\Login
\/td/tr;
echo /form;
echo /table;
echo /center;
}

//Include template head
include_once 'templateHead.php';
//Check to see if the user submitted a login
if(isset($_POST[userName])){
//Get PEAR DB
require_once 'dbCompassConnect.php';
//Fetch the user's credintials and check their password
$postUserName = $_POST[userName];
$user = $db-getRow(SELECT user_id, user_name, password, template, 
first_access FROM users WHERE user_name = '$p
ostUserName');

$myUserId = $user[0];
$myUserName = $user[1];
$myPassword = $user[2];
$myTemplate = $user[3];
//Check to see if password matches
if ($_POST[password] == $myPassword){
//Store myUserId and myTemplate for use in my session
$_SESSION['sessionUserId'] = $myUserId;
$_SESSION['myTemplate'] = $myTemplate;
//Test to see if you actually got to this part
echo You should be going somewhere!;
echo META HTTP-EQUIV=REFRESH CONTENT=\0;URL=main_page.php\;
} else {
printLogin();
echo brcenterInvalid username/password/center;
}
}else{
printLogin();
}
//Include the tail template
include_once 'templateTail.php';
?
. . . . . . . . . .
My dbCompassConnect.php file:
?php
//Get PEAR DB
require 'DB.php';
//Make the connection - username and password are fake for security
$db = DB::connect('mysql://username:[EMAIL PROTECTED]/compass');
//Check for database connection errors
if (DB::isError($db)) { die(Can't connect:  . $db-getMessage()); }
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: RES: [PHP] Game development approach

2005-03-25 Thread maillists
On Friday 25 March 2005 09:37, Alexandre wrote:
 I mean like a script I would start and it would keep running
 constantly, checking for new commands in a queue, updating objects status,
 can it be done or the server would kill it?

 Kind regards,
 Alex

PHP is server script and you would need a client script to keep the commands 
running.  JavaScript and PHP together might do it.  You could use the 
JavaScript to keep executing the PHP script.

-- 
Win a Vespa Scooter or a Dell Gift Card worth $3,000.00
http://www.morningstarcom.net/raffle-contest.php

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

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



RE: RES: [PHP] Game development approach

2005-03-25 Thread Jay Blanchard
[snip]
Pretty interesting, Jay. So you have this script running as others
interface 
with all the other stuff in the site? Just another question, you start
it via 
web like a common script, but it is only accessed by you and it keeps on

running? The server doesn't kill it if it keeps running indefenitly?
[/snip]

Yes it runs as others interface the site. I start it from an IFRAME that
is 1px by 1px in the interface of the connected user so that the user
cannot see it. When the interface goes away the script is killed. You
could use it to check your server side game clock and update as
required. I also like the JavaScript approach that Robert has written
about.

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



[PHP] header already sent problem

2005-03-25 Thread AndreaD
is there an alternative way to suppress the headers already sent problem? 
Ob_start/flush is not very neat way to so this.

AD 

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



Re: [PHP] Game development approach

2005-03-25 Thread Robert Cummings
On Fri, 2005-03-25 at 09:44, Alexandre wrote:
 Robert Cummings wrote:
  
  Javascript. And perhaps use XmlHttpRequest to synchronize the game cycle
  with your web server from time to time. Or if the pages are being
  submitted, you can just synchronize at that time.
 
 Hi Rob, thanks for your answer. Let me see if I got it right, I would use 
 javascript to be run on the client as to time the cycle and request the 
 update 
 to the server, that would run the cycle. The XMLHTTPrequest would be used to 
 keep all the requests synchronized, so that one player can't get an update 
 berfore the cycle time is counted, and hence all players get the updates at 
 the 
 same time. Is it so?

Well generally you will have many more clock cycles than can possibly be
fed by the PHP script on the server, but at the same time you want to
ensure that all your players are fairly equal. So using javascript to
produce the clock cycles on the client side will give you the
granularity you'll probably need, then every 10, 30, 60 seconds (or
whatever is necessary you can fire off an XmlHttpRequest in the
background to do things like synchronize the client's clock with the
server, and to retrieve any other information that might be important
(perhaps other plane positions, other players, chat channels, etc. Other
plane positions would probably require fairly short update intervals so
you could test for collisions. The XmlHttpRequest object will not ensure
that all players get an update at the same time, since you can't ensure
data reaches the client at the same time regardless of whether you
synchronize the requests on the server.

HTH,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] mySQL outputting XML

2005-03-25 Thread Chris Boget
If you use the mysql command line tool, you can pass
the -X parameter so that all results will be returned in
XML format.  Is there an easy way to do that in PHP
using the native mysql_*() functions w/o having to
manually generate the XML using the result set?  Or
does anyone know if this is possible using PEAR?  I
looked at the PEAR docs and it doesn't seem to be
possible but I could have missed something.

thnx,
Chris

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



RE: [PHP] Problem with header in an if

2005-03-25 Thread Jay Blanchard
[snip]
   /* send the errors to the interface and exit*/
   if('' !== $errorsReported){
   for($i = 0; $i  count($errorsReported); $i++){
   echo $errorsReported[$i];
   }
unset($errorsReported);
print_r($errorsReported);
   } else {
   /* reload the empty interface */


Well, the array still appears, it is empty  and unset (see modified code
above) does not get rid of it. Here is how it comes back 
Array ( [0] = [1] = [2] = [3] = ) 
[/snip]

The $errorsReported array does not test as 'empty', it only has no
values. There are 4 keys set, so what I have to do is figure out how to
not set them.

/* check for errors */
$arrCheckItems = array( 
'Name',
'Dept',
'Level',
);
/* check for blanks */
foreach($_POST AS $key=$value){
if(in_array(niceName($key), $arrCheckItems)){
$errorsReported[] = notBlank($key, $value);
} 
}

Even if the return from notBlank is nothing, $errorReported[] gets set
for each item passed in the foreach loop. I have tried using conditional
returns in the function, but to no avail. Perhaps my logic is screwed on
this.

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



[PHP] Array problem

2005-03-25 Thread virtualsoftware
Hi,
I have a form like this:
form action=products.php method=post
input name=position[pos][value 1]  type=text  id=position[pos][value 1]  
value=number 1
input name=position[pos][value 2]  type=text  id=position[pos][value 2]  
value=number 2
input name=position[pos][value 3]  type=text  id=position[pos][value 3]  
value=number 3
/form

For each element of the array i want to update the value in the database. For 
example, for position[pos][value 1] i want to update the value (number 1) in 
the database.

Thanks in advance for your help!!!

[PHP] modules

2005-03-25 Thread Cima
hi,

im building a web site and i have seen some sites built using modules to 
facilitate further maintainance. by modules im referring to having a module for 
administrating the web site , another for searchs to be done, another for 
reports to be generated ect. i hope im explaining my self. 

what i would like are references to documentation on how to build such a web 
site using php (im working php 4).

thanx.


[PHP] Re: Re: Getting the process ID

2005-03-25 Thread Joshua Beall
 But a double-submit is likely to come from separate Apache  processes, so 
 I don't see where the pid comes into the picture.  If I reload a page and 
 resend the post data, that POST request is going to be  processed a second 
 time most likely by a different httpd process.  What  you need to do is 
 put a unique (you can use the uniqid function) in the actual transaction 
 data and not allow the transaction if that token is already  present in 
 your datastore.

I'm with you so far, but here is the problem I am having.  Let me preface 
this by saying that, in retrospect, I did not solve this problem as 
elegantly as I should have.  At any rate, let P1 and P2 represent separate 
parallel transactions.  $key is the same in both processes.

P1: Does token.status = 'locked' WHERE key=$key ?
P2: Does token.status = 'locked' WHERE key=$key ?
P1: {Receives negative response}
P2: {Receives negative response}
P1: Updates token.status. = 'locked' WHERE key=$key
P2: Updates token.status. = 'locked' WHERE key=$key
P1: Processes transaction
P2: Processes transaction

Now in retrospect this was not the simplest way to do it, but it worked (and 
here is where PID comes in): After P1 inserts the token in the database, it 
checks again to see that it is inserted *and* that it is the owner (token 
has a field for owner).  Like this:

P1: Updates token.status = 'locked'  owner=getmypid() WHERE key=$key  
owner = ''
P2: Updates token.status = 'locked'  owner=getmypid() WHERE key=$key  
owner = ''
P1: Checks to see if token is locked and P1 is owner.  If not, abort.
P2: Checks to see if token is locked and P2 is owner.  If not, abort.

Now, whichever one of these exectues first will get the token.  The other 
will abort.

But you see that I need the PID (or some other unique identifier) so that 
the script can identify itself, otherwise P1 and P2 might both in parallel 
attempt to lock the token, and both would appear to have received the lock.

At any rate, I am realizing now as I talk this through that there were other 
simpler methods for doing what I needed.  Oh well.  But for now I solved the 
problem as described above.

Thanks for the input.  When I got in to PHP I didn't anticipate carrying on 
a casual conversation with the guy who invented it!

  -Josh 

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



Re: [PHP] Meta HTTP refresh problem

2005-03-25 Thread Josh Whiting
 Recently, during a rewrite of my login page, the Meta Refresh I am using 
 suddenly stopped working. I've tried using it by echoing it with php and 
 by just using it in HTML. I've also tried using a javascript redirect 
 with no luck either. Any thoughts on how to debug and what might be 
 holding me up?
[snip]
 //Test to see if you actually got to this part
 echo You should be going somewhere!;
 echo META HTTP-EQUIV=REFRESH CONTENT=\0;URL=main_page.php\;
 } else {
 printLogin();
 echo brcenterInvalid username/password/center;
 }

META tags have to go in the HEAD section of the HTML document.

this is an optional suggestion but, overall, one thing that would be
better is to determine (before you send any ouput) if the login was
correct or not, and if not, use an HTTP redirect:

if (bad login) {
  header(Location: http://mydomain.com/login.php?tryAgain=1;);
} else {
  header(Location: http://mydomain.com/mainpage.php;);
}

(the tryAgain=1 is to tell the script that you want to show a  
login failed, please try again message)

using a redirect instead of a meta refresh is more user friendly because
(1) it's faster since some browsers force a waiting period before the
refresh happens (as a usability feature), and (2) the user can use
back/forward without running into the this page contains POST data, do
you want to resend it? alert, which I avoid in my designs like the 
plague (always using a redirect instead of showing output as the result 
of a POST action).

HTH
/josh w

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



Re: [PHP] header(Location: page.php target=_parent)?????

2005-03-25 Thread Josh Whiting
 How should I formulate the header function to replace the current frameset 
 page with a new one?  I have tried a combination of header(Location: 
 page.php target=_parent); but I get an error message saying the page does 
 not exist.

 Also, can I save a frameset page with a .php extension?  I have tried it out 
 and it seems to work.  Maybe perhaps I should not do this as there  may be 
 some implications later on???

you cannot replace the main frameset using HTTP headers in the
individual frame pages.  HTTP headers do not allow for this because
frames are a feature of HTML, not HTTP. therefore you must use HTML or
javascript techniques to get a single frame to change the overall
frameset.

however, for what it's worth, you can replace the main framset using a
header in the main frameset page itself, if you make that a php script
and use the header() function. (which means the answer to your second
question is yes)

/jw

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



[PHP] redirection, same host, two domains

2005-03-25 Thread Alexandru Martin
   Okay, here is my problem. I had a site hosted on a sub domain 
(mysite.domain.com) , now I registered my own domain, mysite.com . The 
thing is mysite.com is still hosted on mysite.domain.com. What i want to 
do is :  If people type in their browsers mysite.domain.com redirect to 
mysite.com and if they type mysite.com to display the page.
   I'm guessing it should be something like this : if ( refferer = 
mysite.domain.com ) { redirect to mysite.com } else { my html code }

P.S:  I need this because I don't want google to think it's a duplicate 
site.

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


Re: [PHP] redirection, same host, two domains

2005-03-25 Thread maillists
On Friday 25 March 2005 11:36, Alexandru Martin wrote:
 Okay, here is my problem. I had a site hosted on a sub domain
 (mysite.domain.com) , now I registered my own domain, mysite.com . The
 thing is mysite.com is still hosted on mysite.domain.com. What i want to
 do is :  If people type in their browsers mysite.domain.com redirect to
 mysite.com and if they type mysite.com to display the page.
 I'm guessing it should be something like this : if ( refferer =
 mysite.domain.com ) { redirect to mysite.com } else { my html code }

This probably would be better accomplished through apache and DNS

-- 
Win a Vespa Scooter or a Dell Gift Card worth $3,000.00
http://www.morningstarcom.net/raffle-contest.php

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

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



RE: [PHP] Problem with header in an if SOLVED

2005-03-25 Thread Jay Blanchard
[snip]
/* check for errors */
$arrCheckItems = array( 
'Name',
'Dept',
'Level',
);
/* check for blanks */
foreach($_POST AS $key=$value){
if(in_array(niceName($key), $arrCheckItems)){
$errorsReported[] = notBlank($key, $value);
} 
}

Even if the return from notBlank is nothing, $errorReported[] gets set
for each item passed in the foreach loop. I have tried using conditional
returns in the function, but to no avail. Perhaps my logic is screwed on
this.
[/snip]

I changed to  the following code and it solves the problem ...

foreach($_POST AS $key=$value){
if(in_array(niceName($key), $arrCheckItems)){
$nbr = notBlank($key, $value);
if(!('' == $nbr)){
$errorsReported[] = $nbr;
}
} 
}

Before I was directly assigning the value of the return from the
notBlank function to $errorsReported. Now something only gets assigned
to $errorsReported if there is something to assign. 

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



Re: [PHP] Getting the process ID

2005-03-25 Thread trlists
On 25 Mar 2005 Joshua Beall wrote:

 P1: Does token.status = 'locked' WHERE key=$key ?
 P2: Does token.status = 'locked' WHERE key=$key ?
 P1: {Receives negative response}
 P2: {Receives negative response}
 P1: Updates token.status. = 'locked' WHERE key=$key
 P2: Updates token.status. = 'locked' WHERE key=$key

The problem here is that the check / lock operation has to be atomic, 
that is you can't let a second process check or lock the resource while 
the first is in the process of locking it.  This is a basic issue for 
any kind of semaphore, you have to be able to do an atomic test and 
set or you get problems exactly as described above.

If it's a MySQL table then to me the simple solution is to use a LOCK 
TABLES then test and set the token stored in the database, then UNLOCK 
TABLES.  But that might be a bit expensive in terms of overhead, and 
you can probably find a way to do it with local files as well.  Also 
the shared memory functions look like they could be useful in this 
regard, if supported on your platform.

--
Tom

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



[PHP] Problem with arrays

2005-03-25 Thread virtualsoftware
Hi,
I have a form like this:
form action=products.php method=post
input name=position[pos][$value]  type=text  id=position[pos][$value]  
value=number 1
input name=position[pos][$value]  type=text  id=position[pos][$value]  
value=number 2
input name=position[pos][$value]  type=text  id=position[pos][$value]  
value=number 3
/form

Note that $value from position[pos][$value] is different in all 3 fields. 

For each element of the array i want to update the value in the database. For 
example, for each value of the position[pos][$value] i want to update the 
database with the specific number.
Something like this:

$query = UPDATE table SET value = 'number 1'  WHERE id='$value'; 

Thanks in advance for your help!!!

RE: [PHP] Problem with arrays

2005-03-25 Thread Jay Blanchard
[snip]
form action=products.php method=post
input name=position[pos][$value]  type=text
id=position[pos][$value]  value=number 1
input name=position[pos][$value]  type=text
id=position[pos][$value]  value=number 2
input name=position[pos][$value]  type=text
id=position[pos][$value]  value=number 3
/form

Note that $value from position[pos][$value] is different in all 3
fields. 

For each element of the array i want to update the value in the
database. For example, for each value of the position[pos][$value] i
want to update the database with the specific number.
Something like this:

$query = UPDATE table SET value = 'number 1'  WHERE id='$value'; 
[/snip]

On Good Friday, when traffic is really slow, we have someone who wants
to post their problem over and over again.cool

Lets start simply, shall we?

http://www.php.net/print_r

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



Re: [PHP] redirection, same host, two domains

2005-03-25 Thread Ken
On Fri, 25 Mar 2005 11:42:15 -0500, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 On Friday 25 March 2005 11:36, Alexandru Martin wrote:
  Okay, here is my problem. I had a site hosted on a sub domain
  (mysite.domain.com) , now I registered my own domain, mysite.com . The
  thing is mysite.com is still hosted on mysite.domain.com. What i want to
  do is :  If people type in their browsers mysite.domain.com redirect to
  mysite.com and if they type mysite.com to display the page.
  I'm guessing it should be something like this : if ( refferer =
  mysite.domain.com ) { redirect to mysite.com } else { my html code }
 
 This probably would be better accomplished through apache and DNS
 
 --
 Win a Vespa Scooter or a Dell Gift Card worth $3,000.00
 http://www.morningstarcom.net/raffle-contest.php
 
 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.
 MailScanner thanks transtec Computers for their support.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

If it's running apache stick this in a file named .htaccess and place
it in the web root folder

Redirect 301 / http://www.mysite.com

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



[PHP] header already sent problem

2005-03-25 Thread Ken
On Fri, 25 Mar 2005 15:03:45 -, AndreaD
[EMAIL PROTECTED] wrote:
 is there an alternative way to suppress the headers already sent problem?
 Ob_start/flush is not very neat way to so this.

 AD

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


you can set

output_buffering = 4096;

or some value you want in your php.ini file.

Alternatively try to rearrange your code to make sure that you put all
your header() commands BEFORE anything is sent to the browser. Many
CMS out there don't use OB as their code are well written so that
anything to do with header() is before data sent to browser.

HTH

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



Re: [PHP] html image

2005-03-25 Thread Dotan Cohen
On Thu, 24 Mar 2005 20:48:50 +0200, delos [EMAIL PROTECTED] wrote:
 i would like to produce a script that can make an image (screenshot)
 based only on the site url. so that i enter an URL and php makes the
 picture.
 
 can such a thing be done by php? if not, maybe by some other language?
 

You would need a program that would take the HTML code that you
receive and then know how to format it. In other words, a web browser.

I know that this is possible because as far back as three years ago I
was getting spam that included a screenshot of my site. I thought it
was rather cool- the screenshot showed the site optimized for a 1024-
width screen and I had at that point only ever seen my own site on a
800*600 15 inch monitor.

You would probably need to combine about 3 tools to do this: a
browser, a screen shot utility, and THEN php. php cannot transform the
html code into a 'webpage'. Unless, hehehe, you want to write a
browser in php.

Dotan Cohen

http://English-Lyrics.com/
http://Song-Lyriks.com/

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



[PHP] auto appending .php extension

2005-03-25 Thread Evert | Rooftop Solutions
Hi Folks,
I'm using PHP 4.3.10, the Zend Optimizer and Apache 1.3.33.
Somehow, if I want to open for example /dikkerapper.php, it is also 
possible to access it through /dikkerapper (without the .php extension)
I haven't seen this before, but when I checked it also occurs on my 
other servers. The thing is, it causes some big problems with 
mod_rewrite. For example:

the contents of the dir:
/dikkerapper.php
/dispatcher.php
And the mod_rewrite directives are set like this:
/hello - /dispatcher.php?a=hello
/how/are/you - /dispatcher.php?a=how/are/you
but when
/dikkerapper
is requested, it first (apperently) finds dikkerapper.php is found in 
the directory, and the url is rewritten to:

/dispatcher.php?a=dikkerapper.php
This might be an apache issue, but can also be related to php.ini I 
guess. Any ideas? I don't get any replies on the apache configuration 
newsgroups.

I'm using slackware packages for php and apache.
regards,
Evert
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PHP4 and PHP5 in virtual Host

2005-03-25 Thread Juan Pablo Herrera
Hi!
I have apache, php4 and php5 on my server.
I use virtual host in this server. The virtual host have or not PHP4 using:
php_admin_flag engine off/on in apache2.conf
How can i use PHP5 or PHP4 or both?
PHP4 is running as module and PHP5 is running as cgi.

Regards,
JP

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



[PHP] Re: mySQL outputting XML

2005-03-25 Thread C Drozdowski
There is a pear package that does this: XML_sql2xml.
It's at:
http://pear.php.net/package-info.php?pacid=18
There is more info at:
http://php.chregu.tv/sql2xml/
It's pretty flexible. But not so complicated that you cannot read 
through the code to figure out what's going on.

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


Re: [PHP] html image

2005-03-25 Thread Joe Harman
check out http://www.whois.sc

they do exactley what you are talking about. i don't think you can
make PHP do this.. there maybe someway to do it with imagemagik
but i am not even sure about that also...

here is a free ware program that does it.. but you have to do it manually
http://www.snapfiles.com/get/web2pic.html

good luck! let us know what you find!
Joe 


On Fri, 25 Mar 2005 19:47:43 +0200, Dotan Cohen [EMAIL PROTECTED] wrote:
 On Thu, 24 Mar 2005 20:48:50 +0200, delos [EMAIL PROTECTED] wrote:
  i would like to produce a script that can make an image (screenshot)
  based only on the site url. so that i enter an URL and php makes the
  picture.
 
  can such a thing be done by php? if not, maybe by some other language?
 
 
 You would need a program that would take the HTML code that you
 receive and then know how to format it. In other words, a web browser.
 
 I know that this is possible because as far back as three years ago I
 was getting spam that included a screenshot of my site. I thought it
 was rather cool- the screenshot showed the site optimized for a 1024-
 width screen and I had at that point only ever seen my own site on a
 800*600 15 inch monitor.
 
 You would probably need to combine about 3 tools to do this: a
 browser, a screen shot utility, and THEN php. php cannot transform the
 html code into a 'webpage'. Unless, hehehe, you want to write a
 browser in php.
 
 Dotan Cohen
 
 http://English-Lyrics.com/
 http://Song-Lyriks.com/
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] header already sent problem

2005-03-25 Thread AndreaD
It's not a header it is a setcookie, how do I arrange the code so the 
cookies are set before the header is set? At what point in the HTML are the 
headers sent.


R.
Ken [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Fri, 25 Mar 2005 15:03:45 -, AndreaD
 [EMAIL PROTECTED] wrote:
 is there an alternative way to suppress the headers already sent problem?
 Ob_start/flush is not very neat way to so this.

 AD

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


 you can set

 output_buffering = 4096;

 or some value you want in your php.ini file.

 Alternatively try to rearrange your code to make sure that you put all
 your header() commands BEFORE anything is sent to the browser. Many
 CMS out there don't use OB as their code are well written so that
 anything to do with header() is before data sent to browser.

 HTH 

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



[PHP] reg expressions

2005-03-25 Thread Steve Buehler
Ok.  I am really bad at regular expressions.  I have to search through some 
files and put the contents into an array.  A file could look like this:
$aliases=`cat /home/virtual/site$site_id/fst/etc/mail/local-host-names`;
start of file
# local-host-names - include all aliases for your machine here.
# Please do not add any domain names in this file.
domain.net
domain.com
end of file

In $aliases, I need to ignore the lines that start with a # sign.  It is 
possible, but not probably that it will be more than just the first 2 lines 
and possible that it isn't even the first two lines.  After done, $aliases 
should have just the two domain names in it.  One per line.  Then I need to 
loop through the lines in $aliases and do stuff with each line.  Any help 
would be GREATLY appreciated.  It would also be fine to just do a loop that 
checks each line.  Since I guess that would be quicker.  If the line starts 
with a #, then ignore it, otherwise, do some other stuff.

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


[PHP] setlocale and pt_BR problem on debian

2005-03-25 Thread Jonis Maurin Ceará
Hi
I'm trying to use setlocale to setup my language to pt_BR for ue with 
strftime but don't work.

I've tryied:
pt_BR
pt_BR.ISO_8859-1
portuguese.br
etc...
but don't work, i just get in english.
What's wrong? :(
My system:
OS: Debian Sarge
Apache 2
PHP 4.3.10-9
My simple code:
setlocale(LC_ALL, pt_BR.ISO_8859-1); // Tryed others too
echo strftime(%A);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] reg expressions

2005-03-25 Thread Steve Buehler
At 01:50 PM 3/25/2005, you wrote:
Ok.  I am really bad at regular expressions.  I have to search through 
some files and put the contents into an array.  A file could look like this:
$aliases=`cat /home/virtual/site$site_id/fst/etc/mail/local-host-names`;
start of file
# local-host-names - include all aliases for your machine here.
# Please do not add any domain names in this file.
domain.net
domain.com
end of file

In $aliases, I need to ignore the lines that start with a # sign.  It is 
possible, but not probably that it will be more than just the first 2 
lines and possible that it isn't even the first two lines.  After done, 
$aliases should have just the two domain names in it.  One per line.  Then 
I need to loop through the lines in $aliases and do stuff with each 
line.  Any help would be GREATLY appreciated.  It would also be fine to 
just do a loop that checks each line.  Since I guess that would be 
quicker.  If the line starts with a #, then ignore it, otherwise, do some 
other stuff.
Ya know.  You can look all you want, but for some reason, you never find 
what you are looking for until you ask somebody and then keep 
looking.  Anyway, I found the answer.  here it is:
$fc=file(/home/virtual/site$site_id/fst/etc/mail/local-host-names);
$key=#;
foreach($fc as $line){
if(!strstr($line,$key)){
}else{
echo $line;
}
}

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


Re: [PHP] header already sent problem

2005-03-25 Thread Chris Shiflett
AndreaD wrote:
It's not a header it is a setcookie
setcookie() is just a function that makes setting cookies a bit more 
convenient. It's still setting a header called Set-Cookie. In fact, you 
can manually set cookies:

header('Set-Cookie: foo=bar');
how do I arrange the code so the cookies are set before the header is
set?
These are essentially the same thing, so this question doesn't make sense.
At what point in the HTML are the headers sent.
The short answer is, as soon as there is content (HTML), you can no 
longer set headers.

The more accurate answer is, PHP must send all HTTP header instructions 
to Apache before it sends any content. As a developer, this means that 
you need to make sure to set all of your headers before you output 
anything, or you need to buffer your output using something like 
ob_start(), which causes PHP to not send content to Apache before the 
script terminates (or you manually flush).

Hope that helps.
Chris
--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] redirection, same host, two domains

2005-03-25 Thread Leif Gregory
Hello Alexandru,

Friday, March 25, 2005, 9:36:12 AM, you wrote:
AM Okay, here is my problem. I had a site hosted on a sub domain
AM (mysite.domain.com) , now I registered my own domain, mysite.com .
AM The thing is mysite.com is still hosted on mysite.domain.com. What
AM i want to do is : If people type in their browsers
AM mysite.domain.com redirect to mysite.com and if they type
AM mysite.com to display the page. I'm guessing it should be
AM something like this : if ( refferer = mysite.domain.com ) {
AM redirect to mysite.com } else { my html code }


http://www.devtek.org/snippets/index.php#domainRedirection

The only difference in your case is you don't need the second check,
and you'll just place your mysite.com HTML below the PHP.



Cheers,
Leif Gregory 

-- 
TB Lists Moderator (and fellow registered end-user)
PCWize Editor  /  ICQ 216395  /  PGP Key ID 0x7CD4926F
Web Site http://www.PCWize.com

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



RE: [PHP] reg expressions

2005-03-25 Thread Chris W. Parker
Steve Buehler mailto:[EMAIL PROTECTED]
on Friday, March 25, 2005 11:50 AM said:

 It would also be fine to just do a loop that checks each line.
 Since I guess that would be quicker.  If the line starts with
 a #, then ignore it, otherwise, do some other stuff.

Yeah do this. You don't need a regular expression in this case. Look at
the string functions in the PHP manual (http://php.net/substr) to find
out how to check what the first character of the line is.

Does that help?


Chris.

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



[PHP] following php development

2005-03-25 Thread mbneto
hi,

I used to visit zend.com for the weekly summary but it seems that it
has not been updated in a while.

Besides the php-devel is there any other source of information about 
php's development ?

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



Re: [PHP] Problem with header in an if SOLVED

2005-03-25 Thread Jochem Maas
Jay Blanchard wrote:
[snip]
/* check for errors */
$arrCheckItems = array(	
	'Name',
	'Dept',
	'Level',
);
/* check for blanks */
foreach($_POST AS $key=$value){
	if(in_array(niceName($key), $arrCheckItems)){
	 	$errorsReported[] = notBlank($key, $value);
	} 
}

Even if the return from notBlank is nothing, $errorReported[] gets set
for each item passed in the foreach loop. I have tried using conditional
returns in the function, but to no avail. Perhaps my logic is screwed on
this.
[/snip]
I changed to  the following code and it solves the problem ...
foreach($_POST AS $key=$value){
	if(in_array(niceName($key), $arrCheckItems)){
	 	$nbr = notBlank($key, $value);
		if(!('' == $nbr)){
			$errorsReported[] = $nbr;
		}
	} 
}

?
// one less if :-)...
foreach($_POST AS $key=$value){
if(in_array(niceName($key), $arrCheckItems)  !('' == ($nbr = 
notBlank($key, $value {
// error to report.
$errorsReported[] = $nbr;
}
}
// ...also array_filter() with only 1 arg (array) is handy for remove empty vals
$errorsReported = array();
foreach($_POST AS $k = $v){
if(in_array(niceName($k), $arrCheckItems)) {
$errorsReported[] = notBlank($k, $v);
}
}
if (count($errorsReported = array_filter($errorsReported))) {
// error msgs to report!
}
?
quote from manual:
If the callback function is not supplied, array_filter() will remove
all the entries of input that are equal to FALSE. See converting to
boolean for more information.
I do like array filter - also very handy in conjunction with create_function() 
:-)
rgds,
jochem
Before I was directly assigning the value of the return from the
notBlank function to $errorsReported. Now something only gets assigned
to $errorsReported if there is something to assign. 

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


Fw: [PHP] Problem with arrays

2005-03-25 Thread Jeff Schmidt
I sent this to the original user, but forgot to CC it to the list. I'm just 
sending this now, for completeness.
- Original Message - 
From: Jeff Schmidt [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 25, 2005 5:10 PM
Subject: Re: [PHP] Problem with arrays


Hello there.
Well, let me start with a pointer to some documentation. I think you will 
find the following to be helpful:
http://www.php.net/manual/en/control-structures.foreach.php

In a nutshell, when your form is submitted, you will have present in the 
$_POST super-global array, a reference to an array representing 
position[pos].
(As an aside, why are you using the same value for the first key in each 
of the fields? What you will end up with is an array that looks like:
array( pos = array(1 = number 1, 2=number 2, etc. . .))
Which seems like an extraneous level of nesting to me. . .)

You can use foreach to walk through that array like so:
foreach ($_POST['position']['pos'] as $key = $value)
{
//some code to update the database here.
}
NOTE: your $value from the form, in this case, corresponds to $key in the 
code above.

That is, even though you are calling it $value in your original post, what 
you really are setting is a key in an associative array in PHP. Anyhow, 
back to the example code. This structure will loop through the array of 
form elements that were submitted, and each time it loops, it will set 
$key and $value to the submitted key and submitted value respectively, 
once for each text input.

So, looking at your form below, let's say that the first text field has a 
$value of 1, second has $value of 2, etc.

That is, the form gets sent to the user's browser like this:
form action=products.php method=post
input name=position[pos][1] type=text id=position[pos][1] 
value=number 1 /
!-- etc --
/form

The first time our foreach loop executes, $key will be assigned the value 
1, and $value will be assigned the value number 1 (or whatever the 
user put into the text field, as they probably have changed it).

So, bringing it all together, the code will look something like this:
foreach ($_POST['position']['pos'] as $key = $value)
{
  $key = mysql_real_escape_string($key);
  $value = mysql_real_escape_string($value);
  $query = UPDATE TABLE tablename SET value='$value' WHERE id='$key';
 //code to actually execute the query goes here.
}
You can call the local values that foreach assigns to something other than 
$key and $value, but that is kind of a convention, and helps to keep the 
code clear.Also, I'd just like to throw out here, as a suggestion, in case 
you aren't already aware of this, that since user-input isn't trustworthy, 
before constructing your query string, you should make $key and $value 
'safe' by using something like mysql_real_escape_string(), as in the 
example above.

Hope this helps.
Jeff Schmidt
- Original Message - 
From: [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Friday, March 25, 2005 12:01 PM
Subject: [PHP] Problem with arrays

Hi,
I have a form like this:
form action=products.php method=post
input name=position[pos][$value]  type=text 
id=position[pos][$value] value=number 1
input name=position[pos][$value]  type=text 
id=position[pos][$value] value=number 2
input name=position[pos][$value]  type=text 
id=position[pos][$value] value=number 3
/form

Note that $value from position[pos][$value] is different in all 3 fields.
For each element of the array i want to update the value in the database. 
For example, for each value of the position[pos][$value] i want to update 
the database with the specific number.
Something like this:

$query = UPDATE table SET value = 'number 1'  WHERE id='$value';
Thanks in advance for your help!!! 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] following php development

2005-03-25 Thread Philip Olson

 I used to visit zend.com for the weekly summary but it seems that it
 has not been updated in a while.
 
 Besides the php-devel is there any other source of information about 
 php's development ?

While not about PHP Internals specifically, the following
do touch up on it and other PHP happenings:

 * http://www.phpdeveloper.org/
 * http://www.planet-php.net/
 
Regards,
Philip

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



Re: [PHP] reg expressions

2005-03-25 Thread Matthew Fonda
I wouldnt recommend using a regular expression for this. Regular
expressions most of the time are now the answer. You could just do
something like:

foreach ($line as file('/home/virtual/')) {
if (substr(trim($line), 0, 1) == '#') {
//$line is a comment
} else {
//$line is not a comment
}
}

On Fri, 2005-03-25 at 11:50, Steve Buehler wrote:
 Ok.  I am really bad at regular expressions.  I have to search through some 
 files and put the contents into an array.  A file could look like this:
 $aliases=`cat /home/virtual/site$site_id/fst/etc/mail/local-host-names`;
 start of file
 # local-host-names - include all aliases for your machine here.
 # Please do not add any domain names in this file.
 domain.net
 domain.com
 end of file
 
 In $aliases, I need to ignore the lines that start with a # sign.  It is 
 possible, but not probably that it will be more than just the first 2 lines 
 and possible that it isn't even the first two lines.  After done, $aliases 
 should have just the two domain names in it.  One per line.  Then I need to 
 loop through the lines in $aliases and do stuff with each line.  Any help 
 would be GREATLY appreciated.  It would also be fine to just do a loop that 
 checks each line.  Since I guess that would be quicker.  If the line starts 
 with a #, then ignore it, otherwise, do some other stuff.
 
 Thanks
 Steve
-- 
Regards,
Matthew Fonda
http://mfonda.info

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



Re: [PHP] following php development

2005-03-25 Thread Matthew Fonda
Aaron Wormus writes an article called the PHPBarnstormer which contains
a weekly summary of what is going on in PHP and in the mailing lists,
you might check it out.

http://phpbarnstormer.com


On Fri, 2005-03-25 at 13:49, mbneto wrote:
 hi,
 
 I used to visit zend.com for the weekly summary but it seems that it
 has not been updated in a while.
 
 Besides the php-devel is there any other source of information about 
 php's development ?
-- 
Regards,
Matthew Fonda
http://mfonda.info

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



[PHP] create multiple jpg thumbnails and use in a page

2005-03-25 Thread Kevin Coyner

Is there a way to create multiple jpg thumbnails from a series of larger
originals and use all of the on-the-fly generated thumbnails in a page
(without saving any of the thumbnails to the filesystem)?

For example, I've got 5 full size jpg's in a directory, and I'd like to
list them on a page in table form as follows


image1.jpg  thumnbnail imageimage1 size datestamp
image2.jpg  thumnbnail imageimage2 size datestamp
image3.jpg  thumnbnail imageimage3 size datestamp
image4.jpg  thumnbnail imageimage4 size datestamp
image5.jpg  thumnbnail imageimage5 size datestamp

From php.net, I've found plenty of examples of how to create thumbnails
from files and have done a couple successfully.  My objective, however,
is to have a page dynamically create multiple thumbnails from full sized
images.  I don't want to be creating and saving thumbnails to be used
later.

Possible?  If so, then please just a pointer in the right direction.

Thanks, Kevin
-- 

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



[PHP] Re: html image

2005-03-25 Thread Matthew Fonda
Hello,

I cannot think of anyway you could do this natively in PHP without using
some kind of exterior library. You could always write a PHP extension to
render HTML, then create a snapshot from that, but that would be a lot
of work. I was searching around and found this,
http://www.babysimon.co.uk/khtml2png/index.html
you could use that, or even create a wrapper extension for it.

Delos [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 i would like to produce a script that can make an image (screenshot)
 based only on the site url. so that i enter an URL and php makes the
 picture.

 can such a thing be done by php? if not, maybe by some other language?

--
Regards,
Matthew Fonda
http://www.mfonda.info

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



RE: [PHP] create multiple jpg thumbnails and use in a page

2005-03-25 Thread Mike
 
Here's how I'd go about that -

1) create two pages 
  a) the page that is displaying the images
  b) the script that generates the thumbnails

2) 'a' is simple - it just reads the directory and creates the HTML to
image_thumbnail.php?image=image.jpg

3) 'b' is passed 'image.jpg', reads the file, creates the thumbnail (rather
simple and lots of code in the manual and on the net) and outputs the proper
header info and the right data stream. 

4) watch your performance drop and your scripts possibly time out


Simple matter of the fact is that image processing is a dog. It consumes a
lot of resources and has little gain for being done on-the-fly in most
situations. And when you think about it - you're taking a very large amount
of input to output the same exact thing - just smaller. While I know it's
very bad HTML practice, if this is a fast site, you might get faster page
loads by just loading the full image with the image tag set with height and
width constraints ;)

If it's not a heavy/fast site, it might not be a problem. But if it's under
any serious load, pending the image sizes, it might be a big hit.

Just my $.02.

-M

 -Original Message-
 From: Kevin Coyner [mailto:[EMAIL PROTECTED] 
 Sent: Friday, March 25, 2005 9:33 PM
 To: php-general@lists.php.net
 Subject: [PHP] create multiple jpg thumbnails and use in a page
 
 
 Is there a way to create multiple jpg thumbnails from a 
 series of larger originals and use all of the on-the-fly 
 generated thumbnails in a page (without saving any of the 
 thumbnails to the filesystem)?
 
 For example, I've got 5 full size jpg's in a directory, and 
 I'd like to list them on a page in table form as follows
 
 
 image1.jpg  thumnbnail imageimage1 size datestamp
 image2.jpg  thumnbnail imageimage2 size datestamp
 image3.jpg  thumnbnail imageimage3 size datestamp
 image4.jpg  thumnbnail imageimage4 size datestamp
 image5.jpg  thumnbnail imageimage5 size datestamp
 
 From php.net, I've found plenty of examples of how to create 
 thumbnails from files and have done a couple successfully.  
 My objective, however, is to have a page dynamically create 
 multiple thumbnails from full sized images.  I don't want to 
 be creating and saving thumbnails to be used later.
 
 Possible?  If so, then please just a pointer in the right direction.
 
 Thanks, Kevin
 -- 
 
 --
 PHP General Mailing List (http://www.php.net/) To 
 unsubscribe, visit: http://www.php.net/unsub.php
 

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



[PHP] Ending PHP

2005-03-25 Thread Marquez Design
I have an if statement, and if it is true, I want PHP not to continue.

How do I do this?

The following statement is true

If ($a = $b){

This

}

Do not continue to the next piece of code, if false, continue to the next
piece of code.

Thanks for any help.

--
Steve Marquez
[EMAIL PROTECTED]

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



[PHP] Re: Ending PHP

2005-03-25 Thread Gerhard Pfeiffer
* Marquez Design [EMAIL PROTECTED]:
 I have an if statement, and if it is true, I want PHP not to continue.

 How do I do this?

if ($a == $b) {
exit();
}

http://de3.php.net/exit

 The following statement is true

 If ($a = $b){

btw: Most of the times you will want to user == in an if-statement :)

Ciao,
  Gerhard

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



Re: [PHP] Ending PHP

2005-03-25 Thread Matthew Fonda
you could use die() or exit()
they both take an optional parameter of a string to display when called.

On Fri, 2005-03-25 at 20:12, Marquez Design wrote:
 I have an if statement, and if it is true, I want PHP not to continue.
 
 How do I do this?
 
 The following statement is true
 
 If ($a = $b){
 
 This
 
 }
 
 Do not continue to the next piece of code, if false, continue to the next
 piece of code.
 
 Thanks for any help.
 
 --
 Steve Marquez
[EMAIL PROTECTED]
-- 
Regards,
Matthew Fonda
http://mfonda.info

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



[PHP] Test Send

2005-03-25 Thread Juan Pablo Herrera
I can't send email. Right?

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



Re: [PHP] Referer checking is able to be referer spoofed

2005-03-25 Thread Dan Rossi
On 20/03/2005, at 5:40 AM, Marek Kilimajer wrote:
If you need only hotlink protection then the current referer checking 
is just enough. Most users will not install referer spoofing software.

But if you need to be 100% sure the videos are streamed through 
affiliate server, you can use tokens - a script at the affiliate 
server will request a token from the streaming server (with 
username/password/clip id etc.). This token will be sent with the link 
to the streaming server. Hope this is clear.



Hi there sorry to return back to this, but we are somehow needing to 
create a token url that will be generated on the customer's webpage 
before the link is redirected to an access script of our clients video 
feeds site. What would be the most safest credentials to use to create 
a token with and how could the access script decrypt this information 
to validate access ? Let me know if this is too vague of a question 
thanks.

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