Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as PHP by Blaze'Meuch ( 14 years ago )
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* mCMS Shop-Core Class
*
* @package mCMS
* @subpackage Libraries
* @category Dofus 1.29 - Shop-Core
* @version 1.0
*/
// ------------------------------------------------------------------------
class MY_Shop
{
private $_obj;
private $_ancestrar = array();
/**
*
* Constructor - Initializes and references CI
*
*/
function __construct()
{
$this->_obj =& get_instance();
$this->_obj->load->config('mCMS');
$this->_obj->load->database('default');
$this->_obj->load->library('session');
}
public function liste($Categorie, $offset = 0, $admin = 0)
{
$CategorieId = $this->GetCategorie($Categorie);
$this->_obj->load->library('cache');
if($this->_obj->cache->get('shop/'.$Categorie) && $admin == 0)
{
$Liste = $this->_obj->cache->get('shop/'.$Categorie);
}
else
{
if($admin == 0)
{
$this->_obj->db->where('Categorie', $CategorieId);
}
$Liste = $this->_obj->db->get('boutique')->result();
if($admin == 0)
{
$this->_obj->cache->write($Liste, 'shop/'.$Categorie, 600);
}
}
return $Liste;
}
private function GetCategorie($Categorie)
{
switch($Categorie)
{
case 'coiffes':
$cat_id = 1;
break;
case 'capes':
$cat_id = 2;
break;
case 'bottes':
$cat_id = 3;
break;
case 'ceintures':
$cat_id = 4;
break;
case 'amulettes':
$cat_id = 5;
break;
case 'anneaux':
$cat_id = 6;
break;
case 'boucliers':
$cat_id = 7;
break;
case 'dofus':
$cat_id = 8;
break;
case 'familliers':
$cat_id = 9;
break;
case 'montures':
$cat_id = 10;
break;
case 'epees':
$cat_id = 11;
break;
case 'dagues':
$cat_id = 12;
break;
case 'pelles':
$cat_id = 13;
break;
case 'marteaux':
$cat_id = 14;
break;
case 'batons':
$cat_id = 15;
break;
case 'baguettes':
$cat_id = 16;
break;
case 'arcs':
$cat_id = 17;
break;
case 'services':
$cat_id = 18;
break;
case 'divers':
$cat_id = 19;
break;
case 'autres':
$cat_id = 20;
break;
case 'emots':
$cat_id = 21;
break;
case 'hall':
$cat_id = 22;
break;
case 'kamas':
$cat_id = 23;
break;
case 'titres':
$cat_id = 24;
break;
case 'surprises':
$cat_id = 25;
break;
case 'haches':
$cat_id = 26;
break;
case 'prestige':
$cat_id = 27;
break;
case 'admin':
$cat_id = 1337;
break;
default:
return $this->_obj->common->_display("Aucune catégorie correcte sélectionée.", "Erreur boutique");
exit();
break;
}
return $cat_id;
}
public function Analyze($Obj)
{
$Obj = explode('-', $Obj);
if($Obj[0] == 'I')
{
$data['type'] = 'Item';
$data['item'] = $Obj[1];
}
elseif($Obj[0] == 'K')
{
$data['type'] = 'Kamas';
$data['kamas'] = $Obj[1];
}
elseif($Obj[0] == 'TI')
{
$data['type'] = 'Title';
$data['value'] = $Obj[1];
}
elseif($Obj[0] == 'TA')
{
$data['type'] = 'Tag';
$data['value'] = $Obj[1];
}
elseif($Obj[0] == 'S')
{
$data['type'] = 'Stats';
if($Obj[1] == '101')
{
$data['cat'] = 'all';
$data['number'] = '101';
}
else
{
$data['cat'] = $Obj[1];
$data['number'] = $Obj[2];
}
}
elseif($Obj[0] == 'P')
{
$data['type'] = 'Points';
$data['cat'] = $Obj[1];
$sata['points'] = $Obj[2];
}
return $data;
}
public function BuyObj($Obj)
{
$Obj = $this->Analyze($Obj);
$this->_obj->db->select('points');
$this->_obj->db->where('guid', $this->AccountId);
$account = $this->_obj->db->get('accounts')->result_array();
if($Obj['type'] == 'Item')
{
$this->_obj->db->select('ItemId, cost');
$this->_obj->db->where('id', $Obj['item']);
$item = $this->_obj->db->get('boutique');
if($item->num_rows() == 1)
{
$item = $item->result_array();
if($account[0]['points'] >= $item[0]['cost'])
{
if($this->RecvItem($item[0]['ItemId'], TRUE))
{
$Solde = $account[0]['points'] - $item[0]['cost'];
$this->_obj->db->where('guid', $this->AccountId);
$this->_obj->db->update('accounts', array('points' => $Solde));
$this->_obj->session->set_userdata(array('points' => $Solde));
$data = array( 'AccountId' => $this->AccountId,
'PlayerId' => $this->PlayerId,
'Type' => $Obj['type'],
'Value' => $item[0]['ItemId'],
'Cost' => $item[0]['cost'],
'IP' => $this->_obj->input->ip_address());
$this->_obj->db->insert('achats', $data);
return $this->_obj->common->_display("Vous avez bien commandé votre Item - <a >Boutique</a> / <a >Page d'accueil</a>.", "Commande effectuée", "succes");
exit();
}
else
{
return $this->_obj->common->_display();
exit();
}
}
else
{
return $this->_obj->common->_display("Vous n'avez pas assé de points.", "Erreur boutique");
exit();
}
}
else
{
return $this->_obj->common->_display("Objet sélectionné inconnu.", "Erreur boutique");
exit();
}
}
elseif($Obj['type'] == 'Kamas')
{
switch($Obj['kamas'])
{
case 5000000: // Nombre de Kamas
$Cost = 200; // Prix en Points
break;
case 10000000:
$Cost = 300;
break;
default:
return $this->_obj->common->_display("Montant en Kamas invalide.", "Erreur boutique");
exit();
break;
}
if($account[0]['points'] >= $Cost)
{
if($this->RecvKamas($Obj['kamas']))
{
$Solde = $account[0]['points'] - $Cost;
$this->_obj->db->where('guid', $this->AccountId);
$this->_obj->db->update('accounts', array('points' => $Solde));
$this->_obj->session->set_userdata(array('points' => $Solde));
$data = array( 'AccountId' => $this->AccountId,
'PlayerId' => $this->PlayerId,
'Type' => $Obj['type'],
'Value' => $Obj['kamas'],
'Cost' => $Cost,
'IP' => $this->_obj->input->ip_address());
$this->_obj->db->insert('achats', $data);
return $this->_obj->common->_display("Vous avez bien commandé vos Kamas - <a >Boutique</a> / <a >Page d'accueil</a>.", "Commande effectuée", "succes");
exit();
}
else
{
return $this->_obj->common->_display();
exit();
}
}
else
{
return $this->_obj->common->_display("Vous n'avez pas assé de points.", "Erreur boutique");
exit();
}
}
elseif($Obj['type'] == 'Title')
{
switch($Obj['value'])
{
case 1: // Id du Titre
$Title = "Champion légendaire"; // Titre
$Cost = 100; // Prix en Points
break;
case 2:
$Titre = "Béni des dieux";
$Cost = 100;
break;
case 3:
$Titre = "Gladiateur destructeur";
$Cost = 100;
break;
case 4:
$Titre = "Héros légendaire";
$Cost = 200;
break;
case 5:
$Titre = "Pro Skillz";
$Cost = 400;
break;
case 6:
$Titre = "Crèmme de la Crème";
$Cost = 650;
break;
case 7:
$Titre = "Dieu parmi les hommes";
$Cost = 800;
break;
default:
return $this->_obj->common->_display("Id titre invalide.", "Erreur boutique");
exit();
break;
}
if($account[0]['points'] >= $Cost)
{
if($this->RecvTitle($Obj['value']))
{
$Solde = $account[0]['points'] - $Cost;
$this->_obj->db->where('guid', $this->AccountId);
$this->_obj->db->update('accounts', array('points' => $Solde));
$this->_obj->session->set_userdata(array('points' => $Solde));
$data = array( 'AccountId' => $this->AccountId,
'PlayerId' => $this->PlayerId,
'Type' => $Obj['type'],
'Value' => $Obj['value'],
'Cost' => $Cost,
'IP' => $this->_obj->input->ip_address());
$this->_obj->db->insert('achats', $data);
return $this->_obj->common->_display("Vous avez bien commandé votre titre - <a >Boutique</a> / <a >Page d'accueil</a>.", "Commande effectuée", "succes");
exit();
}
else
{
return $this->_obj->common->_display();
exit();
}
}
else
{
return $this->_obj->common->_display("Vous n'avez pas assé de points.", "Erreur boutique");
exit();
}
}
elseif($Obj['type'] == 'Tag')
{
switch($Obj['value'])
{
case 1: // Id du Tag
$Tag = "[Skillz]"; // Tag
$Cost = 80; // Prix en Points
break;
default:
return $this->_obj->common->_display("Id tag invalide.", "Erreur boutique");
exit();
break;
}
if($account[0]['points'] >= $Cost)
{
if($this->RecvTag($Tag))
{
$Solde = $account[0]['points'] - $Cost;
$this->_obj->db->where('guid', $this->AccountId);
$this->_obj->db->update('accounts', array('points' => $Solde));
$this->_obj->session->set_userdata(array('points' => $Solde));
$data = array( 'AccountId' => $this->AccountId,
'PlayerId' => $this->PlayerId,
'Type' => $Obj['type'],
'Value' => $Tag,
'Cost' => $Cost,
'IP' => $this->_obj->input->ip_address());
$this->_obj->db->insert('achats', $data);
return $this->_obj->common->_display("Vous avez bien commandé votre tag - <a >Boutique</a> / <a >Page d'accueil</a>.", "Commande effectuée", "succes");
exit();
}
else
{
return $this->_obj->common->_display();
exit();
}
}
else
{
return $this->_obj->common->_display("Vous n'avez pas assé de points.", "Erreur boutique");
exit();
}
}
}
private function RecvItem($Item, $Max = FALSE)
{
// Action 20 -> Jet Aléatoire
// Action 21 -> Jet Max
$data['PlayerID'] = $this->PlayerId;
if($Max)
{
$data['Action'] = 21;
}
else
{
$data['Action'] = 20;
}
$data['Nombre'] = $Item;
if($this->_obj->db->insert('live_action', $data))
{
return TRUE;
}
else
{
return FALSE;
}
}
private function RecvKamas($Kamas)
{
// Action 3 -> Kamas
$data['PlayerID'] = $this->PlayerId;
$data['Action'] = 3;
$data['Nombre'] = $Kamas;
if($this->_obj->db->insert('live_action', $data))
{
return TRUE;
}
else
{
return FALSE;
}
}
public function RecvTitle($Title)
{
$this->_obj->db->where('guid', $this->PlayerId);
if($this->_obj->db->update('Personnages', array('titulo' => $Title)))
{
return TRUE;
}
else
{
return FALSE;
}
}
public function RecvTag($Tag)
{
$this->_obj->db->where('guid', $this->PlayerId);
$query = $this->_obj->db->get('Personnages')->result_array();
$query[0]['nom'] = preg_replace('/\[(.*)\]/', '', $query[0]['nom']);
$data['nom'] = $Tag.$query[0]['nom'];
$this->_obj->db->where('guid', $this->PlayerId);
if($this->_obj->db->update('Personnages', $data))
{
$this->_obj->load->library('cache');
$this->_obj->cache->delete('accounts/characters-'.$this->_obj->session->userdata('id'));
return TRUE;
}
else
{
return FALSE;
}
}
private function RecvStats($Parcho = 0, $Sats = array())
{
// Action 118 -> Force
// Action 119 -> Agilité
// Action 123 -> Chance
// Action 124 -> Sagesse
// Action 125 -> Vitalité
// Action 126 -> Intelligence
}
private function RecvLevel($Level)
{
// Action 2 -> XP
}
private function RecvPoints($Categorie = array(), $Number)
{
// Action 4 -> Points Capital
// Action 5 -> Points Sort
}
public function GetItem($id)
{
$this->_obj->db->where('id', $id);
$Liste = $this->_obj->db->get('boutique')->result_array();
return $Liste;
}
}
/* End of file Shop.php */
/* Location: ./application/libraries/Shop.php */
Revise this Paste