Advertisement
Guest User

Kunena Tapatalk

a guest
Jun 21st, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.82 KB | None | 0 0
  1. <?php
  2.  
  3. define('MBQ_IN_IT', true);  /* is in mobiquo flag */
  4. define('MBQ_DEBUG', false);  /* is in debug mode flag */
  5. define('MBQ_REG_SHUTDOWN', true);  /* regist shutdown function flag */
  6.  
  7. if (MBQ_DEBUG) {
  8.     ini_set('display_errors','1');
  9.     ini_set('display_startup_errors','1');
  10.     //error_reporting(E_ALL);
  11.     error_reporting(E_ALL ^ E_NOTICE);
  12. } else {    // Turn off all error reporting
  13.     error_reporting(0);
  14. }
  15. set_time_limit(60);
  16.  
  17. require_once('MbqConfig.php');
  18. require_once('piwikTracker.class.php');
  19.  
  20. /**
  21.  * frame main program
  22.  *
  23.  * @since  2012-7-2
  24.  * @author Wu ZeTao <578014287@qq.com>
  25.  */
  26. Abstract Class MbqMain extends MbqBaseMain {
  27.  
  28.     public static function init() {
  29.         parent::init();
  30.         self::$oMbqCm->changeWorkDir('..');  /* change work dir to parent dir.Important!!! */
  31.         self::regShutDown();
  32.     }
  33.    
  34.     /**
  35.      * action
  36.      */
  37.     public static function action() {
  38.         parent::action();
  39.         if (self::hasLogin()) {
  40.             header('Mobiquo_is_login: true');
  41.         } else {
  42.             header('Mobiquo_is_login: false');
  43.         }
  44.         self::$oMbqConfig->calCfg();    /* you should do some modify within this function in multiple different type applications! */
  45.         if (!self::$oMbqConfig->pluginIsOpen()) {
  46.             MbqError::alert('', "Plugin is not in service!");
  47.         }
  48.         if (isset($_GET['method_name']) && $_GET['method_name']) {     //for more flexibility
  49.             self::$cmd = $_GET['method_name'];
  50.         }
  51.         if (isset($_POST['method_name']) && $_POST['method_name']) {    //for upload_attach and other post method
  52.             self::$cmd = $_POST['method_name'];
  53.             foreach ($_POST as $k => $v) {
  54.                 self::$input[$k] = $v;
  55.             }
  56.         }
  57.         if (self::$cmd) {
  58.             self::$cmd = (string) self::$cmd;
  59.             //MbqError::alert('', self::$cmd);
  60.             if (preg_match('/[A-Za-z0-9_]{1,128}/', self::$cmd)) {
  61.                 $arr = explode('_', self::$cmd);
  62.                 foreach ($arr as &$v) {
  63.                     $v = ucfirst(strtolower($v));
  64.                 }
  65.                 $actionClassName = 'MbqAct'.implode('', $arr);
  66.                 if (self::$oClk->hasReg($actionClassName)) {
  67.             self::doPiwikTrack($actionClassName);
  68.                     self::$oAct = self::$oClk->newObj($actionClassName);
  69.                     self::$oAct->actionImplement();
  70.                 } else {
  71.                     //MbqError::alert('', "Not support action for ".self::$cmd."!", '', MBQ_ERR_NOT_SUPPORT);
  72.                     MbqError::alert('', "Sorry!This feature is not available in this forum.Method name:".self::$cmd, '', MBQ_ERR_NOT_SUPPORT);
  73.                 }
  74.             } else {
  75.                 MbqError::alert('', "Need valid cmd!");
  76.             }
  77.         } else {
  78.             MbqError::alert('', "Need not empty cmd!");
  79.         }
  80.     }
  81.    
  82.     /**
  83.      * do something before output
  84.      */
  85.     public static function beforeOutPut() {
  86.         parent::beforeOutput();
  87.     }
  88.  
  89.     /**
  90.      * do Piwik-User tracking
  91.      */
  92.      private function doPiwikTrack($actionClassName) {
  93.         //Set the piwik-url
  94.     PiwikTracker::$URL = 'http://piwik.example.com';
  95.  
  96.     //The site-id for this website
  97.     $piwikTracker = new PiwikTracker( $idSite = 1 );
  98.  
  99.     //Piwik token auth (see piwik panel -> API)
  100.     $piwikTracker->setTokenAuth('myexampletoken');
  101.  
  102.     //Set the user IP (if not set, server IP will be used)
  103.     $piwikTracker->setIp($_SERVER['REMOTE_ADDR']);
  104.  
  105.     //Change the Tapatalk useragent
  106.     $version = str_replace('Mozilla/5.0 Firefox/3.5.6 ','',$_SERVER['HTTP_USER_AGENT']);
  107.     $piwikTracker->setUserAgent($version.' (Tapatalk) Tapatalk');
  108.  
  109.     //Fire the tracking with used Tapatalk method  
  110.     $piwikTracker->doTrackPageView('Tapatalk - '.$actionClassName);
  111.      }
  112.    
  113. }
  114.  
  115. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement