Пример #1
0
 /**
  *
  */
 function process()
 {
     $mainframe = JFactory::getApplication();
     //backward compatible with Jomcomment component.
     //The Jomcomment component uses $my as global variable so we need to declare $my as global
     //The global declearation is only added if com_jomcomment folder is existing
     //@Todo: A standard fix should remove the $my global in Jomcomment. For now we use this fix solution to minimize the effort
     if (file_exists(JAX_SITE_ROOT . '/components/com_jomcomment')) {
         global $my;
     }
     $my = JFactory::getUser();
     if (!defined('SERVICES_JSON_SLICE')) {
         include_once AZRUL_SYSTEM_PATH . '/pc_includes/JSON.php';
     }
     $json = new Services_JSON();
     if (@isset($_REQUEST['task']) && $_REQUEST['task'] == 'azrul_ajax') {
         if (!isset($my)) {
             $my = $mainframe->getUser();
         }
         $func = @$_REQUEST['func'];
         // Security fix.
         // 1. check if user are trying to run an eval
         # build an array of args
         $args = array();
         $argCount = 0;
         # All POST data that are meant to be send to the function will
         # be appended by 'arg' keyword. Only pass this vars to the function
         foreach ($_REQUEST as $key => $postData) {
             if (substr($key, 0, 3) == 'arg') {
                 //if ( get_magic_quotes_gpc() ) {
                 if (is_array($postData)) {
                     foreach ($postData as &$data) {
                         $data = stripcslashes($data);
                     }
                 } else {
                     $postData = stripcslashes($postData);
                 }
                 //}
                 $postData = $this->nl2brStrict($postData);
                 if (!is_array($postData)) {
                     $decoded = $json->decode($postData);
                 } else {
                     //array input decode need to be implemented in the future
                     $decoded = $postData;
                 }
                 $key = "";
                 $val = "";
                 # if the args is an array, we need to pass it as an array
                 # todo@ we need to expand this array further. We now assume,
                 # if an array is passed, it comes in a pair of (key/value)
                 if (is_array($decoded)) {
                     foreach ($decoded as $index => $value) {
                         $tempArray = array();
                         if (is_array($value)) {
                             foreach ($value as $val) {
                                 // The value is an array so we need to chuck them in
                                 // a multidimensional array instead
                                 if (is_array($val)) {
                                     // Since the values here are array, we will
                                     // always assume that the index 0 is always the key
                                     $key = $val[0];
                                     $data = $this->br2nl(rawurldecode($val[1]));
                                     // We will also always assume that the index 1 will be the value
                                     $decoded[$key][] = $data;
                                 } else {
                                     // We always assume that the index 0 is the key of the array.
                                     $key = $value[0];
                                     // We always assume that the index 1 is the data of the array.
                                     $data = $this->br2nl(rawurldecode($value[1]));
                                     if (substr($value[0], 0, 6) == '_d_') {
                                         $decoded = array($val);
                                     } else {
                                         $newArray = array($key => $data);
                                         $decoded = array_merge($decoded, $newArray);
                                         //$newA     = array($key => $val);
                                         //$decoded  = array_merge($decoded, $newA);
                                     }
                                 }
                             }
                         } else {
                             // If data passed is not array we treat
                             if ($value != '_d_') {
                                 $decoded = $this->br2nl(rawurldecode($value));
                             }
                         }
                     }
                     $args[] = $decoded;
                 } else {
                     $args[] = $this->br2nl(rawurldecode($decoded));
                 }
                 $argCount++;
             }
         }
         # Include the main component file
         $comName = $_REQUEST['option'];
         ob_start();
         global $jaxFuncNames;
         //check if user is in the admin interface or not
         if (JFactory::getApplication()->isAdmin()) {
             include_once JAX_SITE_ROOT . "/administrator/components/com_{$comName}/{$comName}.php";
             // Test, and make sure $my object is valid
             if (!$my->id) {
                 echo "Invalid access";
                 exit;
             }
         } else {
             include_once JAX_SITE_ROOT . "/components/com_{$comName}/{$comName}.php";
         }
         @ob_end_clean();
         $jaxFilename = JAX_SITE_ROOT . "/components/com_{$comName}/jax.{$comName}.php";
         include_once $jaxFilename;
         // check and make sure the fucntion name is actually registered
         if (!in_array($func, $jaxFuncNames)) {
             //print_r($jaxFuncNames);
             echo 'Invalid Function Calls';
             exit;
         }
         $funcArray = explode(',', $func);
         // Joomla post session token checking
         if (!JSession::checkToken('post')) {
             $func = $_REQUEST['func'];
             $list = explode(',', $func);
             if ($list[0] !== 'register' && $list[0] !== 'connect' && $list[1] !== 'ajaxUpdate' && $list[1] !== 'ajaxGetLoginFormToken') {
                 require_once JPATH_ROOT . '/components/com_community/controllers/controller.php';
                 $controller = new CommunityBaseController();
                 echo $controller->ajaxBlockUnregister();
             }
         }
         // Object call
         if (count($funcArray) > 1) {
             //$response = call_user_func_array($funcArray, $args);
             $entryPoint = $comName . 'AjaxEntry';
             $arg = array();
             $arg[] = $func;
             $arg[] = $args;
             $response = call_user_func_array($entryPoint, $arg);
         } else {
             $response = call_user_func_array($func, $args);
         }
         //header('Content-type: text/plain');
         //echo $response;
         //exit;
     }
 }
Пример #2
0
 /**
  * Constructor
  * @param type $config
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->_facebook = new CFacebook();
 }