Docurl
جستجوي سند
نوشته هاي اخير
in.php
  1. <?php
  2. //===========================================================================\
  3. // VISIOLIST is a proud derivative work of Aardvark Topsites                 \
  4. // Copyright (c) 2000-2009 Jeremy Scheff.  All rights reserved.              \
  5. //---------------------------------------------------------------------------\
  6. // http://www.aardvarktopsitesphp.com/                http://www.avatic.com/ \
  7. //---------------------------------------------------------------------------\
  8. // This program is free software; you can redistribute it and/or modify it   \
  9. // under the terms of the GNU General Public License as published by the     \
  10. // Free Software Foundation; either version 2 of the License, or (at your    \
  11. // option) any later version.                                                \
  12. //                                                                           \
  13. // This program is distributed in the hope that it will be useful, but       \
  14. // WITHOUT ANY WARRANTY; without even the implied warranty of                \
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General \
  16. // Public License for more details.                                          \
  17. //===========================================================================\
  18.  
  19. if (!defined('VISIOLIST')) {
  20.   die("This file cannot be accessed directly.");
  21. }
  22.  
  23. class in extends in_out {
  24.     function  in() {
  25.     global $CONF, $DB, $FORM;
  26.  
  27.     if (isset($_SERVER['HTTP_REFERER'])) {
  28.       $referer = $DB->escape($_SERVER['HTTP_REFERER'], 1);
  29.     }
  30.  
  31.     $go_to_rankings = 0;
  32.     if (isset($FORM['a']) && $FORM['a'] == 'in') {
  33.       $go_to_rankings = 1;
  34.       $username = $DB->escape($FORM['u']);
  35.     }
  36.     else {
  37.       // Get user by referer?
  38.       $good_referer = 0;
  39.       if (isset($referer) && !isset($FORM['a']) && mb_strpos($referer, $CONF['list_url']) === false) {
  40.         // Make sure it's not a search engine
  41.         if (mb_strpos($referer, 'http://www.google.com/search') === false && mb_strpos($referer, 'http://search.yahoo.com') === false && mb_strpos($referer, 'http://search.msn.com') === false) {
  42.           $good_referer = 1;
  43.         }
  44.       }
  45.  
  46.       if ($good_referer) {
  47.         $username = $this->get_username($referer);
  48.       }
  49.       else {
  50.         $username = '';
  51.       }
  52.  
  53.     }
  54.  
  55.     if ($username) {
  56.       list($username_sql, $username_active) = $DB->fetch("SELECT username, active FROM {$CONF['sql_prefix']}_sites WHERE username = '{$username}'", __file__, __line__);
  57.       if ($username_sql == $username) {
  58.         if ($CONF['gateway'] && !isset($FORM['sid'])) {
  59.           $this->gateway($username);
  60.         }
  61.         else {
  62.           $not_blacklisted = new join_edit;
  63.  
  64.           if ($CONF['gateway']) {
  65.             $valid = $this->check($username);
  66.           }
  67.           else {
  68.             $valid = 1;
  69.           }
  70.  
  71.           if ($valid && $not_blacklisted->check_ban('vote')) {
  72.             // Site made inactive due inactivity? Make it active again
  73.             if ($username_active == 3) {
  74.                 $DB->query("UPDATE {$CONF['sql_prefix']}_sites SET active = 1 WHERE username = '{$username}'", __file__, __line__);
  75.             }
  76.             $this->record($username, 'in');
  77.            
  78.             eval (PluginManager::getPluginManager ()->pluginHooks ('in_valid'));
  79.           }
  80.         }
  81.       }
  82.     }
  83.  
  84.     if ($go_to_rankings) {
  85.       $vote_url = "{$CONF['list_url']}/";
  86.  
  87.       // Plugin hook, redirect after voting. simply call $vote_url via a plugin
  88.       eval (PluginManager::getPluginManager ()->pluginHooks ('in_redirect'));
  89.  
  90.       header("Location: {$vote_url}");
  91.       exit;
  92.     }
  93.   }
  94.  
  95.  
  96.   static public function  check($username) {
  97.     global $CONF, $FORM;
  98.  
  99.     require_once("{$CONF['path']}/sources/misc/session.php");
  100.     $session = new session;
  101.     list($type, $data) = $session->get($FORM['sid']);
  102.     $session->delete($FORM['sid']);
  103.  
  104.     if ($type == 'gateway' && $data == $username) {
  105.       return 1;
  106.     }
  107.     else {
  108.       return 0;
  109.     }
  110.   }
  111.  
  112.   static public function  gateway($username) {
  113.     global $DB, $LNG, $CONF, $FORM, $TMPL;
  114.  
  115.     require_once("{$CONF['path']}/sources/misc/session.php");
  116.     $session = new session;
  117.     $TMPL['sid'] = $session->create('gateway', $username);
  118.  
  119.     $TMPL['username'] = $username;
  120.     $TMPL['gateway_top'] = '';
  121.     $TMPL['gateway_bottom'] = '';
  122.  
  123.     $result = $DB->query("SELECT * FROM {$CONF['sql_prefix']}_sites WHERE username = '{$username}'", __file__, __line__);
  124.     while ($row = $DB->fetch_array($result)) {
  125.         $TMPL = array_merge($TMPL, $row);
  126.     }
  127.  
  128.     eval (PluginManager::getPluginManager ()->pluginHooks ('in_gateway'));
  129.  
  130.     echo base::do_skin('gateway');
  131.     exit;
  132.   }
  133.  
  134.   static public function  get_username($url) {
  135.     global $CONF, $DB;
  136.  
  137.     $url = in::short_url($url);
  138.     $count = 0;
  139.  
  140.     $username = '';
  141.     while (!$username) {
  142.       list($username) = $DB->fetch("SELECT username FROM {$CONF['sql_prefix']}_sites WHERE short_url = '{$url}'", __file__, __line__);
  143.  
  144.       if (!$username) {
  145.         $url = in::short_url("{$url}.");
  146.       }
  147.  
  148.       $count++;
  149.       if ($count >= 10) {
  150.         $username = 0;
  151.         break;
  152.       }
  153.     }
  154.  
  155.     return $username;
  156.   }
  157.  
  158.   static public function short_url($url) {
  159.     // Lowercase
  160.     $url = mb_strtolower($url);
  161.  
  162.     // Get rid of www.
  163.     $url = preg_replace('///www./', '//', $url);
  164.  
  165.     // Get rid of trailing slash
  166.     $url = preg_replace('//$/', '', $url);
  167.  
  168.     // Get rid of page after the last slash
  169.     preg_match('/^(http://.+)/(.+)/', $url, $matches);
  170.     if (!isset($matches[0])) {
  171.       // Just a domain with a slash at the end
  172.       $url = preg_replace('/^(http://.+)//', '\1', $url);
  173.     }
  174.     else {
  175.       // All other URLs
  176.       // Check to see if after the trailing slash is a file or a directory
  177.       if (mb_strpos($matches[2], '.')) { $url = $matches[1]; }
  178.     }
  179.  
  180.     return $url;
  181.   }
  182. }
  183. ?>
تجزیه شده در 0.105 ثانیه
محتویات سند

GoStats provides website analytics

اولین مرجع اشتراک گذاری متن و اسکریپت - قدرت گرفته از Docurl