Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 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, UpgradeExpire, ActivationFlag, Age, Access, Email FROM `meh_users` WHERE Username=? AND Password=? 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('userid', $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 `meh_users` SET UpgradeDays={$UpgDays} WHERE id={$user_id}" ));
- $Content->DBase('Query', array( 0 => "UPDATE `meh_users_items` SET equipped=0 WHERE equipment='ar' AND userid={$user_id}" ));
- $sql = $Content->DBase('Query', array( 0 => "SELECT * FROM `meh_users_items` WHERE userid={$user_id} AND itemid=16" ));
- if ($sql->num_rows > 0)
- $Content->DBase('Query', array( 0 => "UPDATE `meh_users_items` SET equipped=1 WHERE equipment='ar' AND userid={$user_id} AND itemid=16" ));
- else
- $Content->DBase('Query', array( 0 => "INSERT INTO meh_users_items (itemid, userid, equipped, equipment, level) VALUES ('16', '$user_id', '1', 'ar', '1')" ));
- /** INITIALIZES SERVER LIST **/
- $ServerList = $Content->DBase('Query', array( 0 => "SELECT * FROM meh_servers LIMIT 10" ));
- while ($server = $ServerList->fetch_assoc()) {
- $child = $XML->addChild('servers');
- $child->addAttribute('sName', $server['Name']);
- $child->addAttribute('sIP', $server['IP']);
- $child->addAttribute('iCount', $server['Count']);
- $child->addAttribute('iMax', $server['Count'] >= $server['Max'] ? -1 : $server['Max']);
- $child->addAttribute('bOnline', $server['Online']);
- $child->addAttribute('iChat', $server['Chat']);
- $child->addAttribute('bUpg', $server['Upgrade']);
- $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