Re: [PHP] Include/Require limit?

2013-05-30 Thread Julian Wanke

Hi,it outputs a corrupt image (I think the function imagepng)Am 30.05.2013, 11:17 Uhr, schrieb Alex Pojarsky divine.ra...@gmail.com:Hey.Afaik - only in case if your PHP process instance exeeds allowed memory limit.Other then this - explain how does it fail exactly. Any error messages? Errorous behavior?
On Thu, May 30, 2013 at 12:49 PM, Julian Wanke billa...@gmx.at wrote:
Hi,

I use the pretty large Library PHP Image Workshop (http://phpimageworkshop.com/) at my project. It is about 75,5 KB. Everything works fine but if I try to include a 15 KB file with country codes, it fails.

With the other files I easily get over 100 KB inclusion size, so my question;
Is there a size limitation for include?

Best regards

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


-- Erstellt mit Operas E-Mail-Modul: http://www.opera.com/mail/

Re: [PHP] include() Error

2013-05-29 Thread Marc Guay
Is the echo $mySQL_user; inside of a function?  I believe you'll
need to say global $mySQL_user; to gain access to it if so.


On 29 May 2013 12:39, Ron Piggott ron.pigg...@actsministries.org wrote:

 Good morning all:

 I have recently purchased a computer and am using it as a dedicated server.  
 A friend helped me install PHP and configure.  I am saying this because I 
 wonder if using a newer version of PHP (compared to my commercial web host) 
 may be the reasoning behind the error I am receiving.

 I created a function to generate a form submission key.
 - This created hidden variable for forms
 - This is also session variable

 With this function I have an ‘ include ‘ for the file containing the mySQL 
 database, username and password.  I know this file is being accessed because 
 I added:

 ===
 echo $mySQL_user;
 ===

 following the login credentials.

 But when I remove this line from mySQL_user_login.inc.php and place within 
 the function on the line following the include the echo” returns nothing.

 ===
 include(mySQL_user_login.inc.php);

 echo $mySQL_user;
 ===

 Can any of you tell me why this is happening?

 Ron Piggott



 www.TheVerseOfTheDay.info

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



Re: [PHP] include selectively or globally?

2012-08-28 Thread tamouse mailing lists
What do your performance measurements show so you have actual data
comparisons to make a valid decsion?

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



Re: [PHP] include selectively or globally?

2012-08-28 Thread Matijn Woudt
On Tue, Aug 28, 2012 at 3:49 AM, Adam Richardson simples...@gmail.com wrote:
 On Mon, Aug 27, 2012 at 6:54 PM, Matijn Woudt tijn...@gmail.com wrote:
 On Mon, Aug 27, 2012 at 10:56 PM, Haluk Karamete
 halukkaram...@gmail.com wrote:

 Now, the question is... should you use a global include that points to
 this library - across the board - so that ALL the pages ( including
 the 90% that do not need the library ) will get it, or should you
 selectively add that include reference only on the pages you need?


 Since searching for files is one of the most expensive (in time)
 operations, you're probably best off with only a single PHP file.

 Maybe I misinterpreted the question, but I don't think I agree.

 If you have a 50K PHP file that's only needed in only 10% of the
 pages, then, when solely considering performance, that file should
 only be included on the 10% of the pages that actually use the file.
 Now, there are reasons where you might want to include the file
 globally (maintenance purposes, etc.) Loading the 50K of PHP code
 requires building up all of the associated infrastructure (zvals,
 etc.) for the user code (even if APC is used, the cached opcode/PHP
 bytecode still has to be parsed and built up for the user-defined
 classes and functions per request, even if they're unused), is
 certainly going to perform more slowly than selectively including the
 library on only the pages that need the library.

 Adam


First of all, I believe PHP is smart enough to not generate bytecode
for functions that are not used in the current file. Think about the
fact that you can write a function with errors, which will run fine
until you call the function. (except for syntax errors).

The speed difference between loading 5K file or 50K file (assuming
continuous blocks) is extremely small. If you split this library, you
would have PHP files that require you to load maybe 3 or 4 different
files to have all their functions. This would require 3 or 4 more file
searches, first the file needs to be located in the file table, then
on the disk. If you compare the required time for those operations,
they are enormous compared to time needed for a bigger file.
Just for the facts, if you're on a high end server drive (15000RPM
with 120MB/s throughput), you would have an average access time of
7ms. (rotational and seek time). Loading 5k with 120MB/s thereafter
only takes 0.04ms. 50k would take 0.4ms. That would save you 0.36ms if
a file only needs 1 include, if you need 2, that would cost you 6.68
ms. 3 would cost 13.72 ms, etc. With an 3.8GHz CPU, there are approx
4.000.000 clock cycles in 1ms, so in this case you would lose for only
loading 2 files instead of one, approx 27.250.000 clock cycles.. Think
about what PHP could do with all those clock cycles..

- Matijn

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



Re: [PHP] include selectively or globally?

2012-08-28 Thread David Harkness
On Tue, Aug 28, 2012 at 4:39 AM, Matijn Woudt tijn...@gmail.com wrote:

 First of all, I believe [A] PHP is smart enough to not generate bytecode
 for functions that are not used in the current file. Think about the
 fact that you can write a function with errors, which will run fine
 until you call the function. [B] (except for syntax errors).


 [B] negates [A]. PHP must either parse the file into opcodes or load them
from APC and further execute the top-level opcodes. That means defining
functions (not calling them unless called directly), constants, global
variables, classes, etc. No amount of measuring is required to tell me that
doing X vs. not doing X in this case clearly takes longer.

Now, is that time significant enough to warrant the extra logic required?
In my case, absolutely. We organize our library into many classes in
multiple files. By using an autoloader, we simply don't need to think about
it. Include bootstrap.php which sets up the autoloader and include paths.
Done.

In the case with a single 50k library file that is used on 10% of the
pages, I'd absolutely require_once it only in the pages that need it
without measuring the performance. It's so trivial to maintain that single
include in individual pages that the gain on 90% of the pages is not worth
delving deeper.

Peace,
David


Re: [PHP] include selectively or globally?

2012-08-28 Thread Adam Richardson
On Tue, Aug 28, 2012 at 7:39 AM, Matijn Woudt tijn...@gmail.com wrote:
 On Tue, Aug 28, 2012 at 3:49 AM, Adam Richardson simples...@gmail.com wrote:
 On Mon, Aug 27, 2012 at 6:54 PM, Matijn Woudt tijn...@gmail.com wrote:
 On Mon, Aug 27, 2012 at 10:56 PM, Haluk Karamete
 halukkaram...@gmail.com wrote:

 First of all, I believe PHP is smart enough to not generate bytecode
 for functions that are not used in the current file. Think about the
 fact that you can write a function with errors, which will run fine
 until you call the function. (except for syntax errors).

I believe this is untrue. PHP generates the bytecode and then parses
the bytecode per request to generate the userland infrastructure,
including classes and functions, for the entire include file. During
the generation of bytecode, PHP doesn't know apriori which functions
will be called at runtime. I suspect if you asked for confirmation of
this on the internals list, they'd confirm this. In terms of errors,
there are certainly different stages that errors can occur, and what
you're referring to are runtime errors. Runtime errors don't
necessarily show up in every possible execution branch. That doesn't
mean that PHP didn't generate the code for the userland functionality.

 The speed difference between loading 5K file or 50K file (assuming
 continuous blocks) is extremely small. If you split this library, you
 would have PHP files that require you to load maybe 3 or 4 different
 files to have all their functions.

Here's where I believe we have a communication issue. I never spoke of
splitting up the library into 3 or 4, or any number of different
files. The opening post states that only 10% of the pages need the
library. I suggested that he only include the library in the 10% of
the pages that need the library. That said, it's possible I
misinterpreted him.

I will say that I do disagree with your analysis that difference
between loading a 5K or 50K php file is extremely small. So I just put
this to the test.

I created a 5K file and a 50K file, both of which have the form:

function hello1(){
echo hello again;
}

function hello2(){
echo hello again;
}

etc.

I have XDegub installed, have APC running, warmed the caches, and then
test a few times. There results all hover around the following:

Including the 5K requires around 50 microseconds. Including the 50K
requires around 180 microseconds. The point is that there is a
significant difference due to the work PHP has to do behind the
scenes, even when functions (or classes, etc. are unused.) And,
relevant to the dialog for this current thread, avoiding including an
unused 50K PHP on 90% of the pages (the pages that don't need the
library) will lead to a real difference.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

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



Re: [PHP] include selectively or globally?

2012-08-28 Thread Matijn Woudt
On Tue, Aug 28, 2012 at 6:55 PM, David Harkness
davi...@highgearmedia.com wrote:
 On Tue, Aug 28, 2012 at 4:39 AM, Matijn Woudt tijn...@gmail.com wrote:

 First of all, I believe [A] PHP is smart enough to not generate bytecode
 for functions that are not used in the current file. Think about the
 fact that you can write a function with errors, which will run fine
 until you call the function. [B] (except for syntax errors).


  [B] negates [A]. PHP must either parse the file into opcodes or load them
 from APC and further execute the top-level opcodes. That means defining
 functions (not calling them unless called directly), constants, global
 variables, classes, etc. No amount of measuring is required to tell me that
 doing X vs. not doing X in this case clearly takes longer.

[B] does not negate [A]. There's a difference between parsing the
syntax and defining functions, classes constants and globals, and
generating bytecode. In a 'normal' file I guess syntax definitions are
only about 5% of the total contents, the rest can be ignored until
being called.


 Now, is that time significant enough to warrant the extra logic required? In
 my case, absolutely. We organize our library into many classes in multiple
 files. By using an autoloader, we simply don't need to think about it.
 Include bootstrap.php which sets up the autoloader and include paths. Done.

 In the case with a single 50k library file that is used on 10% of the pages,
 I'd absolutely require_once it only in the pages that need it without
 measuring the performance. It's so trivial to maintain that single include
 in individual pages that the gain on 90% of the pages is not worth delving
 deeper.

 Peace,
 David


Let me quote the OP, I think that suffices:
When answering this question, please approach the matter strictly from
a caching/performance point of view, not from a convenience point of
view just to avoid that the discussion shifts to a programming style
and the do's and don'ts.

- Matijn

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



Re: [PHP] include selectively or globally?

2012-08-28 Thread Matijn Woudt
On Tue, Aug 28, 2012 at 7:18 PM, Adam Richardson simples...@gmail.com wrote:
 On Tue, Aug 28, 2012 at 7:39 AM, Matijn Woudt tijn...@gmail.com wrote:
 On Tue, Aug 28, 2012 at 3:49 AM, Adam Richardson simples...@gmail.com 
 wrote:
 On Mon, Aug 27, 2012 at 6:54 PM, Matijn Woudt tijn...@gmail.com wrote:
 On Mon, Aug 27, 2012 at 10:56 PM, Haluk Karamete
 halukkaram...@gmail.com wrote:

 First of all, I believe PHP is smart enough to not generate bytecode
 for functions that are not used in the current file. Think about the
 fact that you can write a function with errors, which will run fine
 until you call the function. (except for syntax errors).

 I believe this is untrue. PHP generates the bytecode and then parses
 the bytecode per request to generate the userland infrastructure,
 including classes and functions, for the entire include file. During
 the generation of bytecode, PHP doesn't know apriori which functions
 will be called at runtime. I suspect if you asked for confirmation of
 this on the internals list, they'd confirm this. In terms of errors,
 there are certainly different stages that errors can occur, and what
 you're referring to are runtime errors. Runtime errors don't
 necessarily show up in every possible execution branch. That doesn't
 mean that PHP didn't generate the code for the userland functionality.

 The speed difference between loading 5K file or 50K file (assuming
 continuous blocks) is extremely small. If you split this library, you
 would have PHP files that require you to load maybe 3 or 4 different
 files to have all their functions.

 Here's where I believe we have a communication issue. I never spoke of
 splitting up the library into 3 or 4, or any number of different
 files. The opening post states that only 10% of the pages need the
 library. I suggested that he only include the library in the 10% of
 the pages that need the library. That said, it's possible I
 misinterpreted him.

I interpreted it as: I have a 50K library, and some files only use
10%, some use 20% and some 30%. To be able to include it separately,
you would need to split and some would need to include maybe 3 or 4
files.


 I will say that I do disagree with your analysis that difference
 between loading a 5K or 50K php file is extremely small. So I just put
 this to the test.

 I created a 5K file and a 50K file, both of which have the form:

 function hello1(){
 echo hello again;
 }

 function hello2(){
 echo hello again;
 }

 etc.

 I have XDegub installed, have APC running, warmed the caches, and then
 test a few times. There results all hover around the following:

 Including the 5K requires around 50 microseconds. Including the 50K
 requires around 180 microseconds. The point is that there is a
 significant difference due to the work PHP has to do behind the
 scenes, even when functions (or classes, etc. are unused.) And,
 relevant to the dialog for this current thread, avoiding including an
 unused 50K PHP on 90% of the pages (the pages that don't need the
 library) will lead to a real difference.

 Adam

Finally, you're the first one that actually has measured something.
You should redo your test with real world files, because in real world
functions aren't that small.
In functions with more lines (say ~100 lines per function), you'll see
a different ratio between 5k and 50k. In my tests it is:
- 5K: 22ms
- 50K: 34 ms

When I create files that only contain 1 function, with just a number
of echo Hello world; lines until 5k or 50k, the results are:
- 5K: 15 ms
- 50K: 17 ms


Cheers,

Matijn

Ps. Code used:
?php

$time_start = microtime(true);

include '5k.php'; // 5k.php or 50k.php

$time_end = microtime(true);
echo ($time_end - $time_start).s;

?

System specs:
Ubuntu 12.04 LTS with Apache 2.2.22 and PHP 5.3.10 default config with
no cache etc.
AMD Phenom X4 9550 (2.2GHz)
4 GB DDR2-800
Disk where PHP files at: WD 500GB  with average read speed of 79.23
MB/s (as Measured with hdparm)

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



Re: [PHP] include selectively or globally?

2012-08-28 Thread Adam Richardson
On Tue, Aug 28, 2012 at 3:28 PM, Matijn Woudt tijn...@gmail.com wrote:
 On Tue, Aug 28, 2012 at 7:18 PM, Adam Richardson simples...@gmail.com wrote:

 Finally, you're the first one that actually has measured something.
 You should redo your test with real world files, because in real world
 functions aren't that small.

In terms of redoing the test with real world files, that's an
entirely different debate (and one I won't enter into at this time,
though this list has discussed this topic before, most recently in a
post Ted made talking about screen height.)

The point is, there is a real difference. The question remains if the
difference is enough to act on in future code bases (and I would say
yes if my tests showed this difference, you may say no.)

 In functions with more lines (say ~100 lines per function), you'll see
 a different ratio between 5k and 50k. In my tests it is:
 - 5K: 22ms
 - 50K: 34 ms

Those trends/results depend significantly on the contents of the
functions, too. The overly simplistic example we've used both helps
and hurts the analysis (I'll admit my example likely has more
functions than other 5K/50K files, and I suspect most functions
require more complicated work behind the scenes to build up than echo
statements.)

The point I'd make here is that it's very difficult to have apriori
knowledge of how something will perform without testing it.

 When I create files that only contain 1 function, with just a number
 of echo Hello world; lines until 5k or 50k, the results are:
 - 5K: 15 ms
 - 50K: 17 ms

Ummm... sure. What did you say about real world before :)

Have a nice day!

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

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



Re: [PHP] include selectively or globally?

2012-08-28 Thread David Harkness
On Tue, Aug 28, 2012 at 12:11 PM, Matijn Woudt tijn...@gmail.com wrote:

 On Tue, Aug 28, 2012 at 6:55 PM, David Harkness
 davi...@highgearmedia.com wrote:
  On Tue, Aug 28, 2012 at 4:39 AM, Matijn Woudt tijn...@gmail.com wrote:
 
  First of all, I believe [A] PHP is smart enough to not generate bytecode
  for functions that are not used in the current file. Think about the
  fact that you can write a function with errors, which will run fine
  until you call the function. [B] (except for syntax errors).
 
   [B] negates [A]. PHP must either parse the file into opcodes or load
 them
  from APC and further execute the top-level opcodes. That means defining
  functions (not calling them unless called directly), constants, global
  variables, classes, etc.

 [B] does not negate [A]. There's a difference between parsing the
 syntax and defining functions, classes constants and globals, and
 generating bytecode. In a 'normal' file I guess syntax definitions are
 only about 5% of the total contents, the rest can be ignored until
 being called.


I won't claim a deep understanding of the PHP internals, but I have enough
experience with varied compiled and interpreted languages and using PHP and
APC that I'm confident that the process to include a file involves:

1. Load the opcodes
A. Either read the file from disk and parse the PHP into opcodes, or
B. Load the cached opcodes from APC.
2. Execute the top-level opcodes

Any syntax errors--even those in unreachable code blocks--will cause the
script to fail parsing. For example,

if (false) {
function foo() {
SYNTAX ERROR!
}
}

will cause the parse to fail even though the function cannot logically be
defined. PHP doesn't even get that far.

PHP Parse error:  syntax error, unexpected T_STRING in php shell code
on line 3


 When answering this question, please approach the matter strictly from
 a caching/performance point of view, not from a convenience point of
 view just to avoid that the discussion shifts to a programming style
 and the do's and don'ts.


While out of convenience you might be tempted to include the file in every
script, when considering performance alone you should include the file only
in those scripts that will make use of its contents.

Peace,
David


Re: [PHP] include selectively or globally?

2012-08-27 Thread Matijn Woudt
On Mon, Aug 27, 2012 at 10:56 PM, Haluk Karamete
halukkaram...@gmail.com wrote:
 With this question, I aim to understand the inner workings of PHP a
 little better.

 Assume that you got a 50K library. The library is loaded with a bunch
 of handy functions that you use here and there. Also assume that these
 functions are needed/used by say 10% of the pages of your site. But
 your home page definitely needs it.

 Now, the question is... should you use a global include that points to
 this library - across the board - so that ALL the pages ( including
 the 90% that do not need the library ) will get it, or should you
 selectively add that include reference only on the pages you need?

 Before answering this question, let me point why I ask this question...

 When you include that reference, PHP may be caching it. So the
 performance hit I worry may be one time deal, as opposed to every
 time. Once that one time out of the way, subsequent loads may not be
 as bad as one might think. That's all because of the smart caching
 mechanisms that PHP deploys - which I do not have a deep knowledge of,
 hence the question...

 Since the front page needs that library anyway, the argument could be
 why not keep that library warm and fresh in the memory and get it
 served across the board?

 When answering this question, please approach the matter strictly from
 a caching/performance point of view, not from a convenience point of
 view just to avoid that the discussion shifts to a programming style
 and the do's and don'ts.

 Thank you

 http://stackoverflow.com/questions/12148966/include-selectively-or-globally

Since searching for files is one of the most expensive (in time)
operations, you're probably best off with only a single PHP file. PHP
parses a file initially pretty quickly (it's only checking syntax half
on load), so unless you're having a 100MHz CPU with SSD drive, I'd say
go with a single PHP file. If you make sure the file isn't fragmented
over your disk, it should load pretty quick to memory. I'm not sure if
PHP caches that much, but if you really care, take a look at memcached
or APC.

- Matijn

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



Re: [PHP] include selectively or globally?

2012-08-27 Thread Adam Richardson
On Mon, Aug 27, 2012 at 6:54 PM, Matijn Woudt tijn...@gmail.com wrote:
 On Mon, Aug 27, 2012 at 10:56 PM, Haluk Karamete
 halukkaram...@gmail.com wrote:

 Now, the question is... should you use a global include that points to
 this library - across the board - so that ALL the pages ( including
 the 90% that do not need the library ) will get it, or should you
 selectively add that include reference only on the pages you need?


 Since searching for files is one of the most expensive (in time)
 operations, you're probably best off with only a single PHP file.

Maybe I misinterpreted the question, but I don't think I agree.

If you have a 50K PHP file that's only needed in only 10% of the
pages, then, when solely considering performance, that file should
only be included on the 10% of the pages that actually use the file.
Now, there are reasons where you might want to include the file
globally (maintenance purposes, etc.) Loading the 50K of PHP code
requires building up all of the associated infrastructure (zvals,
etc.) for the user code (even if APC is used, the cached opcode/PHP
bytecode still has to be parsed and built up for the user-defined
classes and functions per request, even if they're unused), is
certainly going to perform more slowly than selectively including the
library on only the pages that need the library.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

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



Re: Re: [PHP] include

2011-11-21 Thread Tim Streater
On 20 Nov 2011 at 23:46, Tamara Temple tamouse.li...@tamaratemple.com wrote: 

 Tim Streater t...@clothears.org.uk wrote:

 At the moment I'm using an instance of apache to run PHP scripts, as
 and when required via AJAX. Having got some understanding of web
 sockets, I'm minded to look at having a small server to execute these
 functions as required. The scripts, some 50 or so, are only about
 300kbytes of source code, which seems small enough that it could all
 be loaded with include, as in:

 ?php
 $fn = 'wiggy.php';
 include $fn;
 ?

 This appears to work although I couldn't see it documented.

 I'm really not sure what you're looking for here -- that is pretty
 standard php practice to load php files with include -- what were you
 expecting here?

I'm looking for confirmation that:

  include $fn;

is an allowed form of the include statement.

 While it's certainly possible to rig up something using sockets, I don't
 think that's how AJAX works, and you'd need a JS library that did.

Hmmm, I think perhaps I've not made myself clear - sorry about that. At present 
I'm using AJAX and apache; I'd like to *stop* doing that (and not use another 
web server, either). In my case, client and server are the same machine - the 
user's machine. There is a browser window and JavaScript within it which makes 
the AJAX requests. I just happen to use apache to have a variety of PHP scripts 
run to provide results back to the browser window.

 Generally, you should only really need to dynamically replace parts of a
 long-running program if you don't want to restart it. However, php
 scripts are not long-running programs in general, unlike the apache
 server itself, for example, and certainly if the php scripts are running
 under apache, they will be time- and space-limited by whatever is set in
 the php.ini file. If these little scripts are merely responding to AJAX
 requests, they should be really short-lived.

At present these scripts generally are short-lived, but with some notable 
exceptions. Hence my exploration of whether I could use websockets instead.

--
Cheers  --  Tim

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

Re: Re: [PHP] include

2011-11-21 Thread Tommy Pham
On Mon, Nov 21, 2011 at 2:56 AM, Tim Streater t...@clothears.org.uk wrote:
 On 20 Nov 2011 at 23:46, Tamara Temple tamouse.li...@tamaratemple.com wrote:

 Tim Streater t...@clothears.org.uk wrote:

 At the moment I'm using an instance of apache to run PHP scripts, as
 and when required via AJAX. Having got some understanding of web
 sockets, I'm minded to look at having a small server to execute these
 functions as required. The scripts, some 50 or so, are only about
 300kbytes of source code, which seems small enough that it could all
 be loaded with include, as in:

 ?php
 $fn = 'wiggy.php';
 include $fn;
 ?

 This appears to work although I couldn't see it documented.

 I'm really not sure what you're looking for here -- that is pretty
 standard php practice to load php files with include -- what were you
 expecting here?

 I'm looking for confirmation that:

  include $fn;

 is an allowed form of the include statement.


RTFM [1] example #6 ;)

HTH,
Tommy

[1] http://php.net/function.include

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



Re: [PHP] include

2011-11-21 Thread Tim Streater
On 21 Nov 2011 at 11:10, Tommy Pham tommy...@gmail.com wrote: 

 On Mon, Nov 21, 2011 at 2:56 AM, Tim Streater t...@clothears.org.uk wrote:

 I'm looking for confirmation that:

  include $fn;

 is an allowed form of the include statement.


 RTFM [1] example #6 ;)

 [1] http://php.net/function.include

Thanks - I missed that one.

--
Cheers  --  Tim

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

Re: [PHP] include

2011-11-21 Thread Tamara Temple
Tim Streater t...@clothears.org.uk wrote:
 I'm looking for confirmation that:
 
   include $fn;
 
 is an allowed form of the include statement.

Yes, it is definitely allowed. The syntactic sugar of using parens
around the include subject is optional, as it is in other parts of php
as well. That said, it's usually better to include the syntactic sugar
so as to make future maintenance concerns easier -- there's less chance
of a future change to introduce an error if it's clear what things are
grouped with what. Much less of a concern in this case, but more of a
concern in, say, compound expressions.

?php
$fn=foo.ext;
include $fn;
include $fn;
include ($fn);
include ($fn);
?

are all equivalent, because php interpolates variable references in
double quoted strings.

?php
include '$fn';
?

however is not.

  While it's certainly possible to rig up something using sockets, I don't
  think that's how AJAX works, and you'd need a JS library that did.
 
 Hmmm, I think perhaps I've not made myself clear - sorry about that. At 
 present I'm using AJAX and apache; I'd like to *stop* doing that (and not use 
 another web server, either). In my case, client and server are the same 
 machine - the user's machine. There is a browser window and JavaScript within 
 it which makes the AJAX requests. I just happen to use apache to have a 
 variety of PHP scripts run to provide results back to the browser window.
 
  Generally, you should only really need to dynamically replace parts of a
  long-running program if you don't want to restart it. However, php
  scripts are not long-running programs in general, unlike the apache
  server itself, for example, and certainly if the php scripts are running
  under apache, they will be time- and space-limited by whatever is set in
  the php.ini file. If these little scripts are merely responding to AJAX
  requests, they should be really short-lived.
 
 At present these scripts generally are short-lived, but with some notable 
 exceptions. Hence my exploration of whether I could use websockets instead.

Ah, okay, I'm not at all familiar with websockets, so I'm going to have
to step out of this. Good luck with it!

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



Re: [PHP] include

2011-11-20 Thread Tommy Pham
On Sat, Nov 19, 2011 at 2:16 PM, Tim Streater t...@clothears.org.uk wrote:
 At the moment I'm using an instance of apache to run PHP scripts, as and when 
 required via AJAX. Having got some understanding of web sockets, I'm minded 
 to look at having a small server to execute these functions as required. The 
 scripts, some 50 or so, are only about 300kbytes of source code, which seems 
 small enough that it could all be loaded with include, as in:

 ?php
 $fn = 'wiggy.php';
 include $fn;
 ?

 This appears to work although I couldn't see it documented.

 I'd also like to be able to replace a module without restarting the server. I 
 couldn't see a way to drop an included file, do I therefore take it that 
 there is none? Failing that, is there a good way to dynamically replace parts 
 of a PHP program, possibly using runkit?

 --
 Cheers  --  Tim



Tim,

I think you're approaching this the wrong way.
1) have a clear understanding of PHP - syntax, capabilities, etc.
2) have a clear understand of what you're intending to do -
application's function/purpose, features, manageability,
expandability, portability, etc...
3) understand design patterns

What your asking is practically impossible in any programming language
akin to 'how to un-import packages in Java' or 'how to un-using
namespace in C#'.  If you don't want to use it, don't include it ;)
If this is running as web app, you can use header [1] and pass the
criteria for next phase of the operation as URL parameters.  But doing
this is going to kill the server side with too many unnecessary round
trips.  Which clearly demonstrates point 2 and 3.  You should look
into Interfaces, and Abstract under OOP [2].

HTH,
Tommy

[1] http://php.net/function.header
[2] http://php.net/language.oop5

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



Re: Re: [PHP] include

2011-11-20 Thread Tim Streater
On 20 Nov 2011 at 10:36, Tommy Pham tommy...@gmail.com wrote: 

 I think you're approaching this the wrong way.
 1) have a clear understanding of PHP - syntax, capabilities, etc.

That's what I'm doing - gathering information about bits of PHP that I've not 
used (or not used very much) before to see how my new setup could be structured.

 2) have a clear understand of what you're intending to do -
 application's function/purpose, features, manageability,
 expandability, portability, etc...

I have a clear idea about *that*. I want to figure out if it's possible to use 
web sockets with a small server written in PHP to replace my current structure 
of ajax + apache + processes (which I suppose it forks). I see these benefits:

1) possible benefit - presumably when an ajax request arrives, a new process is 
started and so PHP has to be loaded and initialised each time. But perhaps this 
is in some way optimised so the PHP process is left running and apache then 
just tells it to read/execute a new script.

2) Definite benefit - when a browser makes an ajax request to run a script, it 
gets no information back until the script completes. Then it gets all of it. I 
have a couple of unsatisfactory workarounds for that in my existing structure. 
Websockets appears to offer a way for the browser to receive timely information.

 3) understand design patterns

I don't know what this means.

 What your asking is practically impossible in any programming language
 akin to 'how to un-import packages in Java' or 'how to un-using
 namespace in C#'.  If you don't want to use it, don't include it ;)

I do want to use it but would like to be able to replace it with a newer 
version. If there is no way to do this then that is a data point.

And here's another question. Can a child forked by pcntl_fork() use a socket 
that the parent obtained? Reading the socket stuff in the PHP doc, there are a 
number of user-supplied notes hinting this might be problematic.

--
Cheers  --  Tim

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

Re: Re: [PHP] include

2011-11-20 Thread shiplu
On Mon, Nov 21, 2011 at 3:34 AM, Tim Streater t...@clothears.org.uk wrote:

 On 20 Nov 2011 at 10:36, Tommy Pham tommy...@gmail.com wrote:

  I think you're approaching this the wrong way.
  1) have a clear understanding of PHP - syntax, capabilities, etc.

 That's what I'm doing - gathering information about bits of PHP that I've
 not used (or not used very much) before to see how my new setup could be
 structured.

  2) have a clear understand of what you're intending to do -
  application's function/purpose, features, manageability,
  expandability, portability, etc...

 I have a clear idea about *that*. I want to figure out if it's possible to
 use web sockets with a small server written in PHP to replace my current
 structure of ajax + apache + processes (which I suppose it forks). I see
 these benefits:

 1) possible benefit - presumably when an ajax request arrives, a new
 process is started and so PHP has to be loaded and initialised each time.
 But perhaps this is in some way optimised so the PHP process is left
 running and apache then just tells it to read/execute a new script.


Did you check http://php-fpm.org/



 2) Definite benefit - when a browser makes an ajax request to run a
 script, it gets no information back until the script completes. Then it
 gets all of it. I have a couple of unsatisfactory workarounds for that in
 my existing structure. Websockets appears to offer a way for the browser to
 receive timely information.

  3) understand design patterns

 I don't know what this means.

  What your asking is practically impossible in any programming language
  akin to 'how to un-import packages in Java' or 'how to un-using
  namespace in C#'.  If you don't want to use it, don't include it ;)

 I do want to use it but would like to be able to replace it with a newer
 version. If there is no way to do this then that is a data point.

 And here's another question. Can a child forked by pcntl_fork() use a
 socket that the parent obtained? Reading the socket stuff in the PHP doc,
 there are a number of user-supplied notes hinting this might be problematic.

 --
 Cheers  --  Tim


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




-- 
Shiplu Mokadd.im
Follow me, http://twitter.com/shiplu
Innovation distinguishes between follower and leader


Re: [PHP] include

2011-11-20 Thread Tamara Temple
Tim Streater t...@clothears.org.uk wrote:

 At the moment I'm using an instance of apache to run PHP scripts, as
 and when required via AJAX. Having got some understanding of web
 sockets, I'm minded to look at having a small server to execute these
 functions as required. The scripts, some 50 or so, are only about
 300kbytes of source code, which seems small enough that it could all
 be loaded with include, as in:
 
 
 ?php
 $fn = 'wiggy.php';
 include $fn;
 ?
 
 This appears to work although I couldn't see it documented.

I'm really not sure what you're looking for here -- that is pretty
standard php practice to load php files with include -- what were you
expecting here?

While it's certainly possible to rig up something using sockets, I don't
think that's how AJAX works, and you'd need a JS library that did.

As an alternative, can you set up a lightweight web server like lighttpd
and fastcgi on your host machine? This should give you the speed and
flexibility without incurring the overhead of loading everything into
mod_php under apache. The alternate server would listen on a different
port and dispatch fastcgi to deal with the php scripts.

As well, you could run fastcgi from apache to dispatch the smaller
scripts if you didn't want another web server running, although in
practice this hasn't proven to be an issue for me.

 I'd also like to be able to replace a module without restarting the
 server. I couldn't see a way to drop an included file, do I therefore
 take it that there is none? Failing that, is there a good way to
 dynamically replace parts of a PHP program, possibly using runkit?
 

Generally, you should only really need to dynamically replace parts of a
long-running program if you don't want to restart it. However, php
scripts are not long-running programs in general, unlike the apache
server itself, for example, and certainly if the php scripts are running
under apache, they will be time- and space-limited by whatever is set in
the php.ini file. If these little scripts are merely responding to AJAX
requests, they should be really short-lived.

OTOH, if you do have a need to replace an include file, you can include
it again unless you use something like include_once or
require_once. Otherwise, the bare include and require commands
will merrily go ahead and re-include the file. What you really need to
watch out for is dealing with initialization of variables in the include
file, and if what you're including are classes that the previous version
has objects out for, what happens then is going to be pretty strange.

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



Re: Re: [PHP] include

2011-11-20 Thread Tommy Pham
On Sun, Nov 20, 2011 at 1:34 PM, Tim Streater t...@clothears.org.uk wrote:
 On 20 Nov 2011 at 10:36, Tommy Pham tommy...@gmail.com wrote:

 I think you're approaching this the wrong way.
 1) have a clear understanding of PHP - syntax, capabilities, etc.

 That's what I'm doing - gathering information about bits of PHP that I've not 
 used (or not used very much) before to see how my new setup could be 
 structured.


That's a good starting point.

 2) have a clear understand of what you're intending to do -
 application's function/purpose, features, manageability,
 expandability, portability, etc...

 I have a clear idea about *that*. I want to figure out if it's possible to 
 use web sockets with a small server written in PHP to replace my current 
 structure of ajax + apache + processes (which I suppose it forks). I see 
 these benefits:

 1) possible benefit - presumably when an ajax request arrives, a new process 
 is started and so PHP has to be loaded and initialised each time. But perhaps 
 this is in some way optimised so the PHP process is left running and apache 
 then just tells it to read/execute a new script.

 2) Definite benefit - when a browser makes an ajax request to run a script, 
 it gets no information back until the script completes. Then it gets all of 
 it. I have a couple of unsatisfactory workarounds for that in my existing 
 structure. Websockets appears to offer a way for the browser to receive 
 timely information.


You didn't understand my 2nd point completely.  The 2nd point starts
with what function/purpose does the app provide such as is it an
e-commerce, CMS, forum, etc...  What you're talking about is the
process(es) which facilitate(s) the application's functions ie:
there's more than one way to skin the cat - so to speak.  Which is
part of manageability, portability, expandability (ie: scaling to
clusters, ease of 3rd party plugins, etc), etc

 3) understand design patterns

 I don't know what this means.


Google programming design patterns

 What your asking is practically impossible in any programming language
 akin to 'how to un-import packages in Java' or 'how to un-using
 namespace in C#'.  If you don't want to use it, don't include it ;)

 I do want to use it but would like to be able to replace it with a newer 
 version. If there is no way to do this then that is a data point.


That's why I suggested you read up regarding OOP, including Interface
and Abstracts.  In OOP, you define and guaranteed certain
functionalities with Interfaces - hence the term API (Application
Programming Interface) - but you pass a super/parent class or any of
its sub/child classes, implement those interface(s), to do the work
needed as how you want things done based on certain criteria.  Classic
example:

1) connect to db
2) execute query
3) fetch results
4) process results
5) close connection

given those 5 above steps, there are many ways to proceed about it.
Which way you choose depends on my 2nd point.  In the past, the
standard practice was using client library such as MySQL or MySQLi,
especially prior to PHP5.  Now it's done via PDO or other data
abstraction layer, including ORM depending on a lot of things:
experience, skills, knowledge, project dead line, personal
preference/style, best coding practices, and lazyness in that given
moment - not particularly in those order either.

 And here's another question. Can a child forked by pcntl_fork() use a socket 
 that the parent obtained? Reading the socket stuff in the PHP doc, there are 
 a number of user-supplied notes hinting this might be problematic.

 --
 Cheers  --  Tim


HTH,
Tommy

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



Re: Re: [PHP] include

2011-11-20 Thread Tommy Pham
On Sun, Nov 20, 2011 at 4:44 PM, Tommy Pham tommy...@gmail.com wrote:
 On Sun, Nov 20, 2011 at 1:34 PM, Tim Streater t...@clothears.org.uk wrote:
 On 20 Nov 2011 at 10:36, Tommy Pham tommy...@gmail.com wrote:

 And here's another question. Can a child forked by pcntl_fork() use a socket 
 that the parent obtained? Reading the socket stuff in the PHP doc, there are 
 a number of user-supplied notes hinting this might be problematic.

 --
 Cheers  --  Tim



Forgot to address this in my previous e-mail because I was cooking
while trying to read/reply my e-mails.  Anyway, if I'm not mistaken,
what you're trying to do is making a threaded application.  PHP does
not support threads currently.  PHP and threads has been a heated
discussion on this list in the past.  You're welcome to search the
archives. [1]

HTH,
Tommy

[1] http://marc.info/?l=php-general

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



Re: [PHP] include() and duplicate function definition

2010-11-03 Thread Thijs Lensselink
On Wed, 3 Nov 2010 17:59:06 +0800, David Nelson 
comme...@traduction.biz wrote:

Hi, :-)

I'm making a child theme for WordPress. I need to rewrite one 
function
defined in ../sometheme/functions/actions.php and put that 
rewritten
function in 
wp-content/themes/sometheme-child/functions/actions.php.


But I want to preserve ../sometheme/functions/actions.php unchanged
in any way. (Future theme updates would just overwrite any changes I
made.)

So, in my new actions.php, I put an include followed by the
replacement function definition, named identically to the one I want
to replace:

?php

include '../sometheme/functions/actions.php';

function foo($arg_1, $arg_2, /* ..., */ $arg_n)
{
echo All my new code.\n;
}

?

Because this duplicate foo() function definition comes after the 
foo()

defined in the included file, does it replace the included foo()?

Or how can I achieve what I want?

Big thanks in advance for any suggestions. :-)

David


As far as I know it is not possible to overwrite functions in PHP 
(unless you use runkit, apd). Inside classes this is possible. But 
that's not the case here. Why do the functions have to be equally named?


Try to create a new function and call the original function from there 
if needed...


foo2() {
foo()
}


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



Re: [PHP] include() and duplicate function definition

2010-11-03 Thread Peter Lind
You can check with function_exists to see if a function is already defined.
If not, create it.

Regards
Peter
On Nov 3, 2010 11:40 AM, David Nelson comme...@traduction.biz wrote:
 Hi Thijs, :-)

 On Wed, Nov 3, 2010 at 18:18, Thijs Lensselink d...@lenss.nl wrote:
 As far as I know it is not possible to overwrite functions in PHP (unless
 you use runkit, apd). Inside classes this is possible. But that's not the
 case here. Why do the functions have to be equally named?

 If the functions aren't named the same, my replacement function will
 never get called by the code that uses the WordPress theme code...

 Try to create a new function and call the original function from there if
 needed...

 Sadly, it wouldn't work for the above reason...

 But thanks for your answer. :-)

 David Nelson

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



Re: [PHP] include() and duplicate function definition

2010-11-03 Thread David Nelson
Hi Peter, :-)

On Wed, Nov 3, 2010 at 18:44, Peter Lind peter.e.l...@gmail.com wrote:
 You can check with function_exists to see if a function is already defined.
 If not, create it.

The function is definitely already defined, I just need to replace it
without touching the file in which it's defined...

David Nelson

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



Re: [PHP] include() and duplicate function definition

2010-11-03 Thread Peter Lind
That's not going to happen. My point was you could check in the original
file if the function is defined and if not then define it.
On Nov 3, 2010 11:55 AM, David Nelson comme...@traduction.biz wrote:
 Hi Peter, :-)

 On Wed, Nov 3, 2010 at 18:44, Peter Lind peter.e.l...@gmail.com wrote:
 You can check with function_exists to see if a function is already
defined.
 If not, create it.

 The function is definitely already defined, I just need to replace it
 without touching the file in which it's defined...

 David Nelson


Re: [PHP] include() and duplicate function definition

2010-11-03 Thread David Nelson
Hi, :-)

On Wed, Nov 3, 2010 at 19:29, Peter Lind peter.e.l...@gmail.com wrote:
 That's not going to happen. My point was you could check in the original
 file if the function is defined and if not then define it.

OK, thanks, Thijs and Peter, it looks like I'm trying to do something
that is not currently possible in PHP. Time for some lateral thinking.
:-)

David Nelson

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



Re: [PHP] include() and duplicate function definition

2010-11-03 Thread Thijs Lensselink
On Wed, 3 Nov 2010 19:53:52 +0800, David Nelson 
comme...@traduction.biz wrote:

Hi, :-)

On Wed, Nov 3, 2010 at 19:29, Peter Lind peter.e.l...@gmail.com 
wrote:
That's not going to happen. My point was you could check in the 
original

file if the function is defined and if not then define it.


OK, thanks, Thijs and Peter, it looks like I'm trying to do something
that is not currently possible in PHP. Time for some lateral 
thinking.

:-)

David Nelson


David,

I re-read your original post. And noticed you include the function 
inside your child action.php
Is there a special reason for that? You want to overwrite the original 
function in a child theme.
probably to get different functionality. So why do you need the 
original function?


Just create your action.php and define the same function.


// include '../sometheme/functions/actions.php';

function foo($arg_1, $arg_2, /* ..., */ $arg_n) {
echo All my new code.\n;
}

It's code duplication. But i don't think themes should have 
dependencies to one an other.

You could also create a actions.php file outside the themes folder.

wp-content/shared-functions/action.php

And then in your themes do:

theme 1

include shared-function/action.php;

foo();


theme 2

include shared-function/action.php;

foo();

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



Re: [PHP] include() and duplicate function definition

2010-11-03 Thread Steve Staples
On Thu, 2010-11-04 at 00:00 +0800, David Nelson wrote:
 Hi Thijs, :-)
 
 On Wed, Nov 3, 2010 at 20:38, Thijs Lensselink d...@lenss.nl wrote:
  I re-read your original post. And noticed you include the function inside
  your child action.php
  Is there a special reason for that? You want to overwrite the original
  function in a child theme.
  probably to get different functionality. So why do you need the original
  function?
 
  Just create your action.php and define the same function.
 
 It's a WordPress issue. When theme updates become available from the
 original vendor, you can update them from within the admin backend. In
 that case, any hacks you've applied (such as removing a function) get
 overwritten. So the evangelized solution is to create a child theme.
 The child theme incorporates only files that you've added or changed,
 with the original parent theme being used for all others.
 
 Easy peasy if you want to *add* a function.
 
 But, if you want to *modify* a function, you're faced with the problem
 of the original function still being present in the parent theme files
 and of your having to define a function of the same name in your child
 theme (if you change the function name, you then have to hack other
 code further upstream, and the work involved becomes not worth the
 bother). Somehow, I would need to make my hacked function *replace*
 the original function, *without* touching the original function...
 
 It seems like that's not possible and I'll have to find another
 solution... unless my explanation gives you any good ideas?
 
 Just to put the dots on the I's, the original actions.php contains a
 lot of *other* functions that I don't want to touch, and that I do
 want to leave exposed to the updates process. It's just one single
 function I want to hack...
 
 Sticky problem, huh? :-)
 
 In any case, thanks for your kind help, :-)
 
 David Nelson
 
 P.S. Sorry about the direct mails: I keep forgetting to hit the
 Replly to all button.
 


I am curious on how this would work, if for some reason they were using
a different template?   the function you want to overwrite, wont be
used, and therefore, wouldn't your app/template/whatever be updated
improperly than waht you expect it to be?

Just curious... 


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



Re: [PHP] include() and duplicate function definition

2010-11-03 Thread David Nelson
Hi guys, :-)

Just FYI, I got this answer from the theme dev:

David,
You don't need the include statement. If you create your function in
wp-content/themes/suffusion-child/functions.php it will get
automatically included.

Secondly, using the same function name wouldn't work, because it would
require me to encase the original function definition in actions.php
in a function_exists clause. I would suggest using a different
function name, then using remove_action to remove the older action and
add_action to add the new action.

(http://www.aquoid.com/forum/viewtopic.php?f=4t=3070)

I'm not yet confident about how to actually implement this in code...
Any tips or advice would be gratefully heard.


On Thu, Nov 4, 2010 at 00:13, Steve Staples sstap...@mnsi.net wrote:
 I am curious on how this would work, if for some reason they were using
 a different template?   the function you want to overwrite, wont be
 used, and therefore, wouldn't your app/template/whatever be updated
 improperly than waht you expect it to be?

Steve, maybe the above informs? In any case, the function to be
overwritten is likely to remain fairly stable...

All the best, :-)

David Nelson

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



Re: [PHP] include html

2010-11-02 Thread Karl DeSaulniers


On Nov 2, 2010, at 12:37 AM, Nathan Nobbe wrote:

On Mon, Nov 1, 2010 at 11:22 PM, Karl DeSaulniers  
k...@designdrumm.com wrote:
I need to basically grab the source of the page as text. Then I can  
do a replace() on the link tag. Then insert the text into an  
Iframe. In theory, this I thought would be handled better server  
side. Is this possible?


yes, there are a few options, fopen wrappers, curl or raw sockets  
all come to mind.  fopen wrappers sound like they may be easiest  
for you.


Any examples or urls to make a fopen wrapper? Or is there a simple  
function for getting the source text from a URL?
Thats all I really need, if I can get html.../html in text, I'm  
good!
From that point I can insert the text into a hidden form field and  
grab the text via javascript if need be (but very hackish) or with php.
I think that may be a solution, if I assign an include statement or  
echo of the url inside a hidden form field.
A hidden form field will force the text to be saved and not parsed. I  
think.




I think the problem I'm having is that the domain I'm requesting  
from is not the same domain as mine so their may be some security  
issue.


right, this is why you would setup a server side proxy, to avoid  
client side cross domain security restrictions, however you'll have  
to change all the instances of the remote domain to your domain,  
and ensure that your server actually is able to fulfill requests  
for those resources.


Server side proxy.. I have  heard of this, but do not know exactly  
what a proxy does to know if it would be a solution.
I also have not seen one in action nor made one (that I know of), any  
beginner tuts you can lend?




I also thought about injecting a link tag into the iframe at the  
same time I load the HTML.


when you say link tag are you talking about a tags?  you lost me  
on this last line here.


IE:  [code]
Get the text from their source, something like:

$htmlTextresult = html
head
link href=css/fromtheirsite.css rel=stylesheet type=text/css  
media=all /

/head
body
... their content
/body
/html

then do a string replace on the link tag..
$newTextresult = str_replace($htmlTextresult, 'link href=css/ 
fromtheirsite.css rel=stylesheet type=text/css media=all /',  
'link href=css/frommysite.css rel=stylesheet type=text/css  
media=all /');

or
$newTextresult = str_replace($htmlTextresult, 'css/ 
fromtheirsite.css', 'css/frommysite.css');


insert new text into the iframe..
$newTextresult = html
head
link href=css/frommysite.css rel=stylesheet type=text/css  
media=all /

/head
body
... their content/ my style :)
/body
/html

Or is there a way to strip the text that is in the head , body  
and script  tags?

I could then insert those into a blank html file?



Browsers load the last style sheet on top of others.

this is true, but i doubt you'll be able to have it load a css file  
from your domain atop a css file from a remote domain.


Well contrary, I think, only because all css tuts I found warned  
about using the !important in your css as it would override an  
external css.
Imported css has the least priority out of all and their css is  
imported, maybe if I wrote the css as a style inline within the  
text I received from the source?
I know that would work as far as my css beating out theirs. And the  
idea is to get the source and replace the text that points to their  
css (the  link tag) with mine before its parsed.




 If I could just get the link tag into the iframes contents right  
after I get the source text in there, it may work. But there is  
also the issue of correctly assigning the classes and I'd that are  
used in the iframe. Like


iframe.holder .someclassusedbythem {}

Or do I do?

iframe#holder .someclassusedbythem {}

Or

#holder .someclassusedbythem {}

Sorry if I'm OT with that.

shrug, no worries, but im too lazy to dig into the details of  
client side options. :)


Hey thanks for your help Nathan. I was starting to think I needed to  
scrap.

You have sparked the curiosity again.

Best,



-nathan




Karl DeSaulniers
Design Drumm
http://designdrumm.com



Re: [PHP] include html

2010-11-01 Thread Nathan Nobbe
On Sunday, October 31, 2010, a...@ashleysheridan.co.uk
a...@ashleysheridan.co.uk wrote:
 This can only be done with javascript, as the iframe is client-side, which 
 php knows nothing about.

 sounds to me like OP is building the page which will have the iframe
in it which means this is totally doable server side.  in fact, id
almost prefer server side as that allows masking of the origin making
overriding css values easier afaict.

 I am building a website for a tshirt company that uses another
 company to get garments and promo items to print on.
 The client wants to just have those pages load on top of their
 website, but wants the layout to go with their look and feel. their css.
 We have the go ahead from the other companies to do so as well.

Karl,

this could be done server or client side, however the trouble is
altering the css for every page inside the iframe could be a real
pain.  basically what you could do is act as a proxy, each 'page' from
the original site should be 'made a page' on your site.  basically
youll have to change anchor tag href attributes so each request that
would go back to the original site goes through your site first.  that
way youll have the chance to change the result before handing it back
to the client.  also youll obviously need to change the url to css
file(s) per your primary requirement.  if you do as i suggested above
and make the remote site appear as being served from your domain, you
should be able to get away w/ using a css file served from your domain
as well.

as one of my college professors used to say however, the devil is in
the details, mwahaha.  i would recommend initially experimening to see
if you can use w/e look  feel customizations the remote site offers
to determine if embedding in the iframe w/o any proxy effort is
possible.

-nathan

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



Re: [PHP] include html

2010-11-01 Thread Karl DeSaulniers
I need to basically grab the source of the page as text. Then I can do  
a replace() on the link tag. Then insert the text into an Iframe. In  
theory, this I thought would be handled better server side. Is this  
possible? I think the problem I'm having is that the domain I'm  
requesting from is not the same domain as mine so their may be some  
security issue. I also thought about injecting a link tag into the  
iframe at the same time I load the HTML. Browsers load the last style  
sheet on top of others.  If I could just get the link tag into the  
iframes contents right after I get the source text in there, it may  
work. But there is also the issue of correctly assigning the classes  
and I'd that are used in the iframe. Like


iframe.holder .someclassusedbythem {}

Or do I do?

iframe#holder .someclassusedbythem {}

Or

#holder .someclassusedbythem {}

Sorry if I'm OT with that.

Karl

Sent from losPhone

On Nov 1, 2010, at 11:50 PM, Nathan Nobbe quickshif...@gmail.com  
wrote:



On Sunday, October 31, 2010, a...@ashleysheridan.co.uk
a...@ashleysheridan.co.uk wrote:
This can only be done with javascript, as the iframe is client- 
side, which php knows nothing about.


sounds to me like OP is building the page which will have the iframe
in it which means this is totally doable server side.  in fact, id
almost prefer server side as that allows masking of the origin making
overriding css values easier afaict.


I am building a website for a tshirt company that uses another
company to get garments and promo items to print on.
The client wants to just have those pages load on top of their
website, but wants the layout to go with their look and feel. their  
css.

We have the go ahead from the other companies to do so as well.


Karl,

this could be done server or client side, however the trouble is
altering the css for every page inside the iframe could be a real
pain.  basically what you could do is act as a proxy, each 'page' from
the original site should be 'made a page' on your site.  basically
youll have to change anchor tag href attributes so each request that
would go back to the original site goes through your site first.  that
way youll have the chance to change the result before handing it back
to the client.  also youll obviously need to change the url to css
file(s) per your primary requirement.  if you do as i suggested above
and make the remote site appear as being served from your domain, you
should be able to get away w/ using a css file served from your domain
as well.

as one of my college professors used to say however, the devil is in
the details, mwahaha.  i would recommend initially experimening to see
if you can use w/e look  feel customizations the remote site offers
to determine if embedding in the iframe w/o any proxy effort is
possible.

-nathan


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



Re: [PHP] include html

2010-11-01 Thread Nathan Nobbe
On Mon, Nov 1, 2010 at 11:22 PM, Karl DeSaulniers k...@designdrumm.comwrote:

 I need to basically grab the source of the page as text. Then I can do a
 replace() on the link tag. Then insert the text into an Iframe. In theory,
 this I thought would be handled better server side. Is this possible?


yes, there are a few options, fopen wrappers, curl or raw sockets all come
to mind.  fopen wrappers sound like they may be easiest for you.


 I think the problem I'm having is that the domain I'm requesting from is
 not the same domain as mine so their may be some security issue.


right, this is why you would setup a server side proxy, to avoid client side
cross domain security restrictions, however you'll have to change all the
instances of the remote domain to your domain, and ensure that your server
actually is able to fulfill requests for those resources.


 I also thought about injecting a link tag into the iframe at the same time
 I load the HTML.


when you say link tag are you talking about a tags?  you lost me on this
last line here.


 Browsers load the last style sheet on top of others.


this is true, but i doubt you'll be able to have it load a css file from
your domain atop a css file from a remote domain.


  If I could just get the link tag into the iframes contents right after I
 get the source text in there, it may work. But there is also the issue of
 correctly assigning the classes and I'd that are used in the iframe. Like

 iframe.holder .someclassusedbythem {}

 Or do I do?

 iframe#holder .someclassusedbythem {}

 Or

 #holder .someclassusedbythem {}

 Sorry if I'm OT with that.


shrug, no worries, but im too lazy to dig into the details of client side
options. :)

-nathan


Re: [PHP] include html

2010-10-31 Thread a...@ashleysheridan.co.uk
This can only be done with javascript, as the iframe is client-side, which php 
knows nothing about.

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: Karl DeSaulniers k...@designdrumm.com
Date: Sun, Oct 31, 2010 03:32
Subject: [PHP] include html
To: php-general php-general@lists.php.net

Hello,
I am looking for a solution to inject some dynamic html into an  
iframe and rework the css from the results.
Is there a way to do this in PHP? I am not talking about just using  
the src attribute of the iframe either.

Basically,
I want to call on a web page, grab the html code, replace the link  
tag with my own and insert it into an iframe on my page.

