473,236 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

running php script?

ok... im not quite sure how to describe my problem.
i have a php script that runs through my entire php site and writes the
resulting output to html files. this is necessary as the nature of the
hosting available to me for this particular page prohibits me from using
php/mysql as i would like.

my script works simply by using output buffers and an include
the relevant section of code is as follows:

ob_start();
include($source.$pagename);
$page_buffer = ob_get_contents();
ob_end_clean();

i was wondering if there is a way i can do this without using the include,
because the script only works when it is in the same directory as the site.
this arrangement does not suit me, as i would rather be able to store the
script in a separate folder.

Jul 17 '05 #1
8 3290
Hi,
ob_start();
include($source.$pagename);
$page_buffer = ob_get_contents();
ob_end_clean();

i was wondering if there is a way i can do this without using the include,
because the script only works when it is in the same directory as the site.
this arrangement does not suit me, as i would rather be able to store the
script in a separate folder.


If the included file is on the same Server, you can give the
relative (or absolute) path to the file to include. It
doesn't need to be in the same directory.

Greetz
Paul.
Jul 17 '05 #2

"Sticks" <sa**********@yahoo.com> wrote in message
news:3f********@usenet.per.paradox.net.au...
ok... im not quite sure how to describe my problem.
i have a php script that runs through my entire php site and writes the
resulting output to html files. this is necessary as the nature of the
hosting available to me for this particular page prohibits me from using
php/mysql as i would like.

my script works simply by using output buffers and an include
the relevant section of code is as follows:

ob_start();
include($source.$pagename);
$page_buffer = ob_get_contents();
ob_end_clean();

i was wondering if there is a way i can do this without using the include,
because the script only works when it is in the same directory as the site. this arrangement does not suit me, as i would rather be able to store the
script in a separate folder.


My first thought is to create an array with your directory names that you
want to scan

