473,386 Members | 1,712 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,386 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 3298
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.