Example #1
0
 public function getCharacters($realmid)
 {
     $chardb = JTrinityCoreUtilities::getCharacterDBName($realmid);
     $accid = JTrinityCoreDBHelper::getAccId();
     $sql = "SELECT * FROM " . $chardb . ".characters  WHERE account=" . $accid;
     $db = JTrinityCoreDBHelper::getDB();
     $db->setQuery($sql);
     return $db->loadObjectList();
 }
Example #2
0
 public function teleport($realmid, $guid, $x, $y, $z, $map, $newGold)
 {
     $chardb = JTrinityCoreUtilities::getCharacterDBName($realmid);
     $db = JTrinityCoreDBHelper::getDB();
     $query = 'UPDATE ' . $chardb . '.characters SET position_x="' . $x . '", position_y="' . $y . '", position_z="' . $z . '", map="' . $map . '", money="' . $newGold . '" WHERE guid="' . $guid . '"';
     $db->setQuery($query);
     if (!$db->query()) {
         JLog::add("Error teleporting. SQL=" . $query, JLog::ERROR);
         return false;
     }
     return true;
 }
Example #3
0
 public function buyItem($productid, $realmid, $characterid)
 {
     // Send the item to the character mailbox
     $model = $this->getModel();
     $character = $model->getCharacterInfo($realmid, $characterid);
     $item = $model->getItemInfo($productid);
     if (!$model->sendItem($item, $realmid, $character)) {
         echo "<strong>Error sending item to character. Contact administrator.</strong><br/><br/>";
         JTrinityCoreUtilities::ShowUserPoints(false);
         return false;
     }
     // Show custom message ok
     print JText::sprintf('COM_JTRINITYCORE_BUYITEM_OK', $item->name, $character->name);
 }
Example #4
0
 public function insertDonation($userid, $amount, $paypal_txn_id, $completed = true)
 {
     // Insert the orders table
     $order = new stdClass();
     $order->id = NULL;
     $order->userid = $userid;
     $order->amount = $amount;
     $order->completed = $completed ? 1 : 0;
     $order->paypal_txn_id = $paypal_txn_id;
     $order->donationdate = JTrinityCoreUtilities::getCurrentDatetime();
     if (!$this->_db->insertObject('#__jtc_donations', $order, 'id')) {
         JLog::add("insertDonation(): Error inserting jtc_donations. userid=" . $userid . "  points=" . $points, JLog::ERROR);
         return false;
     }
     return true;
 }
Example #5
0
 protected function unstuck($realmid, $guid)
 {
     // Homebind
     $db = JTrinityCoreDBHelper::getDB();
     $database = JTrinityCoreUtilities::getCharacterDBName($realmid);
     $query = 'SELECT * FROM ' . $database . '.character_homebind WHERE guid = ' . $guid . ' LIMIT 1';
     $db->setQuery($query);
     if (!($obj = $db->loadObject())) {
         JLog::add("Unstuck: error. sql=" . $query, JLog::ERROR);
         return false;
     }
     $query = 'UPDATE ' . $database . '.characters SET position_x="' . $obj->position_x . '", position_y="' . $obj->position_y . '", position_z="' . $obj->position_z . '", map="' . $obj->map . '", zone="' . $obj->zone . '" WHERE guid=' . $guid . ' LIMIT 1';
     $db->setQuery($query);
     if (!$db->query()) {
         JLog::add("Unstuck: error. sql=" . $query, JLog::ERROR);
         return false;
     }
     return true;
 }
Example #6
0
 /**
  * Buy gold to a character
  * @param unknown_type $gold Gold object
  * @param unknown_type $realmid Realmid
  * @param unknown_type $char  Character object
  */
 public function buyGold($gold, $realmid, $char)
 {
     // Start transaction
     $this->_db->transactionStart();
     try {
         // Update user points
         $user = JFactory::getUser();
         $userid = $user->id;
         if (!JTrinityCoreUtilities::substractUserPoints($userid, $gold->cost, $this->_db)) {
             $this->_db->transactionRollback();
             return false;
         }
         $description = "Gold " . $gold->quantity;
         $donationtype = DONATIONTYPE_GOLD;
         // Update order table
         if (!JTrinityCoreUtilities::insertOrderTable($userid, $gold->id, $description, $gold->cost, $donationtype, $char->guid, $realmid, $this->_db)) {
             $this->_db->transactionRollback();
             return false;
         }
         // Update Gold to character
         // Add gold to character
         // Get character DB
         $chardbname = JTrinityCoreUtilities::getCharacterDBName($realmid);
         $dbtc = JTrinityCoreDBHelper::getDB();
         $addmoney = $gold->quantity * 10000;
         $sql = "UPDATE " . $chardbname . ".characters SET money=money+" . $addmoney . " WHERE guid=" . $char->guid;
         $dbtc->setQuery($sql);
         if (!$dbtc->query()) {
             $this->_db->transactionRollback();
             return false;
         }
         $this->_db->transactionCommit();
         return true;
     } catch (Exception $e) {
         JLog::add("Error buygold(): " . $e->getMessage(), JLog::ERROR);
         $this->_db->transactionRollback();
         return false;
     }
 }
