SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member Ralf-J's Avatar
    Join Date
    Oct 2001
    Location
    Hannover, Germany
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP/JavaScript/ writing on a UNIX server

    Hi,

    what I have tried is the following:

    I have a site using php. The html pages include beside the css stuff two JavaScript files into every HTML-page. PHP reads in addition a normal textfile to get a configuration for the menue. The menue's configuration is a combination between this textfile and one of the JavaScript files. Both have to be updated online.

    I know that i could use a database to hold the dynamic data but I want to try it by reading and overwriting this two files. Everything worked fine on my local network (NT/Apache/PHP4).

    After uploading the site to my domain I got errors when the script tried to unlink / rename the files. I can't recall it but I guess it was 'fopen failes no permission...'.

    The php code includes a function which tries different modes to delete the files if unlink doesn't work.

    suppr("../js/openpage.js");

    function suppr($file) {
    $delete = @unlink($file);
    if (@file_exists($file)) {
    $filesys = eregi_replace("/","\\",$file);
    $delete = @system("del $filesys");
    if (@file_exists($file)) {
    $delete = @chmod ($file, 0666); /* was 0755 */
    $delete = @unlink($file);
    $delete = @system("del $filesys");}}}

    But basicly I think there is a problem with the rights on my domains server. So I've tried to set the attributes to 666 but it doesn't seem to work. I have no clue about the rights on Unix but thought it could be better to move all files to the cgi-bin folder.

    When I had done that the HTML page seems to fail if it's going to include the JavaScript file. The link looks (in the PHP script)like this:

    <script language='JavaScript' src='../cgi-bin/openpage.js' type='text/javascript'></script>

    I'm not sure if it works with the 'cgi-bin' part in the link. I have also tried to move everything into the cgi-bin but now my php-scripts are no longer executed.

    I have pulled all my hairs out. I there someone who can send me to the right direction? All I want is to have two files on a Unix server which could be unlinked renamed by the user.

    Once again: I know I could do it by using my database but I'm just trying to learn about reading and writing something under PHP. I know that there would be a lot of security problems if I would use that, it's just an experiment.

    It would be great if I could get some help. Please excuse my bad english, I'm german



    regards

    Ralf-J.

  2. #2
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried:

    $delete = exec('rm $file');

    This executes the rm (delete) command directly through the UNIX shell.

    If this doesnt work either then its definatly an issue with server ownership settings.
    THE INSTRUCTIONS BELOW ARE OLD AND MAY BE INACCURATE.
    THIS INSTALL METHOD IS NOT RECOMMENDED, IT MAY RUN
    OVER YOUR DOG. <-- MediaWiki installation guide


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •