php-general Digest 1 Dec 2004 09:28:51 -0000 Issue 3144

Topics (messages 203183 through 203216):

Using PHP to change Linux IP address
        203183 by: AndyO
        203185 by: John Nichel
        203186 by: AndyO
        203188 by: Greg Donald
        203192 by: John Nichel

My session.c doesnt work!
        203184 by: Colin
        203187 by: Greg Donald

Header's download
        203189 by: Christian Johansson

Re: echo
        203190 by: Christopher Weaver

echo string with question mark in it
        203191 by: Brent Clements
        203193 by: Chris W. Parker

Spawning new pages
        203194 by: Christopher Weaver
        203196 by: Brent Clements
        203197 by: Chris W. Parker
        203198 by: Greg Donald
        203201 by: Chris W. Parker
        203207 by: Christopher Weaver
        203210 by: Jason Wong

regex issue
        203195 by: nate.savingadvice.com
        203199 by: Greg Donald
        203200 by: nate.savingadvice.com
        203208 by: Rick Fletcher

Date Manipulation
        203202 by: Christopher Weaver
        203203 by: John Holmes

Very fresh to php
        203204 by: suneel
        203205 by: Ryan King
        203206 by: Santa

Re: print_r() and SimpleXML
        203209 by: Rick Fletcher

Upload is not working ( Permission Problem), I tried a number of ways , still 
no success!!!!!
        203211 by: Michael Leung
        203212 by: Gareth Williams

Re: php editor or php IDE for linux with autocompletion
        203213 by: Christophe Chisogne

Redirect after download
        203214 by: Justin England
        203215 by: Thomas Munz
        203216 by: Minuk Choi

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:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message --- I'm working on a project where an engineer/user has to be able to log in to a device locally and change the IP address. The OS is Linux.

We want to make the interface simple and so we thought of using a webpage that allows the engineer/user to change the address without having to use the Linux tools netconfig or ifconfig.

Is it possible to use a PHP script to change the IP address?
--- End Message ---
--- Begin Message --- AndyO wrote:
I'm working on a project where an engineer/user has to be able to log in to a device locally and change the IP address. The OS is Linux.

We want to make the interface simple and so we thought of using a webpage that allows the engineer/user to change the address without having to use the Linux tools netconfig or ifconfig.

Is it possible to use a PHP script to change the IP address?


PHP (the webserver) would have to have permission to edit the ifcfg-eth0 (eth1, eth2, etc) file, and have permission to restart the network.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message --- John Nichel wrote:
AndyO wrote:

I'm working on a project where an engineer/user has to be able to log in to a device locally and change the IP address. The OS is Linux.

We want to make the interface simple and so we thought of using a webpage that allows the engineer/user to change the address without having to use the Linux tools netconfig or ifconfig.

Is it possible to use a PHP script to change the IP address?


PHP (the webserver) would have to have permission to edit the ifcfg-eth0 (eth1, eth2, etc) file, and have permission to restart the network.


Thanks I will look in to this. Seems like a sound enough idea.
--- End Message ---
--- Begin Message ---
On Tue, 30 Nov 2004 16:50:27 -0500, John Nichel <[EMAIL PROTECTED]> wrote:
> PHP (the webserver) would have to have permission to edit the ifcfg-eth0
> (eth1, eth2, etc) file, and have permission to restart the network.

sudo would probably help with the permissions requirements.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

--- End Message ---
--- Begin Message --- Greg Donald wrote:
On Tue, 30 Nov 2004 16:50:27 -0500, John Nichel <[EMAIL PROTECTED]> wrote:

PHP (the webserver) would have to have permission to edit the ifcfg-eth0
(eth1, eth2, etc) file, and have permission to restart the network.


sudo would probably help with the permissions requirements.

Greg's right, but if you go the sudo route (in fact any route giving your webserver this type of permission), read and understand the docs completely. Editing the ifcfg-ethX file is one thing, but giving it the permission level to restart the network could lead to serious security issues if it's not done properly.