$allDirs =
array("/usr/local/apache/htdocs","/usr/local/apache/site1/","/usr/local/apac
he/site1/htdocs") etc...

then iterate through the array and subsequent directory files.

while (list(,$dirName) = each($allDirs) {
// create an array of all files
$allFiles = scandir($dirName);
while (list ($key,$fileName) = each($allFiles) {
// each file within each directory
$page_buffer to $fileName stuf......
}
}

Jul 17 '05 #3
perhaps i havent been clear enough
i dont want to use includes to perform this task. i would like to get the
html output of a php script that is quite complicated and uses a variety of
includes of its own which i do not wish to rewrite unless i absolutely have
to. these includes are disturbed when my script resides in a different
directory to the page.

as it stands, the script works. it just isnt an ideal solution.
i am looking for something along the lines of the exec() command, only for
executing php scripts.

<xyzzy> wrote in message news:Xf********************@comcast.com...

"Sticks" <sa**********@yahoo.com> wrote in message
news:3f********@usenet.per.paradox.net.au...
ok... im not quite sure how to describe my problem.
i have a php script that runs through my entire php site and writes the
resulting output to html files. this is necessary as the nature of the
hosting available to me for this particular page prohibits me from using
php/mysql as i would like.

my script works simply by using output buffers and an include
the relevant section of code is as follows:

ob_start();
include($source.$pagename);
$page_buffer = ob_get_contents();
ob_end_clean();

i was wondering if there is a way i can do this without using the include, because the script only works when it is in the same directory as the site.
this arrangement does not suit me, as i would rather be able to store the script in a separate folder.


My first thought is to create an array with your directory names that you
want to scan

$allDirs =

array("/usr/local/apache/htdocs","/usr/local/apache/site1/","/usr/local/apac he/site1/htdocs") etc...

then iterate through the array and subsequent directory files.

while (list(,$dirName) = each($allDirs) {
// create an array of all files
$allFiles = scandir($dirName);
while (list ($key,$fileName) = each($allFiles) {
// each file within each directory
$page_buffer to $fileName stuf......
}
}

Jul 17 '05 #4
Sticks wrote:
[re-ordered you post because top-posting is evil :o)]
<xyzzy> wrote in message news:Xf********************@comcast.com...

"Sticks" <sa**********@yahoo.com> wrote in message
news:3f********@usenet.per.paradox.net.au...
ok... im not quite sure how to describe my problem.
i have a php script that runs through my entire php site and writes the
resulting output to html files. this is necessary as the nature of the
hosting available to me for this particular page prohibits me from using
php/mysql as i would like.

my script works simply by using output buffers and an include
the relevant section of code is as follows:

ob_start();
include($source.$pagename);
$page_buffer = ob_get_contents();
ob_end_clean();

i was wondering if there is a way i can do this without using the include, because the script only works when it is in the same directory as the

site.
this arrangement does not suit me, as i would rather be able to store the script in a separate folder.


My first thought is to create an array with your directory names that you
want to scan

$allDirs =

array("/usr/local/apache/htdocs","/usr/local/apache/site1/","/usr/local/apac
he/site1/htdocs") etc...

then iterate through the array and subsequent directory files.

while (list(,$dirName) = each($allDirs) {
// create an array of all files
$allFiles = scandir($dirName);
while (list ($key,$fileName) = each($allFiles) {
// each file within each directory
$page_buffer to $fileName stuf......
}
}

perhaps i havent been clear enough
i dont want to use includes to perform this task. i would like to get the
html output of a php script that is quite complicated and uses a variety of
includes of its own which i do not wish to rewrite unless i absolutely have
to. these includes are disturbed when my script resides in a different
directory to the page.

as it stands, the script works. it just isnt an ideal solution.
i am looking for something along the lines of the exec() command, only for
executing php scripts.


I'm not sure I understand your problem, but if you want to execute php scripts
on Linux, you can use

/pathinfo/php -q /pathinfo/scriptname.php

from the command line or a cron job. The "-q" suppresses HTTP headers. Or you
could do:

/pathinfo/php -q /pathinfo/scriptname.php > index.html

to send all output from that php script to a file called index.html. Be careful
with this, though, as it's easy to overwrite the wrong files...

HTH,
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #5
this is *almost* what im looking for
trouble is, im running a windoze XP box.... is there any way to do the
'greater than' output to file thing in windoze?
and the other trouble is that if i want to perform that action from a php
script i have to use 'exec', which is not ideal if i want to move the script
to a *nix server some time in the future (which is highly likely)

the biggest issue is that running the script from any directory other than
the directory in which the page to export resides plays merry havoc with the
document relative paths in the script.
perhaps i should clarify - i have an entire website designed in php, built
off a mysql database, complete with a stack of includes and images and
what-have-you. the problem is that the hosting available to the organisation
that the website is for decided to pull the pin on their previous hosting
plan and are not willing to shell the extra $ for php/mysql hosting. my idea
then was to create this script which parses every single php page it can
become aware of (i had to adjust the databases and scrips a little bit to
respond to a $htmldump flag) and then creates new page names based on
obvious content. it then creates a table of all of the pages it created and
what those pages were created from... say for eg:
"page.php?frame=listbuild.php&hw_type=printers " becomes "printerslist.htm".
the script then looks through ALL of the newly created html pages for links
that belong to the old php site and updates them to the corresponding html
link, as well as copying other files and folders to recreate the site
structure.

the way the script is designed (and i might add that although it is
functional it is one piss poor piece of programming and i am embarrassed to
show it to people) is such that it MUST reside in the same directory as the
website it is dumping. i can see no other way to do it with output buffers
and includes (as i have been doing) without rewriting the entire website to
take into account the relocation of the output script. i REALLY do not want
to do this.

thank you very much for the reply though. i will definitely investigate
whether this will work as a band-aid solution.
sticks

"Shawn Wilson" <sh***@glassgiant.com> wrote in message
news:3F***************@glassgiant.com...
Sticks wrote:
[re-ordered you post because top-posting is evil :o)]
<xyzzy> wrote in message news:Xf********************@comcast.com...

"Sticks" <sa**********@yahoo.com> wrote in message
news:3f********@usenet.per.paradox.net.au...
> ok... im not quite sure how to describe my problem.
> i have a php script that runs through my entire php site and writes the > resulting output to html files. this is necessary as the nature of the > hosting available to me for this particular page prohibits me from using > php/mysql as i would like.
>
> my script works simply by using output buffers and an include
> the relevant section of code is as follows:
>
> ob_start();
> include($source.$pagename);
> $page_buffer = ob_get_contents();
> ob_end_clean();
>
> i was wondering if there is a way i can do this without using the include,
> because the script only works when it is in the same directory as the site.
> this arrangement does not suit me, as i would rather be able to store
the
> script in a separate folder.
>
>
>
>
>
My first thought is to create an array with your directory names that
you want to scan

$allDirs =

array("/usr/local/apache/htdocs","/usr/local/apache/site1/","/usr/local/apac
he/site1/htdocs") etc...

then iterate through the array and subsequent directory files.

while (list(,$dirName) = each($allDirs) {
// create an array of all files
$allFiles = scandir($dirName);
while (list ($key,$fileName) = each($allFiles) {
// each file within each directory
$page_buffer to $fileName stuf......
}
}

perhaps i havent been clear enough
i dont want to use includes to perform this task. i would like to get

the html output of a php script that is quite complicated and uses a variety of includes of its own which i do not wish to rewrite unless i absolutely have to. these includes are disturbed when my script resides in a different
directory to the page.

as it stands, the script works. it just isnt an ideal solution.
i am looking for something along the lines of the exec() command, only for executing php scripts.


I'm not sure I understand your problem, but if you want to execute php

scripts on Linux, you can use

/pathinfo/php -q /pathinfo/scriptname.php

from the command line or a cron job. The "-q" suppresses HTTP headers. Or you could do:

/pathinfo/php -q /pathinfo/scriptname.php > index.html

to send all output from that php script to a file called index.html. Be careful with this, though, as it's easy to overwrite the wrong files...

HTH,
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com

Jul 17 '05 #6

"Sticks Random" <ba***********@hotmail.com> wrote in message
news:3f**********************@freenews.iinet.net.a u...
this is *almost* what im looking for
trouble is, im running a windoze XP box.... is there any way to do the
'greater than' output to file thing in windoze?
and the other trouble is that if i want to perform that action from a php
script i have to use 'exec', which is not ideal if i want to move the script to a *nix server some time in the future (which is highly likely)


This is cut from another post by Nikolai Chuvakhin here in this NG:

"
Spawn your asynchronous process via an exec() call with background
execution (& operator; Unix only). Examples:

exec ('myprogram &');
// executes a standalone program in the background

exec ('wget http://server.com/path/script.php --quiet -O /dev/null &');
// executes a PHP script in the background
// via the standard interface

exec ('php /path/script.php &');
// executes a PHP script in the background
// via command-line interface
"

Won't that work for you on a *nix box?

<snipped>

--
Dag.
Jul 17 '05 #7
Sticks Random wrote:
[Post moved to bottom because top-posting is evil :o) ] "Shawn Wilson" <sh***@glassgiant.com> wrote in message
news:3F***************@glassgiant.com...
Sticks wrote:
[re-ordered you post because top-posting is evil :o)]
<xyzzy> wrote in message news:Xf********************@comcast.com...
>
> "Sticks" <sa**********@yahoo.com> wrote in message
> news:3f********@usenet.per.paradox.net.au...
> > ok... im not quite sure how to describe my problem.
> > i have a php script that runs through my entire php site and writes the > > resulting output to html files. this is necessary as the nature of the > > hosting available to me for this particular page prohibits me from using > > php/mysql as i would like.
> >
> > my script works simply by using output buffers and an include
> > the relevant section of code is as follows:
> >
> > ob_start();
> > include($source.$pagename);
> > $page_buffer = ob_get_contents();
> > ob_end_clean();
> >
> > i was wondering if there is a way i can do this without using the
include,
> > because the script only works when it is in the same directory as the > site.
> > this arrangement does not suit me, as i would rather be able to store the
> > script in a separate folder.
> >
> >
> >
> >
> >
> My first thought is to create an array with your directory names that you > want to scan
>
> $allDirs =
>
array("/usr/local/apache/htdocs","/usr/local/apache/site1/","/usr/local/apac > he/site1/htdocs") etc...
>
> then iterate through the array and subsequent directory files.
>
> while (list(,$dirName) = each($allDirs) {
> // create an array of all files
> $allFiles = scandir($dirName);
> while (list ($key,$fileName) = each($allFiles) {
> // each file within each directory
> $page_buffer to $fileName stuf......
> }
> }
>
>
perhaps i havent been clear enough
i dont want to use includes to perform this task. i would like to get the html output of a php script that is quite complicated and uses a variety of includes of its own which i do not wish to rewrite unless i absolutely have to. these includes are disturbed when my script resides in a different
directory to the page.

as it stands, the script works. it just isnt an ideal solution.
i am looking for something along the lines of the exec() command, only for executing php scripts.


I'm not sure I understand your problem, but if you want to execute php

scripts
on Linux, you can use

/pathinfo/php -q /pathinfo/scriptname.php

from the command line or a cron job. The "-q" suppresses HTTP headers.

Or you
could do:

/pathinfo/php -q /pathinfo/scriptname.php > index.html

to send all output from that php script to a file called index.html. Be

careful
with this, though, as it's easy to overwrite the wrong files...

this is *almost* what im looking for
trouble is, im running a windoze XP box.... is there any way to do the
'greater than' output to file thing in windoze?
and the other trouble is that if i want to perform that action from a php
script i have to use 'exec', which is not ideal if i want to move the script
to a *nix server some time in the future (which is highly likely)

the biggest issue is that running the script from any directory other than
the directory in which the page to export resides plays merry havoc with the
document relative paths in the script.
perhaps i should clarify - i have an entire website designed in php, built
off a mysql database, complete with a stack of includes and images and
what-have-you. the problem is that the hosting available to the organisation
that the website is for decided to pull the pin on their previous hosting
plan and are not willing to shell the extra $ for php/mysql hosting. my idea
then was to create this script which parses every single php page it can
become aware of (i had to adjust the databases and scrips a little bit to
respond to a $htmldump flag) and then creates new page names based on
obvious content. it then creates a table of all of the pages it created and
what those pages were created from... say for eg:
"page.php?frame=listbuild.php&hw_type=printers " becomes "printerslist.htm".
the script then looks through ALL of the newly created html pages for links
that belong to the old php site and updates them to the corresponding html
link, as well as copying other files and folders to recreate the site
structure.

the way the script is designed (and i might add that although it is
functional it is one piss poor piece of programming and i am embarrassed to
show it to people) is such that it MUST reside in the same directory as the
website it is dumping. i can see no other way to do it with output buffers
and includes (as i have been doing) without rewriting the entire website to
take into account the relocation of the output script. i REALLY do not want
to do this.

thank you very much for the reply though. i will definitely investigate
whether this will work as a band-aid solution.


Could you make your script write a <base href="http://yoursite.com/pathinfo">
into the <head> of each file?

Regards,
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #8
youre forgetting - it needs to be OS independent

"Dag Sunde" <da******@orion.no.way> wrote in message
news:PI*********************@juliett.dax.net...

"Sticks Random" <ba***********@hotmail.com> wrote in message
news:3f**********************@freenews.iinet.net.a u...
this is *almost* what im looking for
trouble is, im running a windoze XP box.... is there any way to do the
'greater than' output to file thing in windoze?
and the other trouble is that if i want to perform that action from a php script i have to use 'exec', which is not ideal if i want to move the

script
to a *nix server some time in the future (which is highly likely)


This is cut from another post by Nikolai Chuvakhin here in this NG:

"
Spawn your asynchronous process via an exec() call with background
execution (& operator; Unix only). Examples:

exec ('myprogram &');
// executes a standalone program in the background

exec ('wget http://server.com/path/script.php --quiet -O /dev/null &');
// executes a PHP script in the background
// via the standard interface

exec ('php /path/script.php &');
// executes a PHP script in the background
// via command-line interface
"

Won't that work for you on a *nix box?

<snipped>

--
Dag.

Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Damien Renwick | last post by:
I have a php script which simply stops midway through a while loop that processes records returned by a MySQL query. The HTML page continues trying to load the page but the php has stopped running...
10
by: shumaker | last post by:
I don't need a detailed description of a solution(although I wouldn't mind), but I am hoping someone could tell me in general the best path to go about accomplishing a task, since I don't know all...
1
by: Ennio-Sr | last post by:
Hi all! Testing a script where I need to make sure that postgresql is running before passing a <psql dbasename -c "insert into ..." > instruction I faced this curious behaviour: This is the...
2
by: Benjamin Rutt | last post by:
I often execute a long-running python script which is a "driver" for my application; it may run for several hours on a large input. Under CPython, is it safe for me to modify the Python script...
1
by: Anonieko | last post by:
Query: How to display progress bar for long running page Answer: Yet another solution. REFERENCE: http://www.eggheadcafe.com/articles/20050108.asp My only regret is that when click the...
1
by: Aaron West | last post by:
Try this script to see what queries are taking over a second. To get some real output, you need a long-running query. Here's one (estimated to take over an hour): PRINT GETDATE() select...
5
by: This | last post by:
I have a pretty basic emailing script that sends a relatively small number (150) of html emails. The emails are compiled, personalised from a mysql db subscribers list, and sent using mail() -...
9
by: Scott | last post by:
What is the most reliable method to determine the folder a script is running in? I was looking at the globals in $_SERVER but all the variables also listed the actual file the script was running...
5
by: Christopher Brewster | last post by:
I am running the same script on the same data on two different machines (the folder is synchronised with Dropbox). I get two different results. All the script does is count words in different...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.