Example #7
0
<?php

// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
<h1 class="contentheading">
<?php 
echo JText::_('COM_JTRINITYCORE_BUYPOINTS_TITLE');
?>
</h1 class="contentheading">
<?php 
$user_points = JTrinityCoreUtilities::ShowUserPoints();
?>
<br/><br/>
<form action="<?php 
echo JRoute::_('index.php?option=com_jtrinitycore&amp;view=buypoints&amp;layout=paypalexpresscheckout');
?>
" method="post" name="frmPuntos" id="frmPuntos">
<p style="padding-right: 25px;">
 
</p>
<input type="radio" name="typebuy" checked value="custom">
<?php 
echo JText::_('COM_JTRINITYCORE_ENTER_POINTS');
?>
<input type="text" size=6 name="points" value="5"><br/><br/>
<?php 
/*
<input type="radio" name="typebuy"  value="pack">&nbsp;&nbsp;<?php  echo JText::_('COM_JTRINITYCORE_ENTER_POINTS_SELECT_PACK');?> <br/>

<p style="padding-left: 25px;">
Example #8
0

<?php 
echo '<h1 class="contentheading">' . JText::_('COM_JTRINITYCORE_DONATION_SHOP_GOLD') . '</h1>';
// show user points
JTrinityCoreUtilities::ShowUserPoints(false);
?>


<form action="<?php 
echo JRoute::_('index.php?option=com_jtrinitycore&amp;view=buygold&amp;layout=buygold');
?>
" onsubmit="return validateForm();" method="post" name="frmBuy" id="frmBuy">

<?php 
JTrinityCoreUtilities::getRealmsOptionHTML(true);
?>
<select name="characterid" id="characterid">
<option  value="0"><?php 
echo JText::_('COM_JTRINITYCORE_SELECTCHARACTER');
?>
</option>
</select>
<br/> <br/>

<h3>
<?php 
echo JText::_('COM_JTRINITYCORE_SELECT_GOLD');
?>
</h3>
Example #9
0
<?php

/**
 * This is view file for cpanel
 *
 * PHP version 5
 *
 * @category   JTrinityCore
 * @package    ViewsAdmin
 * @subpackage Cpanel
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
//display the paypal donation button
JTrinityCoreUtilities::displayDonate();
?>
<table class="adminform"><tr><td width="55%" valign="top">

<div id="cpanel">
   
    <div style="float:left;">
            <div class="icon">
                <a href="index.php?option=com_jtrinitycore&view=items" >
                <img src="../media/com_jtrinitycore/images/items.png" height="50px" width="50px">
                <span><?php 
echo JText::_('COM_JTRINITYCORE_ITEMS');
?>
</span>
                </a>
            </div>
    </div>
Example #10
0
<?php

// No direct access to this file
defined('_JEXEC') or die('Restricted Access');
JRequest::checkToken() or die('Invalid Token');
// Get gold info
$model = $this->getModel();
$gold = $model->getGoldInfo(JRequest::getVar('gold'));
$characterid = JRequest::getVar('characterid');
$realmid = JRequest::getVar('realmid');
// Check if user has enough points
$userpoints = JTrinityCoreUtilities::getPoints();
if ($userpoints < $gold->cost) {
    echo JText::_('COM_JTRINITYCORE_NOT_ENOUGH_POINTS');
    return;
}
$char = JTrinityCoreDBHelper::getCharacterInfo($realmid, $characterid);
if ($model->buyGold($gold, $realmid, $char)) {
    echo JText::sprintf('COM_JTRINITYCORE_BUYGOLD_OK', $char->name, (int) floor($char->money / 10000) + $gold->quantity);
} else {
    echo JText::_('COM_JTRINITYCORE_BUYGOLD_ERROR');
}
Example #11
0
<?php

// no direct access
defined('_JEXEC') or die('Restricted access');
JTrinityCoreUtilities::CheckUserLogged();
$images = "media/com_jtrinitycore/images/";
?>


<?php 
$html = '<h1 class="contentheading">' . JText::_('COM_JTRINITYCORE_DONATIONSHOP_TITLE') . '</h1>
<h5>' . JText::_('COM_JTRINITYCORE_DONATIONSHOP_SELECT_DONATION') . '</h5><br/>';
// Items
$html .= '															 
      <table style="border-spacing: 25px;" ><tr>
      <td valign="top"><img width="60" height="50" border="0" src="' . $images . 'axe_trans.png"></td>
      <td valign="center">
      <a href="index.php?option=com_jtrinitycore&view=buyitems"> ' . JText::_('COM_JTRINITYCORE_DONATION_SHOP_ITEMS') . ' </a> <br/>      
      </td>
      </tr></table>';
// Powerleveling
$html .= '<br/>
<table ><tr>
<td valign="top"><img width="60" height="50" border="0" src="' . $images . 'powerleveling.gif"></td>
<td valign="center">
<a href="index.php?option=com_jtrinitycore&view=buypowerleveling"> ' . JText::_('COM_JTRINITYCORE_DONATION_SHOP_POWERLEVELING') . ' </a> <br/>
</td>
</tr></table>';
// Gold
$html .= '<br/>
<table><tr>
Example #12
0
 /**
  * Build an SQL query to load the list data.
  *	
  *
  * @return	JDatabaseQuery
  * @since	1.6
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $worlddb = JTrinityCoreUtilities::getWorldDBName(JRequest::getVar('realmid'));
     $db = JTrinityCoreDBHelper::getDB();
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select($this->getState('list.select', 'DISTINCT a.entry as itemid, itemlevel, requiredlevel, a.name as englishname, quality, allowablerace, subclass, class, inventorytype'));
     $query->from($worlddb . '.item_template AS a');
     $query->where('a.flags<>16 AND (a.name IS NOT NULL) AND (a.name not like \'%deprecated%\') AND (a.name not like \'%test%\')');
     $name = "a.name";
     $locale = JTrinityCoreUtilities::getLocale();
     if ($locale > 1) {
         $name = "name_loc" . $locale;
         $query->select($name . " as name");
         $query->where($name . " IS NOT NULL");
         $query->join('INNER', $worlddb . '.locales_item AS li ON li.entry=a.entry ');
         #__users AS uc ON uc.id=a.checked_out
     } else {
         $query->select("a.name as name");
     }
     // Filter by class state
     $class = $this->getState('filter.class_id');
     if (is_numeric($class)) {
         $query->where('a.class = ' . (int) $class);
     }
     // Filter on quality.
     $quality = $this->getState('filter.quality_id');
     if (is_numeric($quality)) {
         $query->where('a.Quality =' . $quality);
     }
     // Filter on Inventory Type.
     $inventory = $this->getState('filter.inventory_id');
     if (is_numeric($inventory)) {
         $query->where('a.InventoryType =' . $inventory);
     }
     // Filter on allowable class
     $allowableclass = $this->getState('filter.allowableclass');
     if (is_numeric($allowableclass)) {
         $query->where('a.AllowableClass =' . $allowableclass);
     }
     // Filter by search in title.
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'itemid:') === 0) {
             $query->where('a.displayid = ' . (int) substr($search, 7));
         } else {
             if (stripos($search, 'itemlevel:') === 0) {
                 $query->where('itemlevel = ' . (int) substr($search, 10));
             }
         }
         if (stripos($search, 'requiredlevel:') === 0) {
             $query->where('requiredlevel = ' . (int) substr($search, 14));
         } else {
             $search = $db->Quote('%' . $db->escape($search, true) . '%');
             $query->where('(' . $name . ' LIKE ' . $search . ')');
         }
     }
     // Add the list ordering clause.
     $orderCol = $this->state->get('list.ordering', 'i.name');
     $orderDirn = $this->state->get('list.direction', 'asc');
     //echo "Order field=".$orderCol."---<br>";
     if ($orderCol == 'a.name' || $orderCol == 'name') {
         $orderCol = 'name ';
     }
     if ($orderCol == 'a.itemid' || $orderCol == 'itemid') {
         $orderCol = 'itemid ';
     }
     if ($orderCol == 'a.itemlevel' || $orderCol == 'itemlevel') {
         $orderCol = 'itemlevel ';
     }
     //sqlsrv change
     /*if($orderCol == 'access_level')
     		$orderCol = 'ag.title';*/
     $query->order($db->escape($orderCol . ' ' . $orderDirn));
     // echo nl2br(str_replace('#__','jos_',$query));
     //JLog::add('Query='.$query, JLog::WARNING, 'deprecated');
     //JError::raiseError(0, JText::sprintf('DB Name antes='.$db->getDatabase()."  Version=".$db->getVersion()."  connected=".$db->connected(), 'hola'));
     return $query;
 }