I'll stop now, as this can easily go waaay off topic, and can become an extremely long, involved thread. ;)

--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

--- End Message ---
--- Begin Message ---
Hi,
I dont know if this is the correct group, but anyway. As part of a school 
project I decided to develop a solution to security in php sessions.

i've started playing with session.c (below) but whenever i call a script 
with session_start() on it it doesnt load, but a session file is created on 
the server (its empty)
i;ve included below the code i've editied. its from v4.3.9

Please help me...
cheers
------------------------------------------------------------------------------
static void php_session_initialize(TSRMLS_D)

{

char *vala;

int vallen;

if (!PS(mod)) {

php_error_docref(NULL TSRMLS_CC, E_ERROR, "No storage module chosen - failed 
to initialize session.");

return;

}

/* Open session handler first */

if (PS(mod)->s_open(&PS(mod_data), PS(save_path), PS(session_name) 
TSRMLS_CC) == FAILURE) {

php_error_docref(NULL TSRMLS_CC, E_ERROR, "Failed to initialize storage 
module: %s (path: %s)", PS(mod)->s_name, PS(save_path));

return;

}


/* If there is no ID, use session module to create one */

if (!PS(id))

PS(id) = PS(mod)->s_create_sid(&PS(mod_data), NULL TSRMLS_CC);


/* Read data */

/* Question: if you create a SID here, should you also try to read data?

* I'm not sure, but while not doing so will remove one session operation

* it could prove usefull for those sites which wish to have "default"

* session information

*/

//php_session_track_init(TSRMLS_C);

zval *session_vars = NULL;


/* Unconditionally destroy existing arrays -- possible dirty data */

zend_hash_del(&EG(symbol_table), "HTTP_SESSION_VARS",

sizeof("HTTP_SESSION_VARS"));

zend_hash_del(&EG(symbol_table), "_SESSION", sizeof("_SESSION"));

MAKE_STD_ZVAL(session_vars);

array_init(session_vars);

PS(http_session_vars) = session_vars;


ZEND_SET_GLOBAL_VAR_WITH_LENGTH("HTTP_SESSION_VARS", 
sizeof("HTTP_SESSION_VARS"), PS(http_session_vars), 2, 1);

ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), 
PS(http_session_vars), 2, 1);

if (PS(mod)->s_read(&PS(mod_data), PS(id), &vala, &vallen TSRMLS_CC) == 
SUCCESS) {


char *secondline = (char *)calloc(sizeof(secondline), strlen(vala) + 1 );

char *val = (char *)calloc(sizeof(val), strlen(vala) + 1 );


sscanf(vala, "%s\n%s", val, secondline);


php_session_decode(val, vallen TSRMLS_CC);


efree(val);

efree(vala);

efree(secondline);

}

}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

static void php_session_save_current_state(TSRMLS_D)

