Changeset 21237


Ignore:
Timestamp:
Mar 6, 2013, 12:38:35 PM (7 years ago)
Author:
plg
Message:

compatibility with Piwigo 2.5: replace mysql_* functions by pwg_db_* equivalent

disable whois online feature for search engine robots to avoid useless CPU usage

Location:
extensions/whois_online
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/whois_online/config.php

    r9145 r21237  
    146146// The whois_online table summary
    147147if (isset($_GET['tab']) and $_GET['tab']=='monitor') {
    148   $whois_status = mysql_fetch_assoc(pwg_query('SHOW TABLE STATUS LIKE "' . WHOIS_ONLINE_TABLE .'%" ;'));
     148  $whois_status = pwg_db_fetch_assoc(pwg_query('SHOW TABLE STATUS LIKE "' . WHOIS_ONLINE_TABLE .'%" ;'));
    149149  $whois_status['table'] = WHOIS_ONLINE_TABLE;
    150150  $whois_status['size'] = ($whois_status['Data_length'] + $whois_status['Index_length']) . ' bytes';
     
    169169        if (!empty($result))
    170170        {
    171                 while ($row = mysql_fetch_assoc($result))
     171                while ($row = pwg_db_fetch_assoc($result))
    172172                {
    173173                        $tpl[$row['session_id']] = $row['username'];
     
    187187        if (!empty($result))
    188188        {
    189                 while ($row = mysql_fetch_assoc($result))
     189                while ($row = pwg_db_fetch_assoc($result))
    190190                {
    191191                        $tpl[$row['session_id']] = $row['username'];
     
    218218          'a:1:{s:6:"fields";a:5:{s:10:"date-after";s:10:"2009-09-09";s:11:"date-before";s:10:"2009-09-09";s:5:"types";a:4:{i:0;s:4:"none";i:1;s:7:"picture";i:2;s:4:"high";i:3;s:5:"other";}s:4:"user";s:2:"-1";s:17:"display_thumbnail";s:26:"display_thumbnail_hoverbox";}}'
    219219          .'\');');
    220           $conf_whois['Search id'] = mysql_insert_id();
     220          $conf_whois['Search id'] = pwg_db_insert_id();
    221221                $conf['Whois Online'] = serialize($conf_whois);
    222222                pwg_query('REPLACE INTO ' . CONFIG_TABLE . " (param,value,comment)
     
    224224        }
    225225        // Get and Set to current date the stupid History search.
    226         list($serialized_rules) = mysql_fetch_row(pwg_query('SELECT rules FROM '.SEARCH_TABLE.'
     226        list($serialized_rules) = pwg_db_fetch_row(pwg_query('SELECT rules FROM '.SEARCH_TABLE.'
    227227          WHERE id = '.$conf_whois['Search id'].';'));
    228228        $page['search'] = unserialize($serialized_rules);
     
    234234        // Most members ever online was
    235235        if (!isset($conf_whois['Users']['count']) or $conf_whois['Users']['count'] == 0) {
    236                 $count = mysql_fetch_assoc(pwg_query('SELECT MAX(`'. $conf['user_fields']['id'] .'`) AS `ctr` FROM ' . USERS_TABLE));
     236                $count = pwg_db_fetch_assoc(pwg_query('SELECT MAX(`'. $conf['user_fields']['id'] .'`) AS `ctr` FROM ' . USERS_TABLE));
    237237                $conf_whois['Users']['count'] = $count['ctr'];
    238238        }
  • extensions/whois_online/include/wo_functions.inc.php

    r6386 r21237  
    5858        $ctr = 0; $Online[0] = '';
    5959        $result = pwg_query('SELECT * FROM ' . WHOIS_ONLINE_TABLE . $order . ';');
    60         while($row=mysql_fetch_array($result)) {
     60        while($row=pwg_db_fetch_assoc($result)) {
    6161                $row['delay'] = (int) time() - $row['last_access'];
    6262                $row['elm_ids'] = explode(' ', $row['last_elm_ids']);
  • extensions/whois_online/main.inc.php

    r16632 r21237  
    3030*/
    3131
     32// no need to show this info to search engine robots: even if we tell them
     33// rel="nofollow" they follow the link. By deactivation this plugin to
     34// robots, we avoid wasting resources on servers.
     35if (preg_match('/(Googlebot|bingbot|Baiduspider|yandex|AhrefsBot|msnbot)/', $_SERVER["HTTP_USER_AGENT"]))
     36{
     37  return;
     38}
     39
    3240global $prefixeTable, $conf;
    3341// $conf['debug_l10n'] = true;
  • extensions/whois_online/maintain.inc.php

    r6193 r21237  
    4444                pwg_query('DELETE FROM ' . WHOIS_ONLINE_TABLE);
    4545        }
    46         list($hits) = mysql_fetch_row(pwg_query('SELECT SUM(hit) FROM '.IMAGES_TABLE.';'));
     46        list($hits) = pwg_db_fetch_row(pwg_query('SELECT SUM(hit) FROM '.IMAGES_TABLE.';'));
    4747        $pags = floor($hits * 1.69); /* estimate : 1.69 is a frequent ratio between images hits and pages hits */
    4848        pwg_query('INSERT IGNORE INTO ' . WHOIS_ONLINE_TABLE . ' (`IP`, `hidden_IP`, `session_id`, `user_id`,`username`,`lang`,`permanent`,`last_access`,
  • extensions/whois_online/reload.php

    r6386 r21237  
    7171
    7272// prefetch to optimize
    73 $local_guest = mysql_fetch_assoc(pwg_query('SELECT * FROM ' . USER_INFOS_TABLE .
     73$local_guest = pwg_db_fetch_assoc(pwg_query('SELECT * FROM ' . USER_INFOS_TABLE .
    7474        ' WHERE user_id = ' . $conf['guest_id'] .';'));
    7575       
     
    8989$result = pwg_query('SELECT * FROM ' . IMAGES_TABLE .
    9090        ' WHERE id IN (' . $inlist .');');
    91 while ($row = mysql_fetch_assoc($result)) {
     91while ($row = pwg_db_fetch_assoc($result)) {
    9292        $images[$row['id']] = $row;
    9393        $images[$row['id']]['tn_url'] = get_thumbnail_url($row);
     
    113113        }
    114114        else {
    115                 $online[$k]['user'] = mysql_fetch_assoc(pwg_query('SELECT * FROM ' . USER_INFOS_TABLE .
     115                $online[$k]['user'] = pwg_db_fetch_assoc(pwg_query('SELECT * FROM ' . USER_INFOS_TABLE .
    116116                 ' WHERE user_id = ' . $v['user_id'] .';'));
    117117                $online[$k]['guest'] =  false;
Note: See TracChangeset for help on using the changeset viewer.