Example #13
0
 public static function insertOrderTable($userid, $productid, $description, $cost, $donationtype, $charid = null, $realmid = null, $db = null)
 {
     // Insert the orders table
     $order = new stdClass();
     $order->id = NULL;
     $order->userid = $userid;
     $order->description = $description;
     $order->productid = $productid;
     $order->points = $cost;
     if ($charid) {
         $order->charid = $charid;
     }
     if ($realmid) {
         $order->realmid = $realmid;
     }
     $order->ordertype = $donationtype;
     $order->orderdate = JTrinityCoreUtilities::getCurrentDatetime();
     if (!$db) {
         $db = JFactory::getDbo();
     }
     if (!$db->insertObject('#__jtc_orders', $order, 'id')) {
         JLog::add("insertOrderTable(): Error inserting jtc_orders. Userid=" . $userid . " producti=" . $productid, JLog::ERROR);
         return false;
     }
     return true;
 }
Example #14
0
 /**
  * Send the item purchased to the mailbox character
  * @param unknown_type $item  item object from joomla database
  * @param unknown_type $realmid the realm of the character
  * @param unknown_type $character character object
  */
 public function sendItem($item, $realmid, $character)
 {
     // Get character DB
     $chardbname = JTrinityCoreUtilities::getCharacterDBName($realmid);
     $dbo = JTrinityCoreDBHelper::getDB();
     $characterid = $character->guid;
     $itemid = $item->itemid;
     //JLog::add("characterid=".$characterid."   productid=".$productid."   realmid=".$realmid." item name=".$item->name);
     // Get the mail id to insert
     // Start transaction
     $dbo->transactionStart();
     try {
         $ok = true;
         $sql = "SELECT MAX(id) FROM " . $chardbname . ".mail";
         $dbo->setQuery($sql);
         $id = $dbo->loadResult();
         if (!$id) {
             $id = 0;
         }
         $id = $id + 1;
         $mail = new stdClass();
         $mail->id = $id;
         $mail->messageType = 5;
         $mail->stationery = 41;
         $mail->sender = 0;
         // Should  be the admin GM
         $mail->receiver = $characterid;
         $mail->has_items = 1;
         $mail->subject = JText::_('COM_JTRINITYCORE_MAIL_ITEM_SUBJECT');
         $mail->body = JText::sprintf('COM_JTRINITYCORE_MAIL_ITEM_BODY', $character->name, $item->name);
         // Insert into mail table
         if ($dbo->insertObject($chardbname . '.mail', $mail, 'id')) {
             // Insert into item instance table
             $sql = "SELECT MAX(guid) FROM " . $chardbname . ".item_instance";
             $dbo->setQuery($sql);
             $iteminstanceid = $dbo->loadResult();
             if (!$iteminstanceid) {
                 $iteminstanceid = 0;
             }
             $iteminstanceid = $iteminstanceid + 1;
             $item_instance = new stdClass();
             $item_instance->guid = $iteminstanceid;
             $item_instance->itemEntry = $item->itemid;
             $item_instance->owner_guid = $characterid;
             $item_instance->durability = $this->getMaxDurability($item->itemid, $relmid);
             // $item->maxdurability;
             if ($dbo->insertObject($chardbname . '.item_instance', $item_instance, 'guid')) {
                 // Insert into mail_items table
                 $mail_item = new stdClass();
                 $mail_item->mail_id = $id;
                 $mail_item->item_guid = $iteminstanceid;
                 $mail_item->receiver = $characterid;
                 if (!$dbo->insertObject($chardbname . '.mail_items', $mail_item)) {
                     $ok = false;
                     JLog::add("sendItem(): Error inserting item_instance. ", JLog::ERROR, 'donationshop');
                 }
             } else {
                 $ok = false;
             }
         } else {
             $ok = false;
             JLog::add("sendItem(): Error inserting table mail. ", JLog::ERROR, 'donationshop');
         }
         if (!$ok) {
             $dbo->transactionRollback();
             return false;
         }
         $dbo->transactionCommit();
         $user = JFactory::getUser();
         $cost = $item->cost;
         // Update the new points to the user
         if (!JTrinityCoreUtilities::substractUserPoints($user->id, $cost)) {
             return false;
         }
         // Insert into the order table
         $description = $item->name . " (Level=" . $item->itemlevel . ")";
         $donationtype = DONATIONTYPE_ITEM;
         $userid = $user->id;
         if (!JTrinityCoreUtilities::insertOrderTable($userid, $item->id, $description, $cost, $donationtype, $characterid, $realmid)) {
             return false;
         }
         return true;
     } catch (Exception $e) {
         JLog::add("Error: " . $e->getMessage(), JLog::ERROR, "donationhop->sendItem");
         $dbo->transactionRollback();
         return false;
     }
 }
Example #15
0
<?php 
foreach ($this->items as $i => $item) {
    ?>
	<tr class="row<?php 
    echo $i % 2;
    ?>
">
		<td>
			<?php 
    echo $item->id;
    ?>
		</td>		
		<td>
			<?php 
    echo JTrinityCoreUtilities::getOrderTypeText($item->ordertype);
    ?>
		</td>
		<td>
			<?php 
    echo $item->description;
    ?>
		</td>	
		
		<td>
			<?php 
    echo $item->points;
    ?>
		</td>
		
		<td>
Example #16
0
    standard button). The fields PayPal recommends checking are:
    1. Check the $_POST['payment_status'] is "Completed"
    2. Check that $_POST['txn_id'] has not been previously processed
    3. Check that $_POST['receiver_email'] is your Primary PayPal email
    4. Check that $_POST['payment_amount'] and $_POST['payment_currency']
    are correct
    Since implementations on this varies, I will leave these checks out of this
    example and just send an email using the getTextReport() method to get all
    of the details about the IPN.
    */
    mail($mail, 'Verified IPN', $listener->getTextReport());
    JLog::add("Verified IPN. UserId=" . $user->id . "  Username="******"   Remote IP=" . JTrinityCoreUtilities::getRemoteIP() . "  Report=" . $listener->getTextReport(), JLog::INFO, 'ipn.php');
    JLog::add("Verified IPN. Payment amount=" . JRequest::getVar('payment_amount') . "  Receiver mail=" . JRequest::getVar('receiver_email') . " Payment status=" . JRequest::getVar('payment_status'), 'ipn.php');
    // Check if succesfull to add the points to the user
    if (JRequest::getVar('payment_status') == 'Completed' && !transactionExist(JRequest::getVar('txn_id'))) {
        // Add transaction ID to the database with status COMPLETED
        // Add points to the user
        // Message OK to the user
    } else {
        // Add transaction id to the database with status NO completed
        // Message failed to the user
    }
} else {
    /*
    An Invalid IPN *may* be caused by a fraudulent transaction attempt. It's
    a good idea to have a developer or sys admin manually investigate any
    invalid IPN.
    */
    mail($mail, 'Invalid IPN', $listener->getTextReport());
    JLog::add("Invalid IPN. UserId=" . $user->id . "  Username="******"   Remote IP=" . JTrinityCoreUtilities::getRemoteIP() . "  Report=" . $listener->getTextReport(), JLog::CRITICAL, 'ipn.php');
}
Example #17
0
<?php

// No direct access to this file
defined('_JEXEC') or die('Restricted Access');
JRequest::checkToken() or die(JText::_('Invalid Token'));
$app = JFactory::getApplication();
$productid = $app->getUserState("productid");
$donationtype = $app->getUserState("donationtype");
$realmid = JRequest::getVar("realmid");
$characterid = JRequest::getVar("characterid");
if ($donationtype == DONATIONTYPE_POWERLEVELING) {
    if (!$this->buyPowerleveling($productid, $realmid, $characterid)) {
        return false;
    }
} elseif ($donationtype == DONATIONTYPE_ITEM) {
    if (!$this->buyItem($productid, $realmid, $characterid)) {
        return false;
    }
} else {
    die("Wrong donationtype");
}
// show user points
JTrinityCoreUtilities::ShowUserPoints(false);
?>