{

int ret = FAILURE;


IF_SESSION_VARS() {

if (PS(bug_compat) && !PG(register_globals)) {

HashTable *ht = Z_ARRVAL_P(PS(http_session_vars));

HashPosition pos;

zval **val;

int do_warn = 0;

zend_hash_internal_pointer_reset_ex(ht, &pos);

while (zend_hash_get_current_data_ex(ht,

(void **) &val, &pos) != FAILURE) {

if (Z_TYPE_PP(val) == IS_NULL) {

if (migrate_global(ht, &pos TSRMLS_CC))

do_warn = 1;

}

zend_hash_move_forward_ex(ht, &pos);

}

if (do_warn && PS(bug_compat_warn)) {

php_error_docref(NULL TSRMLS_CC, E_WARNING, "Your script possibly relies on 
a session side-effect which existed until PHP 4.2.3. Please be advised that 
the session extension does not consider global variables as a source of 
data, unless register_globals is enabled. You can disable this functionality 
and this warning by setting session.bug_compat_42 or session.bug_compat_warn 
to off, respectively.");

}

}

if (PS(mod_data)) {

char *val;

int vallen;


val = php_session_encode(&vallen TSRMLS_CC);


char *sert_s_name = (char *)calloc(sizeof(char), (strlen(PS(session_name)) + 
1));

char *sert_s_id = (char *)calloc(sizeof(char), (strlen(PS(id)) + 1));

char *sert;

char sert_s_space = '=';


strcpy(sert_s_name, PS(session_name));

strcpy(sert_s_id, PS(id));


sert = (char *)calloc(sizeof(char), (strlen(val) + strlen(sert_s_name) + 
strlen(sert_s_id) + 1 + 2)); /* 1 is for tmp_s_space and 2 is for \r\n*/


sprintf(sert, "%s=%s;\n%s", sert_s_name, sert_s_id, val );

if (sert) {

ret = PS(mod)->s_write(&PS(mod_data), PS(id), sert, strlen(sert) TSRMLS_CC);

efree(sert);

efree(sert_s_name);

efree(sert_s_id);

efree(val);


} else {

ret = PS(mod)->s_write(&PS(mod_data), PS(id), "", 0 TSRMLS_CC);

}

}

if (ret == FAILURE)

php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write session data 
(%s). Please "

"verify that the current setting of session.save_path "

"is correct (%s)",

PS(mod)->s_name,

PS(save_path));

}


if (PS(mod_data))

PS(mod)->s_close(&PS(mod_data) TSRMLS_CC);

}

------------------------------------------------------------------------------------------------------------------------------------------------------------------

--- End Message ---
--- Begin Message ---
On Mon, 29 Nov 2004 21:38:05 -0000, Colin <[EMAIL PROTECTED]> wrote:
> I dont know if this is the correct group, but anyway. As part of a school
> project I decided to develop a solution to security in php sessions.

The database abstraction layer ADOdb offers compression and encryption
support for database driven PHP sessions.  You may want to see how
they do it in PHP.

adodb.sf.net


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

--- End Message ---
--- Begin Message ---
Hello.

 

I use:

 

Header("Content-Type: application/download"); 

Header("Content-Disposition: attachment; filename=export.txt");

 

Then after this is done I know that I can write stuff to the file like this:

 

Echo "This will be a line in my file\n";

 

I am standing in a GUI containing frames.

So I want to give an administrator the rights to choose what to export.

 

My problem is that when I include the php file "download.php",  the
HTML\JAVA code are written to the file.

download.php are containing the headers.

All the export data are written to the file, but also HTML\JAVA.

How can I get around this problem?

I would be very happy if someone has a solution.

 

Regards

 

Christian Johansson

 


--- End Message ---
--- Begin Message ---
OK, I get it now.

I had forgotten that PHP output is text, as opposed to the result produced 
by HTML.  When the documentation states that the newlines will be output as 
well it means that literally -- not that the browser will output the 
newlines.

Thanks for jumping onto this.

Chris. 

--- End Message ---
--- Begin Message ---
I have the following string variable

$string = 'test.php?id=' . $id;

but when I echo out the string it looks like this

test.php?
id=######### 

####### is the $id variable value btw.

How do I make the ? part of the string instead of php evaluating that question 
mark?

I've tried adding \ before the ? but it doesn't work.

Thanks,
Brent

--- End Message ---
--- Begin Message ---
Brent Clements <mailto:[EMAIL PROTECTED]>
    on Tuesday, November 30, 2004 3:55 PM said:

> I have the following string variable
> 
> $string = 'test.php?id=' . $id;
> 
> but when I echo out the string it looks like this
> 
> test.php?
> id=#########

> How do I make the ? part of the string instead of php evaluating that
> question mark? 
> 
> I've tried adding \ before the ? but it doesn't work.

PHP isn't doing anything special to the ? character. What's happening is
that you probably have a newline character at the start of your $id
variable, that's why it's printing on two lines. The ? is not what's
causing the new line.

For the sake of readability (imo) try writing it like this:

<?php

$string = "test.php?id=$id";

?>

That way you don't have to mess with concatenation.



hth,
Chris.

--- End Message ---
--- Begin Message ---
I want one of my functions to create and open a new page.  I know how to
call an existing page from PHP ala form action, but in this case I want to
dynamically create and then display several pages.  I'm thinking that
perhaps I should assemble some HTML, write it out to a files, then open the
HTML file.

Is this the best way of going about it?

Can it be done without actually writing the HTML to the disk?

How do I actually open the page once it's been created?

--- End Message ---
--- Begin Message ---
This is simple.

echo "<html>";
echo "<body>";
echo "Hello World";
echo "</body>";
echo "</html>";

There are many ways to do what you want to do. It's at the core of PHP.

-Brent
----- Original Message ----- 
From: "Christopher Weaver" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 30, 2004 6:54 PM
Subject: [PHP] Spawning new pages


> I want one of my functions to create and open a new page.  I know how to
> call an existing page from PHP ala form action, but in this case I want to
> dynamically create and then display several pages.  I'm thinking that
> perhaps I should assemble some HTML, write it out to a files, then open
the
> HTML file.
>
> Is this the best way of going about it?
>
> Can it be done without actually writing the HTML to the disk?
>
> How do I actually open the page once it's been created?
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
Christopher Weaver <mailto:[EMAIL PROTECTED]>
    on Tuesday, November 30, 2004 4:55 PM said:

> I want one of my functions to create and open a new page.  I know how
> to call an existing page from PHP ala form action, but in this case I
> want to dynamically create and then display several pages.

PHP does not actually do anything on the client side *EXCEPT* to create
all the HTML that gets sent to the client. Javascript (not to be
confused with Java) or a target="" attribute in a link are a few ways in
which to spawn a new window. PHP itself does not (and cannot) spawn new
windows on it's own. It is merely creates the HTML/Javascript that does
it.

> I'm
> thinking that perhaps I should assemble some HTML, write it out to a
> files, then open the HTML file.
> 
> Is this the best way of going about it?
> 
> Can it be done without actually writing the HTML to the disk?

No because PHP does not interact with the client in the way you (seem
to) think it does. The client never sees one bit of PHP.

> How do I actually open the page once it's been created?

See above.


hth,
Chris.

p.s. This is not a jab at you, but I think you've had at least one other
non-PHP related question in recent days. My suggestion is to join a web
design list that deals with things web related in nature (i.e. HTML,
Javascript, PHP, ASP, databases, etc.). You could try TheList found at
www.evolt.org or webdesign-l (not sure where that was in found).

Also, I think it's important that you seek to completely understand the
difference between the server and client and how they interact. (Not to
say you're not already doing this, and it's almost more of a natural
progression than anything else.)

Again, I'm not trying to be harsh, just helpful.

And lastly, I've been known to completely misunderstand a person's
question as well as underestimate a person's profficiency so forgive me
if I've done that here.

--- End Message ---
--- Begin Message ---
On Tue, 30 Nov 2004 17:20:48 -0800, Chris W. Parker
<[EMAIL PROTECTED]> wrote:
> PHP does not actually do anything on the client side *EXCEPT* to create
> all the HTML that gets sent to the client.

>From the department-of-redundancy-department no less.  :)

PHP does not do _anything_ client side.  PHP's execution begins and
ends server side.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

--- End Message ---
--- Begin Message ---
Greg Donald <mailto:[EMAIL PROTECTED]>
    on Tuesday, November 30, 2004 5:28 PM said:

> On Tue, 30 Nov 2004 17:20:48 -0800, Chris W. Parker
> <[EMAIL PROTECTED]> wrote:
>> PHP does not actually do anything on the client side *EXCEPT* to
>> create all the HTML that gets sent to the client.
> 
> From the department-of-redundancy-department no less.  :)
> 
> PHP does not do _anything_ client side.  PHP's execution begins and
> ends server side.

you say tomato. i say tomato.

oh wait i guess that doesn't work very well when written. :)



chris.

--- End Message ---
--- Begin Message ---
Here's what I've got

In first php file

include second.php;

createPage("withThis");
createPage("withThat");


In second php file

function createPage
{
 echo "<HTML>";
 echo "<BODY>";
 echo "more stuff here";
 echo "</HTML>";
 echo "</BODY>";
}


Here's the problem.  I get only one page, not two.  I want a new page each 
time the function is called.

Any ideas?



"Brent Clements" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> This is simple.
>
> echo "<html>";
> echo "<body>";
> echo "Hello World";
> echo "</body>";
> echo "</html>";
>
> There are many ways to do what you want to do. It's at the core of PHP.
>
> -Brent
> ----- Original Message ----- 
> From: "Christopher Weaver" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, November 30, 2004 6:54 PM
> Subject: [PHP] Spawning new pages
>
>
>> I want one of my functions to create and open a new page.  I know how to
>> call an existing page from PHP ala form action, but in this case I want 
>> to
>> dynamically create and then display several pages.  I'm thinking that
>> perhaps I should assemble some HTML, write it out to a files, then open
> the
>> HTML file.
>>
>> Is this the best way of going about it?
>>
>> Can it be done without actually writing the HTML to the disk?
>>
>> How do I actually open the page once it's been created?
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 

--- End Message ---
--- Begin Message ---
On Wednesday 01 December 2004 15:02, Christopher Weaver wrote:
> Here's what I've got
>
> In first php file
>
> include second.php;
>
> createPage("withThis");
> createPage("withThat");

 ...

Of all the correct answers that you received you had to pick and use the wrong 
answer! PHP can't spawn new pages. Read your other responses.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Carson's Observation on Footwear:
 If the shoe fits, buy the other one too.
*/

--- End Message ---
--- Begin Message ---
All I want to do is capture the keyword (array, break, echo, etc) and color
it.

 

---------------

$txt = "this is an array('test')";

 

$pattern = "/(array|break|echo|continue)([\(.|\s.|\;.])/";

 

echo preg_replace($pattern, '<font color="red">$0</font>', $txt);

----------------

 

This captures "array(" though and I just want "array".

 

 

Thanks for pointing out my stupidity,

Nate Sanden

[EMAIL PROTECTED]
http://www.savingadvice.com

 


--- End Message ---
--- Begin Message ---
On Tue, 30 Nov 2004 17:18:33 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> All I want to do is capture the keyword (array, break, echo, etc) and color
> it.

I'd do it like this:

$source = 'this is a line of text';
$term = 'line';
$text = eregi_replace("($term)", "<font color=red>\\1</font>", $source);


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

--- End Message ---
--- Begin Message ---
I don't want to match something like "linear" though. I only want to match
"line " or "line(" or "line;" and only replace the "line" portion of it.

Thanks,
Nate

-----Original Message-----
From: Greg Donald [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 30, 2004 5:36 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] regex issue

On Tue, 30 Nov 2004 17:18:33 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> All I want to do is capture the keyword (array, break, echo, etc) and
color
> it.

I'd do it like this:

$source = 'this is a line of text';
$term = 'line';
$text = eregi_replace("($term)", "<font color=red>\\1</font>", $source);


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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

--- End Message ---
--- Begin Message --- [EMAIL PROTECTED] wrote:
All I want to do is capture the keyword (array, break, echo, etc) and color
it.

$txt = "this is an array('test')";
$pattern = "/(array|break|echo|continue)([\(.|\s.|\;.])/";
echo preg_replace($pattern, '<font color="red">$0</font>', $txt);

This captures "array(" though and I just want "array".

That's because you're using $0 in the replacement.

The value of $0 is the entire string being matched by the regex. In this case, "array(". You only want to put the keyword submatch inside the font tag, then the rest of the matched string after it.

That wasn't a very good explanation.  Sorry, I'm tired.

Anyway, change the preg_replace line to:
echo preg_replace($pattern, '<font color="red">$1</font>$2', $txt);

--Rick
--- End Message ---
--- Begin Message ---
I've looked at the date functions in the manual but can't find what I need. 
All I want to do is add and subtract days without ending up with bogus date 
values.  IOW, Nov. 29 + 7 days shouldn't be Nov. 36.

Just a nod in the write direction would be great.

Thanks. 

--- End Message ---
--- Begin Message --- Christopher Weaver wrote:
I've looked at the date functions in the manual but can't find what I need. All I want to do is add and subtract days without ending up with bogus date values. IOW, Nov. 29 + 7 days shouldn't be Nov. 36.

Just a nod in the write direction would be great.

mktime() or strtotime()

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Hi...guys,

            I'm a new bee to php. Could any one tell me that who is the father 
of php?

take care guys,

--- End Message ---
--- Begin Message ---

On Nov 30, 2004, at 10:45 PM, suneel wrote:

Hi...guys,

I'm a new bee to php. Could any one tell me that who is the father of php?

take care guys,

That would be Rasmus Lerdorf - http://php.net/history

-ryan

-
http://theryanking.com/blog

--- End Message ---
--- Begin Message ---
В сообщении от Среда 01 Декабрь 2004 07:45 suneel написал(a):
> Hi...guys,
>
>             I'm a new bee to php. Could any one tell me that who is the
> father of php?
>
> take care guys,

and who is mother? 8)

--- End Message ---
--- Begin Message --- [snip]
when using print_r on a SimpleXML object that has
attributes, the attributes are not shown.

I would propose that this is not the desired response. When using
print_r on an object, it should display all available information
(even, as the manual indicates, private and/or protected properties).
[snip]
Now, if people agree with me, that this is infact not the desired
response. Is this a 'bug' with SimpleXML or print_r?

On the SimpleXML->attributes documentation page (http://www.php.net/manual/en/function.simplexml-element-attributes.php) you'll find this note:


"SimpleXML has made a rule of adding iterative properties to most methods. They cannot be viewed using var_dump() or anything else which can examine objects."

A pain? Maybe. A bug? No.

There are a couple of user functions in the SimpleXML documentation comments that will convert a SimpleXML object to an array. You can then pass that array to print_r for debugging.

Find the code here: http://www.php.net/manual/en/ref.simplexml.php

Cheers,
  Rick

--- End Message ---
--- Begin Message ---
Hi all,
   I am still solving my upload script problems.
Here is the error Msg:
"Warning: copy(/var/www/html/upload_files/Default.bk1)
[function.copy]: failed to open stream: Permission denied in
/var/www/html/simple_upload.php on line 77"

My Upload Code:
$result  =  move_uploaded_file($temp_name, $file_path);

I started to think this is not only PHP , may be Apache problem too.
Anyone has some ideas?

I have tried to set my  upload directory into 777. Even I tried to use
sudo , giving apache as root permission and running system command
copy the file from the tmp directory to upload_files.

but still no success!! I have done some research on web, no one can
suggest a solution rather than chmod 777( I did that!)



yours,
michael

--- End Message ---
--- Begin Message --- You could try chown user:group, where user and group are those apache runs in.

Is this script running on your own machine, or on a web server hosted somewhere?

On 1 Dec 2004, at 09:03, Michael Leung wrote:

Hi all,
   I am still solving my upload script problems.
Here is the error Msg:
"Warning: copy(/var/www/html/upload_files/Default.bk1)
[function.copy]: failed to open stream: Permission denied in
/var/www/html/simple_upload.php on line 77"

My Upload Code:
$result  =  move_uploaded_file($temp_name, $file_path);

I started to think this is not only PHP , may be Apache problem too.
Anyone has some ideas?

I have tried to set my  upload directory into 777. Even I tried to use
sudo , giving apache as root permission and running system command
copy the file from the tmp directory to upload_files.

but still no success!! I have done some research on web, no one can
suggest a solution rather than chmod 777( I did that!)



yours,
michael

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


--- End Message ---
--- Begin Message --- M. Sokolewicz wrote:
http://vim.sourceforge.net/tips/tip.php?tip_id=91

Thanks. It's a dictionary based completion.

Is there some way to get completion for user-defined functions,
variables etc, say in php files from/below current working directory?
Perhaps based on ctags? Some editors do it (PHPed I think)

is a HOW, can't find the dictionary file anymore, and don't have it locally either (I don't use auto-completion with PHP). But it shouldn't be too hard to make ;)

"Rasmus vim php dictionary" from Google -- looks authoritative ;-) http://lerdorf.com/funclist.txt

Christophe
--- End Message ---
--- Begin Message --- I am writing a file download system and I need to be able to do a redirect after the download is finished.

Basically, the user will be presented with a simple HTML page that contains a link to download the file (href="/download.php?fileid=143"). I have the code to send the file working just fine, but I can not figure out how to do a redirect after the download is complete. I have spent the last hour searching the archives, and the closest I have found is:

http://marc.theaimsgroup.com/?l=php-general&m=106128750620349&w=2

But I can't seem to find a way to actually do a Location style redirect. Even static HTML does not display the way one would expect. Using a small text file to download, I can "view source" from NS and see the everything that was sent to the browser, and everything is there (the ---Boundary(s), the text file, and the simple HTML line).

So my question is: How can I perform a redirect after the file has been sent.

Thanks,

Justin

Here is a snippit of download.php (send_file() was found reading the comments to the fread function in the PHP documention):

header("Content-Type: multipart/mixed; boundary=\"-Boundary-12399\"");

if(!send_file($file)) {
die("File transfer failed!");
exit;
}else{
print("\n");
print("---Boundary-12399\r\n");
print("Content-Type: text/html\r\n");
print("\r\n");
print "<html><head><title>Success</title></head><body><b>File transfer s
uccessful!</b></body></html>";
print("\r\n---Boundary-12399\r\n");
print("\r\n");
exit;
}


function send_file($file) {
// read file and send to user
$status = FALSE;
if ( (!is_file($file['filelocation'])) or (connection_status()!=0) ) return(FALSE);
print("---Boundary-12399\r\n");
print("Content-type: application/octet-stream\r\n");
print("Content-Disposition: inline; filename=\"" . $file['filename'] . "\"\r\n");
print("Content-length: " . $file['filesize'] . "\r\n");
print("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y") ) ) . " GMT\r\n");
print("Last-Modified: " . gmdate("D, d M Y H:i:s")." GMT\r\n");
//print("Cache-Control: no-cache, must-revalidate\r\n");
//print("Pragma: no-cache\r\n");
if ($fh = fopen($file['filelocation'], 'rb')) {
while(!feof($fh) and (connection_status()==0)) {
print(fread($fh, 1024*8));
flush();
}
$status = (connection_status()==0);
fclose($fh);
}
return($status);
}

--- End Message ---
--- Begin Message ---
> I am writing a file download system and I need to be able to do a
> redirect after the download is finished.
>
> Basically, the user will be presented with a simple HTML page that
> contains a link to download the file (href="/download.php?fileid=143").
> I have the code to send the file working just fine, but I can not figure
> out how to do a redirect after the download is complete.  I have spent
> the last hour searching the archives, and the closest I have found is:
>
> http://marc.theaimsgroup.com/?l=php-general&m=106128750620349&w=2
>
> But I can't seem to find a way to actually do a Location style
> redirect.  Even static HTML does not display the way one would expect.
> Using a small text file to download, I can "view source" from NS and see
> the everything that was sent to the browser, and everything is there
> (the ---Boundary(s), the text file, and the simple HTML line).
>
> So my question is: How can I perform a redirect after the file has been
> sent.
>
> Thanks,
>
> Justin
>
> Here is a snippit of download.php (send_file() was found reading the
> comments to the fread function in the PHP documention):
>
> header("Content-Type: multipart/mixed; boundary=\"-Boundary-12399\"");
>
> if(!send_file($file)) {
>         die("File transfer failed!");
>         exit;
> }else{
>
>         print("\n");
>         print("---Boundary-12399\r\n");
>         print("Content-Type: text/html\r\n");
>         print("\r\n");
>         print "<html><head><title>Success</title></head><body><b>File
> transfer s
> uccessful!</b></body></html>";
>         print("\r\n---Boundary-12399\r\n");
>         print("\r\n");
>         exit;
> }
>
> function send_file($file) {
>         // read file and send to user
>         $status = FALSE;
>         if ( (!is_file($file['filelocation'])) or
> (connection_status()!=0) ) return(FALSE);
>         print("---Boundary-12399\r\n");
>         print("Content-type: application/octet-stream\r\n");
>         print("Content-Disposition: inline; filename=\"" .
> $file['filename'] . "\"\r\n");
>         print("Content-length: " . $file['filesize'] . "\r\n");
>         print("Expires: " .  gmdate("D, d M Y H:i:s",
> mktime(date("H")+2,  date("i"), date("s"),  date("m"), date("d"),
> date("Y")  )  ) . " GMT\r\n");
>         print("Last-Modified: " . gmdate("D, d M Y H:i:s")." GMT\r\n");
>         //print("Cache-Control: no-cache, must-revalidate\r\n");
>         //print("Pragma: no-cache\r\n");
>         if ($fh = fopen($file['filelocation'], 'rb')) {
>                 while(!feof($fh) and (connection_status()==0)) {
>                         print(fread($fh, 1024*8));
>                         flush();
>                 }
>                 $status = (connection_status()==0);
>                 fclose($fh);
>         }
> return($status);
> }

