Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Advanced HiddenProject Content Management System - Game Login
- *
- * Copyright (c) 2012 Naufal Hardiansyah (www.gremory.cu.cc)
- * The program is distributed under the terms of the GNU General Public License
- *
- * This file is part of Advanced HiddenProject Content Management System (AdvHPContentMS).
- *
- * AdvHPContentMS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * Naufal Hardiansyah, either version 3 of the License, or any later version.
- *
- * AdvHPContentMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with AdvHPContentMS. If not, see .
- **/
- /** DateTime::diff issues
- * SEEMS THERE IS AN ISSUE WITH PHP >= 5.3.0
- * SO I DECIDED TO CREATE AN ALTERNATE FUNCTION TO SOLVE IT, TO ENABLE THIS FUNCTION:
- * REPLACE:
- $datetime1 = new DateTime(date('Y-m-d h:i:s'));
- $datetime2 = new DateTime($UpgradeExpire);
- $interval = $datetime1->diff($datetime2);
- $UpgDays = $interval->format('%R%a');
- * WITH:
- $UpgDays = date_diff(date('Y-m-d h:i:s'), $UpgradeExpire);
- * ENABLE THIS FUNCTION:
- function date_diff($date1, $date2) {
- $current = $date1;
- $datetime2 = date_create($date2);
- $count = 0;
- while (date_create($current) < $datetime2){
- $current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current)));
- $count++;
- }
- return $count;
- }
- **/
- /** READS CONFIGURATIONS **/
- require_once 'config.php';
- /** DEFINES CLASSES **/
- DefineClass('class.content');
- DefineClass('class.core');
- /** SETS CONTENT TYPE **/
- header("Content-Type: text/xml");
- /** CREATES NEW CLASSES **/
- $Content = new HiddenProjectCMS();
- $Client = new Core();
- $XML = new SimpleXMLElement('');
- $DOM = new DOMDocument();
- /** CONFIGURES MYSQL PARAMETERS **/
- $MySQL = new stdClass();
- $MySQL->HOST = Configurations::MySQLHost;
- $MySQL->USER = Configurations::MySQLUser;
- $MySQL->PASS = Configurations::MySQLPass;
- $MySQL->DATA = Configurations::MySQLData;
- $Content->MYSQL = $MySQL;
- /** INITIALIZES MYSQL CONNECTIONS **/
- $Content->Initialize('Connection');
- if (isset($_POST['strUsername']) AND isset($_POST['strPassword'])) {
- $Username = $Content->DBase('EscapeString', array( 0 => $_POST['strUsername'] ));
- $Password = $Client->Initialize('UserToken', array( 0 => $_POST['strPassword'], 1 => $Username ));
- $upgdays = -1;
- /** PARSES USER DATA **/
- if ($stmt = $Content->DBase('Prepare', array( 0 => 'SELECT id, iUpgExp, iEmailSent, iAge, iAccess, strEmail FROM `etl_users` WHERE strUsername=? AND strPassword=? LIMIT 1' ))) {
- $stmt->bind_param("ss", $Username, $Password);
- $stmt->execute();
- $stmt->bind_result($user_id, $UpgradeExpire, $ActivationFlag, $Age, $Access, $Email);
- if ($stmt->fetch()) {
- /** HANDLES USER UPGRADE DAYS **/
- $datetime1 = new DateTime(date('Y-m-d h:i:s'));
- $datetime2 = new DateTime($UpgradeExpire);
- $interval = $datetime1->diff($datetime2);
- $UpgDays = $interval->format('%R%a');
- /** PARSES USER UPGRADE DAYS **/
- if ($UpgDays <= -0 AND $UpgDays != +0 OR $UpgDays == 0)
- $UpgDays = -1;
- $XML->addAttribute('bSuccess', '1');
- $XML->addAttribute('user_id', $user_id);
- $XML->addAttribute('iAccess', $Access);
- $XML->addAttribute('iUpg', $UpgDays >= 0 ? 1 : 0);
- $XML->addAttribute('iAge', $Age);
- $XML->addAttribute('sToken', $Password);
- $XML->addAttribute('dUpgExp', preg_replace('/\s+/', 'T', $UpgradeExpire));
- $XML->addAttribute('iUpgDays', $UpgDays);
- $XML->addAttribute('iSendEmail', $ActivationFlag);
- $XML->addAttribute('strEmail', $Email);
- $XML->addAttribute('bCCOnly', 0);
- } else {
- $XML->addAttribute('bSuccess', '0');
- $XML->addAttribute('sMsg', 'The username and password you entered did not match. Please check the spelling and try again.');
- }
- } $stmt->close();
- /** READS XML DATA **/
- $DOM->loadXML($XML->asXML());
- $DOM->getElementsByTagName('login');
- $DOC = $DOM->getElementsByTagName('login');
- foreach ($DOC as $ELEMENT) {
- if ($ELEMENT->getAttribute('bSuccess') == '1') {
- /** SOME ADDONS **/
- $Content->DBase('Query', array( 0 => "UPDATE `etl_users` SET iUpgDays={$UpgDays} WHERE id={$user_id}" ));
- $Content->DBase('Query', array( 0 => "UPDATE `etl_users_items` SET bEquip=0 WHERE sES='ar' AND user_id={$user_id}" ));
- $sql = $Content->DBase('Query', array( 0 => "SELECT * FROM `etl_users_items` WHERE user_id={$user_id} AND item_id=2" ));
- if ($sql->num_rows > 0)
- $Content->DBase('Query', array( 0 => "UPDATE `etl_users_items` SET bEquip=1 WHERE sES='ar' AND user_id={$user_id} AND item_id=6" ));
- else
- $Content->DBase('Query', array( 0 => "INSERT INTO etl_users_items (item_id, user_id, bEquipp, sES, iLvl) VALUES ('6', '$user_id', '1', 'ar', '1')" ));
- /** INITIALIZES SERVER LIST **/
- $ServerList = $Content->DBase('Query', array( 0 => "SELECT * FROM etl_servers LIMIT 10" ));
- while ($server = $ServerList->fetch_assoc()) {
- $child = $XML->addChild('servers');
- $child->addAttribute('sName', $server['sName']);
- $child->addAttribute('sIP', $server['sIP']);
- $child->addAttribute('iCount', $server['iCount']);
- $child->addAttribute('iMax', $server['iCount'] >= $server['iMax'] ? -1 : $server['iMax']);
- $child->addAttribute('bOnline', $server['bOnline']);
- $child->addAttribute('iChat', $server['iChat']);
- $child->addAttribute('bUpg', $server['bUpg']);
- $child->addAttribute('sLang', 'xx');
- }
- /** INITIALIZES LOGIN STATUS **/
- $Client->HandleUser('Login', array( 0 => $Content, 1 => $_POST['strUsername'], 2 => $_POST['strPassword'] ));
- break;
- }
- }
- } else {
- $XML->addAttribute('bSuccess', '0');
- $XML->addAttribute('sMsg', 'Invalid Input');
- }
- /** PARSES XML DOM **/
- $XMLDOM = dom_import_simplexml($XML);
- $XMLString = $XMLDOM->ownerDocument->saveXML($XMLDOM->ownerDocument->documentElement);
- /** PRINTS FINAL OUTPUT **/
- $Content->SITE->CONTENT = $XMLString;
- $Content->FlushContent(false);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement