schwim

  • 16 May
  • Joined Jun 22, 2006
  • Hi there everyone,

    All of my forums are getting hammered by junk requests, it seems to be a thing for everyone, at least judging by phpBB's support forums.

    I'm currently handling it by blocking countries.(BR, CN, RU, VN, and SG), which is working to restore the forums to an operable status but I keep hitting geoplugin's cap and I'm unable to build my geoIP db quickly enough to handle the junk page requests.

    Is there a service out there with a relatively high cap for this sort of information or am I just out of luck until I eek out the necessary info from geoplugin?

    And just so I don't look like I'm holding forum participation over the head of people from these countries, none of these forums are active, they're test beds for me and the most active one has a total of 2 active members aside from me. That's why I'm not pursuing paid API access.

    Even if it's dropping down to other free services in the event my PHP request doesn't end in a 200 status, I'd be happy with that, I just can't find any other services with free tiers. All the links in old SE topics are dead.

    Thanks for your time!

    EDIT: to clarify, this is the service I'm currently using.

    $ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $viewing_user_ip));

    • This issue is making it impossible to have a discussion. With no notification emails, now not seeing a post count or bold subject leaves me needing to click every topic I'm interested in every time I visit the site to see if it's got replies.

      This is one example. The front page has missed 5 replies to this topic.

      Front page:

      In topic:

      EDIT: And this topic did not receive an update on the front page either.

    • dalecosp I do something similar. I don't add to the htaccess but my sites all run through index.php and the very first thing I do on page load is check for their existence in the ban table, stopping page load with a simple "banned" before spending any overhead on the visitor. The second thing I do is check URL string, UA, IP, POST/GET data, referer, etc for honeypot stuff, banning them if a match is found.

      Low effort ban results(like a script trying all the popular WP exploits) get a one hour ban while more serious efforts get 30 days.

    • sneakyimp I saw that but my PHP is not configured to use browscap so I figured I'd just grab some matches in the UA string for my needs. Also, it seems that the function returns a wealth of antiquated info and I just need OS and hints towards desktop/mobile.

      • Hi there guys, thanks very much for the help. That was indeed the issue. It seems unzipping onto the mounted file system b0rked the permissions. I ended up unzipping locally and moving the files over which resolved the issue.

        • Hi there everyone,

          You can visit this template at https://warcraftian.com

          I'm trying to move my template over to my server and I'm having a problem with including the files in the template(css and js). For some reason, it's resulting in a 403 error for both files. I've checked permissions and ownership and they show as correct.

          This file system is mounted as a network drive on my computer and I can open these files to edit, they are not corrupt or unreadable. I also loaded the file into the editor, saved it as a copy and tried to load those but those files failed to load as well.

          Can someone tell me what I'm getting wrong?

          My files:
          Working index(to show owner/group/permissions):

          web22@system:~/web$ pwd
          /var/www/clients/client1/web22/home/schwim_warweb/web
          web22@system:~/web$ ls -la
          total 80
          drwx--x--x 7 web22 client1 4096 Mar 19 09:36 .
          drwxr-xr-x 17 root root 4096 Mar 1 21:12 ..
          -rw-r--r-- 1 web22 client1 1017 Mar 10 09:28 blizzapitest.php
          -rw-r--r-- 1 web22 client1 162 Mar 17 14:01 composer.json
          -rw-r--r-- 1 web22 client1 26219 Mar 17 13:51 composer.lock
          -rw-rw-r-- 1 web22 client1 1150 Jun 23 2023 favicon.ico
          -rw-r--r-- 1 web22 client1 215 Jun 21 2023 .htaccess
          drwxr-xr-x 8 web22 client1 4096 Mar 17 15:17 includities
          -rw-r--r-- 1 web22 client1 3956 Mar 17 11:47 index.php
          drwxr-xr-x 3 web22 client1 4096 Mar 9 2023 lib
          -rw-r--r-- 1 web22 client1 31 Mar 9 2023 robots.txt
          drwxr-xr-x 2 web22 client1 4096 Mar 19 00:06 stats
          drwxr-xr-x 10 web22 client1 4096 Mar 17 13:58 vendor
          drwxr-xr-x 6 web22 client1 4096 Mar 10 10:41 ZZZ-unused
          web22@system:~/web$

          Non working files:

          eb22@system:~/web/includities/theme/darkmode$ cd css
          web22@system:~/web/includities/theme/darkmode/css$ ls -la
          total 1688
          drwx------ 2 web22 client1 4096 Dec 22 08:59 .
          drwx------ 6 web22 client1 4096 Dec 22 08:59 ..
          -rw-rw-r-- 1 web22 client1 392522 Dec 22 08:59 mdb.dark.min.css
          -rw-rw-r-- 1 web22 client1 84657 Dec 22 08:59 mdb.dark.min.css.map
          -rw-rw-r-- 1 web22 client1 394464 Dec 22 08:59 mdb.dark.rtl.min.css
          -rw-rw-r-- 1 web22 client1 377057 Dec 22 08:59 mdb.min.css
          -rw-rw-r-- 1 web22 client1 79413 Dec 22 08:59 mdb.min.css.map
          -rw-rw-r-- 1 web22 client1 379000 Dec 22 08:59 mdb.rtl.min.css
          web22@system:~/web/includities/theme/darkmode/css$

          and

          web22@system:~/web/includities/theme/darkmode/css$ cd ../js
          web22@system:~/web/includities/theme/darkmode/js$ ls -la
          total 1304
          drwx------ 2 web22 client1 4096 Dec 22 08:59 .
          drwx------ 6 web22 client1 4096 Dec 22 08:59 ..
          -rw-rw-r-- 1 web22 client1 167907 Dec 22 08:59 mdb.es.min.js
          -rw-rw-r-- 1 web22 client1 520668 Dec 22 08:59 mdb.es.min.js.map
          -rw-rw-r-- 1 web22 client1 126062 Dec 22 08:59 mdb.umd.min.js
          -rw-rw-r-- 1 web22 client1 505049 Dec 22 08:59 mdb.umd.min.js.map
          web22@system:~/web/includities/theme/darkmode/js$

          My inspector:

          • Thanks a bunch for your help 🙂

            Is the double dollar sign(I looked it up and learned about a variable variable) so that it will match the value of is_win and not look for the string is_win itself?

            Regarding carrying a separate variable for each, I don't think it's necessary. I just store a value of 0 or 1 for those rows in a database since some of my rows overlap(mobile/tablet/android, for instance.) With that usage, would it still make more sense to combine the variables?

          • Hi there everyone!

            PHP 8.3

            To start, this is not code I use to make important decisions, like serving a mobile site or other. I just use this to fill out some additional stats on visitors for my own interest.

            I wrote a short block to do this but not only does it look ugly, it seems to lack things that I might want in the future, for instance, instead of just "this", if "this" OR "that" is in the string, it's a match.

            I'm wondering if you guys wouldn't mind looking at this and offering any suggestions to make it better.

            // Platform check
            $is_win = $is_lin = $is_android = $is_iphone = $is_ipad = $is_ios = $is_mobile = $is_tablet = $is_phone = '0';
            if(str_contains(strtolower($_SERVER["HTTP_USER_AGENT"]), 'windows')){
            	$is_win = '1';
            }elseif(str_contains(strtolower($_SERVER["HTTP_USER_AGENT"]), 'linux')){
            	$is_lin = '1';
            }elseif(str_contains(strtolower($_SERVER["HTTP_USER_AGENT"]), 'ios')){
            	$is_android = '1';
            }elseif(str_contains(strtolower($_SERVER["HTTP_USER_AGENT"]), 'android')){
            	$is_ios = '1';
            }
            • Thank you both very much for your help. The only thing I can think of is that the composer install didn't go well and it was overriding my included package in my PHP code.

              Weedpacket which means the full name of the class you're instantiating is \Detection\MobileDetect; try using that.

              I did try that. In fact, I had gone through and tried every include that I found in documentation/search results (\Detection\MobileDetect, Mobile_Detect, MobileDetect) but I couldn't get the error to go away.

              During the process, I realized I didn't need that much code for what I want(just some very simple stats of site usage) so I am going to try to just write a small blob of code to give me some info based on the user agent string.

              • Hi there everyone!

                I'm trying to include Mobile-Detect in my PHP script and for some reason, it can't find the class.
                PHP 8.3
                source: https://github.com/serbanghita/Mobile-Detect/releases/tag/4.8.06

                My code:

                // Third party inclusion for mobile detection
                require_once ('./includities/Mobile-Detect/MobileDetect.php');
                $detect = new MobileDetect;

                Inside MobileDetect.php:

                class MobileDetect
                {
                    /**
                     * A cache for resolved matches
                     *  Implementation of PSR-16: Common Interface for Caching Libraries
                     *  https://www.php-fig.org/psr/psr-16/
                     *
                     * Replace this with your own implementation.
                     */
                    protected Cache $cache;
                
                    /**
                     * Stores the version number of the current release.
                     */
                    protected string $VERSION = '4.8.06';

                On pageload:

                Error: Class "MobileDetect" not found

                I've tried installing this via composer as well as the current(and previously successful) inclusion of the src code but for some reason, this time I can't get this to work at all. Reading the documentation, I've tried the various methods of calling this but nothing I've tried seems to work.

                What am I fudging?

                • It looks like it didn't care for my $usr['id'] in the SQL statement. Changing that seems to have resolved the error:

                  $banchk = $db->run(
                  	"SELECT
                  		id, 
                  		public_note, 
                  		type 
                  	FROM bans WHERE
                  		ip = ?
                  	OR 
                  		( 
                  			? <> ? 
                  		AND 
                  			user_id = ?
                  		) 
                  	AND 
                  		( 
                  			ban_end = ? 
                  		OR 
                  			ban_end > ?
                  		)
                  	",
                  	[
                  		$usr['ip'],
                  		$usr['id'], 
                  		'0', 
                  		$usr['id'], 
                  		'0', 
                  		$rightnow
                  	]
                  )->fetch();
                  • Hello there, everyone,

                    I'm trying to convert my stuff over to PDO and I've been doing ok but for some reason, I can't figure out what's causing the error on this one. Could someone help me with what I'm failing to fix?
                    PHP 8.3

                    $banchk = $db->run("SELECT id, public_note, type FROM bans WHERE ip = ? OR ( $usr['id'] <> ? AND user_id = ? ) AND ( ban_end = ? OR ban_end > ? )", [$usr['ip'], '0', $usr['id'], '0', $rightnow])->fetch();

                    Error:

                    Error: syntax error, unexpected string content "", expecting "-" or identifier or variable or number

                    • Hello there, everyone!

                      I'm running late but I'm doing the advent of code 2023 at adventofcode.com and for the first day, I ended up with the following. I"m wondering if someone could point out what I could have done to make it more efficient/better.

                      Day 1:

                      The newly-improved calibration document consists of lines of text; each line originally contained a specific calibration value that the Elves now need to recover. On each line, the calibration value can be found by combining the first digit and the last digit (in that order) to form a single two-digit number.

                      $input = "start
                      ckmb52fldxkseven3fkjgcbzmnr7
                      gckhqpb6twoqnjxqplthree2fourkspnsnzxlz1
                      2onetwocrgbqm7
                      frkh2nineqmqxrvdsevenfive
                      four9two";
                      
                      $total = 0;
                      $separator = "\r\n";
                      $line = strtok($input, $separator);
                      while ($line !== false) {
                          $line = strtok( $separator );
                          foreach (str_split($line) as $char) {
                              if (is_numeric($char)) {
                                  if(!ISSET($none)){
                                      $none = $char;
                                  }
                                  $ntwo = $char;
                                  
                              }
                          }
                          $total = $none.$ntwo + $total;
                          echo $total."<br>";
                          UNSET($none);
                          UNSET($ntwo);
                      }
                      • Hi there Ronny. It's very straightforward, I used to create an editable section of websites for my clients. There are a few sections we could break this down into:

                        1) Authentication system: You want only approved people to be able to make changes.
                        2) Content submission/storage: An edit form for the user and upon submission, a way to store the content, whether it be via a file or a MySQL table.
                        3) Content retrieval/display: When the page loads, that portion of the page needs to retrieve and format the content to display to the visitor.

                        I'd handle it in that order. Create your authentication portion, move on to back end submission then set the public page up to pull the data and display it.`

                      • NogDog Out of curiosity, what elements of WD don't you like?

                      • The bot persists, perchance that one day it will win.