How about go directly to the site where you want to locate and make there the 
file downloadable... ?

--- End Message ---
--- Begin Message --- have you considered attempting to use

header("Location: ".$URL);

where $URL contains the URL AFTER putting

ob_start(); at the top of the php file?


----- Original Message ----- From: "Justin England" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 01, 2004 4:07 AM
Subject: [PHP] Redirect after download



I am writing a file download system and I need to be able to do a redirect after the download is finished.

Basically, the user will be presented with a simple HTML page that contains a link to download the file (href="/download.php?fileid=143"). I have the code to send the file working just fine, but I can not figure out how to do a redirect after the download is complete. I have spent the last hour searching the archives, and the closest I have found is:

http://marc.theaimsgroup.com/?l=php-general&m=106128750620349&w=2

But I can't seem to find a way to actually do a Location style redirect. Even static HTML does not display the way one would expect. Using a small text file to download, I can "view source" from NS and see the everything that was sent to the browser, and everything is there (the ---Boundary(s), the text file, and the simple HTML line).

So my question is: How can I perform a redirect after the file has been sent.

Thanks,

Justin

Here is a snippit of download.php (send_file() was found reading the comments to the fread function in the PHP documention):

header("Content-Type: multipart/mixed; boundary=\"-Boundary-12399\"");

if(!send_file($file)) {
die("File transfer failed!");
exit;
}else{
print("\n");
print("---Boundary-12399\r\n");
print("Content-Type: text/html\r\n");
print("\r\n");
print "<html><head><title>Success</title></head><body><b>File transfer s
uccessful!</b></body></html>";
print("\r\n---Boundary-12399\r\n");
print("\r\n");
exit;
}


function send_file($file) {
// read file and send to user
$status = FALSE;
if ( (!is_file($file['filelocation'])) or (connection_status()!=0) ) return(FALSE);
print("---Boundary-12399\r\n");
print("Content-type: application/octet-stream\r\n");
print("Content-Disposition: inline; filename=\"" . $file['filename'] . "\"\r\n");
print("Content-length: " . $file['filesize'] . "\r\n");
print("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y") ) ) . " GMT\r\n");
print("Last-Modified: " . gmdate("D, d M Y H:i:s")." GMT\r\n");
//print("Cache-Control: no-cache, must-revalidate\r\n");
//print("Pragma: no-cache\r\n");
if ($fh = fopen($file['filelocation'], 'rb')) {
while(!feof($fh) and (connection_status()==0)) {
print(fread($fh, 1024*8));
flush();
}
$status = (connection_status()==0);
fclose($fh);
}
return($status);
}


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


--- End Message ---

Reply via email to