I am sure this is not as complicated as I am making it, but I have  
been trying with Ajax for the past couple of days and no luck.
So I was wondering if there was a php alternative to do this with. Or  
if it is even possible or ok to do so.

I am building a website for a tshirt company that uses another  
company to get garments and promo items to print on.
The client wants to just have those pages load on top of their  
website, but wants the layout to go with their look and feel. their css.
We have the go ahead from the other companies to do so as well.

TIA,

Karl DeSaulniers
Design Drumm
http://designdrumm.com



[PHP] Re: PHP include security

2010-04-17 Thread Micky Hulse
 What do ya'll think? Any suggestions?

Sorry for the duplicate posting... I had some problems signing-up for
the list. :(

Also, I moved my test code to sniplr:

http://snipplr.com/view/32192/php-security-include-path-cleansing/

TIA!

Cheers
M

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



Re: [PHP] Include security?

2010-04-16 Thread Ryan Sun
if allow_url_include is turned off, you don't have to worry much about http,
if '.' is a invalide char, you can't include *.php...
the include path probably should be the inc(whatever the name)
folder(not accessible from web) instead of the web root and '..'
should be disallowed

On Fri, Apr 16, 2010 at 4:09 PM, Micky Hulse mickyhulse.li...@gmail.com wrote:
 Hi,

 Code:

 =

 ob_start();
 switch ($this-command)
 {
       case 'include':
               @include($x);
               break;
       default:
               @readfile($x);
 }
 $data = ob_get_contents();
 ob_end_clean();

 =

 The above code snippet is used in a class which would allow developers
 (of a specific CMS) to include files without having to put php include
 tags on the template view.

 The include path will be using the server root path, and the include
 files will probably be stored above the web root.

 My question:

 What would be the best way to clean and secure the include string?

 Maybe something along these lines (untested):

 $invalidChars=array(.,\\,\,;); // things to remove.
 $include_file = strtok($include_file,'?'); // No need for query string.
 $include_file=str_replace($invalidChars,,$include_file);

 What about checking to make sure the include path is root relative,
 vs. http://...?

 What do ya'll think? Any suggestions?

 Many thanks in advance!

 Cheers,
 Micky

 --
 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] Include security?

2010-04-16 Thread Micky Hulse
 if allow_url_include is turned off, you don't have to worry much about http,
 if '.' is a invalide char, you can't include *.php...
 the include path probably should be the inc(whatever the name)
 folder(not accessible from web) instead of the web root and '..'
 should be disallowed

Hi Ryan! Many thanks for your help, I really appreciate it. :)

How does this look:

http://sandbox.hulse.me/secure_inc_str.txt

How could my code be improved?

Thanks again for the help, I really appreciate it. :)

Cheers,
Micky

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



Re: [PHP] include path in httpd.conf

2010-04-05 Thread ad

Ash,

Nice call.   .htaccess was not being processed at all which led me to a 
cname configuration error for the sub domain.


Thanks!.

On 4/5/2010 8:27 PM, Ashley Sheridan wrote:

On Mon, 2010-04-05 at 19:40 -0400, ad wrote:

I have several virtual hosts on a dedicated server.
In a IFmodule mod_php5c container in an httpd.conf  include file I have
the following to create a unique include path for each virtual host:

IfModule mod_php5.c
php_value include_path .:/home/virtual/site#/path/to/include
php_admin_flag safe_mode off
/IfModule

  For one of the virtual hosts I've set up a dev site in a subdomain at
  dev.site#.com for development.
  In the root directory of this development site I have an .htacces file
  to create another unique include_path solely for this development subdomain.

  php_value include_path  .:/home/virtual/site#/path/to/dev/includes

  Also in the httpd.conf I have
  Directory /home/virtual/site#/path/to/dev/root/
  Allow from all
  AllowOverride All
  Order allow,deny
  /Directory


  The configuration is CentOS 5.3, Apache/2.2.3, PHP 5.1.6

  I recently upgraded the OS from FC6 and the PHP version and I have not
  been able to get the include_path to change for this dev.subdomain.
  Even after restarting apache it PHPinfo tells me it is reading the
  server php.ini and the virtual host include path for the httpd.conf but
  it is ignoring the .htaccess file.

  I've even tried putting the php.ini with specific settings in the
  /home/virtual/site#/root directory to no avail.

Any ideas how to make this work or even a better set up?

Thanks in advance.


 


Are you able to determine if you can set any attributes with the 
.htaccess file? Is it possible the .htaccess isn't being processed at all?


I'm not sure why the virtual server settings are being ignored in the 
httpd.conf file though. Have you checked any other .conf files in that 
directory to see that they are not being set there? As far as I can 
remember, the .conf files in that directory are executed in 
alphabetical order, so a different file might be overriding your settings?


Thanks,
Ash
http://www.ashleysheridan.co.uk






Re: [PHP] Include Files in HTML

2009-09-06 Thread Ashley Sheridan
On Fri, 2009-09-04 at 18:21 -0500, phphelp -- kbk wrote:
 On Sep 4, 2009, at 5:03 PM, sono...@fannullone.us wrote:
 
  Depends on what you are including. The only tags that can be  
  inside the
  head are base, link, meta, script, style,  and title.
  Everything else is either body or prologue.
 
  I meant PHP includes like this one:
  ?php @include_once(/home/passwords/login.php); ?
 
 We know what you mean. Read the responses more carefully, as they are  
 telling you what you need to know.
 
 For simplification: The INCLUDE commands put the contents of the  
 INCLUDed file into this file, just as if as you had typed it in there.
 
 Ken
 
It's good to remember that PHP isn't inserted into HTML, but the other
way round. PHP can output HTML, but is often used to output many other
formats, from images to xml to documents.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



RE: [PHP] Include Files in HTML

2009-09-04 Thread Bob McConnell
From: sono-io at fannullone.us

   In my readings, I've run across examples showing include files
being  
 called from within the head/head tags, and other examples showing

 them called within body/body.  I've always put them in the header

 section myself, but I was wondering if one is better than the other,  
 or is it just personal preference?

Depends on what you are including. The only tags that can be inside the
head are base, link, meta, script, style,  and title.
Everything else is either body or prologue.

The full specs can be found at
http://www.w3schools.com/tags/default.asp.

Bob McConnell

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



RE: [PHP] Include Files in HTML

2009-09-04 Thread Joost
Bob McConnell wrote:

 From: sono-io at fannullone.us
 
 In my readings, I've run across examples showing include files
 being
 called from within the head/head tags, and other examples showing
 
 them called within body/body.  I've always put them in the header
 
 section myself, but I was wondering if one is better than the other,
 or is it just personal preference?
 
 Depends on what you are including. The only tags that can be inside the
 head are base, link, meta, script, style,  and title.
 Everything else is either body or prologue.
 
 The full specs can be found at
 http://www.w3schools.com/tags/default.asp.
 
 Bob McConnell

Sure enough. What the OP might not have realized:

In the end, what PHP evaluates to, is a stream of html, script, css etc 
text/data, which is sent to the browser. PHP's include( file ) statement 
inserts the content of file here-and-now. You can even put the include 
statement within a for loop in order to include something multiple times... 
In that sense it is more like a /function/ and really different from cpp's 
#include /directive/.

file can contain PHP code, which is evaluated as if it was here-and-now in 
the including PHP file; it can contain text/data, which is appended to the 
text/data stream being produced.

All in all, to PHP the spot of file inclusion is not interesting, as long as 
the resulting PHP code and/or stream data is meaningful.

Now back to you, Bob :-)

Regards,
Joost.

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



Re: [PHP] Include Files in HTML

2009-09-04 Thread sono-io


On Sep 4, 2009, at 1:05 PM, Bob McConnell wrote:

Depends on what you are including. The only tags that can be inside  
the

head are base, link, meta, script, style,  and title.
Everything else is either body or prologue.


I meant PHP includes like this one:
?php @include_once(/home/passwords/login.php); ?

Frank

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



Re: [PHP] Include Files in HTML

2009-09-04 Thread Tommy Pham
- Original Message 
 From: sono...@fannullone.us sono...@fannullone.us
 To: PHP General List php-general@lists.php.net
 Sent: Friday, September 4, 2009 12:57:08 PM
 Subject: [PHP] Include Files in HTML
 
 In my readings, I've run across examples showing include files being 
 called 
 from within the tags, and other examples showing them called 
 within .  I've always put them in the header section myself, but I 
 was wondering if one is better than the other, or is it just personal 
 preference?
 
 Frank
 
 --PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

Depends on your application design and/or your desired result.  If you design 
your application to do all processing before output is sent starting with 
html, then all your includes goes before html.  If you want to have the 
modular approach of including css  js files inside the head element, you 
don't have to worry about going back to changing every single output file when 
you decide the change your layout or javascript framework.  It also makes your 
code page a bit cleaner when you do use include in the head.  If you want to 
make use of chunked encoding, you can including the rest within the body.

Thus, include everything before html gives you a slight pause 'waiting for 
reply...' in the status bar before the client even begin to download anything.  
When includes are scattered all over, server processes some sends the web 
browser info, here go fetch some more (css, js, images) until the the last 
buffered output is sent /html  (that is if your page is compliant ;)

Regards,
Tommy


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



Re: [PHP] Include Files in HTML

2009-09-04 Thread Tommy Pham
- Original Message 
 From: Tommy Pham tommy...@yahoo.com
 To: php-general@lists.php.net
 Sent: Friday, September 4, 2009 4:11:31 PM
 Subject: Re: [PHP] Include Files in HTML
 
 - Original Message 
  From: sono...@fannullone.us 
  To: PHP General List 
  Sent: Friday, September 4, 2009 12:57:08 PM
  Subject: [PHP] Include Files in HTML
  
  In my readings, I've run across examples showing include files being 
 called 
  from within the tags, and other examples showing them called 
  within .  I've always put them in the header section myself, but I 
  was wondering if one is better than the other, or is it just personal 
  preference?
  
  Frank
  
  --PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 Depends on your application design and/or your desired result.  If you design 
 your application to do all processing before output is sent starting with 
 , then all your includes goes before .  If you want to have the 
 modular approach of including css  js files inside the  element, you 
 don't have to worry about going back to changing every single output file 
 when 
 you decide the change your layout or javascript framework.  It also makes 
 your 
 code page a bit cleaner when you do use include in the .  If you want to 
 make use of chunked encoding, you can including the rest within the .
 
 Thus, include everything before  gives you a slight pause 'waiting for 
 reply...' in the status bar before the client even begin to download 
 anything.  
 When includes are scattered all over, server processes some sends the web 
 browser info, here go fetch some more (css, js, images) until the the last 
 buffered output is sent   (that is if your page is compliant ;)
 
 Regards,
 Tommy
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

Forgot to mention a few things, if your app is sophisticated enough to require 
header settings (content-type, etc), those include have to go before the 
buffered output is sent.  Also, you want to make use of chunked encoding, you 
cannot use/specify content-length in the header.


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



Re: [PHP] Include Files in HTML

2009-09-04 Thread phphelp -- kbk

On Sep 4, 2009, at 5:03 PM, sono...@fannullone.us wrote:

Depends on what you are including. The only tags that can be  
inside the

head are base, link, meta, script, style,  and title.
Everything else is either body or prologue.


I meant PHP includes like this one:
?php @include_once(/home/passwords/login.php); ?


We know what you mean. Read the responses more carefully, as they are  
telling you what you need to know.


For simplification: The INCLUDE commands put the contents of the  
INCLUDed file into this file, just as if as you had typed it in there.


Ken

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



Re: [PHP] Include Paths

2009-08-12 Thread Conor Mac Aoidh

Could you post some of the code that you have used.

--
Conor

http://conormacaoidh.com

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



Re: [PHP] Include Paths

2009-08-12 Thread Adam Shannon
On Wed, Aug 12, 2009 at 10:02 AM, Julian Muscat Doublesin 
opensourc...@gmail.com wrote:

 I had a problem with the include and require paths when using AJAX. This I
 have solved by using the document root. However since doing so I am
 experiencing performance issues. Loading 20 records has suddenly turned
 into
 something of a matter of a minute rather then seconds.

 Has anyone ever experienced such an issue?

 Can anyone please advise?

 Thanks


I wonder if loading the script/page with an absolute path would fix the
problem.



-- 
- Adam Shannon ( http://ashannon.us )


Re: [PHP] Include Paths

2009-08-12 Thread Rick Duval
SORRY BUT
I CAN'T GET OFF THIS LIST, I CAN'T GET OFF THIS LIST, I CAN'T GET OFF THIS LIST
I'VE TRIED. NO RESPONSE. IS THERE AN ADMIN OUT THERE? PLEASE GET ME
OFF THIS LIST!


This message has been scanned for
viruses and dangerous content by
Accurate Anti-Spam Technologies.
www.AccurateAntiSpam.com



On Wed, Aug 12, 2009 at 11:08 AM, Adam Shannona...@ashannon.us wrote:
 On Wed, Aug 12, 2009 at 10:02 AM, Julian Muscat Doublesin 
 opensourc...@gmail.com wrote:

 I had a problem with the include and require paths when using AJAX. This I
 have solved by using the document root. However since doing so I am
 experiencing performance issues. Loading 20 records has suddenly turned
 into
 something of a matter of a minute rather then seconds.

 Has anyone ever experienced such an issue?

 Can anyone please advise?

 Thanks


 I wonder if loading the script/page with an absolute path would fix the
 problem.



 --
 - Adam Shannon ( http://ashannon.us )

 -
 This message has been scanned for
 viruses and dangerous content by
 Accurate Anti-Spam Technologies.
 www.AccurateAntiSpam.com



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



Re: [PHP] Include Paths

2009-08-12 Thread Ashley Sheridan
On Wed, 2009-08-12 at 12:03 -0400, Rick Duval wrote:
 SORRY BUT
 I CAN'T GET OFF THIS LIST, I CAN'T GET OFF THIS LIST, I CAN'T GET OFF THIS 
 LIST
 I'VE TRIED. NO RESPONSE. IS THERE AN ADMIN OUT THERE? PLEASE GET ME
 OFF THIS LIST!
 
 
 This message has been scanned for
 viruses and dangerous content by
 Accurate Anti-Spam Technologies.
 www.AccurateAntiSpam.com
 
 
 
 On Wed, Aug 12, 2009 at 11:08 AM, Adam Shannona...@ashannon.us wrote:
  On Wed, Aug 12, 2009 at 10:02 AM, Julian Muscat Doublesin 
  opensourc...@gmail.com wrote:
 
  I had a problem with the include and require paths when using AJAX. This I
  have solved by using the document root. However since doing so I am
  experiencing performance issues. Loading 20 records has suddenly turned
  into
  something of a matter of a minute rather then seconds.
 
  Has anyone ever experienced such an issue?
 
  Can anyone please advise?
 
  Thanks
 
 
  I wonder if loading the script/page with an absolute path would fix the
  problem.
 
 
 
  --
  - Adam Shannon ( http://ashannon.us )
 
  -
  This message has been scanned for
  viruses and dangerous content by
  Accurate Anti-Spam Technologies.
  www.AccurateAntiSpam.com
 
 
 
Wow!

First off, have you followed the unsubscription details on the website?

Failing that, have you tried emailing the unsubscribe email address?
It's found in all the email headers that are part of the mailing list.

And don't shout!

Thanks,
Ash
http://www.ashleysheridan.co.uk


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



Re: [PHP] Include Paths

2009-08-12 Thread Bastien Koert
On Wed, Aug 12, 2009 at 12:06 PM, Ashley
Sheridana...@ashleysheridan.co.uk wrote:
 On Wed, 2009-08-12 at 12:03 -0400, Rick Duval wrote:
 SORRY BUT
 I CAN'T GET OFF THIS LIST, I CAN'T GET OFF THIS LIST, I CAN'T GET OFF THIS 
 LIST
 I'VE TRIED. NO RESPONSE. IS THERE AN ADMIN OUT THERE? PLEASE GET ME
 OFF THIS LIST!

 
 This message has been scanned for
 viruses and dangerous content by
 Accurate Anti-Spam Technologies.
 www.AccurateAntiSpam.com



 On Wed, Aug 12, 2009 at 11:08 AM, Adam Shannona...@ashannon.us wrote:
  On Wed, Aug 12, 2009 at 10:02 AM, Julian Muscat Doublesin 
  opensourc...@gmail.com wrote:
 
  I had a problem with the include and require paths when using AJAX. This I
  have solved by using the document root. However since doing so I am
  experiencing performance issues. Loading 20 records has suddenly turned
  into
  something of a matter of a minute rather then seconds.
 
  Has anyone ever experienced such an issue?
 
  Can anyone please advise?
 
  Thanks
 
 
  I wonder if loading the script/page with an absolute path would fix the
  problem.
 
 
 
  --
  - Adam Shannon ( http://ashannon.us )
 
  -
  This message has been scanned for
  viruses and dangerous content by
  Accurate Anti-Spam Technologies.
  www.AccurateAntiSpam.com
 
 

 Wow!

 First off, have you followed the unsubscription details on the website?

 Failing that, have you tried emailing the unsubscribe email address?
 It's found in all the email headers that are part of the mailing list.

 And don't shout!

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk


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



Thought it was a rap song to the tune of You Can't Touch This

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Include Paths

2009-08-12 Thread Robert Cummings

Have you gone here:

http://www.php.net/unsub.php

Make sure you input the email address with which you registered:

r...@duvals.ca

It's really not very hard... my 10 month old baby could do it.

Cheers,
Rob.



Rick Duval wrote:

SORRY BUT
I CAN'T GET OFF THIS LIST, I CAN'T GET OFF THIS LIST, I CAN'T GET OFF THIS LIST
I'VE TRIED. NO RESPONSE. IS THERE AN ADMIN OUT THERE? PLEASE GET ME
OFF THIS LIST!


This message has been scanned for
viruses and dangerous content by
Accurate Anti-Spam Technologies.
www.AccurateAntiSpam.com



On Wed, Aug 12, 2009 at 11:08 AM, Adam Shannona...@ashannon.us wrote:

On Wed, Aug 12, 2009 at 10:02 AM, Julian Muscat Doublesin 
opensourc...@gmail.com wrote:


I had a problem with the include and require paths when using AJAX. This I
have solved by using the document root. However since doing so I am
experiencing performance issues. Loading 20 records has suddenly turned
into
something of a matter of a minute rather then seconds.

Has anyone ever experienced such an issue?

Can anyone please advise?

Thanks


I wonder if loading the script/page with an absolute path would fix the
problem.



--
- Adam Shannon ( http://ashannon.us )

-
This message has been scanned for
viruses and dangerous content by
Accurate Anti-Spam Technologies.
www.AccurateAntiSpam.com






--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Include Paths

2009-08-12 Thread Ralph Deffke
a rap song hihi haha
best comment I've ever read on a mailing list. reminds me that live is fun

thanks for making my day
thanks sheridan for ur shakespear like abbilities
thanks bastien for ur humor

GREAT



Bastien Koert phps...@gmail.com wrote in message
news:d7b6cab70908120909u593cbd6v692f34ae6ddea...@mail.gmail.com...
 On Wed, Aug 12, 2009 at 12:06 PM, Ashley
 Sheridana...@ashleysheridan.co.uk wrote:
  On Wed, 2009-08-12 at 12:03 -0400, Rick Duval wrote:
  SORRY BUT
  I CAN'T GET OFF THIS LIST, I CAN'T GET OFF THIS LIST, I CAN'T GET OFF
THIS LIST
  I'VE TRIED. NO RESPONSE. IS THERE AN ADMIN OUT THERE? PLEASE GET ME
  OFF THIS LIST!
 
  
  This message has been scanned for
  viruses and dangerous content by
  Accurate Anti-Spam Technologies.
  www.AccurateAntiSpam.com
 
 
 
  On Wed, Aug 12, 2009 at 11:08 AM, Adam Shannona...@ashannon.us wrote:
   On Wed, Aug 12, 2009 at 10:02 AM, Julian Muscat Doublesin 
   opensourc...@gmail.com wrote:
  
   I had a problem with the include and require paths when using AJAX.
This I
   have solved by using the document root. However since doing so I am
   experiencing performance issues. Loading 20 records has suddenly
turned
   into
   something of a matter of a minute rather then seconds.
  
   Has anyone ever experienced such an issue?
  
   Can anyone please advise?
  
   Thanks
  
  
   I wonder if loading the script/page with an absolute path would fix
the
   problem.
  
  
  
   --
   - Adam Shannon ( http://ashannon.us )
  
   -
   This message has been scanned for
   viruses and dangerous content by
   Accurate Anti-Spam Technologies.
   www.AccurateAntiSpam.com
  
  
 
  Wow!
 
  First off, have you followed the unsubscription details on the website?
 
  Failing that, have you tried emailing the unsubscribe email address?
  It's found in all the email headers that are part of the mailing list.
 
  And don't shout!
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 Thought it was a rap song to the tune of You Can't Touch This

 -- 

 Bastien

 Cat, the other other white meat



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



Re: [PHP] include file in a class with global/parent scope?

2009-06-16 Thread Daniel Kolbo
Martin Scotta wrote:
 Where is $vars? there is no $vars in your code...
 
 You can extract all the global space in the CScope method, it's quite
 simple, but less performant.
 
 
 class CScope {
 
public $vars = 'class scope\n';
 
function cinclude($filename) {
extract( $GLOBALS );
include('vars.php');
echo In class $vars\n;
}
 }
 
 On Sun, Jun 14, 2009 at 1:41 PM, Daniel Kolbo kolb0...@umn.edu
 mailto:kolb0...@umn.edu wrote:
 
 Hello,
 
 I understand the why $vars is not in the global scope, but i was
 wondering if there was a way from within the class file to include a
 file in the parent's scope?
 
 i tried ::include('vars.php'), parent::include('vars.php'), but this
 breaks syntax...
 
 Please consider the following three files:
 
 'scope.class.inc'
 ?php
 class CScope {
 
public $vars = 'class scope\n';
 
function cinclude($filename) {
include('vars.php');
echo In class $vars\n;
}
 }
 ?
 
 'vars.php'
 ?php
 //global $vars;//if this line is uncommented then the desired result is
 achieved however, i don't want to change all the variables to global
 scope (this file is includeded in other files where global scoped
 variables is not desireable).
 $vars = 'vars.php scope\n';
 ?
 
 'scope.php'
 ?php
 include('scope.class.inc');
 $object = new CScope;
 $object-cinclude('vars.php');
 echo In original $vars\n;//$vars is not defined***
 ?
 
 Thanks,
 dK
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 -- 
 Martin Scotta

replace all $var with $vars.  The extract method proposed is the
opposite of what i'm looking to do.  I want to bring the class's include
scope into the calling object's scope.

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



Re: [PHP] include file in a class with global/parent scope?

2009-06-16 Thread Daniel Kolbo
Hello,

I've cleaned up my question a bit.

I want the included file which is called within a method of a class to
have the same scope as the instantiation of the class's object.  That
is, i want a class to include a file in the calling object's scope.  How
would one do this?

'test.php'
?php
class CSomeClass {
 public function cinclude() {
   include('vars.php');
 }
}

$object = new CSomeClass;
$object-cinclude();
echo $vars;//i want this to print 'hi'
include('vars.php');
echo obvious $vars;
?

'vars.php'
?php
$vars = hi;
?

OUTPUT:
Notice: Undefined variable: vars in ...\test.php on line 10
obvious hi

DESIRED OUTPUT:
hi
obvious hi

Thanks,
dK

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



Re: [PHP] include file in a class with global/parent scope?

2009-06-16 Thread Shawn McKenzie
Daniel Kolbo wrote:
 Hello,
 
 I've cleaned up my question a bit.
 
 I want the included file which is called within a method of a class to
 have the same scope as the instantiation of the class's object.  That
 is, i want a class to include a file in the calling object's scope.  How
 would one do this?
 
 'test.php'
 ?php
 class CSomeClass {
  public function cinclude() {
include('vars.php');
  }
 }
 
 $object = new CSomeClass;
 $object-cinclude();
 echo $vars;//i want this to print 'hi'
 include('vars.php');
 echo obvious $vars;
 ?
 
 'vars.php'
 ?php
 $vars = hi;
 ?
 
 OUTPUT:
 Notice: Undefined variable: vars in ...\test.php on line 10
 obvious hi
 
 DESIRED OUTPUT:
 hi
 obvious hi
 
 Thanks,
 dK

Should get you started:

//one way
?php
class CSomeClass {
 public function cinclude() {
   include('vars.php');
   return get_defined_vars();
 }
}

$object = new CSomeClass;
$inc_vars = $object-cinclude();
echo $inc_vars['vars'];//i want this to print 'hi'

---or---

//another way
?php
class CSomeClass {
 var $inc_vars;
 public function cinclude() {
   include('vars.php');
   $this-inc_vars = get_defined_vars();
 }
}

$object = new CSomeClass;
$object-cinclude();
echo $object-inc_vars['vars'];//i want this to print 'hi'


-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] include file in a class with global/parent scope?

2009-06-16 Thread Shawn McKenzie
Shawn McKenzie wrote:
 Daniel Kolbo wrote:
 Hello,

 I've cleaned up my question a bit.

 I want the included file which is called within a method of a class to
 have the same scope as the instantiation of the class's object.  That
 is, i want a class to include a file in the calling object's scope.  How
 would one do this?

 'test.php'
 ?php
 class CSomeClass {
  public function cinclude() {
include('vars.php');
  }
 }

 $object = new CSomeClass;
 $object-cinclude();
 echo $vars;//i want this to print 'hi'
 include('vars.php');
 echo obvious $vars;
 ?

 'vars.php'
 ?php
 $vars = hi;
 ?

 OUTPUT:
 Notice: Undefined variable: vars in ...\test.php on line 10
 obvious hi

 DESIRED OUTPUT:
 hi
 obvious hi

 Thanks,
 dK
 
 Should get you started:
 
 //one way
 ?php
 class CSomeClass {
  public function cinclude() {
include('vars.php');
return get_defined_vars();
  }
 }
 
 $object = new CSomeClass;
 $inc_vars = $object-cinclude();
 echo $inc_vars['vars'];//i want this to print 'hi'
 
 ---or---
 
 //another way
 ?php
 class CSomeClass {
  var $inc_vars;
  public function cinclude() {
include('vars.php');
$this-inc_vars = get_defined_vars();
  }
 }
 
 $object = new CSomeClass;
 $object-cinclude();
 echo $object-inc_vars['vars'];//i want this to print 'hi'
 
 

Another way off the top of my head:

//vars.php
$vars['something'] = 'hi';
$vars['whatever'] = 'bye';

//test.php
class CSomeClass {
 var $vars;
 public function cinclude() {
   include('vars.php');
   $this-vars = $vars;
 }
}

$object = new CSomeClass;
$object-cinclude();
echo $object-vars['something'];//i want this to print 'hi'

-- 
Thanks!
-Shawn
http://www.spidean.com

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



RE: [PHP] Include File Errors with Comments

2009-03-11 Thread Bob McConnell
From: Patrick Moloney
 
 I have a simple web site with a simple page that all works well, 
 although I have had a similar problem a couple of times that seems to
be 
 caused by Comment Lines in the included files. I wonder if I have it 
 entirely right.
 All my files are .php files, but almost all the code is HTML.
 The file for my Web page is a complete HTML document, the file is
.php. 
 The web page file Includes a few other files by putting the Include 
 statement in PHP tags, all by itself. The problem file contains the
menu 
 as the include. I made a change to the menu, that works, but I added a

 line with a comment at the top, which causes problems. The menu is
read 
 like text.
 The first few lines in my menu file, menu.php, are comments using HTML

 syntax. The menu file has on UL and LI tags for the menu items - no 
 HTML, BODY etc. So I have a line of PHP in my web page file calling a 
 .php file where the first 2 lines are HTML comments. It was working
with 
 2 comment lines, the failed with 3 lines. Even when it fails the 
 remainder of the page displays ok although it is down lower because of

 the menu being displayed as text. I remove the comment it works.
 
 Does PHP preprocess the file but treat the comments as text because I 
 never said it was HTML? Would PHP comments have to be inside PHP tags?
 Am I correct in having just a fragment of HTML in the included file 
 without the entire HTML organization? I'd like to have comments in the
file.

This is one detail that I have not seen a good explanation for. When PHP
opens an included file, it defaults back to HTML mode. You must have the
PHP tags to force it into PHP mode. This is true no matter what file
extension you have on them. So if you want to use PHP style comments,
you must wrap them with the proper tags.

Bob McConnell

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



Re: [PHP] Include File Errors with Comments

2009-03-10 Thread Michael A. Peters

Patrick Moloney wrote:



Does PHP preprocess the file but treat the comments as text because I 
never said it was HTML?


I've not had it do that.


Would PHP comments have to be inside PHP tags?


Yes. If you use a php comment it has to be inside a php tag.

One issue I have seen though is xml/xhtml files.
php sometimes sees the ?xml and assumes it is a php start tag.

I assume the appropriate thing to do is turn off short tags in your 
php.ini file - but unfortunately a lot of 3rd party classes and apps 
make heavy use of them.


Am I correct in having just a fragment of HTML in the included file 
without the entire HTML organization? I'd like to have comments in the 
file.


Use html comments and it should be fine - or put php tags around the 
comments.







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



Re: [PHP] Include File Errors with Comments

2009-03-10 Thread Chris

Patrick Moloney wrote:
I have a simple web site with a simple page that all works well, 
although I have had a similar problem a couple of times that seems to be 
caused by Comment Lines in the included files. I wonder if I have it 
entirely right.

All my files are .php files, but almost all the code is HTML.
The file for my Web page is a complete HTML document, the file is .php. 
The web page file Includes a few other files by putting the Include 
statement in PHP tags, all by itself. The problem file contains the menu 
as the include. I made a change to the menu, that works, but I added a 
line with a comment at the top, which causes problems. The menu is read 
like text.
The first few lines in my menu file, menu.php, are comments using HTML 
syntax. The menu file has on UL and LI tags for the menu items - no 
HTML, BODY etc. So I have a line of PHP in my web page file calling a 
.php file where the first 2 lines are HTML comments. It was working with 
2 comment lines, the failed with 3 lines. Even when it fails the 
remainder of the page displays ok although it is down lower because of 
the menu being displayed as text. I remove the comment it works.


Does PHP preprocess the file but treat the comments as text because I 
never said it was HTML? Would PHP comments have to be inside PHP tags?
Am I correct in having just a fragment of HTML in the included file 
without the entire HTML organization? I'd like to have comments in the 
file.


If you're putting php comments outside php tags, they are treated as 
text (they're not inside php tags, it's not php).


The php tags tell php when to start parsing/processing the script. 
Without that, it passes it to your webserver to just display the content.


If that's not what you're doing post a short (very short - don't post 
your whole scripts) example of what you mean.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] include question

2009-03-07 Thread Nathan Rixham

Daniel Brown wrote:

On Fri, Mar 6, 2009 at 08:53, Stuart stut...@gmail.com wrote:

   1.) We use regular open tags to be compatible with all stock
PHP configurations.
   2.) We echo out the response from dirname() so that it's
output to the HTML source.
   3.) We use dirname() twice, so it gives the dirname() of the
dirname(), rather than '..'.
   4.) There are double underscores around FILE.  The same is
true with LINE, FUNCTION, etc.

5.) dirname() gives you the full path on disk, not the URL. Usually you can
just remove the document root path to get the URL. This could be in
$_SERVER['DOCUMENT_ROOT'] but you can't rely on that between servers or when
the config changes.


6.) When used in conjunction with realpath()[1], it will
resolve the absolute local pathname.

^1: http://php.net/realpath



that's the way i do it, for example

require_once realpath( dirname(__FILE__) . '/lib/LibAllTests.php' );

also I often use set_include_path to ensure everything works throughout, 
it's a lot simpler for require/includes


set_include_path( get_include_path() . PATH_SEPARATOR . realpath( 
dirname(__FILE__) . DIRECTORY_SEPARATOR ) );


for example.. then all subsequent requires will be:

require_once 'Folder/file.php';

regards

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



Re: [PHP] include question

2009-03-06 Thread Daniel Brown
On Fri, Mar 6, 2009 at 08:37, PJ af.gour...@videotron.ca wrote:
 good morning all,

 How can I include src and href in include files that will refer the
 right paths from files in different hierarchies(directory tree levels)?
 Example:
 include dirname(_FILE_)./../lib/header1.php; ?

 This does not work:
 snippetysnip...
 LINK href=dirname(_FILE_).'/../lib/index.css' rel=stylesheet
 type=text/css
 /head
 Nor does this: (NOTE THE DIFFERENCES  AND ' IN THE SRC AND HREF)
 div id=frame
    IMG SRC=dirname(_FILE_)./../images/bannerbae1.gif ...snippetysnip
 Perhaps it's not possible?

It is when it's parsed by PHP.  You're just putting it through as
straight HTML, which - even though it may have a .php extension -
won't work as you might be expecting.

Instead, you have to instruct the parsing engine where and when to
interpret, compile, and execute the code, like so:

img src=?php echo dirname(dirname(__FILE__)); ?/images/bannerbae1.gif

In the above snippet, notice a few very important things:

1.) We use regular open tags to be compatible with all stock
PHP configurations.
2.) We echo out the response from dirname() so that it's
output to the HTML source.
3.) We use dirname() twice, so it gives the dirname() of the
dirname(), rather than '..'.
4.) There are double underscores around FILE.  The same is
true with LINE, FUNCTION, etc.



-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] include question

2009-03-06 Thread Stuart
2009/3/6 Daniel Brown danbr...@php.net

 On Fri, Mar 6, 2009 at 08:37, PJ af.gour...@videotron.ca wrote:
  good morning all,
 
  How can I include src and href in include files that will refer the
  right paths from files in different hierarchies(directory tree levels)?
  Example:
  include dirname(_FILE_)./../lib/header1.php; ?
 
  This does not work:
  snippetysnip...
  LINK href=dirname(_FILE_).'/../lib/index.css' rel=stylesheet
  type=text/css
  /head
  Nor does this: (NOTE THE DIFFERENCES  AND ' IN THE SRC AND HREF)
  div id=frame
 IMG SRC=dirname(_FILE_)./../images/bannerbae1.gif ...snippetysnip
  Perhaps it's not possible?

 It is when it's parsed by PHP.  You're just putting it through as
 straight HTML, which - even though it may have a .php extension -
 won't work as you might be expecting.

Instead, you have to instruct the parsing engine where and when to
 interpret, compile, and execute the code, like so:

 img src=?php echo dirname(dirname(__FILE__)); ?/images/bannerbae1.gif

In the above snippet, notice a few very important things:

1.) We use regular open tags to be compatible with all stock
 PHP configurations.
2.) We echo out the response from dirname() so that it's
 output to the HTML source.
3.) We use dirname() twice, so it gives the dirname() of the
 dirname(), rather than '..'.
4.) There are double underscores around FILE.  The same is
 true with LINE, FUNCTION, etc.


5.) dirname() gives you the full path on disk, not the URL. Usually you can
just remove the document root path to get the URL. This could be in
$_SERVER['DOCUMENT_ROOT'] but you can't rely on that between servers or when
the config changes.
-Stuart

-- 
http://stut.net/


Re: [PHP] include question

2009-03-06 Thread Daniel Brown
On Fri, Mar 6, 2009 at 08:53, Stuart stut...@gmail.com wrote:

        1.) We use regular open tags to be compatible with all stock
 PHP configurations.
        2.) We echo out the response from dirname() so that it's
 output to the HTML source.
        3.) We use dirname() twice, so it gives the dirname() of the
 dirname(), rather than '..'.
        4.) There are double underscores around FILE.  The same is
 true with LINE, FUNCTION, etc.

 5.) dirname() gives you the full path on disk, not the URL. Usually you can
 just remove the document root path to get the URL. This could be in
 $_SERVER['DOCUMENT_ROOT'] but you can't rely on that between servers or when
 the config changes.

6.) When used in conjunction with realpath()[1], it will
resolve the absolute local pathname.

^1: http://php.net/realpath

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] include question

2009-03-06 Thread PJ
Daniel Brown wrote:
 On Fri, Mar 6, 2009 at 08:53, Stuart stut...@gmail.com wrote:
   
1.) We use regular open tags to be compatible with all stock
 PHP configurations.
2.) We echo out the response from dirname() so that it's
 output to the HTML source.
3.) We use dirname() twice, so it gives the dirname() of the
 dirname(), rather than '..'.
4.) There are double underscores around FILE.  The same is
 true with LINE, FUNCTION, etc.
   
 5.) dirname() gives you the full path on disk, not the URL. Usually you can
 just remove the document root path to get the URL. This could be in
 $_SERVER['DOCUMENT_ROOT'] but you can't rely on that between servers or when
 the config changes.
 

 6.) When used in conjunction with realpath()[1], it will
 resolve the absolute local pathname.

 ^1: http://php.net/realpath

   
Sorry, guys, but none of this works...
I get the document root which is wonderful but it misses the vhost root
completely.
So what I get both with realpath and $SERVER['DOCUMENT_ROOT']is
/usr/local/www/apache22/data/images/file.gif or
/usr/local/www/apache22/data/../images/file.gif
and that, of course misses the main directory for this site which is
ptahhotep

In /ptahhotep/file.php - the path for the image.gif is images/image.gif
In /ptahhotep/admin/another_file.php/ the path  for the image.gif is
../images/image.gif

But as I try different variations, I finally see that adding the root
directory name for the site does the trick.

Have I discovered something new here? :-)


-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



Re: [PHP] Include PHP library file in the .htaccess

2009-01-30 Thread Andrew Ballard
On Fri, Jan 30, 2009 at 12:41 PM, R B rbp...@gmail.com wrote:
 Hello.

 Supose that i have this script:

 ?php

 require_once(lib.php);


 lib_function();
 ?

 I want to know if there is a way to call the lib.php library from the
 .htaccess instead of the PHP script?
 Thanks.


.htaccess won't call it since it isn't actually executed, but you can
set up an auto_prepend_file in .htaccess that will be automatically
prepended to all your PHP scripts in the folder (assuming the server
config allows it).

Andrew

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



Re: [PHP] Include directive..

2008-12-10 Thread dele454

Am having this error in the apache log files WHat does it imply really. I
have no idea. Am trying to run Zf but my pages are all blank so i was
wondering if this has anything to do with it. Thanks will appreciate any
help:

[Wed Dec 10 11:15:03 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
[Wed Dec 10 11:15:05 2008] [error] [client 190.30.20.221] File does not
exist: /usr/local/apache/htdocs/administrator
[Wed Dec 10 11:15:05 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
[Wed Dec 10 11:15:08 2008] [error] [client 190.30.20.221] File does not
exist: /usr/local/apache/htdocs/administrator
[Wed Dec 10 11:15:08 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
[Wed Dec 10 11:15:10 2008] [error] [client 190.30.20.221] File does not
exist: /usr/local/apache/htdocs/administrator
[Wed Dec 10 11:15:10 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
[Wed Dec 10 11:15:12 2008] [error] [client 190.30.20.221] File does not
exist: /usr/local/apache/htdocs/administrator
[Wed Dec 10 11:15:12 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed

-
dee
-- 
View this message in context: 
http://www.nabble.com/Include-directive..-tp20893857p20930853.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Include directive..

2008-12-09 Thread Jim Lucas
dele454 wrote:
 Hi,
 
 I am modifying the apache config file on my domain to include the path to
 the Zend Framework on a specified location outside the public folder.
 
 So in my http.conf file i simply include the path to where the includes file
 is to customise the virtual host:
 
 [CODE]
 
 # To customize this VirtualHost use an include file at the following
 location
  Include
 /usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf
 [/CODE]
 
 And then me.conf looks like this:
 [CODE]
 Include /home/domain/apps
 Include /home/domain/apps/models
 Include /home/domain/apps/lib
 [/CODE]
 
 But then i get this error:
 
 [CODE]
 Failed to generate a syntactically correct Apache configuration.
 Bad configuration file located at
 /usr/local/apache/conf/httpd.conf.1228614930
 Error:
 Configuration problem detected on line 277 of file
 /usr/local/apache/conf/httpd.conf.1228614930:: Syntax error on line
 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf:
 Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
 /home/maineven/apps/Bootstrap.php:1: ?php was not closed.[/CODE]
 
 But i do have the ?php tag closed in my Bootstrap file. I dont know why it
 is saying otherwise.
 
 Please help is needed.
 
 Thanks
 
 -
 dee

Taking in what everybody else has already pointed out, I would like to add that 
their is a php configuration option that will do something along the
line of what you are trying to do.

It is called the 'auto_prepend_file' option.

You could do something like this in your httpd.conf file instead of what you 
are trying to do.

VirtualHost IP:PORT

... All Your normal stuff ...

php_value auto_prepend_file '/path/to/file.php'

/VirtualHost

The above code will include your php file as a standard php include every time 
someone visits the given VirtualHost block.

Hope this helps.

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Include directive..

2008-12-09 Thread Jim Lucas
Dele wrote:
 Hi,
 
 Thanks for the reply. What I did was to edit the includes path in my php.ini
 file to specify the location to my script folders.
 
 I did that but now am experiencing another problem. Don't know if you are
 into the Zend Framework.  :) But any help on tis post will be appreciated
 thanks

Nope, I know nothing about ZF.  Sorry.

 
 http://www.nabble.com/ZF-live-settings-td20911516.html
 
 Regards
 
 Dele
 
 (C) 071 673 4130  (E) [EMAIL PROTECTED]  (S) dee454
 
 Start by doing what's necessary; then do what's possible; and suddenly you
 are doing the impossible. - St. Francis of Assisi.
 
 Disclaimer: This email and any files transmitted with it are confidential
 and intended solely for the use of the individual or entity to whom they are
 addressed. If you have received this email in error please notify the system
 manager. This message contains confidential information and is intended only
 for the individual named. If you are not the named addressee you should not
 disseminate, distribute or copy this e-mail. Please notify the sender
 immediately by e-mail if you have received this e-mail by mistake and delete
 this e-mail from your system. If you are not the intended recipient you are
 notified that disclosing, copying, distributing or taking any action in
 reliance on the contents of this information is strictly prohibited.
 
 -Original Message-
 From: Jim Lucas [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, December 09, 2008 8:19 PM
 To: dele454
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Include directive..
 
 dele454 wrote:
 Hi,

 I am modifying the apache config file on my domain to include the path to
 the Zend Framework on a specified location outside the public folder.

 So in my http.conf file i simply include the path to where the includes
 file
 is to customise the virtual host:

 [CODE]

 # To customize this VirtualHost use an include file at the following
 location
  Include
 /usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf
 [/CODE]

 And then me.conf looks like this:
 [CODE]
 Include /home/domain/apps
 Include /home/domain/apps/models
 Include /home/domain/apps/lib
 [/CODE]

 But then i get this error:

 [CODE]
 Failed to generate a syntactically correct Apache configuration.
 Bad configuration file located at
 /usr/local/apache/conf/httpd.conf.1228614930
 Error:
 Configuration problem detected on line 277 of file
 /usr/local/apache/conf/httpd.conf.1228614930:: Syntax error on
 line
 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf:
 Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
 /home/maineven/apps/Bootstrap.php:1: ?php was not closed.[/CODE]

 But i do have the ?php tag closed in my Bootstrap file. I dont know why
 it
 is saying otherwise.

 Please help is needed.

 Thanks

 -
 dee
 
 Taking in what everybody else has already pointed out, I would like to add
 that their is a php configuration option that will do something along the
 line of what you are trying to do.
 
 It is called the 'auto_prepend_file' option.
 
 You could do something like this in your httpd.conf file instead of what you
 are trying to do.
 
 VirtualHost IP:PORT
 
   ... All Your normal stuff ...
 
   php_value auto_prepend_file '/path/to/file.php'
 
 /VirtualHost
 
 The above code will include your php file as a standard php include every
 time someone visits the given VirtualHost block.
 
 Hope this helps.
 


-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Include directive..

2008-12-08 Thread German Geek
On Tue, Dec 9, 2008 at 12:47 AM, dele454 [EMAIL PROTECTED] wrote:


 Hi,

 I am modifying the apache config file on my domain to include the path to
 the Zend Framework on a specified location outside the public folder.

 So in my http.conf file i simply include the path to where the includes
 file
 is to customise the virtual host:

 [CODE]

 # To customize this VirtualHost use an include file at the following
 location
 Include
 /usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf
 [/CODE]

 And then me.conf looks like this:
 [CODE]
 Include /home/domain/apps
 Include /home/domain/apps/models
 Include /home/domain/apps/lib
 [/CODE]

 But then i get this error:

 [CODE]
 Failed to generate a syntactically correct Apache configuration.
 Bad configuration file located at
 /usr/local/apache/conf/httpd.conf.1228614930
 Error:
 Configuration problem detected on line 277 of file
 /usr/local/apache/conf/httpd.conf.1228614930:: Syntax error on line
 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf:
 Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
 /home/maineven/apps/Bootstrap.php:1: ?php was not closed.[/CODE]


You get this error because you are trying to include a php file in the
apache configuration. Apache config files have tags, such as Directory and
?php looks like it's opening an Apache directive but not closing it with
?php ... /?php

If you want to include php scripts in your php file, you should do that
there, e.g. in incfiles.php:
?php
require_once('file1.php');
require_once('file2.php');
...

Or if you want to include a whole directory, read it with readdir (would
have to look up the function name etc) and iterate over it.

If you have classes you can also use the feature that i really like, called
class autoloading ( http://nz2.php.net/autoload ).


Re: [PHP] Include directive..

2008-12-08 Thread Jochem Maas
dele454 schreef:
 Hi,
 
 I am modifying the apache config file on my domain to include the path to
 the Zend Framework on a specified location outside the public folder.
 
 So in my http.conf file i simply include the path to where the includes file
 is to customise the virtual host:
 
 [CODE]
 
 # To customize this VirtualHost use an include file at the following
 location
  Include
 /usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf
 [/CODE]
 
 And then me.conf looks like this:
 [CODE]
 Include /home/domain/apps
 Include /home/domain/apps/models
 Include /home/domain/apps/lib
 [/CODE]
 
 But then i get this error:
 
 [CODE]
 Failed to generate a syntactically correct Apache configuration.
 Bad configuration file located at

READ THE PRECEDING LINE.

here is a hint: Apache Include directives have NOTHING to do
with PHP includes.

your trying to define a PHP include_path using Apache's Include
directive, guess what ... that won't work.

additionally you seem to be trying to use Apache's Include directive
to 'include' your Bootstrap.php ... which again, won't work.

 /usr/local/apache/conf/httpd.conf.1228614930
 Error:
 Configuration problem detected on line 277 of file
 /usr/local/apache/conf/httpd.conf.1228614930:: Syntax error on line
 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf:
 Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
 /home/maineven/apps/Bootstrap.php:1: ?php was not closed.[/CODE]
 
 But i do have the ?php tag closed in my Bootstrap file. I dont know why it
 is saying otherwise.

'IT' is Apache, which doesn't undetstand your PHP code to be anything
that resembles valid Apache config syntax. Apache sees '?php'  in the [conf]
file you give it and it tries to parse this as a Directive 'tag' which it
obviously fails to do.

 Please help is needed.

I concur.

 Thanks
 
 -
 dee


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



Re: [PHP] Include directive..

2008-12-08 Thread Jason Pruim


On Dec 8, 2008, at 6:47 AM, dele454 wrote:



Hi,

I am modifying the apache config file on my domain to include the  
path to

the Zend Framework on a specified location outside the public folder.

So in my http.conf file i simply include the path to where the  
includes file

is to customise the virtual host:

[CODE]

# To customize this VirtualHost use an include file at the following
location
 Include
/usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf
[/CODE]

And then me.conf looks like this:
[CODE]
Include /home/domain/apps
Include /home/domain/apps/models
Include /home/domain/apps/lib
[/CODE]

But then i get this error:

[CODE]
Failed to generate a syntactically correct Apache configuration.
Bad configuration file located at
/usr/local/apache/conf/httpd.conf.1228614930
Error:
Configuration problem detected on line 277 of file
/usr/local/apache/conf/httpd.conf.1228614930:: Syntax error  
on line
1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/ 
me.conf:

Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
/home/maineven/apps/Bootstrap.php:1: ?php was not closed.[/CODE]

But i do have the ?php tag closed in my Bootstrap file. I dont  
know why it

is saying otherwise.


Would it be possible to see the entire line 277 and a few above that?  
most likely, it's complaining that you missed a  or ; or something  
simple like that...


Also, you could if it's a php file, try putting it into the doc root,  
and hitting the file with error logging set to the highest it can go:


IE:

?PHP

ini_set('error_reporting', E_ALL | E_STRICT);

$a = b;
$x = $a / $b;

?

And with the error reporting on it would show you that $b doesn't  
exist... Helpful for catching errors :)




--
Jason Pruim
[EMAIL PROTECTED]
616.399.2355





Re: [PHP] include methods of one class in another

2008-08-21 Thread Eric Butera
On Thu, Aug 21, 2008 at 6:10 AM, Pavel [EMAIL PROTECTED] wrote:
 Hello, firstly, sorry for my English...

 I have class:
 //---
 class manageClassError{
private $errorsList=array();


private function addError($ex){
$errorsList[]=$ex;
}
public function isError(){
return (bool)(count($this-errorsList));
}
public function getErrorsList(){
return $this-errorsList;
}
public function returnLastError(){
$cErrorsList=count($this-errorsList);
If($cErrorsList==0){
return false;
}else{
return $this-errorsList[$cErrorsList-1];
}
}

 }
 //---
 this class alone can't do anything practicality, but if include this class
 to another it can salve other class to copy code of first class...

 so i had many class,which contain all method of   manageClassError and i need
 to mark managing error in other class...can you help me?

 P.S. I think, use extends isn't good for my idea...

 --
 ===
 С уважением, Манылов Павел aka [R-k]
 icq: 949-388-0
 mailto:[EMAIL PROTECTED]
 ===
 А ещё говорят так:
 I was at this restaurant.  The sign said Breakfast Anytime.  So I
 ordered French Toast in the Rennaissance.
-- Steven Wright
 [fortune]

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



You can make your error class a singleton, perhaps make the methods
static, or use some sort of dependency injection.  This way you can
call it from your other classes.

Two quick examples:

class foo {

/**
 * @var manageClassError
 */
protected $error;

public function __construct(manageClassError $error) {
$this-error = $error;
}

public function process() {
$this-error-addError('uh oh');
}

}


or

class foo { 
public function process() {
$error = manageClassError::getInstance();
$error-addError('uh oh');
}
}


Re: [PHP] include methods of one class in another

2008-08-21 Thread Jochem Maas

Pavel schreef:

Hello, firstly, sorry for my English...

I have class:
//---
class manageClassError{
private $errorsList=array();
   

private function addError($ex){

$errorsList[]=$ex;
}
public function isError(){
return (bool)(count($this-errorsList));
}
public function getErrorsList(){
return $this-errorsList;
}
public function returnLastError(){
$cErrorsList=count($this-errorsList);
If($cErrorsList==0){
return false;
}else{
return $this-errorsList[$cErrorsList-1];
}
}

}

//---
this class alone can't do anything practicality, but if include this class 
to another it can salve other class to copy code of first class...


so i had many class,which contain all method of   manageClassError and i need 
to mark managing error in other class...can you help me?


use a decorator pattern  or wait till hell freezes over and the core devs 
actually
allow the Traits functionality into php.

Traits is actually well thought out and implemented addition AFAICT ... but
there are countless half-baked, 'must-have', buzzword-of-the-moment stuff that
needs to be implemented first ... and the unicode stuff (which is actually 
going to
be kick-ass if they get it right)

you can attribute this to the Narky::Sarcasm namespace.



P.S. I think, use extends isn't good for my idea...




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



Re: [PHP] include methods of one class in another

2008-08-21 Thread Pavel

 use a decorator pattern  or wait till hell freezes over and the core devs
 actually allow the Traits functionality into php.

 I must read about patterns, thanks :)


-- 
===
С уважением, Манылов Павел aka [R-k]
icq: 949-388-0
mailto:[EMAIL PROTECTED]
===
А ещё говорят так:
We all agree on the necessity of compromise.  We just can't agree on
when it's necessary to compromise.
-- Larry Wall
[fortune]


RE: [PHP] Include Problem

2008-06-24 Thread Jay Blanchard
[snip]
foreach ($lines2 as $line_num = $line2) {

echo pLine #b{$line_num}/b :  . htmlspecialchars($line2) .
/p;

}

include ('http://www.mysite.com/calculate.php');



My problem is that when I use a blank file that only has



?php  include 'http://www.mysite.com/calculate.php'; ?



The code works and displays what is meant to display. However, when I
copy this snippet into the code even outside the foreach loop, it does
not even read, or give me an error. Is there something I should not be
doing here?
[/snip]

If you get no error the file is being included properly. What is the
goal here? Is it to have calculate.php perform actions on the returned
data from lung.txt?

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



RE: [PHP] Include Problem

2008-06-24 Thread Wei, Alice J.

From: Jay Blanchard [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 1:10 PM
To: Wei, Alice J.; php-general@lists.php.net
Subject: RE: [PHP] Include Problem

[snip]
foreach ($lines2 as $line_num = $line2) {

echo pLine #b{$line_num}/b :  . htmlspecialchars($line2) .
/p;

}

include ('http://www.mysite.com/calculate.php');



My problem is that when I use a blank file that only has



?php  include 'http://www.mysite.com/calculate.php'; ?



The code works and displays what is meant to display. However, when I
copy this snippet into the code even outside the foreach loop, it does
not even read, or give me an error. Is there something I should not be
doing here?
[/snip]

If you get no error the file is being included properly. What is the
goal here? Is it to have calculate.php perform actions on the returned
data from lung.txt?

The goal is to do a word  count of what was in lung.txt, since I don't want the 
users to interact directly with this file. However, this is not showing up at 
all. Any ideas?

Thanks in advance.

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



Re: [PHP] Include Problem

2008-06-24 Thread Jim Lucas

Wei, Alice J. wrote:


From: Jay Blanchard [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 1:10 PM
To: Wei, Alice J.; php-general@lists.php.net
Subject: RE: [PHP] Include Problem

[snip]
foreach ($lines2 as $line_num = $line2) {

echo pLine #b{$line_num}/b :  . htmlspecialchars($line2) .
/p;

}

include ('http://www.mysite.com/calculate.php');



My problem is that when I use a blank file that only has



?php  include 'http://www.mysite.com/calculate.php'; ?



The code works and displays what is meant to display. However, when I
copy this snippet into the code even outside the foreach loop, it does
not even read, or give me an error. Is there something I should not be
doing here?
[/snip]

If you get no error the file is being included properly. What is the
goal here? Is it to have calculate.php perform actions on the returned
data from lung.txt?

The goal is to do a word  count of what was in lung.txt, since I don't want the 
users to interact directly with this file. However, this is not showing up at 
all. Any ideas?

Thanks in advance.



Make sure you have these enabled

allow_url_fopen = On
allow_url_include = On

This might be your problem.  They limit things so remote files cannot be access 
via fopen/include/etc...


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



RE: [PHP] Include Problem

2008-06-24 Thread Wei, Alice J.

From: Jim Lucas [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 1:32 PM
To: Wei, Alice J.
Cc: Jay Blanchard; php-general@lists.php.net
Subject: Re: [PHP] Include Problem

Wei, Alice J. wrote:
 
 From: Jay Blanchard [EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 1:10 PM
 To: Wei, Alice J.; php-general@lists.php.net
 Subject: RE: [PHP] Include Problem

 [snip]
 foreach ($lines2 as $line_num = $line2) {

 echo pLine #b{$line_num}/b :  . htmlspecialchars($line2) .
 /p;

 }

 include ('http://www.mysite.com/calculate.php');



 My problem is that when I use a blank file that only has



 ?php  include 'http://www.mysite.com/calculate.php'; ?



 The code works and displays what is meant to display. However, when I
 copy this snippet into the code even outside the foreach loop, it does
 not even read, or give me an error. Is there something I should not be
 doing here?
 [/snip]

 If you get no error the file is being included properly. What is the
 goal here? Is it to have calculate.php perform actions on the returned
 data from lung.txt?

 The goal is to do a word  count of what was in lung.txt, since I don't want 
 the users to interact directly with this file. However, this is not showing 
 up at all. Any ideas?

 Thanks in advance.


Make sure you have these enabled

allow_url_fopen = On
allow_url_include = On

This might be your problem.  They limit things so remote files cannot be access
via fopen/include/etc...

One of them was off when I checked, but it appears that the output does not 
change when I have the foreach and the include in the file. This is not in a 
function or a subroutine, so this should not have a global problem, I think. 
Could there be other things I missed?

Alice

--
Jim Lucas

Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
 by William Shakespeare

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



Re: [PHP] Include Problem

2008-06-24 Thread Daniel Brown
On Tue, Jun 24, 2008 at 1:32 PM, Jim Lucas [EMAIL PROTECTED] wrote:

 Make sure you have these enabled

 allow_url_fopen = On
 allow_url_include = On

In addition to what Jay and Jim already correctly suggested, you
may also want to try this at the top of your files to see if there are
any errors or hints at all:

?php
ini_set('display_errors','On');
error_reporting(E_ALL);
//  continue with your code here.
?

Further, you can echo out the response code from include, like so:

?php
echo include('http://www.mysite.com/calculate.php');
?

 or, with short_open_tags = On:

?=include('http://www.mysite.com/calculate.php');?

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



RE: [PHP] Include Problem

2008-06-24 Thread Wei, Alice J.
Hi,

  This is the error I got:

Warning: include() [function.include]: URL file-access is disabled in the 
server configuration in C:\Inetpub\wwwroot\read.php on line 29
Warning: include(http://www.mysite.com/calculate.php) [function.include]: 
failed to open stream: no suitable wrapper could be found in 
C:\Inetpub\wwwroot\read.php on line 29
Warning: include() [function.include]: Failed opening 
'http://www.mysite.com/calculate.php' for inclusion 
(include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\read.php on line 29

When I installed the PHP with Apache, I selected the Unix binary, but the 
message above implies that it somehow does not know what file to look for, 
right?

Is there somehow I can solve this? My calculate.php is stored on a Linux, while 
my read.php is on a Windows.
Thanks in advance.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

From: Daniel Brown [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 1:51 PM
To: Jim Lucas
Cc: Wei, Alice J.; Jay Blanchard; php-general@lists.php.net
Subject: Re: [PHP] Include Problem

On Tue, Jun 24, 2008 at 1:32 PM, Jim Lucas [EMAIL PROTECTED] wrote:

 Make sure you have these enabled

 allow_url_fopen = On
 allow_url_include = On

In addition to what Jay and Jim already correctly suggested, you
may also want to try this at the top of your files to see if there are
any errors or hints at all:

?php
ini_set('display_errors','On');
error_reporting(E_ALL);
//  continue with your code here.
?

Further, you can echo out the response code from include, like so:

?php
echo include('http://www.mysite.com/calculate.php');
?

 or, with short_open_tags = On:

?=include('http://www.mysite.com/calculate.php');?

--
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Include Problem

2008-06-24 Thread Daniel Brown
On Tue, Jun 24, 2008 at 1:55 PM, Wei, Alice J. [EMAIL PROTECTED] wrote:
 Hi,

  This is the error I got:

 Warning: include() [function.include]: URL file-access is disabled in the 
 server configuration in C:\Inetpub\wwwroot\read.php on line 29
 Warning: include(http://www.mysite.com/calculate.php) [function.include]: 
 failed to open stream: no suitable wrapper could be found in 
 C:\Inetpub\wwwroot\read.php on line 29
 Warning: include() [function.include]: Failed opening 
 'http://www.mysite.com/calculate.php' for inclusion 
 (include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\read.php on line 29

Did you remember to restart your web server after making the
changes that Jim mentioned?

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



RE: [PHP] Include Problem

2008-06-24 Thread Wei, Alice J.

From: Daniel Brown [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 1:59 PM
To: Wei, Alice J.
Cc: Jim Lucas; Jay Blanchard; php-general@lists.php.net
Subject: Re: [PHP] Include Problem

On Tue, Jun 24, 2008 at 1:55 PM, Wei, Alice J. [EMAIL PROTECTED] wrote:
 Hi,

  This is the error I got:

 Warning: include() [function.include]: URL file-access is disabled in the 
 server configuration in C:\Inetpub\wwwroot\read.php on line 29
 Warning: include(http://www.mysite.com/calculate.php) [function.include]: 
 failed to open stream: no suitable wrapper could be found in 
 C:\Inetpub\wwwroot\read.php on line 29
 Warning: include() [function.include]: Failed opening 
 'http://www.mysite.com/calculate.php' for inclusion 
 (include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\read.php on line 29

Did you remember to restart your web server after making the
changes that Jim mentioned?

Yes, I restarted my Apache twice after each of the changes I made. As I 
mentioned before, the error I get from calculate.php is located on the Linux 
server. Does this have to do anything with the compilation because it is trying 
to find a Windows directory?

Alice
--
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



RE: [PHP] Include Problem

2008-06-24 Thread Boyd, Todd M.
 -Original Message-
 From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 1:04 PM
 To: Daniel Brown
 Cc: Jim Lucas; Jay Blanchard; php-general@lists.php.net
 Subject: RE: [PHP] Include Problem
 
 
 From: Daniel Brown [EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 1:59 PM
 To: Wei, Alice J.
 Cc: Jim Lucas; Jay Blanchard; php-general@lists.php.net
 Subject: Re: [PHP] Include Problem
 
 On Tue, Jun 24, 2008 at 1:55 PM, Wei, Alice J. [EMAIL PROTECTED]
 wrote:
  Hi,
 
   This is the error I got:
 
  Warning: include() [function.include]: URL file-access is disabled
in
 the server configuration in C:\Inetpub\wwwroot\read.php on line 29
  Warning: include(http://www.mysite.com/calculate.php)
 [function.include]: failed to open stream: no suitable wrapper could
be
 found in C:\Inetpub\wwwroot\read.php on line 29
  Warning: include() [function.include]: Failed opening
 'http://www.mysite.com/calculate.php' for inclusion
 (include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\read.php on line
 29
 
 Did you remember to restart your web server after making the
 changes that Jim mentioned?
 
 Yes, I restarted my Apache twice after each of the changes I made.
 As I mentioned before, the error I get from calculate.php is located
on
 the Linux server. Does this have to do anything with the compilation
 because it is trying to find a Windows directory?
 
 Alice

If you are trying to include() a remote file via HTTP, the remote server
will (most likely) translate the PHP code into the output that it would
produce if you were to visit the script with a web browser. It appears
you are trying to grab a PHP file from a remote server and execute it as
code, which won't work--at least not under normal circumstances.

HTH,


Todd Boyd
Web Programmer




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



RE: [PHP] Include Problem

2008-06-24 Thread Wei, Alice J.
Hi,

  Thanks for the clarifcations.
  I have two more questions regarding this issue:

   1. If I try to do this from Windows platform to another Window platform work?
2. With this type of scenario, if I cannot use include, what type of 
options may I have?

Anything is appreciated.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

From: Boyd, Todd M. [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 2:37 PM
To: Wei, Alice J.
Cc: php-general@lists.php.net
Subject: RE: [PHP] Include Problem

 -Original Message-
 From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 1:04 PM
 To: Daniel Brown
 Cc: Jim Lucas; Jay Blanchard; php-general@lists.php.net
 Subject: RE: [PHP] Include Problem

 
 From: Daniel Brown [EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 1:59 PM
 To: Wei, Alice J.
 Cc: Jim Lucas; Jay Blanchard; php-general@lists.php.net
 Subject: Re: [PHP] Include Problem

 On Tue, Jun 24, 2008 at 1:55 PM, Wei, Alice J. [EMAIL PROTECTED]
 wrote:
  Hi,
 
   This is the error I got:
 
  Warning: include() [function.include]: URL file-access is disabled
in
 the server configuration in C:\Inetpub\wwwroot\read.php on line 29
  Warning: include(http://www.mysite.com/calculate.php)
 [function.include]: failed to open stream: no suitable wrapper could
be
 found in C:\Inetpub\wwwroot\read.php on line 29
  Warning: include() [function.include]: Failed opening
 'http://www.mysite.com/calculate.php' for inclusion
 (include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\read.php on line
 29

 Did you remember to restart your web server after making the
 changes that Jim mentioned?

 Yes, I restarted my Apache twice after each of the changes I made.
 As I mentioned before, the error I get from calculate.php is located
on
 the Linux server. Does this have to do anything with the compilation
 because it is trying to find a Windows directory?

 Alice

If you are trying to include() a remote file via HTTP, the remote server
will (most likely) translate the PHP code into the output that it would
produce if you were to visit the script with a web browser. It appears
you are trying to grab a PHP file from a remote server and execute it as
code, which won't work--at least not under normal circumstances.

HTH,


Todd Boyd
Web Programmer

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



RE: [PHP] Include Problem

2008-06-24 Thread Boyd, Todd M.
 -Original Message-
 From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 1:39 PM
 To: Boyd, Todd M.
 Cc: php-general@lists.php.net
 Subject: RE: [PHP] Include Problem
 
 Hi,
 
   Thanks for the clarifcations.
   I have two more questions regarding this issue:
 
1. If I try to do this from Windows platform to another Window
 platform work?
 2. With this type of scenario, if I cannot use include, what type
 of options may I have?
 
 Anything is appreciated.

---8--- snip

This is the error I got:
  
   Warning: include() [function.include]: URL file-access is disabled
 in
  the server configuration in C:\Inetpub\wwwroot\read.php on line 29
   Warning: include(http://www.mysite.com/calculate.php)
  [function.include]: failed to open stream: no suitable wrapper could
 be
  found in C:\Inetpub\wwwroot\read.php on line 29
   Warning: include() [function.include]: Failed opening
  'http://www.mysite.com/calculate.php' for inclusion
  (include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\read.php on
 line
  29

---8--- snip

 If you are trying to include() a remote file via HTTP, the remote
 server
 will (most likely) translate the PHP code into the output that it
would
 produce if you were to visit the script with a web browser. It appears
 you are trying to grab a PHP file from a remote server and execute it
 as
 code, which won't work--at least not under normal circumstances.

Alice,

If the two Windows machines are on the same network, you can try to use
Windows' file sharing to do the job for you. For instance,

include('\\servername\dirname\filename.php');

Using HTTP from Windows to Windows would yield the same results as using
HTTP from Linux to Windows. You could host the files on a server that
does not parse PHP, and so they would be transmitted as plain text...
but then you get into issues of disclosing their contents to parties you
would rather leave in the dark (read: hackers).

You might consider using FTP, SCP, or another behind-the-scenes file
transfer agent to accomplish what it is you're trying to do. I believe
PHP already has several functions for use with FTP.

Good luck,


Todd Boyd
Web Programmer




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



RE: [PHP] Include Problem

2008-06-24 Thread Boyd, Todd M.
 -Original Message-
 From: Boyd, Todd M. [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 1:48 PM
 To: Wei, Alice J.
 Cc: php-general@lists.php.net
 Subject: RE: [PHP] Include Problem
 
  -Original Message-
  From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, June 24, 2008 1:39 PM
  To: Boyd, Todd M.
  Cc: php-general@lists.php.net
  Subject: RE: [PHP] Include Problem
 
  Hi,
 
Thanks for the clarifcations.
I have two more questions regarding this issue:
 
 1. If I try to do this from Windows platform to another Window
  platform work?
  2. With this type of scenario, if I cannot use include, what
type
  of options may I have?
 
  Anything is appreciated.
 
 ---8--- snip
 
 This is the error I got:
   
Warning: include() [function.include]: URL file-access is
 disabled
  in
   the server configuration in C:\Inetpub\wwwroot\read.php on line 29
Warning: include(http://www.mysite.com/calculate.php)
   [function.include]: failed to open stream: no suitable wrapper
 could
  be
   found in C:\Inetpub\wwwroot\read.php on line 29
Warning: include() [function.include]: Failed opening
   'http://www.mysite.com/calculate.php' for inclusion
   (include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\read.php on
  line
   29
 
 ---8--- snip
 
  If you are trying to include() a remote file via HTTP, the remote
  server
  will (most likely) translate the PHP code into the output that it
 would
  produce if you were to visit the script with a web browser. It
 appears
  you are trying to grab a PHP file from a remote server and execute
it
  as
  code, which won't work--at least not under normal circumstances.
 
 Alice,
 
 If the two Windows machines are on the same network, you can try to
use
 Windows' file sharing to do the job for you. For instance,
 
 include('\\servername\dirname\filename.php');

*cough* ... I meant to double up on those backslashes. I'm not sure if
PHP supports forward-slash file/dir specifications in Windows, but to
double them all up would look like this:

Include(servername\\dirname\\filename.php);
 
 Using HTTP from Windows to Windows would yield the same results as
 using
 HTTP from Linux to Windows. You could host the files on a server that
 does not parse PHP, and so they would be transmitted as plain text...
 but then you get into issues of disclosing their contents to parties
 you
 would rather leave in the dark (read: hackers).
 
 You might consider using FTP, SCP, or another behind-the-scenes file
 transfer agent to accomplish what it is you're trying to do. I believe
 PHP already has several functions for use with FTP.


Todd Boyd
Web Programmer




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



RE: [PHP] Include Problem

2008-06-24 Thread Wei, Alice J.

From: Boyd, Todd M. [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 2:53 PM
To: php-general@lists.php.net; Wei, Alice J.
Subject: RE: [PHP] Include Problem


  If you are trying to include() a remote file via HTTP, the remote
  server
  will (most likely) translate the PHP code into the output that it
 would
  produce if you were to visit the script with a web browser. It
 appears
  you are trying to grab a PHP file from a remote server and execute
it
  as
  code, which won't work--at least not under normal circumstances.

 Alice,

 If the two Windows machines are on the same network, you can try to
use
 Windows' file sharing to do the job for you. For instance,

 include('\\servername\dirname\filename.php');

*cough* ... I meant to double up on those backslashes. I'm not sure if
PHP supports forward-slash file/dir specifications in Windows, but to
double them all up would look like this:

Include(servername\\dirname\\filename.php);

 Using HTTP from Windows to Windows would yield the same results as
 using
 HTTP from Linux to Windows. You could host the files on a server that
 does not parse PHP, and so they would be transmitted as plain text...
 but then you get into issues of disclosing their contents to parties
 you
 would rather leave in the dark (read: hackers).

 You might consider using FTP, SCP, or another behind-the-scenes file
 transfer agent to accomplish what it is you're trying to do. I believe
 PHP already has several functions for use with FTP.

Sorry, I don't think I am intending on passing any file to whatever server.

All I need to do is to have my script be able to execute another program that 
can allow my  PHP script to pass the variables, so this may be using anything 
from PHP, Perl to C. I have seen in the PHP manual that there is this command 
called exec().

Is it possible that I could use something like exec($someurl) to execute the 
script? I tried doing this in PHP, but it tells me this:

arning: exec() [function.exec]: Unable to fork 
[http://www.mysite.com/calculate.php] in C:\Inetpub\wwwroot\read.php on line 31

Is there some way I can fix this error somehow? Or, is this not possible either?

Thanks for your help

Alice


Todd Boyd
Web Programmer

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



RE: [PHP] Include Problem

2008-06-24 Thread Boyd, Todd M.
 -Original Message-
 From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 3:11 PM
 To: Boyd, Todd M.; php-general@lists.php.net
 Subject: RE: [PHP] Include Problem
 
 
 From: Boyd, Todd M. [EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 2:53 PM
 To: php-general@lists.php.net; Wei, Alice J.
 Subject: RE: [PHP] Include Problem
 
 
   If you are trying to include() a remote file via HTTP, the remote
   server
   will (most likely) translate the PHP code into the output that it
  would
   produce if you were to visit the script with a web browser. It
  appears
   you are trying to grab a PHP file from a remote server and execute
 it
   as
   code, which won't work--at least not under normal circumstances.
 
  Alice,
 
  If the two Windows machines are on the same network, you can try to
 use
  Windows' file sharing to do the job for you. For instance,
 
  include('\\servername\dirname\filename.php');
 
 *cough* ... I meant to double up on those backslashes. I'm not sure if
 PHP supports forward-slash file/dir specifications in Windows, but to
 double them all up would look like this:
 
 Include(servername\\dirname\\filename.php);
 
  Using HTTP from Windows to Windows would yield the same results as
  using
  HTTP from Linux to Windows. You could host the files on a server
that
  does not parse PHP, and so they would be transmitted as plain
text...
  but then you get into issues of disclosing their contents to parties
  you
  would rather leave in the dark (read: hackers).
 
  You might consider using FTP, SCP, or another behind-the-scenes file
  transfer agent to accomplish what it is you're trying to do. I
 believe
  PHP already has several functions for use with FTP.
 
 Sorry, I don't think I am intending on passing any file to whatever
 server.
 
 All I need to do is to have my script be able to execute another
 program that can allow my  PHP script to pass the variables, so this
 may be using anything from PHP, Perl to C. I have seen in the PHP
 manual that there is this command called exec().
 
 Is it possible that I could use something like exec($someurl) to
 execute the script? I tried doing this in PHP, but it tells me this:
 
 arning: exec() [function.exec]: Unable to fork
 [http://www.mysite.com/calculate.php] in C:\Inetpub\wwwroot\read.php
on
 line 31
 
 Is there some way I can fix this error somehow? Or, is this not
 possible either?

Alice,

If you simply need to execute a remote PHP script and pass variables,
you could do it behind-the-scenes with cURL or AJAX, and pass the
variables in the url (i.e.,
http://www.mysite.com/script.php?param=value). cURL is capable of
retrieving the page (read: the results of the executed script), which
can then be parsed by your local script.

I actually did something like this where I scraped the World of Warcraft
Armory (ok, groan. No, seriously, let it out). I grabbed their XML
pages, parsed the info, and then pushed this info to a script on a
remote site of mine. I had to do this because the remote site I was
working with did not have cURL installed (nor could I install it myself
due to access restrictions). The remote script would return OK or
FAIL, and my script would expect one of these values and react
accordingly.

Is this a little bit more on target? I can supply you with source code
if you would like.

You could also use AJAX to populate an IFRAME with the results of a
remote PHP script, and then parse those values using a hidden form
submission, perhaps. Just some ideas.

HTH,


Todd Boyd
Web Programmer




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



RE: [PHP] Include Problem

2008-06-24 Thread Wei, Alice J.
Alice,

If you simply need to execute a remote PHP script and pass variables,
you could do it behind-the-scenes with cURL or AJAX, and pass the
variables in the url (i.e.,
http://www.mysite.com/script.php?param=value). cURL is capable of
retrieving the page (read: the results of the executed script), which
can then be parsed by your local script.

I actually did something like this where I scraped the World of Warcraft
Armory (ok, groan. No, seriously, let it out). I grabbed their XML
pages, parsed the info, and then pushed this info to a script on a
remote site of mine. I had to do this because the remote site I was
working with did not have cURL installed (nor could I install it myself
due to access restrictions). The remote script would return OK or
FAIL, and my script would expect one of these values and react
accordingly.

Is this a little bit more on target? I can supply you with source code
if you would like.

You could also use AJAX to populate an IFRAME with the results of a
remote PHP script, and then parse those values using a hidden form
submission, perhaps. Just some ideas.

 I think that the variables passed to will be used by that code to do 
perform some operations on another remote machine, (according to what I got 
from my client, he calls this behind the scenes to avoid users screw up the 
front end, and he is thinking of using C,  Perl or Python), which is why I am 
hoping that I can produce one single script, and have it execute some script 
without the user pushing any button. I don't think I plan on scraping 
websites. However, if you are suggesting that it is easier to do in Ajax to do 
what I am intending to do here, I would love to check it out and forget about 
PHP (hopefully not).

   Most of the documentation I have been seeing on exec() seems to be 
executing UNIX commands at http://us2.php.net/manual/en/function.exec.php. One 
main issue, which I am not sure if it is entirely relevant, is that I am using 
PHP on Windows with my current script, (the one to execute things from), while 
the script that would be executed is located on a Linux machine. Would this be 
an issue when I am doing this with what I am trying to do here?

 Thanks in advance.

Alice

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



RE: [PHP] Include Problem

2008-06-24 Thread Boyd, Todd M.
 -Original Message-
 From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 3:51 PM
 To: Boyd, Todd M.; php-general@lists.php.net
 Subject: RE: [PHP] Include Problem
 
 Alice,
 
 If you simply need to execute a remote PHP script and pass variables,
 you could do it behind-the-scenes with cURL or AJAX, and pass the
 variables in the url (i.e.,
 http://www.mysite.com/script.php?param=value). cURL is capable of
 retrieving the page (read: the results of the executed script), which
 can then be parsed by your local script.
 
 I actually did something like this where I scraped the World of
 Warcraft
 Armory (ok, groan. No, seriously, let it out). I grabbed their XML
 pages, parsed the info, and then pushed this info to a script on a
 remote site of mine. I had to do this because the remote site I was
 working with did not have cURL installed (nor could I install it
myself
 due to access restrictions). The remote script would return OK or
 FAIL, and my script would expect one of these values and react
 accordingly.
 
 Is this a little bit more on target? I can supply you with source code
 if you would like.
 
 You could also use AJAX to populate an IFRAME with the results of a
 remote PHP script, and then parse those values using a hidden form
 submission, perhaps. Just some ideas.

 ---
 
  I think that the variables passed to will be used by that code to
 do perform some operations on another remote machine, (according to
 what I got from my client, he calls this behind the scenes to avoid
 users screw up the front end, and he is thinking of using C,  Perl or
 Python), which is why I am hoping that I can produce one single
script,
 and have it execute some script without the user pushing any button. I
 don't think I plan on scraping websites. However, if you are
 suggesting that it is easier to do in Ajax to do what I am intending
to
 do here, I would love to check it out and forget about PHP (hopefully
 not).
 
Most of the documentation I have been seeing on exec() seems to
 be executing UNIX commands at
 http://us2.php.net/manual/en/function.exec.php. One main issue, which
I
 am not sure if it is entirely relevant, is that I am using PHP on
 Windows with my current script, (the one to execute things from),
while
 the script that would be executed is located on a Linux machine. Would
 this be an issue when I am doing this with what I am trying to do
here?

Alice,

exec() will execute Windows commands, as well. However, I'm not sure I
understand the reason for separating your script into two files--the
remote and the local scripts.

I will assume you are gathering data in your script (local), shipping
this off to a script on the client's machine (remote), and passing a
program (C/Python/Whatever) values you gathered using your script
(local).

Under this assumption, I would gather the data via
form/extraction/upload/whatever, and use cURL (a PHP library) to visit
the remote script, passing values either via GET or POST. The remote
script would then parse these values and send them to the appropriate
exec() command.

Am I off base?


Todd Boyd
Web Programmer




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



RE: [PHP] Include Problem

2008-06-24 Thread Wei, Alice J.

==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

From: Boyd, Todd M. [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 4:55 PM
To: Wei, Alice J.; php-general@lists.php.net
Subject: RE: [PHP] Include Problem

 -Original Message-
 From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 3:51 PM
 To: Boyd, Todd M.; php-general@lists.php.net
 Subject: RE: [PHP] Include Problem

 Alice,

 If you simply need to execute a remote PHP script and pass variables,
 you could do it behind-the-scenes with cURL or AJAX, and pass the
 variables in the url (i.e.,
 http://www.mysite.com/script.php?param=value). cURL is capable of
 retrieving the page (read: the results of the executed script), which
 can then be parsed by your local script.

 I actually did something like this where I scraped the World of
 Warcraft
 Armory (ok, groan. No, seriously, let it out). I grabbed their XML
 pages, parsed the info, and then pushed this info to a script on a
 remote site of mine. I had to do this because the remote site I was
 working with did not have cURL installed (nor could I install it
myself
 due to access restrictions). The remote script would return OK or
 FAIL, and my script would expect one of these values and react
 accordingly.

 Is this a little bit more on target? I can supply you with source code
 if you would like.

 You could also use AJAX to populate an IFRAME with the results of a
 remote PHP script, and then parse those values using a hidden form
 submission, perhaps. Just some ideas.

 ---

  I think that the variables passed to will be used by that code to
 do perform some operations on another remote machine, (according to
 what I got from my client, he calls this behind the scenes to avoid
 users screw up the front end, and he is thinking of using C,  Perl or
 Python), which is why I am hoping that I can produce one single
script,
 and have it execute some script without the user pushing any button. I
 don't think I plan on scraping websites. However, if you are
 suggesting that it is easier to do in Ajax to do what I am intending
to
 do here, I would love to check it out and forget about PHP (hopefully
 not).

Most of the documentation I have been seeing on exec() seems to
 be executing UNIX commands at
 http://us2.php.net/manual/en/function.exec.php. One main issue, which
I
 am not sure if it is entirely relevant, is that I am using PHP on
 Windows with my current script, (the one to execute things from),
while
 the script that would be executed is located on a Linux machine. Would
 this be an issue when I am doing this with what I am trying to do
here?

Alice,

exec() will execute Windows commands, as well. However, I'm not sure I
understand the reason for separating your script into two files--the
remote and the local scripts.

   To answer your question, I am separating these because the script that will 
be placed on the remoate server is filled with dense calculation operations, 
and putting these on the same server as the one I am writing and running from 
the local machine would possibly take up too much resources of the local 
server, and thus this only interacts with the local server I am working with 
and not with the client machine.

I will assume you are gathering data in your script (local), shipping
this off to a script on the client's machine (remote), and passing a
program (C/Python/Whatever) values you gathered using your script
(local).

 That would be correect, although I am not passing this to a client as I 
mentioned previously, and therefore everything would be ideally executed 
directly without any person to invoke the script.

Under this assumption, I would gather the data via
form/extraction/upload/whatever, and use cURL (a PHP library) to visit
the remote script, passing values either via GET or POST. The remote
script would then parse these values and send them to the appropriate
exec() command.

   That sounds like something I have to do, but the question is, if I don't 
have anyone pushing any button to invoke the script, how would it execute 
without using GET or POST before it uses exec()?

Hope this makes a little more sense now.

Alice

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



RE: [PHP] Include Problem

2008-06-24 Thread Boyd, Todd M.
 -Original Message-
 From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 24, 2008 4:07 PM
 To: Boyd, Todd M.; php-general@lists.php.net
 Subject: RE: [PHP] Include Problem

---8--- snip

   I think that the variables passed to will be used by that code
 to
  do perform some operations on another remote machine, (according to
  what I got from my client, he calls this behind the scenes to avoid
  users screw up the front end, and he is thinking of using C,  Perl
or
  Python), which is why I am hoping that I can produce one single
 script,
  and have it execute some script without the user pushing any button.
 I
  don't think I plan on scraping websites. However, if you are
  suggesting that it is easier to do in Ajax to do what I am intending
 to
  do here, I would love to check it out and forget about PHP
(hopefully
  not).
 
 Most of the documentation I have been seeing on exec() seems
 to
  be executing UNIX commands at
  http://us2.php.net/manual/en/function.exec.php. One main issue,
which
 I
  am not sure if it is entirely relevant, is that I am using PHP on
  Windows with my current script, (the one to execute things from),
 while
  the script that would be executed is located on a Linux machine.
 Would
  this be an issue when I am doing this with what I am trying to do
 here?
 
 Alice,
 
 exec() will execute Windows commands, as well. However, I'm not sure I
 understand the reason for separating your script into two files--the
 remote and the local scripts.
 
To answer your question, I am separating these because the script
 that will be placed on the remoate server is filled with dense
 calculation operations, and putting these on the same server as the
one
 I am writing and running from the local machine would possibly take up
 too much resources of the local server, and thus this only interacts
 with the local server I am working with and not with the client
 machine.
 
 I will assume you are gathering data in your script (local), shipping
 this off to a script on the client's machine (remote), and passing a
 program (C/Python/Whatever) values you gathered using your script
 (local).

 ---

  That would be correect, although I am not passing this to a
client
 as I mentioned previously, and therefore everything would be ideally
 executed directly without any person to invoke the script.
 
 Under this assumption, I would gather the data via
 form/extraction/upload/whatever, and use cURL (a PHP library) to
 visit
 the remote script, passing values either via GET or POST. The remote
 script would then parse these values and send them to the appropriate
 exec() command.
 
That sounds like something I have to do, but the question is,
if
 I don't have anyone pushing any button to invoke the script, how would
 it execute without using GET or POST before it uses exec()?
 
 Hope this makes a little more sense now.

Alice,

I'm not sure I follow you. Are you speaking of the local script or the
remote script as far as automation? The local script is executed when a
user requests it. The remote script will be executed when your local
script uses cURL to visit it. No users pressing buttons involved to my
knowledge.

Unless... is it a form? I'm a bit lost now. I'm not Midwestern tourist
in Malaysia lost, but I'm definitely a bit confused.


Todd Boyd
Web Programmer




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



Re: [PHP] Include problems

2008-04-14 Thread Daniel Brown
On Sat, Apr 12, 2008 at 11:06 PM, Bojan Tesanovic [EMAIL PROTECTED] wrote:

  On Apr 12, 2008, at 8:28 AM, GoWtHaM NaRiSiPaLli wrote:


  if(file_exists(../common/config.ini)) {
   $configData = parse_ini_file(../common/config.ini);
  } else {
 


  Try changing above code so it reads


  if(file_exists(common/config.ini)) {
   $configData = parse_ini_file(common/config.ini);
  } else {

In your primary file, you could also consider adding:

?php
$base_path = dirname(__FILE__);
?

And then, all includes from within that file would be included as such:

?php
include($base_path.'/common/config.ini');
?

Finally, on a different note, it may not be in your best interest
to keep a .ini extension on a configuration file, since this is
generally readable on the web.

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Include problems

2008-04-12 Thread Bojan Tesanovic


On Apr 12, 2008, at 8:28 AM, GoWtHaM NaRiSiPaLli wrote:


if(file_exists(../common/config.ini)) {
  $configData = parse_ini_file(../common/config.ini);
} else {



Try changing above code so it reads

if(file_exists(common/config.ini)) {
  $configData = parse_ini_file(common/config.ini);
} else {


As the xyz.php is in

/var/www/sites/project/  folder , and  that is the starting path of  
the script


so any script that needs to include
/var/www/sites/project/common/someFile.php
you need to specify relative path to '/var/www/sites/project/'  which  
is 'common/someFile.php'


this should work unless some of included files uses 'chdir'  function  
that changes current directory




Igor Jocic
http://www.carster.us/ Used Car Classifieds






Re: [PHP] Include fails when ./ is in front of file name

2008-04-08 Thread Noah Spitzer-Williams
I appreciate the help guys.  I don't understand what's going on.  Here's 
what I've tried since posting:


Copied over the PHP binaries and php.ini from my old server to my new one. 
No luck.

Copied over the phpMyAdmin from my old server to my new one.  No luck.

I've double-checked all permissions.  Seriously, what else could there be?!

I repeat:
   on old server, include('./file.inc.php') works FINE
   on new server, include('./file.inc.php') BREAKS

I'm about to do a replace of ./ with  but I know that's giving up!



Daniel Brown [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

On Mon, Apr 7, 2008 at 1:05 PM, Lester Caine [EMAIL PROTECTED] wrote:


 People seem to be missing the point here. These are PUBLIC applications
that are failing to work for Noah. He should not need to re-write 
PHPMyAdmin

in order to get it to work?

 Next people will be saying that we should re-write PHP if it does not 
work

for us.


   Oh, did I say that?  Must not have been paying attention as I
typed in words to that effect.  Sorry.

   I'm giving steps to debug and recreate the issue, not to rewrite
anyone else's code.  You may have noticed where I mentioned
cross-platform portability.

--
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed! 



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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Daniel Brown
On Sun, Apr 6, 2008 at 5:17 PM, Noah Spitzer-Williams [EMAIL PROTECTED] wrote:
 This works:
include(file.inc.php);

  This doesn't:
include(./file.inc.php);

That's pretty vague, Noah.  Is it unable to locate the file?
What's the error message you're receiving?

Also, what happens if you create two simple files in the same
directory like so:
?php
// file1.php
echo Okay.\n;
?

?php
// file2.php
include(dirname(__FILE__).'/file1.php');
?

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Philip Thompson

On Apr 7, 2008, at 9:36 AM, Daniel Brown wrote:
On Sun, Apr 6, 2008 at 5:17 PM, Noah Spitzer-Williams [EMAIL PROTECTED] 
 wrote:

This works:
  include(file.inc.php);

This doesn't:
  include(./file.inc.php);


   That's pretty vague, Noah.  Is it unable to locate the file?
What's the error message you're receiving?


It's Windows. From experience, I know that it provides little to no  
error reporting in some instances. For example, if you're missing a  
semi-colon and you have error reporting turned on, all you get is a  
blank page - no other info. So, odds are is that he isn't receiving an  
error message.


~Phil


   Also, what happens if you create two simple files in the same
directory like so:
?php
// file1.php
echo Okay.\n;
?

?php
// file2.php
include(dirname(__FILE__).'/file1.php');
?


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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Stut

Philip Thompson wrote:

On Apr 7, 2008, at 9:36 AM, Daniel Brown wrote:
On Sun, Apr 6, 2008 at 5:17 PM, Noah Spitzer-Williams 
[EMAIL PROTECTED] wrote:

This works:
  include(file.inc.php);

This doesn't:
  include(./file.inc.php);


   That's pretty vague, Noah.  Is it unable to locate the file?
What's the error message you're receiving?


It's Windows. From experience, I know that it provides little to no 
error reporting in some instances. For example, if you're missing a 
semi-colon and you have error reporting turned on, all you get is a 
blank page - no other info. So, odds are is that he isn't receiving an 
error message.


I'm not sure where you got that from, error reporting does not differ 
between Windows and other platforms except where platform-specific 
differences exist in the implementation (of which there are few).


What you're experiencing is probably the effect of the display_errors 
configuration option. Look it up in the manual for details.


To the OP: Check that your include_path contains '.', if it doesn't add 
it and see if that fixes your problem.


-Stut

--
http://stut.net/

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 11:20 AM, Philip Thompson [EMAIL PROTECTED] wrote:

  It's Windows. From experience, I know that it provides little to no error
 reporting in some instances. For example, if you're missing a semi-colon and
 you have error reporting turned on, all you get is a blank page - no other
 info. So, odds are is that he isn't receiving an error message.

error_reporting() == error_reporting() !platform

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



  1   2   3   4   5   6   7   >