PageRenderTime 52ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/cake/app_controller.php

https://bitbucket.org/fxrialab/spsp_editor
PHP | 240 lines | 109 code | 20 blank | 111 comment | 9 complexity | 9c47b236144d6ed049b9258695598a7c MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. /* SVN FILE: $Id: app_controller.php 4409 2007-02-02 13:20:59Z phpnut $ */
  3. /**
  4. * Short description for file.
  5. *
  6. * This file is application-wide controller file. You can put all
  7. * application-wide controller-related methods here.
  8. *
  9. * PHP versions 4 and 5
  10. *
  11. * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
  12. * Copyright 2005-2007, Cake Software Foundation, Inc.
  13. * 1785 E. Sahara Avenue, Suite 490-204
  14. * Las Vegas, Nevada 89104
  15. *
  16. * Licensed under The MIT License
  17. * Redistributions of files must retain the above copyright notice.
  18. *
  19. * @filesource
  20. * @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
  21. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  22. * @package cake
  23. * @subpackage cake.cake
  24. * @since CakePHP(tm) v 0.2.9
  25. * @version $Revision: 4409 $
  26. * @modifiedby $LastChangedBy: phpnut $
  27. * @lastmodified $Date: 2007-02-02 07:20:59 -0600 (Fri, 02 Feb 2007) $
  28. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  29. */
  30. /**
  31. * This is a placeholder class.
  32. * Create the same file in app/app_controller.php
  33. *
  34. * Add your application-wide methods in the class below, your controllers
  35. * will inherit them.
  36. *
  37. * @package cake
  38. * @subpackage cake.cake
  39. */
  40. class AppController extends Controller {
  41. var $components = array('RequestHandler','Gcheckout','Paypal');
  42. //the public variables are used for PAYPAL
  43. //put tha clock of code in
  44. public $returnUrl="";
  45. public $cancelUrl="";
  46. public $notifyUrl="";
  47. public $amountPay=NULL;
  48. public $userEmail=NULL;
  49. public $eventId=NULL;
  50. public $userId=NULL;
  51. public $merchantEmail=NULL;
  52. public $itemName=NULL;
  53. public $itemNumber=NULL;
  54. public $itemQuantity=NULL;
  55. public $invoice=NULL;
  56. public $custom=NULL;
  57. public $paypalUrl='https://www.sandbox.paypal.com/cgi-bin/webscr';
  58. public $ticketPaymentMsg=NULL;
  59. function paypal() {
  60. if(isset($this->ticketPaymentMsg))
  61. $this->Paypal->ticketPayment=$this->ticketPaymentMsg;
  62. $this->Paypal->paypal_class();
  63. $this->Paypal->paypal_url = $this->paypalUrl;
  64. $this->Paypal->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
  65. $this->Paypal->add_field('business', $this->merchantEmail);
  66. $this->Paypal->add_field('return', $this->returnUrl);
  67. //$this->Paypal->add_field('cancel_return', $this->cancelUrl);
  68. $this->Paypal->add_field('notify_url', $this->notifyUrl);
  69. $this->Paypal->add_field('item_name', $this->itemName);
  70. $this->Paypal->add_field('amount', $this->amountPay);
  71. $this->Paypal->add_field('quantity', $this->itemQuantity);
  72. $this->Paypal->add_field('custom', $this->custom);
  73. $this->Paypal->add_field('invoice',$this->invoice);
  74. $this->Paypal->add_field('cbt','Return to Xoimages.com to complete your transaction');
  75. $this->Paypal->submit_paypal_post(); // submit the fields to paypal
  76. }
  77. //-----
  78. function transactionMaster($transactionDesc = null,$transactionHead = null,$transactionTitle = null, $invoice = null,$invoiceId = null) {
  79. mysql_query("
  80. INSERT INTO
  81. xouser_transactions(transaction_desc,transaction_head,transaction_title,invoice,invoice_id)
  82. VALUES('".$transactionDesc."','".$transactionHead."','".$transactionTitle."','".$invoice."','".$invoiceId."')") or die("Error on line ".__LINE__.mysql_error());
  83. return $xouserTransactionId=mysql_insert_id();
  84. }
  85. //'-1' entry implies that buyer has been charged
  86. //'+1' entry implies thar he has paid the amount that is charged
  87. //At the time of commission calculation we will make the charged entry against the user
  88. function transactionDetail($buyer = null,$amount = null,$DbCr = null,$lastTransactionId = null, $receipient = null) {
  89. mysql_query("INSERT INTO
  90. xouser_transaction_details(user_id,amount,DrCr,xouser_transaction_id,payment_to)
  91. VALUES('".$buyer."','".$amount."','".$DbCr."','".$lastTransactionId."','".$receipient."')");
  92. }
  93. function getPaymentMethods($userId) {
  94. /*$queryAdminPaymentSetup=mysql_query("SELECT paypal_email,gcheckout_email FROM user_payment_setup WHERE user_id='".$userId."'") or die("Error on line :".__LINE__.mysql_error());*/
  95. $queryAdminPaymentSetup=mysql_query("SELECT paypal_email FROM user_payment_setup WHERE user_id='".$userId."'") or die("Error on line :".__LINE__.mysql_error());
  96. $fetchAdminPaymentSetup=mysql_fetch_assoc($queryAdminPaymentSetup);
  97. return $fetchAdminPaymentSetup;
  98. }
  99. function getUserDetails($userId) {
  100. $qry2=mysql_query("SELECT UD.*,U.* FROM user_details UD,users U WHERE UD.user_id=U.id AND U.id='".$userId."'");
  101. $rowQry=mysql_fetch_assoc($qry2);
  102. return $rowQry;
  103. }
  104. function senderMail($sender=null,$receiver=null,$subject=null,$body=null) {
  105. $mailQry = "
  106. INSERT INTO sent_mails(user_id, reciever_id, email_subject, email_body)
  107. VALUES(".$sender.", ".$receiver.", '".$subject."', '".addslashes($body)."')";
  108. $sentMailUpdate = mysql_query($mailQry) or die("1 - ".mysql_error());
  109. }
  110. function receiverMail($receiver=null,$sender=null,$subject=null,$body=null) {
  111. $eMailQry = "
  112. INSERT INTO
  113. emails(user_id, email_creater, email_subject, email_body)
  114. VALUES(".$receiver.", ".$sender.", '".$subject."', '".addslashes($body)."')";
  115. $inboxUpdate = mysql_query($eMailQry) or die("2 - ".mysql_error());
  116. }
  117. function parseXmlArray($xmlData) {
  118. $data = $xmlData;
  119. $xml_parser = xml_parser_create();
  120. xml_parse_into_struct($xml_parser, $data, $vals, $index);
  121. xml_parser_free($xml_parser);
  122. $params = array();
  123. $level = array();
  124. foreach ($vals as $xml_elem) {
  125. if ($xml_elem['type'] == 'open') {
  126. if (array_key_exists('attributes',$xml_elem)) {
  127. list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']);
  128. }
  129. else {
  130. $level[$xml_elem['level']] = $xml_elem['tag'];
  131. }
  132. }
  133. if ($xml_elem['type'] == 'complete') {
  134. $start_level = 1;
  135. $php_stmt = '$params';
  136. while($start_level < $xml_elem['level']) {
  137. $php_stmt .= '[$level['.$start_level.']]';
  138. $start_level++;
  139. }
  140. $php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
  141. eval($php_stmt);
  142. }
  143. }
  144. return $params;
  145. }
  146. function checkSession() {
  147. // If the session info hasn't been set...
  148. if (!$this->Session->check('Admin')) {
  149. // Force the user to login
  150. $this->redirect('/admins/login');
  151. }
  152. else {
  153. $this->layout = 'default_after_login';
  154. /*$hours = date("H");
  155. $minutes = date("i");
  156. $seconds = date("s");
  157. $month = date("m");
  158. $day = date("d");
  159. $year = date("Y");
  160. $total = date("m-d-Y-H-i-s");
  161. $now = mktime($hours, $minutes, $seconds, $month, $day, $year);
  162. $page_qry = "select * from sites where page='$_SERVER[REQUEST_URI]'";
  163. $res_page = mysql_query($page_qry);
  164. if(mysql_num_rows($res_page)==0)
  165. {
  166. $qry = "insert into `sites` (page, time, referrer, browser, ip, timeStamp, pagetitle, visits) values ('$_SERVER[REQUEST_URI]', '$total', '$_SERVER[HTTP_REFERER]', '$_SERVER[HTTP_USER_AGENT]', '$_SERVER[REMOTE_ADDR]', '$now', '".$this->pageTitle."', 1 )";
  167. $res = mysql_query($qry);
  168. }
  169. else
  170. {
  171. $qry = "UPDATE `sites` SET visits = visits + 1 WHERE `page` ='$_SERVER[REQUEST_URI]'";
  172. $res = mysql_query($qry);
  173. }*/
  174. }
  175. }
  176. /*function checkAccess()
  177. {
  178. // Check access using the component:
  179. $access = $_SESSION['Admin_type'];
  180. //access denied
  181. if ($access == 1)
  182. {
  183. return true;
  184. //exit;
  185. }
  186. //access allowed
  187. else
  188. {
  189. return false;
  190. }
  191. }
  192. function checkAccess1($menu_name,$permission_type)
  193. {
  194. // Check access using the component:
  195. //$access = $_SESSION[$menu_name]['modify'];
  196. $access = $this->Acl->check($_SESSION['Admin_cat'],$menu_name,$permission_type);
  197. //access denied
  198. if ($access)
  199. {
  200. return true;
  201. //exit;
  202. }
  203. //access allowed
  204. else
  205. {
  206. $this->redirect('admins/access_denied');
  207. return false;
  208. }
  209. }*/
  210. }
  211. ?>