We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30821
    • 13 Posts
    i’ve been trying some different combinations now. changing the chmod in the codes, changing the permissions via cuteftp, but no success.
    my problem is that i need to upload about 1000 images through ftp and then the idea was to resync the gallery. i actually managed to do a resync at some point, but then it stopped working again, dont ask me why. the problem seems to be who is creating the files and folders on the server, the script or I. The dont seem to work sharing the same files and folders...

    I can upload pics from the web interface, though getting the error, but the pics show up anyway after....

    and now i even got another error message:

    PHP error debug
    Error: chmod() [function.chmod]: stat failed for assets/galleries/54/1top.png
    Error type/ Nr.: Warning - 2
    File: /home/d2152/xxxxxx/assets/snippets/maxigallery/maxigallery.php
    Line: 372
    Line 372 source: chmod($mg->path_to_gal.$name,0644);



    I give up for now. sucks, but i guess i have to wait for another version...
      • 32093
      • 21 Posts
      Could one possible solution be to use the ftp commands in Maxigallery?

      That way I could be uploading the images as a different user thus getting by this problem of permission.
        • 7923
        • 4,213 Posts
        I don’t know, try it out and report back how it went. You need to use the following parameters: &ftp_base_dir, &ftp_pass, &ftp_port, &ftp_server, &ftp_user. See MaxiGallery wiki page for more details. Usually the FTP commands are used when you get a different kind of error, but you can try if it helps..

        Quote from: turtle_in_time at Jan 16, 2008, 01:15 AM

        I give up for now. sucks, but i guess i have to wait for another version...
        I’m not very optimistic in getting this fixed in next release either, because I don’t have a clue what’s the problem. The fixes I have done are in this post and I have made the CHMOD values configurable by parameters.. that’s all..


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 32093
          • 21 Posts
          Ok here we go now thinking outside the box!

          How about if we can write a piece of php code which does a CHOWN or CHMOD as a different user to "take control" of the file we are trying to change rights on?

          Effectively all we are trying to do if change the permissions on our files as the master ftp account, ie not the default apache one.

          Any one know how? I’ll carry on google-ing in the mean time!
            • 32093
            • 21 Posts
            Just to clarify this a bit further.

            The problem is that the Maxigallery snippet is not being allowed to CHMOD the thumbnail file after creation, hence the error. (and thumbnail doesnt show)

            This is always solved by logging on through an FTP client (filezilla for example) as the master ftp account and CHMOD the file manually, then the file shows.

            Obviously my clients cant be asked to do this, so we need to find a way in php where we can log on as ftp master and CHMOD the file.
              • 7923
              • 4,213 Posts
              and using the ftp commands in maxigallery does not help?

              edit: and could you paste the error when using ftp commands.. thanks..


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 32093
                • 21 Posts
                There wasnt an error with the ftp commands, just the same error as before,

                ***************************************************************************************
                Error: chmod() [function.chmod]: No such file or directory
                Error type/ Nr.: Warning - 2
                File: /home/xxxxxxx/public_html/assets/snippets/maxigallery/maxigallery.php
                Line: 374
                Line 374 source: chmod($mg->path_to_gal.$name,0644);
                ***************************************************************************************

                Its definately a permissions problem, ie the default apache users cant CHMOD the file.

                When it uploads the file at first it is given a setting of 0600. it just cant seem to reset this to 644.


                  • 32093
                  • 21 Posts
                  Here’s some code I found that, (I think) might work.

                  It would need to be embedded in the snippet...

                  <?php
                  $file = ’public_html/index.php’;

                  // set up basic connection
                  $conn_id = ftp_connect($ftp_server);

                  // login with username and password
                  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

                  // try to chmod $file to 644
                  if (ftp_chmod($conn_id, 0644, $file) !== false) {
                  echo "$file chmoded successfully to 644\n";
                  } else {
                  echo "could not chmod $file\n";
                  }

                  // close the connection
                  ftp_close($conn_id);
                  ?>

                  anyone care to comment on this?
                    • 7923
                    • 4,213 Posts
                    I did the ftp commands at that time because there was a problem that if the galleries folder was CHMOD by using php chmod function, the move_uploaded_file function call failed in some environment because the script did not have rights to move uploaded files into those folders. That was fixed by doing the CHMOD to folders using ftp commands and after that move_uploaded_file and chmod php functions worked.

                    But in your case, you probably want that all chmod operations are done using ftp commands, so what you could try to do is following:

                    in maxigallery.php line 372 change:
                    chmod($mg->path_to_gal.$name,0666);
                    

                    to:
                    	if(!$mg->mgconfig['use_ftp_commands']) {
                                chmod($mg->path_to_gal.$name,0666);
                    	} else {
                                $connect = ftp_connect($mg->mgconfig['ftp_server'], $mg->mgconfig['ftp_port']);
                                if (!$connect) {
                                	$output = 'Connection to FTP failed.'; 
                                	return;
                                }
                                $login = ftp_login($connect, $mg->mgconfig['ftp_user'], $mg->mgconfig['ftp_pass']);
                                if (!$login) {
                                	$output = 'Could not login to FTP.'; 
                                	return;	
                                }
                                $changeDir = ftp_chdir($connect, $mg->mgconfig['ftp_base_dir'].$path_to_galleries.$mg->pageinfo['id'].'/');
                                if (!$changeDir) {
                                	$output = 'Could not change directory to: '.$mg->mgconfig['ftp_base_dir'].$path_to_galleries;
                                	return;
                                }
                                $old_umask = umask(0);
                                $setPerm = ftp_site($connect, 'CHMOD 0666 /'.$mg->path_to_gal.$name);
                                if (!$setPerm) {
                                	$output = 'Could not set permissions: '.'CHMOD 0666 /'.$mg->path_to_gal.$name;
                                }
                                umask($old_umask);
                                ftp_close($connect);
                              }
                    


                      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                      • 32093
                      • 21 Posts
                      Hi,

                      the above code didnt work.

                      I’m beginning to think that its maybe not the configuration of my server since I tried it on my windows PC with Apache and the same error popped up.

                      It worries me that the actual error is saying "No such file or directory" as if its not finding the file.

                      Could there be a MODx configuration issue going on here?? because the file definately does exist.