php-general Digest 24 Aug 2008 01:55:28 -0000 Issue 5641
Topics (messages 278564 through 278579):
Re: Help and Advice needed please.
278564 by: sean greenslade
278565 by: Luke
278566 by: sean greenslade
Re: Quick question regarding getcwd() and directory location.
278567 by: Ólafur Waage
278570 by: David Otton
278571 by: Ólafur Waage
278575 by: Jochem Maas
278578 by: Micah Gersten
Serving pages based on user input
278568 by: Prasad Chand
278569 by: Ólafur Waage
278573 by: Jochem Maas
278574 by: Jochem Maas
278576 by: tedd
278577 by: tedd
278579 by: Prasad Chand
Re: Simple tiny php template
278572 by: Jochem Maas
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
I would be willing to help with this project. Because of all the different
requirements of this, I would recommend a totally custom set of scripts, and
a mysql database to hold all the data.
On Sat, Aug 23, 2008 at 7:22 AM, Byron <[EMAIL PROTECTED]> wrote:
> Hey.
>
> I do some part-time IT work for a voluntary paramilitary youth
> organisation,
> and we're loooking for a system to digitize the personell files of our
> members. Here's a features list, all advice on how to implement will be a
> great help.
>
> * Web-accesable via login
> * Rank, Name, Phone Number, Address, Email Address, Physical Address.
> * Training History
> * Promotion History
> * Miscellanous Notes.
> * Different types of Administrator and notes that can be attached to
> personell files that are seen by different types of administrator.
> * Activity report page. I.e. This activity happenened on this date and
> these
> people attended from this time to this time. Attendance must be visible on
> personell files.
> * Attendance Register and counter for attendances of members.
> * UI that a 65-year old who believes dialup is fast (the Unit Commander)
> can
> find his way around.
> * Easily copiable and deployable. As in can be used by more than one unit.
>
> --
> I'm going out to find myself, if you see me here, keep me here untill I can
> catch up
>
> If I haven't said so already,
>
> Thanks
> Byron
>
--
Feh.
--- End Message ---
--- Begin Message ---
I'm up for helping too. Also, a big agree to Sean too, MySQL seems the best
way to go here.
2008/8/23 sean greenslade <[EMAIL PROTECTED]>
> I would be willing to help with this project. Because of all the different
> requirements of this, I would recommend a totally custom set of scripts,
> and
> a mysql database to hold all the data.
>
> On Sat, Aug 23, 2008 at 7:22 AM, Byron <[EMAIL PROTECTED]> wrote:
>
> > Hey.
> >
> > I do some part-time IT work for a voluntary paramilitary youth
> > organisation,
> > and we're loooking for a system to digitize the personell files of our
> > members. Here's a features list, all advice on how to implement will be a
> > great help.
> >
> > * Web-accesable via login
> > * Rank, Name, Phone Number, Address, Email Address, Physical Address.
> > * Training History
> > * Promotion History
> > * Miscellanous Notes.
> > * Different types of Administrator and notes that can be attached to
> > personell files that are seen by different types of administrator.
> > * Activity report page. I.e. This activity happenened on this date and
> > these
> > people attended from this time to this time. Attendance must be visible
> on
> > personell files.
> > * Attendance Register and counter for attendances of members.
> > * UI that a 65-year old who believes dialup is fast (the Unit Commander)
> > can
> > find his way around.
> > * Easily copiable and deployable. As in can be used by more than one
> unit.
> >
> > --
> > I'm going out to find myself, if you see me here, keep me here untill I
> can
> > catch up
> >
> > If I haven't said so already,
> >
> > Thanks
> > Byron
> >
>
>
>
> --
> Feh.
>
--
Luke Slater
--- End Message ---
--- Begin Message ---
So Byron, what do you think? Do you like the idea of a mysql database?
On Sat, Aug 23, 2008 at 11:57 AM, Luke <[EMAIL PROTECTED]> wrote:
> I'm up for helping too. Also, a big agree to Sean too, MySQL seems the best
> way to go here.
>
> 2008/8/23 sean greenslade <[EMAIL PROTECTED]>
>
> I would be willing to help with this project. Because of all the different
>> requirements of this, I would recommend a totally custom set of scripts,
>> and
>> a mysql database to hold all the data.
>>
>> On Sat, Aug 23, 2008 at 7:22 AM, Byron <[EMAIL PROTECTED]> wrote:
>>
>> > Hey.
>> >
>> > I do some part-time IT work for a voluntary paramilitary youth
>> > organisation,
>> > and we're loooking for a system to digitize the personell files of our
>> > members. Here's a features list, all advice on how to implement will be
>> a
>> > great help.
>> >
>> > * Web-accesable via login
>> > * Rank, Name, Phone Number, Address, Email Address, Physical Address.
>> > * Training History
>> > * Promotion History
>> > * Miscellanous Notes.
>> > * Different types of Administrator and notes that can be attached to
>> > personell files that are seen by different types of administrator.
>> > * Activity report page. I.e. This activity happenened on this date and
>> > these
>> > people attended from this time to this time. Attendance must be visible
>> on
>> > personell files.
>> > * Attendance Register and counter for attendances of members.
>> > * UI that a 65-year old who believes dialup is fast (the Unit Commander)
>> > can
>> > find his way around.
>> > * Easily copiable and deployable. As in can be used by more than one
>> unit.
>> >
>> > --
>> > I'm going out to find myself, if you see me here, keep me here untill I
>> can
>> > catch up
>> >
>> > If I haven't said so already,
>> >
>> > Thanks
>> > Byron
>> >
>>
>>
>>
>> --
>> Feh.
>>
>
>
>
> --
> Luke Slater
>
--
Feh.
--- End Message ---
--- Begin Message ---
Luke, i am looking for local directory info. Not URL info as i said before.
And Ashley, as i said in the original mail. I had tried $_SERVER.
Thanks for the reply though.
Ólafur Waage
2008/8/23 Luke <[EMAIL PROTECTED]>:
> $_REQUEST?
>
> Luke Slater
> Lead Developer
> NuVoo
>
> On 23 Aug 2008, at 12:53, "Ólafur Waage" <[EMAIL PROTECTED]> wrote:
>
>> Robert, thanks for the reply but i had tried __FILE__ and __DIR__
>> (which is dirname(__FILE__)) but it doesnt work.
>>
>> And thanks for the reply also Ashley but as i said in my first post, i
>> had tried $_SERVER with limited results
>>
>> Ólafur Waage
>>
>> 2008/8/23 Robert Cummings <[EMAIL PROTECTED]>:
>>>
>>> On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote:
>>>>
>>>> On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage <[EMAIL PROTECTED]> wrote:
>>>>>
>>>>> I'll throw out an example here.
>>>>>
>>>>> I have a directory structure of: /var/www/example/
>>>>> And in that i have a file: index.php
>>>>> That file echo's getcwd() and returns: /var/www/example/
>>>>>
>>>>> Now i tell Apache or Lighty that if a directory does not have an
>>>>> index.php file, that it should use /example/index.php (for example via
>>>>> DirectoryIndex of Apache)
>>>>>
>>>>> Then i make a new directory: /var/www/test/
>>>>> And browse to it and it echo's /var/www/example/ since its running
>>>>> that file via DirectoryIndex
>>>>>
>>>>> This is true for all directories i make. Both for Windows and Linux
>>>>> based servers.
>>>>>
>>>>> To my question.
>>>>>
>>>>> I am trying to get the full path of the current directory i am in. Not
>>>>> from where the file is executing. How is that possible so it displays
>>>>> a full path to that directory (regardless to the server setup)?
>>>>>
>>>>> I have tried a variation of things and have gotten mixed results.
>>>>> Using $_SERVER["SCRIPT_FILENAME"] gives me the index file and the full
>>>>> path to that.
>>>>> $_SERVER["DOCUMENT_ROOT"] gets me part of the way but on a hosted
>>>>> server with multiple domains it only gives me a partial path (rough
>>>>> example: /var/www/ when the directory is /var/www/domain.com/test/)
>>>>> And __FILE__ gives me the index.php's path.
>>>>> I have also tried realpath(".");
>>>>> And server("pwd"); with no luck.
>>>>>
>>>>> Any help would be appreciated.
>>>>>
>>>>> Ólafur Waage
>>>>>
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>>
>>>> Maybe dirname(__FILE__) will help.
>>>
>>> When I'm looking for candidates to determine stuff like this I usually
>>> do print_r( $_SERVER ) and see what's what.
>>>
>>> Cheers,
>>> Rob.
>>> --
>>> 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
>>
>
--- End Message ---
--- Begin Message ---
2008/8/23 Ólafur Waage <[EMAIL PROTECTED]>:
> Robert, thanks for the reply but i had tried __FILE__ and __DIR__
> (which is dirname(__FILE__)) but it doesnt work.
>
> And thanks for the reply also Ashley but as i said in my first post, i
> had tried $_SERVER with limited results
If checking the output of phpinfo() doesn't help (and it looks like it
won't), I'd suggest starting with REQUEST_URI, then, if you know where
your webroot is, you should be able to calculate the path to the
target directory ("/var/www/example/../test/" in your original
example) by gluing bits of path together. Hardly an ideal solution as
it needs configuration, but it would work.
I think this is really a mod_rewrite problem, as by the time PHP takes
over you've lost the information you need. You may have better luck in
a forum devoted to mod_rewrite, but I'm not optimistic that it has a
"what file would have handled this request if mod_rewrite hadn't run"
parameter. I think you're going to have to build your directory path
from the information in the original request and some configuration
glue. Good luck
(BTW, I initially thought there might be something in mod_autoindex to
run a custom script, but it doesn't look like there is.)
--
http://www.otton.org/
--- End Message ---
--- Begin Message ---
Thanks for this David, i was using REQUEST_URI and other $_SERVER info
and mixed that together. It worked in some situations but on hosted
servers (like GoDaddy and others like that where they use a
complicated directory setup) it does not work.
Olafur Waage
2008/8/23 David Otton <[EMAIL PROTECTED]>:
> 2008/8/23 Ólafur Waage <[EMAIL PROTECTED]>:
>
>> Robert, thanks for the reply but i had tried __FILE__ and __DIR__
>> (which is dirname(__FILE__)) but it doesnt work.
>>
>> And thanks for the reply also Ashley but as i said in my first post, i
>> had tried $_SERVER with limited results
>
> If checking the output of phpinfo() doesn't help (and it looks like it
> won't), I'd suggest starting with REQUEST_URI, then, if you know where
> your webroot is, you should be able to calculate the path to the
> target directory ("/var/www/example/../test/" in your original
> example) by gluing bits of path together. Hardly an ideal solution as
> it needs configuration, but it would work.
>
> I think this is really a mod_rewrite problem, as by the time PHP takes
> over you've lost the information you need. You may have better luck in
> a forum devoted to mod_rewrite, but I'm not optimistic that it has a
> "what file would have handled this request if mod_rewrite hadn't run"
> parameter. I think you're going to have to build your directory path
> from the information in the original request and some configuration
> glue. Good luck
>
> (BTW, I initially thought there might be something in mod_autoindex to
> run a custom script, but it doesn't look like there is.)
>
> --
>
> http://www.otton.org/
>
--- End Message ---
--- Begin Message ---
Ólafur Waage schreef:
Robert, thanks for the reply but i had tried __FILE__ and __DIR__
(which is dirname(__FILE__)) but it doesnt work.
__DIR__ only came into existence very recently IIRC,
realpath(dirname(__FILE__)); will tell you what directory the
*current script* is actually living in ... anything $_SERVER won't
help you as is, although it might seem to under certain conditions.
your looking to determine what the directory is of the script that
was originally called by the webserver, after any magic URL rewriting, etc
has taken place ... this is actually a PITA to do under certain situations,
and by the sounds of it your trying to build something that will work
regardless.
I run into this stuff before and ended up have to generate the information
myself based on various values like $_SERVER["DOCUMENT_ROOT"],
$_SERVER["PATH_INFO"]
and $_SERVER["REQUEST_URI"].
to be clear, your not looking for 'the current directory' but rather
something more vague i.e. 'the local absolute path to the directory
that maps to the URL that the user requested' (the code to determine that
will probably be as annoying to grok as that last sentence ;-)
And thanks for the reply also Ashley but as i said in my first post, i
had tried $_SERVER with limited results
Ólafur Waage
2008/8/23 Robert Cummings <[EMAIL PROTECTED]>:
On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote:
On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage <[EMAIL PROTECTED]> wrote:
I'll throw out an example here.
I have a directory structure of: /var/www/example/
And in that i have a file: index.php
That file echo's getcwd() and returns: /var/www/example/
Now i tell Apache or Lighty that if a directory does not have an
index.php file, that it should use /example/index.php (for example via
DirectoryIndex of Apache)
Then i make a new directory: /var/www/test/
And browse to it and it echo's /var/www/example/ since its running
that file via DirectoryIndex
This is true for all directories i make. Both for Windows and Linux
based servers.
To my question.
I am trying to get the full path of the current directory i am in. Not
from where the file is executing. How is that possible so it displays
a full path to that directory (regardless to the server setup)?
I have tried a variation of things and have gotten mixed results.
Using $_SERVER["SCRIPT_FILENAME"] gives me the index file and the full
path to that.
$_SERVER["DOCUMENT_ROOT"] gets me part of the way but on a hosted
server with multiple domains it only gives me a partial path (rough
example: /var/www/ when the directory is /var/www/domain.com/test/)
And __FILE__ gives me the index.php's path.
I have also tried realpath(".");
And server("pwd"); with no luck.
Any help would be appreciated.
Ólafur Waage
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Maybe dirname(__FILE__) will help.
When I'm looking for candidates to determine stuff like this I usually
do print_r( $_SERVER ) and see what's what.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
What is the point of figuring that out? If we knew that, we might be
able to help you with a solution. As it stands what you want is not
possible AFAIK.
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
Ólafur Waage wrote:
> I am within a certain directory of the server via the browser.
>
> Example:
>
> http://www.example.com/foo/bar
> would be
> /var/www/example.com/foo/bar
>
> And Apache's DirectoryIndex feature is opening a index.php file that
> is located at
> /var/www/example.com/test/index.php
>
> And from that file i need to figure out the full local path of
> /foo/bar (which would be /var/www/example.com/foo/bar ) or any other
> directory i browse too.
>
> Ólafur Waage
>
>
>
--- End Message ---
--- Begin Message ---
Hi,
I am fairly new to PHP. I would like to serve a page to a user based on
his input. Say, I have a page 1 where user has 3 options(drop down
menu). Based on his selection I would like a php script to direct him to
another page (to pages 2,3,4 based on what he selected). I am unable to
figure how to do this in php. Can you please give me some pointers.
Is there any function which takes path and directs the user to that page?
Thanks,
Prasad
--- End Message ---
--- Begin Message ---
You can read about the header function.
http://is2.php.net/manual/en/function.header.php
Ólafur Waage
2008/8/23 Prasad Chand <[EMAIL PROTECTED]>:
> Hi,
>
> I am fairly new to PHP. I would like to serve a page to a user based on his
> input. Say, I have a page 1 where user has 3 options(drop down menu). Based
> on his selection I would like a php script to direct him to another page (to
> pages 2,3,4 based on what he selected). I am unable to figure how to do this
> in php. Can you please give me some pointers.
>
> Is there any function which takes path and directs the user to that page?
>
> Thanks,
> Prasad
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Prasad Chand schreef:
Hi,
I am fairly new to PHP. I would like to serve a page to a user based on
his input. Say, I have a page 1 where user has 3 options(drop down
menu). Based on his selection I would like a php script to direct him to
another page (to pages 2,3,4 based on what he selected). I am unable to
figure how to do this in php. Can you please give me some pointers.
Is there any function which takes path and directs the user to that page?
millions of them, but not in php itself this is the kind of thing
you have to write yourself.
you don't really want to redirect the user at all (because it's a completely
unecessary round-trip that will cause your server to have to handle another
request when you already have the required info needed to display the relevant
content),
what you want to do is parse the input from the form and then run the relevant
code to generate the relevant content. e.g.
if (isset($_POST['selected_page'])) {
switch ($_POST['selected_page']) {
case 'page1':
include 'myfirstpage.php';
exit;
case 'page2':
include 'mysecondpage.php';
exit;
case 'page3':
include 'mythirdpage.php';
exit;
default:
die('go away smelly hacker!');
}
} else {
// output your page selection form here or something.
}
that's just one lame example, there are as many ways to skin this
cat as there are cats. might I suggest you go and read a few basic
tutorials because what your asking is as basic as it gets ... namely
take some user input and use it to determine what to output ...
Thanks,
Prasad
--- End Message ---
--- Begin Message ---
Ólafur Waage schreef:
You can read about the header function.
http://is2.php.net/manual/en/function.header.php
hi Ólafur,
his situation doesn't require a redirect (he only thinks it does),
and redirects suck when used unecessarily. (plenty of info on the web
about why this is so ... hunt for a 'rant' by the formidable Richard Lynch
in the archives of this list for instance)
Ólafur Waage
2008/8/23 Prasad Chand <[EMAIL PROTECTED]>:
Hi,
I am fairly new to PHP. I would like to serve a page to a user based on his
input. Say, I have a page 1 where user has 3 options(drop down menu). Based
on his selection I would like a php script to direct him to another page (to
pages 2,3,4 based on what he selected). I am unable to figure how to do this
in php. Can you please give me some pointers.
Is there any function which takes path and directs the user to that page?
Thanks,
Prasad
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
At 2:03 PM -0700 8/23/08, Prasad Chand wrote:
Hi,
I am fairly new to PHP. I would like to serve a page to a user based
on his input. Say, I have a page 1 where user has 3 options(drop
down menu). Based on his selection I would like a php script to
direct him to another page (to pages 2,3,4 based on what he
selected). I am unable to figure how to do this in php. Can you
please give me some pointers.
Is there any function which takes path and directs the user to that page?
Thanks,
Prasad
Why use PHP for this?
Standard html with css works quite well for this and is by far more common.
I see no need to bring the php sledgehammer to drive this thumbtack.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
At 1:21 AM +0100 8/24/08, Ashley Sheridan wrote:
On Sat, 2008-08-23 at 20:07 -0400, tedd wrote:
At 2:03 PM -0700 8/23/08, Prasad Chand wrote:
>I am fairly new to PHP. I would like to serve a page to a user based
on his input. Say, I have a page 1 where user has 3 options(drop
down menu). Based on his selection I would like a php script to
direct him to another page (to pages 2,3,4 based on what he
selected). I am unable to figure how to do this in php. Can you
please give me some pointers.
>Is there any function which takes path and directs the user to that page?
Why use PHP for this?
Standard html with css works quite well for this and is by far more common.
I see no need to bring the php sledgehammer to drive this thumbtack.
Standard HTML and CSS will not do, you'd have to use JavaScript to
guarantee it all works correctly on the browser, but this is a bit
like using a dozen thumbs for one thumbtack! If you do it entirely
on the client-side, then each time a visitor wants any of the
"pages", the whole lot is sent to the browser, which is a real bad
idea!
I was addressing providing the user with pages and not the drop-down
menu thing. If you want to entertain a drop-down menu, please review
this:
http://sperling.com/examples/menuh/
That uses html, css, and javascript -- and while I show how to do it,
I would not recommend it for anyone.
Besides, there's no way that php can deliver a drop-down menu because
the user's action are client-side. I've thought about using php with
ajax, but why? It won't work any better.
But, without the drop-down issue, then css and html will deliver
pages quite nicely, like this:
http://sperling.com/index.php
My right side navigation is totally css and html. If you don't want
right navigation, then there's a lot more possibilities, check out:
http://css.maxdesign.com.au/listamatic/
All of these are designed to provide the end-user with the topic
(i.e., page) of their choice -- all without php.
Now, is this something that I'm not getting? Because all of this is
pretty obvious to me. Where am I wrong?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
Prasad Chand schreef:
Hi,
I am fairly new to PHP. I would like to serve a page to a user based
on his input. Say, I have a page 1 where user has 3 options(drop down
menu). Based on his selection I would like a php script to direct him
to another page (to pages 2,3,4 based on what he selected). I am
unable to figure how to do this in php. Can you please give me some
pointers.
Is there any function which takes path and directs the user to that page?
millions of them, but not in php itself this is the kind of thing
you have to write yourself.
you don't really want to redirect the user at all (because it's a
completely
unecessary round-trip that will cause your server to have to handle another
request when you already have the required info needed to display the
relevant content),
what you want to do is parse the input from the form and then run the
relevant
code to generate the relevant content. e.g.
if (isset($_POST['selected_page'])) {
switch ($_POST['selected_page']) {
case 'page1':
include 'myfirstpage.php';
exit;
case 'page2':
include 'mysecondpage.php';
exit;
case 'page3':
include 'mythirdpage.php';
exit;
default:
die('go away smelly hacker!');
}
} else {
// output your page selection form here or something.
}
that's just one lame example, there are as many ways to skin this
cat as there are cats. might I suggest you go and read a few basic
tutorials because what your asking is as basic as it gets ... namely
take some user input and use it to determine what to output ...
Thanks for your reply Jochem. I will keep your advice in mind. This is
off-topic, but the reason I was touchy about includes was because it
could create seo problems.
http://forums.digitalpoint.com/showthread.php?t=31519
Thanks again,
Prasad
Thanks,
Prasad
--- End Message ---
--- Begin Message ---
Stut schreef:
On 22 Aug 2008, at 20:48, Jochem Maas wrote:
Stut schreef:
define('TPL_DIR', dirname(__FILE__).'/tpl/');
function TPL($__filename, $__data = array(), $__return = false)
{
$__retval = '';
$__tplfilename = TPL_DIR.$__filename;
if (file_exists($__tplfilename))
{
if ($__return) ob_start();
extract($__data);
require($__tplfilename);
if ($__return)
{
$__retval = ob_get_contents();
ob_end_clean();
}
else { ob_end_flush(); return; } // I'm guessing this should be in
there too
Nope, not even a little bit. The output buffer is only opened if we are
returning the output from the template.
feck. your right of course, I was still sleeping I guess :-)
-Stut
}
else
{
trigger_error('Template not found: '.$__filename, E_USER_ERROR);
}
return $__retval;
}
// Example usage
TPL('layout/header.tpl.php', array('title' => 'This is the page
title'));
TPL('index.tpl.php');
TPL('layout/footer.tpl.php');
-Stut
On 22 Aug 2008, at 17:26, OOzy Pal wrote:
Hello
Can any one direct to very very tiny simple php template code. I
want to use
it for 5-6 pages website.
Thank you
--
OOzy
Ubuntu-Hard
--- End Message ---