[PHP] Re: OPTIMIZING - The fastest way to open and show a file

2005-10-17 Thread Ruben Rubio Rey

In a almost idle desktop machine always takes arround 0.04.

The measured is on a server when it was with low traffic (average load 
arround 0.7)


ac wrote:


where did these time measured?
on a heavily loaded server or on your own almost idle desktop machine ?


On 10/14/05, Ruben Rubio Rey [EMAIL PROTECTED] wrote:
 


Hi,

I m creating a cache system, and i have a problem: PHP takes a lot of
time opening the file. (Im using 2.6.9-1.667smp and XFS)

* For files less or equal 6 Kb, takes arround 0.02-0.03 miliseconds - its
ok
* For files arround 35 Kb takes arround 0.2-0.4 miliseconds - too much.

What can I do to make faster opening files?

**
Source code:
  if(file_exists($filename)){
$modified_date=filemtime($filename);
if(time()($modified_date+1 * 24 * 60 * 60)){
$handle = fopen($filename, r);
$contents = fread($handle, filesize($filename));
fclose($handle);
echo $contents;
}
 }
**

Thinks that I have tried:
* fopen is *much* faster than include
* filemtime is faster than filectime
* Pear Cache its too much slower (0.5-0.7 milsecond per file)

Thanks in advance
Tk421

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


   




--
all born, to be dying


 



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



Re: [PHP] OPTIMIZING - The fastest way to open and show a file

2005-10-17 Thread Ruben Rubio Rey

Richard Lynch wrote:


On Fri, October 14, 2005 6:29 am, Ruben Rubio Rey wrote:
 


  if(file_exists($filename)){
$modified_date=filemtime($filename);
if(time()($modified_date+1 * 24 * 60 * 60)){
$handle = fopen($filename, r);
$contents = fread($handle, filesize($filename));
fclose($handle);
echo $contents;
}
 }
   



Checking both file_exists and then doing fopen seems a bit silly.

Trap the error from fopen, and just use that as your file_exists test.

I suspect http://php.net/file_get_contents will be SLIGHTLY faster
than doing all of this code, though:

if (filemtime($filename)  time()) $contents =
@file_get_contents($filename);
if ($contents === false){
 //error-handling code
}
else{
 echo $contents;
}

Then, of course, we have to wonder if you NEED $contents for later use
in the script.

If not, something like this will clock in better:

$bytes = @readfile($filename);
if ($bytes === false){
 //error-handling code
}

 

This seems to be the best solution. I do not need $content anymore. I ll 
post results. :)



The difference here is that you don't even stuff the file into the PHP
string.  It's all read and passed out to stdout in low-level internal
PHP C code, and the data never needs to hit PHP variables which are
more expensive to setup and maintain.

Note that which is REALLY fastest will probably depend on the size of
the files, your OS system cache, your hardware, and maybe which
version of PHP you are using, if the underlying functions changed.

Must be nice to be worried about 0.0x milliseconds -- I'm fighting a
mystery 3.0 seconds in a data feed for a search engine myself :-)
 


Search engine ... thats the most complicated!

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



[PHP] Re: OPTIMIZING - The fastest way to open and show a file

2005-10-17 Thread ac
try `ssh' onto the server and
test locally on the server, use `wget', `curl' or even write a small script...
what do you get this time ?

low traffic may also problemical, if the server shares bandwith with
other host, and there are busy ones among them.



On 10/17/05, Ruben Rubio Rey [EMAIL PROTECTED] wrote:
 In a almost idle desktop machine always takes arround 0.04.

 The measured is on a server when it was with low traffic (average load
 arround 0.7)

 ac wrote:

 where did these time measured?
 on a heavily loaded server or on your own almost idle desktop machine ?
 
 
 On 10/14/05, Ruben Rubio Rey [EMAIL PROTECTED] wrote:
 
 
 Hi,
 
 I m creating a cache system, and i have a problem: PHP takes a lot of
 time opening the file. (Im using 2.6.9-1.667smp and XFS)
 
 * For files less or equal 6 Kb, takes arround 0.02-0.03 miliseconds - its
 ok
 * For files arround 35 Kb takes arround 0.2-0.4 miliseconds - too much.
 
 What can I do to make faster opening files?
 
 **
 Source code:
if(file_exists($filename)){
  $modified_date=filemtime($filename);
  if(time()($modified_date+1 * 24 * 60 * 60)){
  $handle = fopen($filename, r);
  $contents = fread($handle, filesize($filename));
  fclose($handle);
  echo $contents;
  }
   }
 **
 
 Thinks that I have tried:
 * fopen is *much* faster than include
 * filemtime is faster than filectime
 * Pear Cache its too much slower (0.5-0.7 milsecond per file)
 
 Thanks in advance
 Tk421
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 
 --
 all born, to be dying
 
 
 
 




--
all born, to be dying

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



[PHP] can't get IIS to run php if the script is not directly under wwwroot

2005-10-17 Thread tony yau
Can someone help please,

in w2k, when i put a test.php directly under wwwroot then it works, when i
try using a virtual directory
it fails/refused to run the script?!

any hint anyone?

-- 
Tony

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



[PHP] Re: a couple of problems with PHP form

2005-10-17 Thread Mark Rees
-
sorry, my editor has not indented again
-
also, I want the field to appear hilighted when there is no
information so I am doing this:

input class=? if($error_msg){ echo error; } ELSE { echo
normal; } id=firstname name=firstname type=text
value={$_POST['firstname']}? /

and I have an error class set up in my CSS, such as

 .error {border: 1px solid red;}

this is not doinf anything either.
-
Assuming that your test for $error_msg is working correctly, change the css
definition to
input.error
-

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



[PHP] RE: php-general Digest 17 Oct 2005 10:35:46 -0000 Issue 3742

2005-10-17 Thread Aftab Alam
hi,
any one can help me

i want to generate Pdf file using php.
how can i  what tools is required for this.

 




Regards, 
  _  

Aftab Alam 




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Monday, October 17, 2005 4:06 PM
To: php-general@lists.php.net
Subject: php-general Digest 17 Oct 2005 10:35:46 - Issue 3742



php-general Digest 17 Oct 2005 10:35:46 - Issue 3742

Topics (messages 224207 through 224218):

Funky array question
224207 by: Brian Dunning
224209 by: Minuk Choi
224210 by: Jordan Miller
224211 by: Jordan Miller
224212 by: Jordan Miller

Re: editor
224208 by: yangshiqi1089

a couple of problems with PHP form
224213 by: Bruce Gilbert
224218 by: Mark Rees

Re: OPTIMIZING - The fastest way to open and show a file
224214 by: Ruben Rubio Rey
224215 by: Ruben Rubio Rey
224216 by: ac

can't get IIS to run php if the script is not directly under wwwroot
224217 by: tony yau

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


--

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



[PHP] Re: can't get IIS to run php if the script is not directly under wwwroot

2005-10-17 Thread tony yau
Hi,

the security for my 'Project' folder (aliases 'phpproject'  where test.php
is under) has

Access Permission:
Read, Script source access, Write, Directory Browsing

Application permission:
Execute(includes scripts)

under window explorer I've allowed Everyone and Internet Guest Account Full
control and both allow inheritable permission from parent. (I'm logged in
with Admin prev)

thanks
Tony

tony yau [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Can someone help please,

 in w2k, when i put a test.php directly under wwwroot then it works, when i
 try using a virtual directory
 it fails/refused to run the script?!

 any hint anyone?

 -- 
 Tony

 -- 
 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] RE: php-general Digest 17 Oct 2005 10:35:46 -0000 Issue 3742

2005-10-17 Thread Ravi
I just had a small doubt..Is it possible to write JavaScript through PHP???

On 10/17/05, Aftab Alam [EMAIL PROTECTED] wrote:
 hi,
 any one can help me

 i want to generate Pdf file using php.
 how can i  what tools is required for this.






 Regards,
   _

 Aftab Alam




 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 17, 2005 4:06 PM
 To: php-general@lists.php.net
 Subject: php-general Digest 17 Oct 2005 10:35:46 - Issue 3742



 php-general Digest 17 Oct 2005 10:35:46 - Issue 3742

 Topics (messages 224207 through 224218):

 Funky array question
 224207 by: Brian Dunning
 224209 by: Minuk Choi
 224210 by: Jordan Miller
 224211 by: Jordan Miller
 224212 by: Jordan Miller

 Re: editor
 224208 by: yangshiqi1089

 a couple of problems with PHP form
 224213 by: Bruce Gilbert
 224218 by: Mark Rees

 Re: OPTIMIZING - The fastest way to open and show a file
 224214 by: Ruben Rubio Rey
 224215 by: Ruben Rubio Rey
 224216 by: ac

 can't get IIS to run php if the script is not directly under wwwroot
 224217 by: tony yau

 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


 --

 --
 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] RE: php-general Digest 17 Oct 2005 10:35:46 -0000 Issue 3742

2005-10-17 Thread Jordan Miller
if you have compiled php with pdflib support, you can do this fairly  
easily. see the manual:


http://www.php.net/pdf

Jordan


On Oct 17, 2005, at 6:06 AM, Aftab Alam wrote:


hi,
any one can help me

i want to generate Pdf file using php.
how can i  what tools is required for this.






Regards,
  _

Aftab Alam




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Monday, October 17, 2005 4:06 PM
To: php-general@lists.php.net
Subject: php-general Digest 17 Oct 2005 10:35:46 - Issue 3742



php-general Digest 17 Oct 2005 10:35:46 - Issue 3742

Topics (messages 224207 through 224218):

Funky array question
224207 by: Brian Dunning
224209 by: Minuk Choi
224210 by: Jordan Miller
224211 by: Jordan Miller
224212 by: Jordan Miller

Re: editor
224208 by: yangshiqi1089

a couple of problems with PHP form
224213 by: Bruce Gilbert
224218 by: Mark Rees

Re: OPTIMIZING - The fastest way to open and show a file
224214 by: Ruben Rubio Rey
224215 by: Ruben Rubio Rey
224216 by: ac

can't get IIS to run php if the script is not directly under wwwroot
224217 by: tony yau

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


--

--
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] Re: can't get IIS to run php if the script is not direc tly under wwwroot

2005-10-17 Thread Jay Blanchard
[snip]
the security for my 'Project' folder (aliases 'phpproject'  where test.php
is under) has

Access Permission:
Read, Script source access, Write, Directory Browsing

Application permission:
Execute(includes scripts)

under window explorer I've allowed Everyone and Internet Guest Account Full
control and both allow inheritable permission from parent. (I'm logged in
with Admin prev)
[/snip]

Using Internet Information Services right click on the folder and then click
Properties. To the right of the Execute Permissions box click the
Configuration button. Click on the App Mapping tab and look for the PHP
extension. If it is not there you did not set up the Virtual Directory
properly.

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



[PHP] Re: Re: can't get IIS to run php if the script is not directly under wwwroot

2005-10-17 Thread tony yau

Executable : C:\Apache\Apache2\php501\php5isapi.dll
Extension .php
Verb All
checked Script engine

I've have tried php.exe here but with no joy!
Tony

Jay Blanchard [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 [snip]
 the security for my 'Project' folder (aliases 'phpproject'  where test.php
 is under) has

 Access Permission:
 Read, Script source access, Write, Directory Browsing

 Application permission:
 Execute(includes scripts)

 under window explorer I've allowed Everyone and Internet Guest Account
Full
 control and both allow inheritable permission from parent. (I'm logged in
 with Admin prev)
 [/snip]

 Using Internet Information Services right click on the folder and then
click
 Properties. To the right of the Execute Permissions box click the
 Configuration button. Click on the App Mapping tab and look for the PHP
 extension. If it is not there you did not set up the Virtual Directory
 properly.

 -- 
 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] Re: Re: can't get IIS to run php if the script is not d irectly under wwwroot

2005-10-17 Thread Jay Blanchard
[snip]
Executable : C:\Apache\Apache2\php501\php5isapi.dll
Extension .php
Verb All
checked Script engine

I've have tried php.exe here but with no joy!
[/snip]

Did you install PHP as a CGI or ISAPI?

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



[PHP] Re: Re: Re: can't get IIS to run php if the script is not directly under wwwroot

2005-10-17 Thread tony yau
Hi Jay

thanks for your time.
i installed it as ISAPI

can i ask if you have had IIS5 on win2k professional running php scripts
that is not under the \wwwroot ?
some how i getting to think it can't (?!) be done although it does work for
II6 win2003 server!

Tony

Jay Blanchard [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 [snip]
 Executable : C:\Apache\Apache2\php501\php5isapi.dll
 Extension .php
 Verb All
 checked Script engine

 I've have tried php.exe here but with no joy!
 [/snip]

 Did you install PHP as a CGI or ISAPI?

 -- 
 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] Re: Re: Re: can't get IIS to run php if the script is n ot directly under wwwroot

2005-10-17 Thread Jay Blanchard
[snip]
thanks for your time.
i installed it as ISAPI

can i ask if you have had IIS5 on win2k professional running php scripts
that is not under the \wwwroot ?
some how i getting to think it can't (?!) be done although it does work for
II6 win2003 server!
[/snip]

I have IIS5 installed on W2K Pro running PHP scripts in virtual directories.
Try commenting the doc_root line in your php.ini and then restarting IIS.
This has been known to cause some problems with virtuals. Make sure that
php.ini can be read by everyone.

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



[PHP] Invoking a DLL with PHP

2005-10-17 Thread Jay Blanchard
Good morning gurus and gurettes!

I have been asked (and I think that we may have discussed this before in
general terms, a long time ago) to perform the preliminary analysis on a
project that ideally would have me invoking an existing .DLL using PHP. I
have been googling for tidbits for several days without much luck. I have
not built a test, but I will be doing so later today or tomorrow.

Does anyone have any insight to this type of process? Would I have to build
a PHP extension and compile the DLL as part of PHP's configuration? Ideally
the DLL would be a black box that could be accessed utilizing functions that
I build without a re-compile of any type.

Thanks for any insight that you may have...all clues welcome!

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



[PHP] Uploaded CSV - database

2005-10-17 Thread Brian Dunning
Does anyone have an example of code to process a CSV file submitted  
via a file upload and parse it out in order to write its records to a  
db?


Hopefully yours,

- Brian

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



Re: [PHP] Invoking a DLL with PHP

2005-10-17 Thread Richard Davey
Hi Jay,

Monday, October 17, 2005, 3:20:58 PM, you wrote:

 Does anyone have any insight to this type of process? Would I have
 to build a PHP extension and compile the DLL as part of PHP's
 configuration? Ideally the DLL would be a black box that could be
 accessed utilizing functions that I build without a re-compile of
 any type.

Have only done this once, but I didn't compile the DLL into PHP
because that would have meant updating the php build every time a new
DLL was released, and updating the functions / documentation
accordingly.

The DLL was built specifically with a COM interface which I accessed
using the PHP COM functions (as I'm sure you've seen already). The DLL
authors had to rejig their original code a little, but it was a far
less painful process than compiling the DLL into PHP. However for the
next revision we are likely to move the DLL code into the .NET
framework, build a SOAP interface to it (C#) and let PHP talk to it
that way. Although that's more of a political decision than a
technical one, I'm just mentioning it incase the idea is useful for
you.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



RE: [PHP] Uploaded CSV - database

2005-10-17 Thread Jim Moseby
 -Original Message-
 From: Brian Dunning [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 17, 2005 10:37 AM
 To: php-general@lists.php.net
 Subject: [PHP] Uploaded CSV - database
 
 
 Does anyone have an example of code to process a CSV file submitted  
 via a file upload and parse it out in order to write its 
 records to a  
 db?
 


With MYSQL (assuming permissions and such are in order) You would simply:

$sql=load data local infile '/path/to/csv' into table tablename fields
terminated by ',';


JM

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



RE: [PHP] Uploaded CSV - database

2005-10-17 Thread Jim Moseby


 -Original Message-
 From: Jim Moseby [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 17, 2005 10:41 AM
 To: 'Brian Dunning'; php-general@lists.php.net
 Subject: RE: [PHP] Uploaded CSV - database
 
 
  -Original Message-
  From: Brian Dunning [mailto:[EMAIL PROTECTED]
  Sent: Monday, October 17, 2005 10:37 AM
  To: php-general@lists.php.net
  Subject: [PHP] Uploaded CSV - database
  
  
  Does anyone have an example of code to process a CSV file 
 submitted  
  via a file upload and parse it out in order to write its 
  records to a  
  db?
  
 
 
 With MYSQL (assuming permissions and such are in order) You 
 would simply:
 
 $sql=load data local infile '/path/to/csv' into table 
 tablename fields
 terminated by ',';
 

I should amend this to say that the columns in your CSV file, and in the
table must match for this to work.

If you wanted to parse through it line by line and do it all manually, check
out the fread() and explode() functions in the PHP manual.  

JM

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



[PHP] Re: Re: Re: Re: can't get IIS to run php if the script is not directly under wwwroot

2005-10-17 Thread tony yau
THANKS JAY, YOU ARE A SAINT :)

I commented out the doc_root and restart and it came alive :)

Thank you all
Tony

Jay Blanchard [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 [snip]
 thanks for your time.
 i installed it as ISAPI

 can i ask if you have had IIS5 on win2k professional running php scripts
 that is not under the \wwwroot ?
 some how i getting to think it can't (?!) be done although it does work
for
 II6 win2003 server!
 [/snip]

 I have IIS5 installed on W2K Pro running PHP scripts in virtual
directories.
 Try commenting the doc_root line in your php.ini and then restarting IIS.
 This has been known to cause some problems with virtuals. Make sure that
 php.ini can be read by everyone.

 -- 
 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] Uploaded CSV - database

2005-10-17 Thread Mark Rees
  -Original Message-
  From: Jim Moseby [mailto:[EMAIL PROTECTED]
  Sent: Monday, October 17, 2005 10:41 AM
  To: 'Brian Dunning'; php-general@lists.php.net
  Subject: RE: [PHP] Uploaded CSV - database
 
 
   -Original Message-
   From: Brian Dunning [mailto:[EMAIL PROTECTED]
   Sent: Monday, October 17, 2005 10:37 AM
   To: php-general@lists.php.net
   Subject: [PHP] Uploaded CSV - database
  
  
   Does anyone have an example of code to process a CSV file
  submitted
   via a file upload and parse it out in order to write its
   records to a
   db?
  
 
 
  With MYSQL (assuming permissions and such are in order) You
  would simply:
 
  $sql=load data local infile '/path/to/csv' into table
  tablename fields
  terminated by ',';
 

 I should amend this to say that the columns in your CSV file, and in the
 table must match for this to work.

 If you wanted to parse through it line by line and do it all manually,
check
 out the fread() and explode() functions in the PHP manual.

and don't forget fgetcsv()

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



RE: [PHP] Invoking a DLL with PHP

2005-10-17 Thread Jay Blanchard
[snip]
The DLL was built specifically with a COM interface which I accessed using
the PHP COM functions (as I'm sure you've seen already). The DLL authors had
to rejig their original code a little, but it was a far
less painful process than compiling the DLL into PHP. However for the next
revision we are likely to move the DLL code into the .NET framework, build a
SOAP interface to it (C#) and let PHP talk to it that way. Although that's
more of a political decision than a technical one, I'm just mentioning it
incase the idea is useful for you.
[/snip]

Unfortunately I may not be able to have the DLL re-built with the COM
interface. It is an older DLL containing engineering functions and it is
huge. The real dingle here is that I only need to access some of the
functionality of the DLL. I also do not want to compile it into PHP as it
(the DLL) is a moving target. This may be one of those projects where I say,
Give me some more development folks and we'll get it done right. otherwise
we may not be able to do the project as it exists.

I am researching the requirements for adding the COM interface now.

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



RE: [PHP] Uploaded CSV - database

2005-10-17 Thread Jim Moseby


 -Original Message-
 From: Mark Rees [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 17, 2005 11:11 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Uploaded CSV - database
 
 
   -Original Message-
   From: Jim Moseby [mailto:[EMAIL PROTECTED]
   Sent: Monday, October 17, 2005 10:41 AM
   To: 'Brian Dunning'; php-general@lists.php.net
   Subject: RE: [PHP] Uploaded CSV - database
  
  
-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Monday, October 17, 2005 10:37 AM
To: php-general@lists.php.net
Subject: [PHP] Uploaded CSV - database
   
   
Does anyone have an example of code to process a CSV file
   submitted
via a file upload and parse it out in order to write its
records to a
db?
   
  
  
   With MYSQL (assuming permissions and such are in order) You
   would simply:
  
   $sql=load data local infile '/path/to/csv' into table
   tablename fields
   terminated by ',';
  
 
  I should amend this to say that the columns in your CSV 
 file, and in the
  table must match for this to work.
 
  If you wanted to parse through it line by line and do it 
 all manually,
 check
  out the fread() and explode() functions in the PHP manual.
 
 and don't forget fgetcsv()

Thanks! Good one.  I didn't forget it, I just didn't know about it.  :-)

JM

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



Re[2]: [PHP] Invoking a DLL with PHP

2005-10-17 Thread Richard Davey
Hi Jay,

Monday, October 17, 2005, 4:15:58 PM, you wrote:

 Unfortunately I may not be able to have the DLL re-built with the
 COM interface. It is an older DLL containing engineering functions
 and it is huge. The real dingle here is that I only need to access
 some of the functionality of the DLL. I also do not want to compile
 it into PHP as it (the DLL) is a moving target.

If the resources allow, you could always write a small command-line
driven Windows app that passes arguments through to the DLL functions
and returns the results? Then exec() the app. It's a bit too messy for
my liking, but it's certainly an option.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] Uploaded CSV - database

2005-10-17 Thread Brian Dunning
It looks like all of those tips will easily cover me for the latter  
half of the operation. Any tips on how to get the uploaded CSV file  
into memory in order to attack it with fgetcsv()? I'd rather not ever  
have to actually write the file to the server's disk.


Thanks!

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



RE: [PHP] Uploaded CSV - database

2005-10-17 Thread Jay Blanchard
[snip]
It looks like all of those tips will easily cover me for the latter  
half of the operation. Any tips on how to get the uploaded CSV file  
into memory in order to attack it with fgetcsv()? I'd rather not ever  
have to actually write the file to the server's disk.
[/snip]

Once you have performed move_uploaded_file() you will have to fopen and loop
through the file to read and perform error checking. After you have
processed the file you could then unlink() it, removing it from the server's
disk. Here is an example where Excel files are uploaded as tab delimited
text;

/*real file name*/
$fileName = ($HTTP_POST_FILES['docfile']['name']);
$docWork = /path/to/file/after/move/;

move_uploaded_file($HTTP_POST_FILES['docfile']['tmp_name'], $docWork .
$fileName) or die(File cannot be uploaded);

/*
** open uploaded file and do stuff to it
*/
$i = 0;
$fileTab = fopen($docWork.$fileName, r);
while(!feof($fileTab)){
$fileLine = fgets($fileTab, 1024);

$arrLine = explode(\t, $fileLine);
$cmLength = strlen($arrLine[0]);

/* do other stuff here */
}
fclose($fileTab);

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



RE: [PHP] Uploaded CSV - database

2005-10-17 Thread Jim Moseby
 -Original Message-
 From: Brian Dunning [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 17, 2005 11:39 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Uploaded CSV - database
 
 
 It looks like all of those tips will easily cover me for the latter  
 half of the operation. Any tips on how to get the uploaded CSV file  
 into memory in order to attack it with fgetcsv()? I'd rather 
 not ever  
 have to actually write the file to the server's disk.
 
 Thanks!
 

If you are using the standard file upload facilities, your file is being
written to disk when it is being uploaded.  As far as I can tell, fgetcsv()
will only read a file from disk:

?php // from the manual
$row = 1;
$handle = fopen (test.csv,r);
while ($data = fgetcsv ($handle, 1000, ,)) {
$num = count ($data);
print p $num fields in line $row: br\n;
$row++;
for ($c=0; $c  $num; $c++) {
print $data[$c] . br\n;
}
}
fclose ($handle);
?

If you are instead using a socket connection to receive the file in a stream
from the client, you could assign it to a string variable, and use
explode().

These are fairly uncharted territories for me, so others will likely have
better answers.

JM

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



[PHP] PHP5+FastCGI Segmentation Fault

2005-10-17 Thread Jason Kovacs
Hello,

I have Apache 2, PHP5 (cgi-fcgi), FastCGI, and Suexec on FC4 64-bit, and it 
works for the most part, 
but some 3rd-party PHP software written for PHP4 will break and in my error_log 
I've seen the message:

FastCGI: (dynamic) server /.../php-fcgi terminated due to uncaught signal '11' 
(Segmentation fault),

causing it to flood the error_log with messages that it could not remain 
running for 30 sec and its restart
was backed off to 600 seconds, then reports an Internal Server Error.

Is this normal or expected from some PHP scripts, or is there a 
misconfiguration in my setup? 
How do I troubleshoot this?  Any help would be appreciated, thanks.

-Jason Kovacs


[PHP] Test

2005-10-17 Thread J.Lubelan

test

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



[PHP] PHP and sessions

2005-10-17 Thread J.Lubelan

Hello

Can anybody help me with sessions?
Where is the problem? I start session in start.php script.

?php // start.php script
session_name('test');
session_start();
$_SESSION['fig1'] = 'split';
..
..
..
$split = http://;. $_SERVER['HTTP-HOST']. dirname($_SERVER['PHP_SELF']).  
/split.php;

?
a href=?php echo $split ? target=_blank title=Split userSplit  
testing/a


__

After link cliking in IE or OPERA they start new session. How can I conect  
to existing session?


?php // split.php
session_name('test');
session_start(); // unable to connect to existing session, create another  
one.

?
..
..
..

I used this two scripts wit DeepNet Explorer and all works fine, but in IE  
and OPERA function session_start() called from split.php start new session  
so I can't read $_SESSON array than.


Thanks for any hints

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



Re: [PHP] Re: a couple of problems with PHP form

2005-10-17 Thread Richard Lynch
On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
 -
 sorry, my editor has not indented again
 -
 also, I want the field to appear hilighted when there is no
 information so I am doing this:

 input class=? if($error_msg){ echo error; } ELSE { echo
 normal; } id=firstname name=firstname type=text
 value={$_POST['firstname']}? /

I think the quote mark balancing is messed up here...

input class=
this starts a quote for the class=

There appears to be no ending quote for that...

It may simply have been lost in email editing, however...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] RE: php-general Digest 17 Oct 2005 10:35:46 -0000 Issue 3742

2005-10-17 Thread Richard Lynch
On Mon, October 17, 2005 6:06 am, Aftab Alam wrote:
 i want to generate Pdf file using php.
 how can i  what tools is required for this.

One way is to start here:
http://php.net/pdf


-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Re: can't get IIS to run php if the script is not directly under wwwroot

2005-10-17 Thread Richard Lynch
On Mon, October 17, 2005 6:24 am, tony yau wrote:
 the security for my 'Project' folder (aliases 'phpproject'  where
 test.php
 is under) has

Are there any security settings on the alias itself 'phpproject'?

Is an alias folder the same as a shortcut like you make in Windows
desktop explorer thingie?

Cuz those damn things are useless to anything but Windows Explorer
itself, as far as I could ever tell...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Troubleshott GD Freetype under Linux

2005-10-17 Thread Richard Lynch
On Sat, October 15, 2005 11:24 am, Feris Thia C. wrote:
 My PHP engine still cannot load JPEG library (GD) and Freetype
 fonts...

 I use ./config.nice to reconfigure PHP coz it works... and I have
 compile it
 with --jpeg-dir options. And seems not working at all.

 How can I troubleshoot and resolve these problems ?

When you run configure (or config.nice) it generates a BUNCH of text
output.

It also logs a BUNCH of stuff to a log file in that same directory.

Re-direct the output and/or look in that log file for WARNING or ERROR
messages from the configure.

configure considers some command-line options such as --jpeg-dir as
non-fatal and cheerfully continues on its merry way, giving you a
valid PHP compile with, errr, not quite what you asked for. :-^

I've long considered this a bug personally, though have never
persuaded anybody else to my way of thinking...

Most likely, the --jpeg-dir and/or the --with-gd are not quite right,
and you just need to adjust a directory name somewhere, or put in some
symlinks so configure finds the stuff it is looking for where it
expects to find it, instead of where you (or your RPMs) put it.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Uploaded CSV - database

2005-10-17 Thread Ben Litton
Actually I think fgetcsv will work with any valid file pointer and at  
least in PHP 5, the streams implementation will allow you to use a variety  
of protocols to create the stream.


http://us2.php.net/manual/en/wrappers.php

I understand that it isn't even too teribbly difficult to implement your  
own stream if one isn't already to your liking, but I'm afraid I haven't  
found need to go beyond the simple read-a-file-from disk style operation.


Ben

On Mon, 17 Oct 2005 11:45:04 -0400, Jim Moseby [EMAIL PROTECTED]  
wrote:



-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Monday, October 17, 2005 11:39 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Uploaded CSV - database


It looks like all of those tips will easily cover me for the latter
half of the operation. Any tips on how to get the uploaded CSV file
into memory in order to attack it with fgetcsv()? I'd rather
not ever
have to actually write the file to the server's disk.

Thanks!



If you are using the standard file upload facilities, your file is  
being
written to disk when it is being uploaded.  As far as I can tell,  
fgetcsv()

will only read a file from disk:

?php // from the manual
$row = 1;
$handle = fopen (test.csv,r);
while ($data = fgetcsv ($handle, 1000, ,)) {
$num = count ($data);
print p $num fields in line $row: br\n;
$row++;
for ($c=0; $c  $num; $c++) {
print $data[$c] . br\n;
}
}
fclose ($handle);
?

If you are instead using a socket connection to receive the file in a  
stream

from the client, you could assign it to a string variable, and use
explode().

These are fairly uncharted territories for me, so others will likely have
better answers.

JM




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Richard Lynch
On Sat, October 15, 2005 7:26 am, Edward Vermillion wrote:
 Do they want the PDF to display in the page, or is a link to a PDF ok
 for them?

I've already warned them that a PDF embedded into a page is impossible.

That may not be true, technically, for all I know, but I've sure never
seen it, and don't even want to try to go somewhere that so few have
gone.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Richard Lynch
On Fri, October 14, 2005 6:03 pm, Jason Kovacs wrote:
 Richard Lynch said the following on Friday, October 14, 2005 3:39 PM:

 So...

 Do I:

 A) Attempt to hack fckEditor to allow a PDF to get uploaded, and
 then display a link to the PDF instead of alink to the fckEditor
 output.

 B) Give them a separate, possibly confusing, input to upload files
 to
 tie in as links to the fckEditor area

 I've had success with this, creating a seperate utility to upload
 documents
 to the filesystem and keeping track of them in mysql.  I chose to
 allow
 displaying the PDF's and Doc's through links in the FCKEditor content,
 because I have never found a way to embed the PDF data into pages.

I don't think PDF embedded into pages exists...

Not saying for sure it doesn't, and sure not saying it SHOULDN'T, but
I've told them it ain't happening for them in the time-frame we've
got. :-)

 I added a custom drop-down menu to FCKEditor's Link window that fills
 in the URL upon selecting the menu item, but this url consisted of
 just a
 path to a redirect.php script where I set a GET variable to the ID of
 the
 document, then passing through the PDF or DOC data.  Though you could
 link the full path to the PDF in the URL, I just had my documents
 stored
 behind the web-accessible address.  Every time a new document was
 uploaded, I decided to write the URL's statically to a file that the
 FCKEditor script (changed fck_link.html to fck_link.php) will read
 into
 Javascript arrays, as opposed to accessing the DB every time this Link
 window was viewed.  I added about 50 lines of Javascript code to
 fck_link.php to do what I wanted in setting the URL from the Select
 list.

Sweet!

 I must warn you though, every time that I upgrade FCKEditor, I have to
 reapply the changes I've done and there is the possibility that the
 FCKEditor scripts may change to cause compatibility problems.  Let me
 know if you are interested in this route and I can post my alterations
 to
 FCKEditor,

Please do!

 but the PDF file management is up to you.

Oh yeah.  That's for sure.

 I've had many
 non-technical users working with this utility just fine for about 6
 months,
 so it works and though its not the most graceful implementation from a
 developer's standpoint, it makes the user interface easiest to work
 with.

It certainly sounds like a very good solution.

Be really nifty if fckEditor folks took a look at it and considered
adding it as a feature.

We can't be the only ones needing this kind of thing.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Torgny Bjers
Richard Lynch wrote:

On Sat, October 15, 2005 7:26 am, Edward Vermillion wrote:
  

Do they want the PDF to display in the page, or is a link to a PDF ok
for them?



I've already warned them that a PDF embedded into a page is impossible.

That may not be true, technically, for all I know, but I've sure never
seen it, and don't even want to try to go somewhere that so few have
gone.
  


I think you would be able to use an IFRAME, or even a FRAME, to load the
PDF into like you would open it in any normal browser using the standard
PDF plugin that's used when you click a PDF in your browser. That is,
set the src of the iframe to the path of the PDF. Give it a try and let
us know how it works out. IFRAMEs are smart sometimes, especially when
building application interfaces.

Regards,
Torgny

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



Re: [PHP] RE: php-general Digest 17 Oct 2005 10:35:46 -0000 Issue 3742

2005-10-17 Thread Ben

Richard Lynch said the following on 10/17/05 13:14:

On Mon, October 17, 2005 6:06 am, Aftab Alam wrote:


i want to generate Pdf file using php.
how can i  what tools is required for this.



One way is to start here:
http://php.net/pdf




When reading the above link note the last sentence under the 
Installation heading.  You want to install the pdflib extension using 
PEAR with the command:

pear install pdflib

Once you've done that edit your php.ini and make sure it includes the line:
extension=pdf.so

Then restart your web server.

- Ben

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



Re: [PHP] Obsession with BC, take 2

2005-10-17 Thread Richard Lynch
On Fri, October 14, 2005 5:18 pm, GamblerZG wrote:
The second one is by using two
different
apache modules. It *does not break anything*, but it's a pain to
setup.

Judging sheerly by functionality and compatibility the second ways
 is
better.

However, judging from what I know about PHP, nobody tries to make
 that
way easier, because everybody assume that everyone else use the
 first
way. Is it good old catch 22 in action, or are there some design
considerations I'm not aware of?

 A great number of people have worked on, and are working on, ways to
 make this easier.

 Most people, however, find it more practical to simply have 2
 different server configurations (old and new) and migrate clients
 onto
 the new server slowly, at the CLIENT'S pace, instead of losing
 customers by just trashing their site out from under them.

 Actually, I was speaking about PHP developers.

As was I...

Keep in mind that most, if not all, PHP developers are also PHP users
and have to manage servers just as you do.

They surely did not intentionally make things difficult for themselves
on purpose.

We know for a fact that they have tried, in the past:
1. Different filename extensions.
2. Having 2 versions in a single Apache Module at one time
3. Running one of 2 versions as CGI
4. Putting some services/hosts on a different server, masking it
through Apache magic proxy thingie.

 The sheer fact that
 they
 bothered to write compatibility mode shows that they don't really
 count
 on hosters using two engines side-by-side. On the other hand, the only
 disadvantage of such approach is installation, and developers have the
 power to remove this shortcoming. Since they preferred the first way
 of
 handling compatibility, there must be some language design issues with
 the second one. It would be interesting to know/discuss them.

Perhaps you should subscribe to and search through the Developers' and
Internals mailing lists where such conversations take place.

I daresay a great deal of information and discussion is there.

I am quite confident that it is nowhere near as simple as you think.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Jasper Bryant-Greene

Richard Lynch wrote:


 On Sat, October 15, 2005 7:26 am, Edward Vermillion wrote:

 Do they want the PDF to display in the page, or is a link to a PDF
 ok for them?


 I've already warned them that a PDF embedded into a page is
 impossible.

 That may not be true, technically, for all I know, but I've sure
 never seen it, and don't even want to try to go somewhere that so few
 have gone.



I would expect that putting the PDF in an iframe would work, but I 
wouldn't trust browsers or the Acrobat plugin to not crash horribly in 
that sort of situation. It's also going to be very confusing for users 
seeing the Acrobat toolbar floating in the middle of their page.


It would be interesting to see some tests of PDF-in-iframe done in 
various different browsers, but unless it just happened to work 
perfectly in every common browser (we can all dream, can't we?) I 
wouldn't touch it.


Jasper

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Torgny Bjers
Jasper Bryant-Greene wrote:

 Richard Lynch wrote:

  On Sat, October 15, 2005 7:26 am, Edward Vermillion wrote:

  Do they want the PDF to display in the page, or is a link to a PDF
  ok for them?


  I've already warned them that a PDF embedded into a page is
  impossible.

  That may not be true, technically, for all I know, but I've sure
  never seen it, and don't even want to try to go somewhere that so few
  have gone.


 I would expect that putting the PDF in an iframe would work, but I
 wouldn't trust browsers or the Acrobat plugin to not crash horribly in
 that sort of situation. It's also going to be very confusing for users
 seeing the Acrobat toolbar floating in the middle of their page.

 It would be interesting to see some tests of PDF-in-iframe done in
 various different browsers, but unless it just happened to work
 perfectly in every common browser (we can all dream, can't we?) I
 wouldn't touch it.

 Jasper


After some consideration I am pretty sure it works, since an iframe/
is just the same as a frame/, and I am dead certain you can open a PDF
document, or a Word document, or a Flash file, inside a frame without
anything crashing. As for the PDF toolbar, I think that with the proper
CSS styles on the iframe/ element you can make it pretty apparent that
the iframe/ contains a PDF document.

Also, when using iframe/ you are weeding out those old browsers that
wouldn't support even loading an iframe/, which means that you get
relatively new browsers, and those should all support this method.

Besides, if this is for an editor interface, for a specific client, one
could reasonably demand that they use at least one of the newer browsers
such as IE5+ or Mozilla. If not for a specific client, or subset of
clients, but for a general update of an entire application that is open
sourced, I agree with Jasper, don't touch it. :)

Regards,
Torgny

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Richard Lynch
On Mon, October 17, 2005 3:31 pm, Torgny Bjers wrote:
 I think you would be able to use an IFRAME, or even a FRAME, to load
 the
 PDF into like you would open it in any normal browser using the
 standard
 PDF plugin that's used when you click a PDF in your browser. That is,
 set the src of the iframe to the path of the PDF. Give it a try and
 let
 us know how it works out. IFRAMEs are smart sometimes, especially when
 building application interfaces.

I'm the kind of guy who considers CSS and JavaScript too unreliable
with older browsers to use...

I don't think I'm gonna be testing iFrames out any time soon.

Plus, I *KNOW* that some users (e.g., me) configure Acrobat to *NOT*
put a PDF in my browser, but open a separate application, because
that's invariably the way I want to view it, flipping back-and-forth
to the 'net to cross-ref with both windows open.

So, even if it sort of worked, for users who don't do that, or even if
I could force it to work, and not LET them open up in another window,
I don't think that's a Good Idea for keeping happy users, so that
ain't gonna happen either.

But that's just me.

Somebody else reading this thread might say keen-o and do it.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Richard Lynch
On Mon, October 17, 2005 3:56 pm, Torgny Bjers wrote:
 Also, when using iframe/ you are weeding out those old browsers that

If somebody else wants to weed out old browsers, that's all fine and
good, but that's not me...

 Besides, if this is for an editor interface, for a specific client,
 one
 could reasonably demand that they use at least one of the newer
 browsers
 such as IE5+ or Mozilla. If not for a specific client, or subset of
 clients, but for a general update of an entire application that is
 open
 sourced, I agree with Jasper, don't touch it. :)

I personally don't think I should demand editors use a specific browser.

I believe in customer choice.

For that matter, *I* probably don't use a browser that does this
right, being as I'm usually on Linux, almost always on Netscape, and
very very very rarely do PDF and/or Flash work really right for me.

And you know what?

I very very very seldom care badly enough about any of the content I'm
missing and when I do care enough to go get it, I'm disappointed by
the content more often than I'm pleased that I took that effort.

Again, this is obviously MY weird world-view at work here. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Jason Karns
-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 17, 2005 5:11 PM
To: Torgny Bjers
Cc: php-general@lists.php.net
Subject: Re: [PHP] fckeditor and PDF and pesky users

On Mon, October 17, 2005 3:56 pm, Torgny Bjers wrote:
 Also, when using iframe/ you are weeding out those old browsers that

If somebody else wants to weed out old browsers, that's all fine and good,
but that's not me...

 Besides, if this is for an editor interface, for a specific client, 
 one could reasonably demand that they use at least one of the newer 
 browsers such as IE5+ or Mozilla. If not for a specific client, or 
 subset of clients, but for a general update of an entire application 
 that is open sourced, I agree with Jasper, don't touch it. :)

I personally don't think I should demand editors use a specific browser.

I believe in customer choice.

For that matter, *I* probably don't use a browser that does this right,
being as I'm usually on Linux, almost always on Netscape, and very very very
rarely do PDF and/or Flash work really right for me.

And you know what?

I very very very seldom care badly enough about any of the content I'm
missing and when I do care enough to go get it, I'm disappointed by the
content more often than I'm pleased that I took that effort.

Again, this is obviously MY weird world-view at work here. :-)

--
Like Music?
http://l-i-e.com/artists.htm

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



Not that you'd want to use a deprecated tag, but using an embed tag with a
src value pointing to a PDF file (with appropriate height/width) will render
the entire Adobe plugin with toolbars and all directly in the page, as
demonstrated here:
http://www.cstv.com/auto_pdf/p_hotos/s_chools/osu/sports/m-footbl/auto_pdf/w
eekly-release

Jason Karns

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Torgny Bjers
Richard Lynch wrote:

On Mon, October 17, 2005 3:56 pm, Torgny Bjers wrote:
  

Also, when using iframe/ you are weeding out those old browsers that



If somebody else wants to weed out old browsers, that's all fine and
good, but that's not me...
  


Didn't say I wanted to. It was a suggestion. :) I personally prefer Lynx
when I am surfing, since then I get rid of everything, including images,
javascript, and plugins -- just me and text. Nah, seriously, I kind of
like Firefox since 80x25 text space in lynx can get a bit annoying when
navigating a site that somebody added a bzillion images to, but let's
not talk about browsers and favorites, since that'd be another long
ardous flame fest. :P

Besides, if this is for an editor interface, for a specific client,
one
could reasonably demand that they use at least one of the newer
browsers
such as IE5+ or Mozilla. If not for a specific client, or subset of
clients, but for a general update of an entire application that is
open
sourced, I agree with Jasper, don't touch it. :)



I personally don't think I should demand editors use a specific browser.

I believe in customer choice.

For that matter, *I* probably don't use a browser that does this
right, being as I'm usually on Linux, almost always on Netscape, and
very very very rarely do PDF and/or Flash work really right for me.

And you know what?

I very very very seldom care badly enough about any of the content I'm
missing and when I do care enough to go get it, I'm disappointed by
the content more often than I'm pleased that I took that effort.

Again, this is obviously MY weird world-view at work here. :-)
  

I wasn't trying to advocate you doing something you don't want to do. If
you consider the feature worth implementing, weighing the options, you
implement it, or you don't, either way, your choice. I merely stated
that it does work, when using a recent browser.

The iframe/ tag was added in IE3+ which is pretty darn old, and if
you've seen ANYBODY using anything Microsoft-made prior to IE3 in your
server logs of late, let me know. :)

The following major browsers have support for iframe/:

Internet Explorer for Macintosh: 5.2 (not sure about 5.1)
Internet Explorer: 3.0 and above
Mozilla: 1.0 and above
Netscape Navigator: above 4.0 (which should be 6.0)
Opera: 4.0 and above
Safari: 1.0 and above

So, if you use one of these browsers, and considering that you rarely
(I'd say about %1-5) see people using anything below these versions,
you'd be safe adding an iframe/ if you wanted to. If the browser does
not have support for iframe/ it will ignore the tag and it won't break
anything at all.

As Jason Karns showed in the example from cstv, and you could test that
on all your different browsers and see what happens, if they have the
plugin installed, it ought to work...

But, on that note, if it is entirely vital to display the PDF, why not
convert the PDF to HTML instead and display that then? Would work in all
browsers, a little hit on the server performance, which can be avoided
by caching the results of a PDF - HTML conversion. Don't ask me where
to get code for this, as I have no clue, but I am sure it exists somewhere.

Regards,
Torgny

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Jason Kovacs

Richard Lynch said the following on Monday, October 17, 2005 3:30 PM:

On Fri, October 14, 2005 6:03 pm, Jason Kovacs wrote:

Richard Lynch said the following on Friday, October 14, 2005 3:39 PM:



I added a custom drop-down menu to FCKEditor's Link window that fills
in the URL upon selecting the menu item, but this url consisted of
just a
path to a redirect.php script where I set a GET variable to the ID of
the
document, then passing through the PDF or DOC data.  Though you could
link the full path to the PDF in the URL, I just had my documents
stored
behind the web-accessible address.  Every time a new document was
uploaded, I decided to write the URL's statically to a file that the
FCKEditor script (changed fck_link.html to fck_link.php) will read
into
Javascript arrays, as opposed to accessing the DB every time this Link
window was viewed.  I added about 50 lines of Javascript code to
fck_link.php to do what I wanted in setting the URL from the Select
list.


Sweet!


I must warn you though, every time that I upgrade FCKEditor, I have to
reapply the changes I've done and there is the possibility that the
FCKEditor scripts may change to cause compatibility problems.  Let me
know if you are interested in this route and I can post my alterations
to
FCKEditor,


Please do!


but the PDF file management is up to you.


Oh yeah.  That's for sure.


I've had many
non-technical users working with this utility just fine for about 6
months,
so it works and though its not the most graceful implementation from a
developer's standpoint, it makes the user interface easiest to work
with.


It certainly sounds like a very good solution.

Be really nifty if fckEditor folks took a look at it and considered
adding it as a feature.

We can't be the only ones needing this kind of thing.


Here's my changes to FCKEditor, and it works on version 2.0 RC3, but should
work for other later versions too unless drastic changes have been made by
it's developers to the affected scripts.   I tried to clean it up for you as
much as possible and took out my customizations using doc ID's and broadened
it to use string URL's, which you'll need to write along with the doc
entry's Title to a static JS file that gets read by FCKEditor (using php).
The code also handles grouping uploaded documents into 1-level-deep groups,
so this is something you'll have to keep track of in your upload utility.
If that's not something you need or can easily figure out, just take out the
JS code that deals with Option Groups and flatten the document data array.

FCKEditor Customization Notes for linking Documents
---
By Jason Kovacs - 2005-05-04

1. Install the FCKeditor utility to /path/to/public_html/js/FCKeditor/.

2. The directory /path/to/public_html/js/data/ must be created and have
permissions of 777.

3. Set up the Document Upload utility to write static data to the file
/path/to/public_html/js/data/fck_link_docdata.js
  with the following structure:
---
var documentGroups = [Group 1,Group 2];
var documentData =
[
[
 [Doc Title 1,URL],
 [Doc Title 2,URL]
],
[
 [Doc Title 1,URL],
 [Doc Title 2,URL]
]
];
---

4. Rename ./js/FCKeditor/editor/dialog/fck_link.html to fck_link.php and
Edit it to have these changes:

4a. Below meta name=robots content=noindex, nofollow /, insert:
SCRIPT Language=JavaScript!-- 
?

@readfile(/path/to/public_html/js/data/fck_link_docdata.js);
?
//--/SCRIPT

4b. Insert the following two Table rows above the tr for Protocol:
tr
 td nowrap=nowrap colspan=3
  span fckLang=DlgLnkDocumentDocuments/spanbr /
  select style=WIDTH: 100% id=cmbLinkDocument
onchange=SetDocumentUrl(this.value);
option
value=0Select a Document File/option
  /select
 /td
/tr

5. Edit ./js/FCKeditor/editor/dialog/fck_link/fck_link.html to have these
changes:

5a. Add these lines after LoadSelection() ; in the window.onload
function() call:
// Load the Documents select menu with optgroups/options from the included
data arrays.
LoadDocumentData() ;

5b. Before the SetLinkType function, add the following:

function LoadDocumentData()
{
var sUrl = GetE('txtUrl').value;
var docSelectObj = GetE('cmbLinkDocument');
for(var i=0; i  documentGroups.length; i++)
{
 optGroup = document.createElement('optgroup');
 optGroup.label = documentGroups[i];
 docSelectObj.appendChild(optGroup);
 for(var j=0; j  documentData[i].length; j++)
 {
  var objOption = document.createElement(option);
  objOption.innerHTML = documentData[i][j][0];
  objOption.value = documentData[i][j][1];
  if(objOption.value == sUrl) objOption.selected = true;
   optGroup.appendChild(objOption);
 }
}
}

5c. Change the line in the function SetLinkType from:
window.parent.SetTabVisibility( 'Advanced' , (linkType != 'anchor' ||
bHasAnchors) ) ;
   To the line:
window.parent.SetTabVisibility( 'Advanced' , false ) ;

5d. Change the line in the function 

Re: [PHP] Invoking a DLL with PHP

2005-10-17 Thread Gonzalo Monzón

Richard Davey escribió:


Hi Jay,

Monday, October 17, 2005, 4:15:58 PM, you wrote:

 


Unfortunately I may not be able to have the DLL re-built with the
COM interface. It is an older DLL containing engineering functions
and it is huge. The real dingle here is that I only need to access
some of the functionality of the DLL. I also do not want to compile
it into PHP as it (the DLL) is a moving target.
   



If the resources allow, you could always write a small command-line
driven Windows app that passes arguments through to the DLL functions
and returns the results? Then exec() the app. It's a bit too messy for
my liking, but it's certainly an option.

Cheers,

Rich
 


Hi all,

I did some succesful works on this issue using php4, i don't know if all 
the methods i'm going to tell you work for php5 anyway.


The details of what you need to do with that dll from the php code or 
the way the target dll works will let you take one or other way... These 
are some of them:


You can build your own dll -or use that older dll as you say-, assuming 
it have exported the necessary functions and calling them using the 
php_w32api extension, just register necessary types, functions and 
you're ready to go, without any kind of recompilation of php or any dll 
static linking, the dll is just loaded when you register the dll 
functions from the php code using that beautiful extension.  There are 
some tricks if you take this way, in relation with the type and size of 
data you need to send or receive from the dll, but it works pretty well. 
And you could code your own dll wrapper interface to the older dll if 
some workaround is needed to have it working -perhaps callbacks, hard 
data types, etc.-


Anyway could be a bit hard to success if you have to send or receive 
complex data types like arrays, pointers, handles, etc. etc. but it 
really depends on what you need to do with your data in the dll side, 
maybe you could serialize and send as a string for the whole array 
-excuse me, sure this is a bit off topic for your case-, or perhaps you 
could call a function per every single item in the array you want to 
send to the dll, then when finished maybe call another function to 
process the previously loaded data. Calls via this extension really go 
very fast and cause very low overhead.


Another way is by using your dll from a COM interface as Richard says, 
an easy way to do this could be create an activex dll from Vb6 (that 
dll or exe is just a com server or maybe you want to call it ole, 
but for this is just the same thing). Then, you could write the needed 
code in Vb for your functionality or perhaps wrapping the dll with this 
Vb activex object. This way you can send from php easily complex data 
types like arrays, and use an oo interface to the dll. Maybe you will 
need to hide some of the complexities with data types in the Vb COM 
interface instead of having to lead with this in the php code -what 
happens with the first way exposed-. So for some uses this can be 
better. The worse is that you need to register the object in the 
registry, as it is a COM server.


One more way is to create your library functions -or wrapper functions- 
within a vc++ executable, and embed php into it, this way you can code 
the php-dll interface as you were coding a php extension and use that 
functions as php functions and methods, linking your project with 
php_embed and handling it inside your executable to do the work. Of 
course, this way isn't really possible if you need to have php running 
on a webserver, as you need to link dynamically with php4_ts.dll


These methods give you poweful ways to extend or workaround over php 
limits... :-P


So that was my 2cents. :^)

Hope it helps to clears a bit what could you do to get the job done.

Gonzalo.

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



[PHP] re: some problems with php form

2005-10-17 Thread Bruce Gilbert
-- Forwarded message --
From: Richard Lynch [EMAIL PROTECTED]
To: Mark Rees [EMAIL PROTECTED]
Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
Subject: Re: [PHP] Re: a couple of problems with PHP form
On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
 -
 sorry, my editor has not indented again
 -
 also, I want the field to appear hilighted when there is no
 information so I am doing this:

 input class=? if($error_msg){ echo error; } ELSE { echo
 normal; } id=firstname name=firstname type=text
 value={$_POST['firstname']}? /
I think the quote mark balancing is messed up here...
input class=
this starts a quote for the class=
There appears to be no ending quote for that...
It may simply have been lost in email editing, however...


adding the input.error didn't solve the problem dang it.! If there is
a ending quote missing, I don't see it right off hand.

I know have:


input class=? if($error_msg){ echo input.error; } ELSE { echo
input.normal; } id=firstname name=firstname type=text
value={$_POST['firstname']}? /

in the css:

input.error {
border: 2px inset red;
margin:0;
font-family: arial, helvetica, sans-serif;
color: #036;
width: 15em;
padding-left: .25em;
font-weight: bold;
background: #eee;
}

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



Re: [PHP] re: some problems with php form

2005-10-17 Thread Minuk Choi

Wait a minute... you meant

input class=
	?PHP 
		if ($error_msg)

{
			echo input.error; 
		} 
		else

{
			echo input.normal; 
		}

? id=firstname name=firstname type=text value=?PHP echo 
$_POST['firstname'];?


...or am I looking at the wrong thing?

Bruce Gilbert wrote:


-- Forwarded message --
From: Richard Lynch [EMAIL PROTECTED]
To: Mark Rees [EMAIL PROTECTED]
Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
Subject: Re: [PHP] Re: a couple of problems with PHP form
On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
 


-
sorry, my editor has not indented again
-
also, I want the field to appear hilighted when there is no
information so I am doing this:

input class=? if($error_msg){ echo error; } ELSE { echo
normal; } id=firstname name=firstname type=text
value={$_POST['firstname']}? /
   


I think the quote mark balancing is messed up here...
 


input class=
this starts a quote for the class=
There appears to be no ending quote for that...
   


It may simply have been lost in email editing, however...


adding the input.error didn't solve the problem dang it.! If there is
a ending quote missing, I don't see it right off hand.

I know have:


input class=? if($error_msg){ echo input.error; } ELSE { echo
input.normal; } id=firstname name=firstname type=text
value={$_POST['firstname']}? /

in the css:

input.error {
border: 2px inset red;
margin:0;
font-family: arial, helvetica, sans-serif;
color: #036;
width: 15em;
padding-left: .25em;
font-weight: bold;
background: #eee;
}

 



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



Re: [PHP] re: some problems with php form

2005-10-17 Thread Chris

Bruce Gilbert wrote:


-- Forwarded message --
From: Richard Lynch [EMAIL PROTECTED]
To: Mark Rees [EMAIL PROTECTED]
Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
Subject: Re: [PHP] Re: a couple of problems with PHP form
On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
 


-
sorry, my editor has not indented again
-
also, I want the field to appear hilighted when there is no
information so I am doing this:

input class=? if($error_msg){ echo error; } ELSE { echo
normal; } id=firstname name=firstname type=text
value={$_POST['firstname']}? /
   


I think the quote mark balancing is messed up here...
 


input class=
this starts a quote for the class=
There appears to be no ending quote for that...
   


It may simply have been lost in email editing, however...


adding the input.error didn't solve the problem dang it.! If there is
a ending quote missing, I don't see it right off hand.

I know have:


input class=? if($error_msg){ echo input.error; } ELSE { echo
input.normal; } id=firstname name=firstname type=text
value={$_POST['firstname']}? /

 

Shouldn't you jsut be echoing error or normal . A period isn't 
allowed in a class dafinition, and the css will work for all elements of 
type input with a class of error. Also you don't seem to be closing the 
PHP tag at the right place


This is how I would do what it looks like you're trying to do.

input class=?php echo !empty($error_msg)?'error':'normal'? id=firstname name=firstname 
type=text value=?php echo htmlspecialchars($_POST['firstname'])? /


Chris


in the css:

input.error {
border: 2px inset red;
margin:0;
font-family: arial, helvetica, sans-serif;
color: #036;
width: 15em;
padding-left: .25em;
font-weight: bold;
background: #eee;
}

 



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