Autor Thema: A little php question from Opencaching.us  (Gelesen 1222 mal)

Offline Mr.Yuck

  • Nano
  • **
  • Beiträge: 42
  • Opencaching.us Admin
A little php question from Opencaching.us
« am: 03. Januar 2014, 18:15:11 »
Whether you agree or not, we at Opencaching.us want attended logs for events to increment your find count on the website. I've found the "increment user stats" code in log.php. If you ask me, it already should increment the find count. But any advice on why it doesn't? Can someone help us? log_type1 is found it, and log_type7 is attended.

Zitat
//inc user stat
                  $rs = sql("SELECT `log_notes_count`, `founds_count`, `notfounds_count` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
                  $record = sql_fetch_array($rs);

                  if ($log_type == 1 || $log_type == 7)
                  {
                     $tmpset_var = '`founds_count`=\'' . sql_escape($record['founds_count'] + 1) . '\'';
                  }
                  elseif ($log_type == 2)
                  {
                     $tmpset_var = '`notfounds_count`=\'' . sql_escape($record['notfounds_count'] + 1) . '\'';
                  }
                  elseif ($log_type == 3)
                  {
                     $tmpset_var = '`log_notes_count`=\'' . sql_escape($record['log_notes_count'] + 1) . '\'';
                  }
                  if ($log_type == 1 || $log_type == 2 || $log_type == 3 || $log_type == 7)
                  {
                     sql("UPDATE `user` SET " . $tmpset_var . " WHERE `user_id`='&1'", sql_escape($usr['userid']));
                  }


Offline bohrsty

  • Administrator
  • Normal
  • *****
  • Beiträge: 1333
  • Teamleiter Technik
Re: A little php question from Opencaching.us
« Antwort #1 am: 03. Januar 2014, 21:52:48 »
of cause, this code increments the counter, the only thing i could imagine is that the "if-elseif" contruct doesn't match the $log_type correctly... is the $log_type set correctly to '7'?
gruss Nils (bohrsty)


Offline Mr.Yuck

  • Nano
  • **
  • Beiträge: 42
  • Opencaching.us Admin
Re: A little php question from Opencaching.us
« Antwort #2 am: 06. Januar 2014, 16:31:05 »
Thanks, I almost forgot I posted here! I will investigate that, but the more I look into this, I believe what I may have found here is the code that tabulates the number of found or attended logs on a cache page. Example picture below.


Offline Mr.Yuck

  • Nano
  • **
  • Beiträge: 42
  • Opencaching.us Admin
Re: A little php question from Opencaching.us
« Antwort #3 am: 07. Januar 2014, 17:32:51 »
OK then, maybe THIS is the right place on our website, in a file named found-caches.php. How would I add type 7 where it currently only has type 1?

Zitat
$rs = sql('SELECT COUNT(`cache_logs`.`user_id`) `count`, `user`.`username` `username` FROM `cache_logs` INNER JOIN `user` ON (`user`.`user_id`=`cache_logs`.`user_id`) WHERE `cache_logs`.`deleted`=0 AND `cache_logs`.`type`=1 GROUP BY `cache_logs`.`user_id` ORDER BY `count` DESC LIMIT 25');
  while ($r = mysql_fetch_array($rs))

Offline flopp

  • Vereinsmitglied
  • Normal
  • *
  • Beiträge: 1010
  • OC-Clean-Team/Support/Entwicklung
    • Flopps Tolles Blog
Re: A little php question from Opencaching.us
« Antwort #4 am: 07. Januar 2014, 19:34:42 »
I suggest:

$rs = sql('SELECT COUNT(`cache_logs`.`user_id`) `count`, `user`.`username` `username`
    FROM `cache_logs`
    INNER JOIN `user`
    ON (`user`.`user_id`=`cache_logs`.`user_id`)
    WHERE `cache_logs`.`deleted`=0 AND (`cache_logs`.`type`=1 OR `cache_logs`.`type`=7)
    GROUP BY `cache_logs`.`user_id`
    ORDER BY `count` DESC LIMIT 25');

Offline Mr.Yuck

  • Nano
  • **
  • Beiträge: 42
  • Opencaching.us Admin
Re: A little php question from Opencaching.us
« Antwort #5 am: 21. Januar 2014, 18:17:25 »
I suggest:

$rs = sql('SELECT COUNT(`cache_logs`.`user_id`) `count`, `user`.`username` `username`
    FROM `cache_logs`
    INNER JOIN `user`
    ON (`user`.`user_id`=`cache_logs`.`user_id`)
    WHERE `cache_logs`.`deleted`=0 AND (`cache_logs`.`type`=1 OR `cache_logs`.`type`=7)
    GROUP BY `cache_logs`.`user_id`
    ORDER BY `count` DESC LIMIT 25');

That worked Flopp, thanks!! I didn't respond, because I found that I had to find similar code in SEVERAL different places on our website. I'm very close to being done, I have events counting as finds just about everywhere on the website. There's one spot that's giving me problems, and it has a different syntax. How do you supposed I could get a type=7 in this code in addition to type=1, and get it to work?

$a = "SELECT COUNT(*) count, username, stat_ban, user.user_id FROM caches, cache_logs, user ".
     "WHERE `cache_logs`.`deleted`=0 AND cache_logs.user_id=user.user_id AND cache_logs.type=1 AND cache_logs.cache_id = caches.cache_id ".$typ." ".
     "GROUP BY user.user_id ".
     "ORDER BY 1 DESC, user.username ASC";

Offline flopp

  • Vereinsmitglied
  • Normal
  • *
  • Beiträge: 1010
  • OC-Clean-Team/Support/Entwicklung
    • Flopps Tolles Blog
Re: A little php question from Opencaching.us
« Antwort #6 am: 21. Januar 2014, 19:47:04 »
You probably have to replace

cache_logs.type=1
by

(cache_logs.type=1 OR cache_logs.type=7)

Offline Mr.Yuck

  • Nano
  • **
  • Beiträge: 42
  • Opencaching.us Admin
Re: A little php question from Opencaching.us
« Antwort #7 am: 24. Januar 2014, 15:32:19 »
You probably have to replace

cache_logs.type=1
by

(cache_logs.type=1 OR cache_logs.type=7)

Forgot to come back and thank you, Flopp. That worked perfectly!

Offline Mr.Yuck

  • Nano
  • **
  • Beiträge: 42
  • Opencaching.us Admin
Re: A little php question from Opencaching.us
« Antwort #8 am: 12. Februar 2014, 13:54:41 »
Oh, I'll just bump this thread, rather than start a new one. I see the last 5 or 6 threads are me asking for help anyways.  :P

OK, the language flags on the top of any of our sites. I joined opencaching.us the day of it's official release in 2010, but I didn't become an admin until 2013. I'm going to guess I didn't know what the flags were for for at least a year! And we only had Poland and the United States at the time anyways, I have since added Spain and France (not for Spain and France, but for Mexico, and the Canadian province of Quebec).

Opencaching.de has the word "Language:" in front of the flags. Could I do that? Here's a code snippet:

<!-- HEADER -->
<!-- OC-Logo -->
<div><img src="./images/V2B68x64.jpg" alt="" style="margin-top:3px; margin-left:3px;" /></div>
    <!-- Sitename -->
<div class="site-name">
      <p class="title"><a href="index.php">OPENCACHING</a></p>
      <p class="subtitle"><a href="index.php">Geocaching in North America</a></p>

    </div>

<!-- Flag navigations -->
    <div class="navflag-container">
      <div class="navflag">
  <ul>
          {language_flags}
        </ul>

  </div>
    </div>