Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

page.php? Can someone assist with this

Quote Reply
page.php? Can someone assist with this
Hello, I looked through the posts here first and didnt really see a detailed answer as to how I can resolve this problem.

I did the install and noticed page.php is placed in my cgi-bin and when I tried to access it from the Links SQL admin I get an internal server error. I guess what I really would like to know is why this page needs to be executed from the cgi directory? could this be a security risk? I'm sorry if I've overlooked something here but it seemed to make the php version work according to the install files I have I will have to reconfigure my server...is this what others are doing and is it recommended?

I had really bought this script because the php functionality but am somewhat bummed out after 2 days not sure how to make it work, if possible can someone give a detailed explanation of whats needs to be done...I read other references to editing something like db_cgi_url everywhere but not really sure where the comments are located to edit...is it possible you guys have an actual install script that makes the php work anywhere other* than my cgi? If not can you please explain exactly the security risks if I do allow this script to be executed from there.

Sorry but I did'nt really see much reference anywheres to this, thanks for your help.



Cheers from Downtown Van :)

Riley
Quote Reply
Re: [Riley] page.php? Can someone assist with this In reply to
In Reply To:
I guess what I really would like to know is why this page needs to be executed from the cgi directory?
It doesn't have to be Smile It's just installed there by default. You can move it anywhere you please (as long as you update this location in the admin => Setup => Paths and URLs => db_php_url). This information is also in the README.php (so next time, remember to check the README's). BTW, the reason you get an internal server error is because your webserver is configured to treat everything inside cgi-bin as a CGI (well when you try access the file from the web). Since the PHP file can't be executed as a CGI, you get the internal server error.

Adrian
Quote Reply
Re: [brewt] page.php? Can someone assist with this In reply to
Thanks for the quick reply Adrian, I have done what you suggested and had actually done this yesterday :) , just didnt realize that line was named db_php_url.



When I moved my page,php to http://www.mysite.com/page.php I now get the following "No such template set: mint" when I try to visit the page? any idea why this may be...sorry I didnt see this mentioned in the readme.
Quote Reply
Re: [Riley] page.php? Can someone assist with this In reply to
In Reply To:
When I moved my page,php to http://www.mysite.com/page.php I now get the following "No such template set: mint" when I try to visit the page?
You have to convert the GT templates to the PHP equivalent using the script that's in admin/Links/PHP. I think I should add that to the README.php Smile. Note to run it you'll need shell (telnet/ssh) access.
It's relatively easy to run. All you pretty much have to do is go:
perl convert.pl --template=mint
and this will create a new template set mint_php.

Adrian
Quote Reply
Re: [brewt] page.php? Can someone assist with this In reply to
Oops, looks like there's a small bug in the convert.pl script. On line ~228:
Code:
s|<%build_images_url%>/default|<?print \$CFG['build_images_url']?>/default|g;
Should be:
Code:
s|<%build_images_url%>|<?print \$CFG['build_images_url']?>|g;

Adrian
Quote Reply
Re: [brewt] page.php? Can someone assist with this In reply to
Expanding on that, we only ship the "default" look that you see at:

http://gossamer-threads.com/...ks-sql2/page.cgi?d=1

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] page.php? Can someone assist with this In reply to
Thanks alot for the suggestions guys, both worked perfectly and after the mod to convert.pl I have the mint_php templates but have one slight problem, when i go to edit the look through the global variables I get a fatal error like this... note I broke the lines here so the code would fit when I post. Basically I am trying to edit the globals to hopefully have it look more like the site, tried changing globals.txt permissions and didnt seem to resolve errors.





A fatal error has occured:
GT::Config (23657): Unable to open '/home/www/docs/www.mysite.com/cgi-bin/links_SQL/admin/templates/mint_php/local/globals.txt' for writing: Permission denied. at /home/www/docs/www.mysite.com/cgi-bin/links_SQL/admin/Links/Tools.pm line 355. Thanks again for your help

Quote Reply
Re: [Riley] page.php? Can someone assist with this In reply to
is the locals directory chmod 777?
Also is the globals.txt writable by the webuser (chmod 777 if you're not sure).

Adrian
Quote Reply
Re: [brewt] page.php? Can someone assist with this In reply to
Yes the local directory that is located at mint_php/local is chmod 777 and inside there is a globals.txt



**Before I got this reply I had just edited the file at mint_php/global.txt and now my page.php looks fine :) ...though is this wrong what I just edited and will it cause probs later?



I also notice when someone trys to enter a link they get odd error...check here http://www.dr7.com/page.php?do=add <----notice the referrer line?

Thanks again Adrian
Quote Reply
Re: [Riley] page.php? Can someone assist with this In reply to
That's another quirk of using the PHP front end. You don't use Perl in the globals. For examples on how to do equivalents in PHP, see the time and date globals.
It would be something like:
Code:
create_function("", '
global $HTTP_SERVER_VARS;
return isset($HTTP_SERVER_VARS["HTTP_REFERER"]) ? $HTTP_SERVER_VARS["HTTP_REFERER"] : "nowhere";
');
Remember, when you use the tag in the template, you access it by:
<?print $referrer()?>

Note the ()'s, as now it's a function, not a regular variable.

Adrian

Last edited by:

brewt: Feb 19, 2002, 11:19 PM
Quote Reply
Re: [brewt] page.php? Can someone assist with this In reply to
Okay so should I be editing the file located at mint_php/globals.txt or the one at mint_php/local/globals.txt ?? I initially edited the one at mint_php/global.txt and though I have the proper color I get that one error

Note: The mint_php directory is is set to 777 , the local directory is set to 777 global.txt file in both directorys is set to 644...is this correct?

?? Why can I not access and change this global file from the LinksSQL interface and get the error

A fatal error has occured:GT::Config (24538): Unable to open '/home/www/docs/www.dr7.com/cgi-bin/links_SQL/admin/templates/mint_php/local/globals.txt' for writing: Permission denied. at /home/www/docs/www.dr7.com/cgi-bin/links_SQL/admin/Links/Tools.pm line 355.

I would feel a bit better being able to edit the globals through a browser than having to telnet in.



***If I do telnet in do I simply change the part in my globals.txt from



'referer' => 'sub { my $ref = $ENV{HTTP_REFERER} || \'nowhere\'; return $ref; }',



TO



'referer' => create_function("", \'
global $HTTP_SERVER_VARS;
return isset($HTTP_SERVER_VARS["HTTP_REFERER"]) ? $HTTP_SERVER_VARS["HTTP_REFERER"] : "nowhere";
\');



Sorry I am very confused here and need a step by step to resolve this error, thanks Adrian



Riley
Quote Reply
Re: [Riley] page.php? Can someone assist with this In reply to
In Reply To:
Okay so should I be editing the file located at mint_php/globals.txt or the one at mint_php/local/globals.txt ??
It's best you don't edit the globals.txt (or language.txt) directly. You should do it in the admin. But if you do edit the directly, you should be changing the template/local/globals.txt. If you add/del/modify globals from the admin, they will be saved in the local directory (same with templates as well). This is so that when you upgrade, your templates that you've modified don't get overwritten.

In Reply To:
Note: The mint_php directory is is set to 777 , the local directory is set to 777 global.txt file in both directorys is set to 644...is this correct?
You need to have the permissions set so that the httpd user (usually nobody) can read and write to the files/directory. If you don't know what user it runs as, then the files in the template directory should be set to 777 as well.

In Reply To:
A fatal error has occured: GT::Config (24538): Unable to open '/home/www/docs/www.dr7.com/cgi-bin/links_SQL/admin/templates/mint_php/local/globals.txt' for writing: Permission denied. at /home/www/docs/www.dr7.com/cgi-bin/links_SQL/admin/Links/Tools.pm line 355.
The user that the httpd runs as doesn't have enough permissions to write to the file. You probably want to chmod 777 the globals.txt.

In Reply To:
Sorry I am very confused here and need a step by step to resolve this error, thanks Adrian
  • Fix the permission error by chmod 777 the files in the template directory (including local)
  • Then you should now be able to add globals in the admin.
    You'll want to type in:
    referrer
    in the Code field (the left one)
    Then:
    Code:
    create_function("", '
    global $HTTP_SERVER_VARS;
    return isset($HTTP_SERVER_VARS["HTTP_REFERER"]) ? $HTTP_SERVER_VARS["HTTP_REFERER"] : "nowhere";
    ');
    in the Description field (middle)
    Then Save changes.

    Remember that with the PHP templates, and the globals for these PHP templates, you can use any valid PHP code. You CAN'T use Perl code in the templates or the globals.

    Adrian
  • Last edited by:

    brewt: Feb 20, 2002, 12:00 AM
    Quote Reply
    Re: [brewt] page.php? Can someone assist with this In reply to
    Right on Adrian got it resolved! :) , okay I did like you said and chmod global.txt to 777 and then was able to change the variable through admin...but then when I checked page.php again I thought dammit!! who is "lamda_11, lambda_5" etc. and then thought about your last words...NO perl in templates as well as globals...I then changed template to <?print $referer()?> like you mentioned earlier...fixed :) , thanks!!



    Riley
    Quote Reply
    Re: [Riley] page.php? Can someone assist with this In reply to
    Another option is to skip globals all together and just edit your template. So instead of putting:

    <?print $referer()?>

    Put:

    <? print isset($HTTP_SERVER_VARS["HTTP_REFERER"]) ? $HTTP_SERVER_VARS["HTTP_REFERER"] : "nowhere";?>

    in the template. Remember these are php pages and will get parsed by php so you can put any valid php code you like in your template.

    Cheers,

    Alex
    --
    Gossamer Threads Inc.
    Quote Reply
    Re: [Alex] page.php? Can someone assist with this In reply to
    hiya,

    Is there any way of doing this without Telnet / SSH access?

    I did a copy of av template as a base to work from, need to run a php script on the details template page. I changed the extentions to .php in the setup > build options, but the script isn't running.

    On page.php , i get no such template set: date. (which is the modified version of av).



    Cheers.
    Quote Reply
    page.php file permissions In reply to
    hello,

    i've just installed LINKS SQL on my server and now i noticed that the file permission of page.php is set to 644... is this correct or i need to chmod to 755 as the other (add.cgi, jump.cgi etc.) files?!?

    thank you very much!
    Quote Reply
    Re: [chico] page.php file permissions In reply to
    PHP files, unlike Perl ones, do NOT need to be CHMODed. Only files that need to be written to need a 666 CHMOD.

    page.php can stay at 644 Smile

    Cheers

    Andy (mod)
    andy@ultranerds.co.uk
    Want to give me something back for my help? Please see my Amazon Wish List
    GLinks ULTRA Package | GLinks ULTRA Package PRO
    Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
    Quote Reply
    Re: [Andy] page.php file permissions In reply to
    thanks! Smile