Announcement

Collapse
No announcement yet.

Too many periods in email address

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    Originally posted by glennrocksvb View Post
    you named it apache2test.php not apache2.php.
    Doh! I just now tried accessing the file. The URL is https://www.kubuntuforums.net/apache2test.php and now it returns:

    string(4) "root" bool(false) bool(false)
    The Linux Community has given me much. I do what I can to return the favor!

    Comment


      #32
      I ran https://www.kubuntuforums.net/apache2test.php and this is the output. It returns false for is_dir and is_writable. That's why the mod logging to CSV doesn't work.

      string(4) "root" bool(false) bool(false)
      Buy me a coffeePayPal QR Code
      My Amazon Affiliate Link
      Fast vBulletin VPS Host:
      This site is hosted by IONOS

      Comment


        #33
        So it turns out that /var/log/apache2/blockedregistrations​ directory doesn't exist at all.
        Buy me a coffeePayPal QR Code
        My Amazon Affiliate Link
        Fast vBulletin VPS Host:
        This site is hosted by IONOS

        Comment


          #34
          Originally posted by glennrocksvb View Post
          So it turns out that /var/log/apache2/blockedregistrations​ directory doesn't exist at all.
          But that is patently untrue!

          Click image for larger version  Name:	Screen Shot 2025-09-23 at 12.00.28 PM.png Views:	0 Size:	373.3 KB ID:	33126

          And I know that the directory is writable by root, as I tested that by creating a .txt file in it while I was logged into our server, and changing to root.
          The Linux Community has given me much. I do what I can to return the favor!

          Comment


            #35
            Update the test PHP file with this:

            PHP Code:
            <?php
            $path = '/var/log/apache2/blockedregistrations';
            clearstatcache(true, $path);
            
            echo "Input path: $path<br />";
            echo "realpath: " . realpath($path) . "<br />";
            echo "file_exists: " . (file_exists($path) ? 'true' : 'false') . "<br />";
            echo "is_dir: " . (is_dir($path) ? 'true' : 'false') . "<br />";
            echo "is_writable: " . (is_writable($path) ? 'true' : 'false') . "<br />";
            echo "Current user: " . exec('whoami') . "<br />";
            echo "PHP SAPI: " . php_sapi_name() . "<br />";
            echo "open_basedir: " . ini_get('open_basedir') . "<br />";
            Buy me a coffeePayPal QR Code
            My Amazon Affiliate Link
            Fast vBulletin VPS Host:
            This site is hosted by IONOS

            Comment


              #36
              Done.

              Input path: /var/log/apache2/blockedregistrations
              realpath:
              file_exists: false
              is_dir: false
              is_writable: false
              Current user: www-data
              PHP SAPI: apache2handler
              open_basedir:​
              The Linux Community has given me much. I do what I can to return the favor!

              Comment


                #37
                Thanks, this output reveals the root cause very clearly. PHP can't see the path (realpath is empty). This is because the PHP actually runs as www-data. You have 2 options to fix this issue:

                Option 1: Change owner to www-data. PHP can read/write, others cannot.
                Code:
                sudo chown www-data:www-data /var/log/apache2/blockedregistrations
                sudo chmod 750 /var/log/apache2/blockedregistrations
                Option 2: Keep owner as root (e.g., for system oversight), but change group to www-data to allow PHP write access.
                Code:
                sudo chown root:www-data /var/log/apache2/blockedregistrations
                sudo chmod 770 /var/log/apache2/blockedregistrations
                Buy me a coffeePayPal QR Code
                My Amazon Affiliate Link
                Fast vBulletin VPS Host:
                This site is hosted by IONOS

                Comment


                  #38
                  Originally posted by glennrocksvb View Post
                  You have 2 options to fix this issue:
                  Just tried both options. The output from running apache2test.php from the browser is the same.

                  First:
                  chown to www-data:www-data /var/log/apache2/blockedregistrations
                  chmod to 750 /var/log/apache2/blockedregistrations

                  Results:

                  Input path: /var/log/apache2/blockedregistrations
                  realpath:
                  file_exists: false
                  is_dir: false
                  is_writable: false
                  Current user: www-data
                  PHP SAPI: apache2handler
                  open_basedir:​

                  Second:
                  chown to root:www-data /var/log/apache2/blockedregistrations
                  chmod to 770 /var/log/apache2/blockedregistrations

                  Results:

                  Input path: /var/log/apache2/blockedregistrations
                  realpath:
                  file_exists: false
                  is_dir: false
                  is_writable: false
                  Current user: www-data
                  PHP SAPI: apache2handler
                  open_basedir:​
                  The Linux Community has given me much. I do what I can to return the favor!

                  Comment


                    #39
                    It seems that although PHP has the right permissions to the directory, the parent directory (/var/log/apache2) permissions prevent www-data from accessing it. It's not recommended to open up /var/log/apache2 so I advise you to move the CSV directory outside /var/log/apache2 and place it in a dedicated storage path, like /var/www/data.

                    Code:
                    sudo mkdir -p /var/www/data/blockedregistrations
                    sudo chown -R www-data:www-data /var/www/data
                    sudo chmod -R 750 /var/www/data
                    Then change the mod settings for the CSV path to /var/www/data/blockedregistrations
                    Buy me a coffeePayPal QR Code
                    My Amazon Affiliate Link
                    Fast vBulletin VPS Host:
                    This site is hosted by IONOS

                    Comment


                      #40
                      Originally posted by glennrocksvb View Post
                      Then change the mod settings for the CSV path to /var/www/data/blockedregistrations


                      The CSV path should actually be /var/www/data/blockedregistrations/blockedusers or whatever filename (red part) you want to use.
                      Buy me a coffeePayPal QR Code
                      My Amazon Affiliate Link
                      Fast vBulletin VPS Host:
                      This site is hosted by IONOS

                      Comment


                        #41
                        Success!
                        Code:
                        root@kfn1:/var/www/data/blockedregistrations# list
                        total 12
                        drwxr-x--- 2 www-data www-data 4096 2025-09-23 18:12:07 .
                        drwxr-x--- 3 www-data www-data 4096 2025-09-23 18:06:47 ..
                        -rw-r--r-- 1 www-data www-data  222 2025-09-23 18:12:07 gmail_block_log.csv
                        
                        ​
                        Code:
                        root@kfn1:/var/www/data/blockedregistrations# cat gmail_block_log.csv
                        Date,Email,Username,"IP Address",Useragent
                        "2025-09-23 18:12:07",[email protected],justsomenewguy,66.41.172.97,"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:144.0) Gecko/20100101 Firefox/144.0"
                        
                        ​
                        The Linux Community has given me much. I do what I can to return the favor!

                        Comment


                          #42
                          Originally posted by glennrocksvb View Post
                          The CSV path should actually be /var/www/data/blockedregistrations/blockedusers or whatever filename you want to use.
                          Well, I didn't do that; did as you said just before, so the path I have is:

                          /var/www/data/blockedregistrations

                          and the file was created anyway. Why?
                          The Linux Community has given me much. I do what I can to return the favor!

                          Comment


                            #43
                            Originally posted by Snowhog View Post
                            Success!
                            FInally! 😊

                            Originally posted by Snowhog View Post
                            and the file was created anyway. Why?
                            I coded the mod to automatically create the CSV file with a default filename gmail_block_log if filename is not specified. 😎
                            Buy me a coffeePayPal QR Code
                            My Amazon Affiliate Link
                            Fast vBulletin VPS Host:
                            This site is hosted by IONOS

                            Comment


                              #44
                              BTW, do not forget to delete the apache2test.php file.
                              Buy me a coffeePayPal QR Code
                              My Amazon Affiliate Link
                              Fast vBulletin VPS Host:
                              This site is hosted by IONOS

                              Comment


                                #45
                                Originally posted by glennrocksvb View Post
                                I coded the mod to automatically create the CSV file with a default filename gmail_block_log if filename is not specified.
                                Kinda figured that was the case, after I asked the question.
                                Originally posted by glennrocksvb View Post
                                BTW, do not forget to delete the apache2test.php file.
                                Done.

                                Thank you very much for seeing me through this. Very much appreciated!
                                The Linux Community has given me much. I do what I can to return the favor!

                                Comment


                                • glennrocksvb
                                  commented
                                  Editing a comment
                                  Glad to help! Thanks for the coffee 🍵

                              Latest Posts

                              Collapse

                              Working...
                              X
                              Searching...Please wait.
                              An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

                              Please push the back button and reload the previous window.'
                              An unexpected error was returned: 'Your submission could not be processed because the token has expired.

                              Please push the back button and reload the previous window.'
                              An internal error has occurred and the module cannot be displayed.
                              There are no results that meet this criteria.
                              Search Result for "|||"