[PHP] Validating form field text input to be a specific variable type

2004-04-06 Thread Merritt, Dave
All,

I have a form on which the user is supposed to select a variable type
(boolean, integer, real, date/time, text) from a select box and enter the
default value for this selected variable type in a text box.  I'm trying to
validate that the default value entered matches the variable type selected
i.e. user selects boolean so valid defaults could only be 0, 1, true, false
and anything else would generate an error, or the user selects integer and
enters 1.7 for the default would also throw a flag.  I know that all of the
form values submitted from the web page are strings but is there a way to
test/convert the strings against the other variable types.

I'm sure that I'm not explaining this very well, but for example, if I use
the following code I will always get an error displayed even if the user
enters a valid value such as 3 in the default field because the form values
are always submitted as strings.  

if ( ($GLOBALS['PageOptions']['Type'] == 'Integer') and (!
is_int($GLOBALS['PageOptions']['Default']) ) )
{
// display an error
}

If I use (int) on the form default value then that won't work either because
if the default field value entered was not an integer but text such as
'snafu' then the value is always converted to an integer regardless.

if ( ($GLOBALS['PageOptions']['Type'] == 'Integer') and (! is_int((int)
$GLOBALS['PageOptions']['Default']) ) )
{
// display an error
}

Thanks in advance,

Dave Merritt
[EMAIL PROTECTED]

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



RE: [PHP] Validating form field text input to be a specific variable type

2004-04-06 Thread Merritt, Dave
Okay seems to makes sense, but when I do the following it doesn't appear to
be working correctly, or I'm viewing my logic incorrectly one:

if ( (int)$PageOptions['Default'] == $PageOptions['Default'] )
{  
// display a message if the integer of the default value matches the
default value
}

Enter 5, message displayed, so correct
Enter 5.0, messaged displayed, incorrect
Enter 5.5, no message, so correct
Enter a, message displayed, incorrect
Enter 5.0a, message displayed, incorrect
Enter 5.5a, no message, so correct
Enter a5.5, message displayed, incorrect

What am I missing here?

Thanks,

Dave Merritt
[EMAIL PROTECTED]




-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 06, 2004 3:19 PM
To: Merritt, Dave; [EMAIL PROTECTED]
Subject: Re: [PHP] Validating form field text input to be a specific
variable type


From: Merritt, Dave [EMAIL PROTECTED]

 I have a form on which the user is supposed to select a variable type 
 (boolean, integer, real, date/time, text) from a select box and enter 
 the default value for this selected variable type in a text box.  I'm 
 trying
to
 validate that the default value entered matches the variable type 
 selected i.e. user selects boolean so valid defaults could only be 0, 
 1, true,
false
 and anything else would generate an error, or the user selects integer 
 and enters 1.7 for the default would also throw a flag.  I know that 
 all of
the
 form values submitted from the web page are strings but is there a way 
 to test/convert the strings against the other variable types.

 I'm sure that I'm not explaining this very well, but for example, if I 
 use the following code I will always get an error displayed even if 
 the user enters a valid value such as 3 in the default field because 
 the form
values
 are always submitted as strings.

Well, if (int)$string == $string, then the value is an integer. Same for
(float)$string == $string for a real number. Boolean would be easy, just
strtolower($string) as compare to 1, 0, 'true', or 'false'. Date/time
validation will probaby require a regular expression or breaking it up to
validate days/month, etc. That can get a little hairy. If they say text,
well, anything goes, right? Maybe just make sure it's not empty()?

Let me know if you need more details. There are probably a ton of different
ways to do this.

---John Holmes...

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



RE: [PHP] Validating form field text input to be a specific variable type

2004-04-06 Thread Merritt, Dave
Okay seems to makes sense, but when I do the following it doesn't appear to
be working correctly, or I'm viewing my logic incorrectly one:

if ( (int)$PageOptions['Default'] == $PageOptions['Default'] ) {  
// display a message if the integer of the default value matches the
default value }

Enter 5, message displayed, so correct
Enter 5.0, messaged displayed, incorrect
Enter 5.5, no message, so correct
Enter a, message displayed, incorrect
Enter 5.0a, message displayed, incorrect
Enter 5.5a, no message, so correct
Enter a5.5, message displayed, incorrect

What am I missing here?

Thanks,

Dave Merritt
[EMAIL PROTECTED]




-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 06, 2004 3:19 PM
To: Merritt, Dave; [EMAIL PROTECTED]
Subject: Re: [PHP] Validating form field text input to be a specific
variable type


From: Merritt, Dave [EMAIL PROTECTED]

 I have a form on which the user is supposed to select a variable type
 (boolean, integer, real, date/time, text) from a select box and enter 
 the default value for this selected variable type in a text box.  I'm 
 trying
to
 validate that the default value entered matches the variable type
 selected i.e. user selects boolean so valid defaults could only be 0, 
 1, true,
false
 and anything else would generate an error, or the user selects integer
 and enters 1.7 for the default would also throw a flag.  I know that 
 all of
the
 form values submitted from the web page are strings but is there a way
 to test/convert the strings against the other variable types.

 I'm sure that I'm not explaining this very well, but for example, if I
 use the following code I will always get an error displayed even if 
 the user enters a valid value such as 3 in the default field because 
 the form
values
 are always submitted as strings.

Well, if (int)$string == $string, then the value is an integer. Same for
(float)$string == $string for a real number. Boolean would be easy, just
strtolower($string) as compare to 1, 0, 'true', or 'false'. Date/time
validation will probaby require a regular expression or breaking it up to
validate days/month, etc. That can get a little hairy. If they say text,
well, anything goes, right? Maybe just make sure it's not empty()?

Let me know if you need more details. There are probably a ton of different
ways to do this.

---John Holmes...

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



[PHP] combining multi-dimensional arrays from multiple parse_ini_file results

2003-03-29 Thread Merritt, Dave
All,

How do I combine the multi-dimensional arrays returned from the
parse_ini_file function on two different ini files?  I tried:

$my_array = parse_ini_file('some_file', true);
$my_array[] = parse_ini_file['another_file', true);

Thanks

Dave
[EMAIL PROTECTED]


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



[PHP] To use PEAR::DB or the PHP database functions

2003-03-20 Thread Merritt, Dave
All,

I've always used MySQL databases and the MySQL functions in PHP for my code
in the past.  However, I'm now working on a project that I want the project
to be able to be database independent so that the user of the project can
use whatever database he/she wishes.  I'm looking primarily at providing
support for MySQL, PostgreSQL, Oracle,  SQL Server databases.  What's the
general consensus on how to handle this?  Do I need to look at using
PEAR::DB so that the type of database is hidden from my code or would I
look at writing different include files for each database type and each of
the include files use the relevant PHP functions?  Or some other totally
different way?

Thanks

Dave Merritt
[EMAIL PROTECTED]

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



[PHP] Recommendations for PHP/MySQl calendar on-line submission/voting

2002-11-22 Thread Merritt, Dave
All,

I working with helping our local high school technical center set up a web
server/site.  Went with the typical AMP solution (unfortunately on MSWin
though).  The center is wanting to add an on-line calendar system.  This
doesn't need to be anything fancy, just something that will display a
monthly view with event titles, a way to provide detail content for the
event, and a way for multiple users to add/edit/remove entries.  I'm doing
some searching for solutions but there's definitely plenty to choose from.,
so if anyone has any recommendations I'd appreciate it.

Also, the school tries to get a lot of community involvement by doing a lot
of Name the ... whatever the activity is at time competitions and they are
wanting to come up with a way to do online entry submission and online
voting/polling of the entries.  Obviously I could write this, but was
wondering if anybody had any suggestions of existing code to do this.

TIA

Dave Merritt
[EMAIL PROTECTED]

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




RE: [PHP] How to show autocad (dwf, dwg) files in browser?

2002-11-15 Thread Merritt, Dave
Lars,

You say you downloaded the Volo View Express, but your plug-in page points
to the WHIP viewer plug.  Regardless, there are two versions of Volo View.
Did you download the DWF version only of Volo View?

Dave

-Original Message-
From: Lars Espelid [mailto:lars_espelid;hotmail.com]
Sent: Friday, November 15, 2002 4:09 PM
To: [EMAIL PROTECTED]
Subject: [PHP] How to show autocad (dwf, dwg) files in browser?


HI,

I have downloaded Volo View Express from www.autodesk.com (plugin to
web-browser) and can see the sample autocad-file that is presented on their
site.

Code ment to display the file drawing1.dwg on my page (none working):
1)
img src=drawing1.dwg
Displays no image.

2)
OBJECT data=drawing1.dwg
type=image/vnd.dwg
A nice drawing.
/OBJECT
The only thing I can see is a blue rectangle whith the following error
message inside it:
Drawing File Format Unrecogr

3)
object
param name=Filename value=drawing1.dwg
embed name=thanks src=drawing1.dwg
pluginspage=http://www.autodesk.com/whip;
/object
The only thing I can see is a blue rectangle whith the following error
message inside it:
Drawing File Format Unrecogr

I'm running Apache 1.3.26.

This is what I have written into httpd.conf:
AddType model/vnd.dwf .dwf
#drawing/x-dwf .dwf
AddType image/vnd.dxf .dxf
AddType image/vnd.dwg .dwg

This is what I have written into mime.types and mime.types.default:
image/vnd.dwg
image/vnd.dxf

Appreciate any help. Thanks


Lars





-- 
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] RE: -- OT -- [PHP] How to show autocad (dwf, dwg) files in browser?

2002-11-15 Thread Merritt, Dave
Okay, the WHIP viewer is only for DWF files from ACAD 13, 14,  2000 only.
It does NOT handle DWG files or DWF from ACAD 2002 based products
(Inventor),  Volo View Express 2.01 handles DWF, DWG,  DXF only if you
download the english language version.  Non-english versions of VVE will NOT
view DWG  DXF files only DWF files from ACAD 2002.

What version fo ACAD are you dealing with?  If it' 13, 14, or 2000 or going
to have to use WHIP  DWF files.  If it's ACAD 2002 and you can use an
english language viewer then you can use DWF, DWG, or DXF.  If it's ACAD
2002 and your using a non-english viewer then it's DWF only.  

If you have a site that has a mixture of ACAD versions from 13 thru 2002, or
going to have to have to either distinguish between the versions somehow and
use the appropriate viewer or you will have to open each file into ACAD 2002
and save each one back into 2002 format.  The file format for DWF changed
between ACAD 2000  2002.  Sucks I know, esp. the english/non-english thing.

Dave

-Original Message-
From: Lars Espelid [mailto:lars_espelid;hotmail.com]
Sent: Friday, November 15, 2002 6:09 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] How to show autocad (dwf, dwg) files in browser?



Only my third code-example points to the whip-viewer plug, and that's most
likely wrong. My first and second example may also be wrong, someone know
how to get it right?

I have tried these two viewers:

Volo View Express 2.01.
On this page http://www.autodesk.no/adsk/index/0,,837403-123112,00.html it
says:
DWF-Only Version of Volo View Express. Views only DWF files and does not
view DWG or DXF files.
When I fill out the form and continue, the next page says:
This version should understand DWG, DXFT, and DWF (ePlot and eView) files.
What is right?

WHIP! 4.0
On this page http://www.autodesk.com/cgi-bin/whipreg.pl it says:
you can view and print AutoCAD drawings without using AutoCAD.
On the next page a plug-in is downloaded and I can see a .dwf file in my
browser.

Still, when I try to execute my code to view drawing1.dwg it won't work.

Is my code right, and if it is where can I download a .dwg-plug-in.

regards,

Lars




Dave Merritt [EMAIL PROTECTED] skrev i melding
news:109DB0BF6260D211A1B30008C7A4AA1B129674A4;postoffice.arvinmeritor.com...
 Lars,

 You say you downloaded the Volo View Express, but your plug-in page points
 to the WHIP viewer plug.  Regardless, there are two versions of Volo View.
 Did you download the DWF version only of Volo View?

 Dave

 -Original Message-
 From: Lars Espelid [mailto:lars_espelid;hotmail.com]
 Sent: Friday, November 15, 2002 4:09 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] How to show autocad (dwf, dwg) files in browser?


 HI,

 I have downloaded Volo View Express from www.autodesk.com (plugin to
 web-browser) and can see the sample autocad-file that is presented on
their
 site.

 Code ment to display the file drawing1.dwg on my page (none working):
 1)
 img src=drawing1.dwg
 Displays no image.

 2)
 OBJECT data=drawing1.dwg
 type=image/vnd.dwg
 A nice drawing.
 /OBJECT
 The only thing I can see is a blue rectangle whith the following error
 message inside it:
 Drawing File Format Unrecogr

 3)
 object
 param name=Filename value=drawing1.dwg
 embed name=thanks src=drawing1.dwg
 pluginspage=http://www.autodesk.com/whip;
 /object
 The only thing I can see is a blue rectangle whith the following error
 message inside it:
 Drawing File Format Unrecogr

 I'm running Apache 1.3.26.

 This is what I have written into httpd.conf:
 AddType model/vnd.dwf .dwf
 #drawing/x-dwf .dwf
 AddType image/vnd.dxf .dxf
 AddType image/vnd.dwg .dwg

 This is what I have written into mime.types and mime.types.default:
 image/vnd.dwg
 image/vnd.dxf

 Appreciate any help. Thanks


 Lars





 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Getting users IP address into a variable.

2002-10-02 Thread Merritt, Dave

Try: $ip=$_SERVER['REMOTE_ADDR']

-Original Message-
From: Webmaster MBTRADINGCO [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 02, 2002 1:08 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Getting users IP address into a variable.


I'm sure there has to be a way to verify which IP address is accessing
from. I need to establish a page where when I enter it records the IP
address I'm logging in from, to a database.

Problem is I can't seem a command in php that can assign that to a
variable, as in:

$ip=HTTP_GET_

ANY IDEAS

Thanks


Elliot J. Balanza



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
**
Any views, opinions or authorizations contained in this email are solely those of the 
author and do not necessarily represent those of ArvinMeritor, Inc. If you are not 
familiar with the corporate authority of the author, please obtain confirmation in 
writing 
of the content of this email prior to taking any action on the basis of the 
information. If 
you are not the intended recipient, you are hereby notified that any disclosure, 
copying 
or distribution of the information enclosed is strictly prohibited. 
**


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




[PHP] Creating/displaying page content and downloading a file at the same time

2002-09-24 Thread Merritt, Dave

All,

I'm trying to write a script that will allow the user to download/save a
file but I also want to be able to display a web page in the browser window
as well.  If a user runs the following code from an empty browser window,
then the contents of the browser window will remain empty.  How do I get the
script to also output page content to the browser window as well as download
the file?  I've played around with trying to add an additional text/html
content type and echoing out text in different places in the script, but I
cannot get any output to appear in the browser window.  I've tried setting
the location so that the page will open another page but then I run into the
headers already sent problem.

from the browser:
http://myhost/download.php/?Filename=/tmp/20020923172330.xls

download.php:

?
$Filename = $_GET['Filename'];

header(Content-Type: application/force-download);
header(Content-Type: application/octet-stream);
header(Content-Type: application/download);
header(Content-Disposition: inline; filename= . basename($Filename));
header(Content-Transfer-Encoding: binary);
header(Content-Length:  . filesize($Filename));
header(Pragma: public);
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);

readfile($Filename); 
?

Thanks

Dave Merritt
[EMAIL PROTECTED]
**
Any views, opinions or authorizations contained in this email are solely those of the 
author and do not necessarily represent those of ArvinMeritor, Inc. If you are not 
familiar with the corporate authority of the author, please obtain confirmation in 
writing 
of the content of this email prior to taking any action on the basis of the 
information. If 
you are not the intended recipient, you are hereby notified that any disclosure, 
copying 
or distribution of the information enclosed is strictly prohibited. 
**


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




[PHP] Closing a browser's child window after user downloads a file

2002-09-20 Thread Merritt, Dave

All,

I have a page that displays results of a database search.  The page contains
a select dropdown box from which the user can pick different options
including the ability to download an Excel or CSV file of the displayed
results.  Once the user selects an option from the dropdown, a Javascript
onchange method will kick in, submit the form and process the selected
option.  If the option is one of the file download choices, then using
Javascript a new, child window will be opened and the location of the child
will be the PHP download script with the file to download.  The script in
the child window will force the browser's download dialog box to open up at
which point the user can save, open, or cancel the file download.  The issue
that I have is that some browsers (IE6) will automatically close the child
window when the user has made a selection from the download dialog box while
other browsers (Mozilla) will leave the child window remaining open.  I need
to either come up with a way to close the child window once the user has
finsished with the download dialog or force the download script to not run
in a child window.  I've thought about applying a timer somewhere but this
isn't reliable because of the unknowns of file download time and user
response time to the download dialog.  I don't have a preference as to
whether the solution is all PHP based, all Javascript, or a mix of both -- I
just need a solution to close this child window when complete.

Code is below.  As usual, thanks in advance.

Dave Merritt
[EMAIL PROTECTED]

Javascript code from the parent search results window opening the child
window  calling the PHP download script:

...
SCRIPT type= text/javascript language=JavaScript
!--
DownloadWindow = window.open(../functions/download.php/?Filename=?echo
$Filename?, Download, toolbar=0, location=0, directories=0, status=0,
menubar=0, scrollbars=0, resizable=0, copyhistory=0, width=200,
height=200);
//--
/SCRIPT
...


download.php:

if (isset($_GET['Filename']))
{
if ( $_GET['Filename'] != '' )
{
$Filename = $_GET['Filename'];

header(Content-Disposition: inline; filename= .
basename($Filename));
header(Content-Type: application/octet-stream);
header(Content-Type: application/force-download);
header(Content-Type: application/download);
header(Content-Transfer-Encoding: binary);
header(Content-Length:  . filesize($Filename));
header(Pragma: public);
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
readfile($Filename); 
}
}
**
Any views, opinions or authorizations contained in this email are solely those of the 
author and do not necessarily represent those of ArvinMeritor, Inc. If you are not 
familiar with the corporate authority of the author, please obtain confirmation in 
writing 
of the content of this email prior to taking any action on the basis of the 
information. If 
you are not the intended recipient, you are hereby notified that any disclosure, 
copying 
or distribution of the information enclosed is strictly prohibited. 
**


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




[PHP] OT - SQL string to get value by latest date only in a join

2002-09-12 Thread Merritt, Dave

All,

I apologize up front for being off topic, but I don't want to have to
subscribe to other lists unless necessary.  I know that someone on this list
should be able to help me out.

I have the SQL string below that I am running.  The problem I'm having is
that the history table being called in the join has multiple entries
referencing back to the single entry in the customer table.  What I want to
be able to do is return only the latest/newest entry by date in the history
table and not older entries.  I assume that I need to add some conditional
to the outer join.  The problem I have is that I don't know what the
conditional would be to allow returning the latest row by date.

Thanks in advance, and again I apologize for the OT question,

Dave Merritt
[EMAIL PROTECTED]

currently running this string:

SELECT customer.customer_id, customer.customer_name,
business_unit.business_unit, customer.created_date, CONCAT_WS(, ,
username.last_name, username.first_name), history.modify_date, CONCAT_WS(,
, modified.last_name, modified.first_name), history.description
FROM `customer` 
LEFT OUTER JOIN `business_unit` ON business_unit.bu_id = customer.bu_id 
LEFT OUTER JOIN `username` ON username.user_id = customer.creator_id 
LEFT OUTER JOIN `history` ON ( history.item_id = customer.customer_id  AND
history.module_id = 1003 )
LEFT OUTER JOIN `username` AS modified ON modified.user_id =
history.modifier_id 
WHERE customer.customer_id LIKE %man% 
OR customer.customer_name LIKE %man% 
OR customer.created_date LIKE %man% 
OR business_unit.business_unit LIKE %man% 
OR username.first_name LIKE %man% 
OR username.last_name LIKE %man% 
OR history.modify_date LIKE %man%
OR history.description LIKE %man%
OR modified.first_name LIKE %man% 
OR modified.last_name LIKE %man% 
ORDER BY customer.customer_name

which returns the following results:

'1040','Allmand Bros. Inc.','Gas Springs, Industrial','2002-03-01
00:00:00','Admin, PDMWeb','2002-11-12 10:53:23','Burnstingle,
Robert','Additional changes made','1003',
'1040','Allmand Bros. Inc.','Gas Springs, Industrial','2002-03-01
00:00:00','Admin, PDMWeb','2002-11-09 13:15:34','Merritt, Dave','A test of
history','1003',
'1050','Ameritool Manufacturing','Gas Springs, Industrial','2002-03-01
00:00:00','Admin, PDMWeb','NULL','','NULL','NULL',
'1053','Ammann-Yanmar','Gas Springs, Industrial','2002-03-01
00:00:00','Admin, PDMWeb','NULL','','NULL','NULL',
'1065','Art's Way Manufacturing','Gas Springs, Industrial','2002-03-01
00:00:00','Admin, PDMWeb','NULL','','NULL','NULL', .


What I'm trying to achieve is the above results both with only one row
returned for the 1040 item like so, and the row returned should be the row
with the latest/newest modified date:

1040','Allmand Bros. Inc.','Gas Springs, Industrial','2002-03-01
00:00:00','Admin, PDMWeb','2002-11-12 10:53:23','Burnstingle,
Robert','Additional changes made','1003',
'1050','Ameritool Manufacturing','Gas Springs, Industrial','2002-03-01
00:00:00','Admin, PDMWeb','NULL','','NULL','NULL',
'1053','Ammann-Yanmar','Gas Springs, Industrial','2002-03-01
00:00:00','Admin, PDMWeb','NULL','','NULL','NULL',
'1065','Art's Way Manufacturing','Gas Springs, Industrial','2002-03-01
00:00:00','Admin, PDMWeb','NULL','','NULL','NULL', .




**
Any views, opinions or authorizations contained in this email are solely those of the 
author and do not necessarily represent those of ArvinMeritor, Inc. If you are not 
familiar with the corporate authority of the author, please obtain confirmation in 
writing 
of the content of this email prior to taking any action on the basis of the 
information. If 
you are not the intended recipient, you are hereby notified that any disclosure, 
copying 
or distribution of the information enclosed is strictly prohibited. 
**


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




[PHP] Trying to locate an image file name from another site

2002-07-09 Thread Merritt, Dave

All,

I have a page on our intranet site that is pulling an image from our
corporate web server.  The corporate server  the image I am accessing is
beyond my control.  The image is generated daily and appears to be named
with a timestamp in the file name so therefore the image name changes daily.

On my site I have the page to check if a cookie exists with the image's file
name.  If the cookie is set then the page will create the IMAGE tag using
the file name specified in the cookie.  If the cookie value is not set then
the code will go open the web page on the corporate server, dump the page's
content into an array, and then the array is parsed until a known string is
found and then the image file name can be pulled out and displayed.

Currently the code I have is working.  However, I know that it can/needs to
be improved but I'm not sure what/how to go about implementing the following
improvements:

1) If the image file name doesn't exist go to the corporate web server,
access the page, and parse the page contents until we find the image.  The
problem I currently have is that the page on the corporate site is huge with
several hundred lines of html in the page and the image I need to access is
closer to the bottom of the page.  How do I walk through the contents of the
page searching for the image starting further down the page than from the
beginning if the page?

2) Is there a better way of trying to find/strip the image name in the page
contents than by using the strpos  substr functions?  If so how?

3) Once I've found the image file name, is there then some way that I can
download the image from the corporate site to our local site?  If so, how do
I do this?  If I can download the image locally, then I can rewrite the code
to check for the existence of the file locally before going out and
accessing the corporate site every time.

Code is below.  Thanks in advance

Dave Merritt
[EMAIL PROTECTED]

%
$Image = $_COOKIE['ImageToday'];
$WebLocation = 'http://www.somesite.com';

if (empty($Image))
{
$Find = 'IMG SRC=/archive/images';

$PageContents = @file($WebLocation);

if (! empty($PageContents))
{
while (list ($ArrayNo, $Line) = each ($PageContents))
{
$Image = stristr($Line, $Find);
if ($Image != )
{
$Image = substr($Image, 0, strpos($Image, ' BORDER=0'));
$Image = substr($Image, strpos($Image, '') + 1);
$Image = $WebLocation . $Image;
%
SCRIPT type= text/javascript language=JavaScript
!--
document.cookie = ImageToday=%echo $Image%; path=/
//--
/SCRIPT
A href=%echo $WebLocation%
IMG src=%echo $Image% border=0 alt=Some label
/A
%   
}
}
}
else
{
%
P class=textUnable to display 
A href=%echo $WebLocation% class=textimage from
site/A!
/P
%
}
}
else
{
%
A href=%echo $WebLocation%IMG src=%echo $Image% border=0
alt=Some label/A
%
}
%


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




RE: [PHP] Trying to locate an image file name from another site

2002-07-09 Thread Merritt, Dave

No.  Having any changes made to the corporate server for my ease of use is
not an option -- too much politics involved (my use of open source solutions
in a Microsoft environment!!!).

Dave

-Original Message-
From: Miguel Cruz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 09, 2002 3:55 PM
To: Merritt, Dave
Cc: PHP General (E-mail)
Subject: Re: [PHP] Trying to locate an image file name from another site


On Tue, 9 Jul 2002, Merritt, Dave wrote:
 I have a page on our intranet site that is pulling an image from our
 corporate web server.  The corporate server  the image I am accessing is
 beyond my control.  The image is generated daily and appears to be named
 with a timestamp in the file name so therefore the image name changes
daily.

Can you ask the corporate web site people to insert a distinctive HTML
comment just before the image? It would just take them a second, have no
impact on their users, and make your job much easier.

miguel

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