daily pastebin goal
45%
SHARE
TWEET

Untitled

richmooOO1 Dec 29th, 2016 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.   * Advanced HiddenProject Content Management System - Game Login
  3.   *
  4.   * Copyright (c) 2012 Naufal Hardiansyah (www.gremory.cu.cc)
  5.   * The program is distributed under the terms of the GNU General Public License
  6.   *
  7.   * This file is part of Advanced HiddenProject Content Management System (AdvHPContentMS).
  8.   *
  9.   * AdvHPContentMS is free software: you can redistribute it and/or modify
  10.   * it under the terms of the GNU General Public License as published by
  11.   * Naufal Hardiansyah, either version 3 of the License, or any later version.
  12.   *
  13.   * AdvHPContentMS is distributed in the hope that it will be useful,
  14.   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.   * GNU General Public License for more details.
  17.   *
  18.   * You should have received a copy of the GNU General Public License
  19.   * along with AdvHPContentMS. If not, see .
  20. **/
  21. /** DateTime::diff issues
  22.   * SEEMS THERE IS AN ISSUE WITH PHP >= 5.3.0
  23.   * SO I DECIDED TO CREATE AN ALTERNATE FUNCTION TO SOLVE IT, TO ENABLE THIS FUNCTION:
  24.   * REPLACE:
  25.       $datetime1 = new DateTime(date('Y-m-d h:i:s'));
  26.       $datetime2 = new DateTime($UpgradeExpire);
  27.       $interval = $datetime1->diff($datetime2);
  28.       $UpgDays = $interval->format('%R%a');
  29.   * WITH:
  30.       $UpgDays = date_diff(date('Y-m-d h:i:s'), $UpgradeExpire);
  31.   * ENABLE THIS FUNCTION:
  32.     function date_diff($date1, $date2) {
  33.       $current = $date1;
  34.       $datetime2 = date_create($date2);
  35.       $count = 0;
  36.       while (date_create($current) < $datetime2){
  37.         $current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current)));
  38.         $count++;
  39.       }
  40.       return $count;
  41.     }
  42. **/
  43.  
  44. /** READS CONFIGURATIONS **/
  45. require_once 'config.php';
  46.  
  47. /** DEFINES CLASSES **/
  48. DefineClass('class.content');
  49. DefineClass('class.core');
  50.  
  51. /** SETS CONTENT TYPE **/
  52. header("Content-Type: text/xml");
  53.  
  54. /** CREATES NEW CLASSES **/
  55. $Content = new HiddenProjectCMS();
  56. $Client = new Core();
  57. $XML = new SimpleXMLElement('');
  58. $DOM = new DOMDocument();
  59.  
  60. /** CONFIGURES MYSQL PARAMETERS **/
  61. $MySQL = new stdClass();
  62. $MySQL->HOST = Configurations::MySQLHost;
  63. $MySQL->USER = Configurations::MySQLUser;
  64. $MySQL->PASS = Configurations::MySQLPass;
  65. $MySQL->DATA = Configurations::MySQLData;
  66. $Content->MYSQL = $MySQL;
  67.  
  68. /** INITIALIZES MYSQL CONNECTIONS **/
  69. $Content->Initialize('Connection');
  70.  
  71. if (isset($_POST['strUsername']) AND isset($_POST['strPassword'])) {
  72.     $Username = $Content->DBase('EscapeString', array( 0 => $_POST['strUsername'] ));
  73.     $Password = $Client->Initialize('UserToken', array( 0 => $_POST['strPassword'], 1 => $Username ));
  74.     $UpgDays = -1;
  75.  
  76.     /** PARSES USER DATA **/
  77.     if ($stmt = $Content->DBase('Prepare', array( 0 => 'SELECT id, UpgradeExpire, ActivationFlag, Age, Access, Email FROM `meh_users` WHERE Username=? AND Password=? LIMIT 1' ))) {
  78.         $stmt->bind_param("ss", $Username, $Password);
  79.         $stmt->execute();
  80.         $stmt->bind_result($user_id, $UpgradeExpire, $ActivationFlag, $Age, $Access, $Email);
  81.         if ($stmt->fetch()) {
  82.             /** HANDLES USER UPGRADE DAYS **/
  83.             $datetime1 = new DateTime(date('Y-m-d h:i:s'));
  84.             $datetime2 = new DateTime($UpgradeExpire);
  85.             $interval = $datetime1->diff($datetime2);
  86.             $UpgDays = $interval->format('%R%a');
  87.  
  88.             /** PARSES USER UPGRADE DAYS **/
  89.             if ($UpgDays <= -0 AND $UpgDays != +0 OR $UpgDays == 0)
  90.                 $UpgDays = -1;
  91.  
  92.             $XML->addAttribute('bSuccess', '1');
  93.             $XML->addAttribute('userid', $user_id);
  94.             $XML->addAttribute('iAccess', $Access);
  95.             $XML->addAttribute('iUpg', $UpgDays >= 0 ? 1 : 0);
  96.             $XML->addAttribute('iAge', $Age);
  97.             $XML->addAttribute('sToken', $Password);
  98.             $XML->addAttribute('dUpgExp', preg_replace('/\s+/', 'T', $UpgradeExpire));
  99.             $XML->addAttribute('iUpgDays', $UpgDays);
  100.             $XML->addAttribute('iSendEmail', $ActivationFlag);
  101.             $XML->addAttribute('strEmail', $Email);
  102.             $XML->addAttribute('bCCOnly', 0);
  103.         } else {
  104.             $XML->addAttribute('bSuccess', '0');
  105.             $XML->addAttribute('sMsg', 'The username and password you entered did not match. Please check the spelling and try again.');
  106.         }
  107.     } $stmt->close();
  108.  
  109.     /** READS XML DATA **/
  110.     $DOM->loadXML($XML->asXML());
  111.     $DOM->getElementsByTagName('login');
  112.     $DOC = $DOM->getElementsByTagName('login');
  113.     foreach ($DOC as $ELEMENT) {
  114.         if ($ELEMENT->getAttribute('bSuccess') == '1') {
  115.             /** SOME ADDONS **/
  116.             $Content->DBase('Query', array( 0 => "UPDATE `meh_users` SET UpgradeDays={$UpgDays} WHERE id={$user_id}" ));    
  117.             $Content->DBase('Query', array( 0 => "UPDATE `meh_users_items` SET equipped=0 WHERE equipment='ar' AND userid={$user_id}" ));
  118.             $sql = $Content->DBase('Query', array( 0 => "SELECT * FROM `meh_users_items` WHERE userid={$user_id} AND itemid=16" ));
  119.             if ($sql->num_rows > 0)
  120.                 $Content->DBase('Query', array( 0 => "UPDATE `meh_users_items` SET equipped=1 WHERE equipment='ar' AND userid={$user_id} AND itemid=16" ));
  121.             else
  122.                 $Content->DBase('Query', array( 0 => "INSERT INTO meh_users_items (itemid, userid, equipped, equipment, level) VALUES ('16', '$user_id', '1', 'ar', '1')" ));        
  123.    
  124.             /** INITIALIZES SERVER LIST **/
  125.             $ServerList = $Content->DBase('Query', array( 0 => "SELECT * FROM meh_servers LIMIT 10" ));
  126.             while ($server = $ServerList->fetch_assoc()) {
  127.                 $child = $XML->addChild('servers');
  128.                 $child->addAttribute('sName', $server['Name']);
  129.                 $child->addAttribute('sIP', $server['IP']);
  130.                 $child->addAttribute('iCount', $server['Count']);
  131.                 $child->addAttribute('iMax', $server['Count'] >= $server['Max'] ? -1 : $server['Max']);
  132.                 $child->addAttribute('bOnline', $server['Online']);
  133.                 $child->addAttribute('iChat', $server['Chat']);
  134.                 $child->addAttribute('bUpg', $server['Upgrade']);
  135.                 $child->addAttribute('sLang', 'xx');
  136.             }
  137.            
  138.             /** INITIALIZES LOGIN STATUS **/
  139.             $Client->HandleUser('Login', array( 0 => $Content, 1 => $_POST['strUsername'], 2 => $_POST['strPassword'] ));  
  140.             break;
  141.         }
  142.     }
  143. } else {
  144.     $XML->addAttribute('bSuccess', '0');
  145.     $XML->addAttribute('sMsg', 'Invalid Input');
  146. }
  147.  
  148. /** PARSES XML DOM **/
  149. $XMLDOM = dom_import_simplexml($XML);
  150. $XMLString = $XMLDOM->ownerDocument->saveXML($XMLDOM->ownerDocument->documentElement);
  151.  
  152. /** PRINTS FINAL OUTPUT **/
  153. $Content->SITE->CONTENT = $XMLString;
  154. $Content->FlushContent(false);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top