Ejemplo n.º 1
0
 public static function g_onCCK_PaymentValidate($data, $success, &$config)
 {
     $update = 'pay_return = "' . JCckDatabase::escape(json_encode($data['order'])) . '",' . 'pay_return_payments = "' . JCckDatabase::escape(json_encode($data['payments'])) . '",' . 'state = ' . $data['order_state'];
     JCckDatabase::execute('UPDATE #__cck_more_ecommerce_orders SET ' . $update . ' WHERE pay_key = "' . $config['pay_key'] . '"');
     if (!$success) {
         return;
     }
     // Cart
     $cart_id = (int) JCckDatabase::loadResult('SELECT a.id FROM #__cck_more_ecommerce_carts AS a WHERE a.pay_key = "' . $config['pay_key'] . '"');
     if ($cart_id) {
         JCckDatabase::execute('UPDATE #__cck_more_ecommerce_carts SET pay_key = "" WHERE id = ' . $cart_id);
         JCckDatabase::execute('DELETE a.* FROM #__cck_more_ecommerce_cart_product AS a WHERE a.cart_id = ' . $cart_id);
     }
     // Execute Processings (Invoice, Notifications, ...)
     if (JCckToolbox::getConfig()->get('processing', 0)) {
         $event = 'onCckPaymentSuccess';
         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile, options FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
         if (isset($processing[$event])) {
             foreach ($processing[$event] as $p) {
                 if (is_file(JPATH_SITE . $p->scriptfile)) {
                     $options = new JRegistry($p->options);
                     include_once JPATH_SITE . $p->scriptfile;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function onContentAfterDelete($context, $data)
 {
     switch ($context) {
         case 'com_content.article':
             $base = 'content';
             $custom = 'introtext';
             $pk = $data->id;
             break;
         case 'com_categories.category':
             $base = 'categories';
             $custom = 'description';
             $pk = $data->id;
             break;
         default:
             return true;
     }
     preg_match('#::cck::(.*)::/cck::#U', $data->{$custom}, $matches);
     $id = $matches[1];
     if (!$id) {
         return true;
     }
     $table = JCckTable::getInstance('#__cck_core', 'id', $id);
     $type = $table->cck;
     $table->delete();
     // Processing
     JLoader::register('JCckToolbox', JPATH_PLATFORM . '/cms/cck/toolbox.php');
     if (JCckToolbox::getConfig()->get('processing', 0)) {
         $event = 'onContentAfterDelete';
         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile FROM #__cck_more_toolbox_processings WHERE published = 1 ORDER BY ordering', 'type');
         if (isset($processing[$event])) {
             foreach ($processing[$event] as $p) {
                 if (is_file(JPATH_SITE . $p->scriptfile)) {
                     include_once JPATH_SITE . $p->scriptfile;
                     /* Variables: $id, $pk, $type */
                 }
             }
         }
     }
     $tables = JCckDatabase::loadColumn('SHOW TABLES');
     $prefix = JFactory::getApplication()->getCfg('dbprefix');
     if (in_array($prefix . 'cck_store_item_' . $base, $tables)) {
         $table = JCckTable::getInstance('#__cck_store_item_' . $base, 'id', $pk);
         if ($table->id) {
             $table->delete();
         }
     }
     if (in_array($prefix . 'cck_store_form_' . $type, $tables)) {
         $table = JCckTable::getInstance('#__cck_store_form_' . $type, 'id', $pk);
         if ($table->id) {
             $table->delete();
         }
     }
     return true;
 }
Ejemplo n.º 3
0
 public static function process($event)
 {
     $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
     if (isset($processing[$event])) {
         foreach ($processing[$event] as $p) {
             if (is_file(JPATH_SITE . $p->scriptfile)) {
                 include_once JPATH_SITE . $p->scriptfile;
             }
         }
     }
 }
Ejemplo n.º 4
0
 public function onUserBeforeSave($user, $isNew, $user2)
 {
     // Processing
     JLoader::register('JCckToolbox', JPATH_PLATFORM . '/cms/cck/toolbox.php');
     if (JCckToolbox::getConfig()->get('processing', 0)) {
         $event = 'onUserBeforeSave';
         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
         if (isset($processing[$event])) {
             foreach ($processing[$event] as $p) {
                 if (is_file(JPATH_SITE . $p->scriptfile)) {
                     include_once JPATH_SITE . $p->scriptfile;
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 public function download()
 {
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id', 0);
     $fieldname = $app->input->getString('file', '');
     $collection = $app->input->getString('collection', '');
     $xi = $app->input->getString('xi', 0);
     $client = $app->input->getString('client', 'content');
     $restricted = '';
     $user = JFactory::getUser();
     if (!$id) {
         $file = $fieldname;
         $path = JPATH_ROOT . '/' . $file;
         $paths = JCck::getConfig_Param('media_paths', '');
         if ($paths != '') {
             $allowed = false;
             $paths = strtr($paths, array("\r\n" => '<br />', "\r" => '<br />', "\n" => '<br />'));
             $paths = explode('<br />', $paths);
             if (count($paths)) {
                 $paths[] = 'tmp/';
                 foreach ($paths as $p) {
                     if (strpos($path, JPATH_ROOT . '/' . $p) !== false) {
                         $allowed = true;
                         break;
                     }
                 }
             }
             if (!$allowed) {
                 $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error");
                 return;
             }
         } elseif (strpos($path, JPATH_ROOT . '/tmp/') === false) {
             $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error");
             return;
         }
     } else {
         $field = JCckDatabase::loadObject('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name="' . ($collection != '' ? $collection : $fieldname) . '"');
         //#
         $query = 'SELECT a.id, a.pk, a.author_id, a.cck as type, a.storage_location, b.' . $field->storage_field . ' as value, c.id as type_id' . ' FROM #__cck_core AS a' . ' LEFT JOIN ' . $field->storage_table . ' AS b on b.id = a.pk' . ' LEFT JOIN #__cck_core_types AS c on c.name = a.cck' . ' WHERE a.id =' . (int) $id;
         $core = JCckDatabase::loadObject($query);
         $config = array('author' => $core->author_id, 'client' => $client, 'collection' => $collection, 'fieldname' => $fieldname, 'id' => $core->id, 'isNew' => 0, 'location' => $core->storage_location, 'pk' => $core->pk, 'pkb' => 0, 'task' => 'download', 'type' => $core->type, 'type_id' => $core->type_id, 'xi' => $xi);
         $dispatcher = JDispatcher::getInstance();
         $field->value = $core->value;
         $pk = $core->pk;
         $value = '';
         JPluginHelper::importPlugin('cck_storage');
         $dispatcher->trigger('onCCK_StoragePrepareDownload', array(&$field, &$value, &$config));
         // Access
         $clients = JCckDatabase::loadObjectList('SELECT a.fieldid, a.client, a.access, a.restriction, a.restriction_options FROM #__cck_core_type_field AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE a.fieldid = ' . (int) $field->id . ' AND b.name="' . (string) $config['type'] . '"', 'client');
         $access = isset($clients[$client]->access) ? (int) $clients[$client]->access : 0;
         $autorised = $user->getAuthorisedViewLevels();
         $restricted = isset($clients[$client]->restriction) ? $clients[$client]->restriction : '';
         if (!($access > 0 && array_search($access, $autorised) !== false)) {
             $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error");
             return;
         }
         JPluginHelper::importPlugin('cck_field');
         $field = JCckDatabase::loadObject('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name="' . $fieldname . '"');
         //#
         if ($restricted) {
             JPluginHelper::importPlugin('cck_field_restriction');
             $field->restriction = $restricted;
             $field->restriction_options = $clients[$client]->restriction_options;
             $allowed = JCck::callFunc_Array('plgCCK_Field_Restriction' . $restricted, 'onCCK_Field_RestrictionPrepareContent', array(&$field, &$config));
             if ($allowed !== true) {
                 $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error");
                 return;
             }
         }
         $dispatcher->trigger('onCCK_FieldPrepareDownload', array(&$field, $value, &$config));
         $file = $field->filename;
     }
     $path = JPATH_ROOT . '/' . $file;
     if (is_file($path) && $file) {
         $size = filesize($path);
         $ext = strtolower(substr(strrchr($path, '.'), 1));
         if ($ext == 'php' || $file == '.htaccess') {
             return;
         }
         $name = substr($path, strrpos($path, '/') + 1, strrpos($path, '.'));
         if ($path) {
             $task2 = isset($field->task) ? $field->task : 'download';
             if ($task2 == 'read') {
                 $this->setRedirect(JURI::root(true) . '/' . $file);
             } else {
                 if ($id) {
                     $event = 'onCckDownloadSuccess';
                     if (JCckToolbox::getConfig()->get('processing', 0)) {
                         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
                         if (isset($processing[$event])) {
                             foreach ($processing[$event] as $p) {
                                 if (is_file(JPATH_SITE . $p->scriptfile)) {
                                     include_once JPATH_SITE . $p->scriptfile;
                                 }
                             }
                         }
                     }
                     $this->_download_hits($id, $fieldname, $collection, $xi);
                 }
                 set_time_limit(0);
                 @ob_end_clean();
                 include JPATH_ROOT . '/components/com_cck/download.php';
             }
         }
     } else {
         $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_DOESNT_EXIST'), 'error');
     }
 }
Ejemplo n.º 6
0
 public function onContentAfterDelete($context, $data)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('name AS object')->from('#__cck_core_objects')->where('context = ' . $db->quote($context));
     $db->setQuery($query);
     $object = $db->loadResult();
     if (!$object) {
         return true;
     }
     $tableKey = $data->getKeyName();
     $pk = $data->{$tableKey};
     $base = str_replace('#__', '', $data->getTableName());
     require_once JPATH_SITE . '/plugins/cck_storage_location/' . $object . '/' . $object . '.php';
     $properties = array('custom');
     $properties = JCck::callFunc('plgCCK_Storage_Location' . $object, 'getStaticProperties', $properties);
     $custom = $properties['custom'];
     $type = '';
     // Core
     if ($custom) {
         preg_match('#::cck::(.*)::/cck::#U', $data->{$custom}, $matches);
         $id = $matches[1];
         if (!$id) {
             return true;
         }
         $table = JCckTable::getInstance('#__cck_core', 'id', $id);
         $type = $table->cck;
     } else {
         $table = JCckTable::getInstance('#__cck_core');
         if ($table->load(array('pk' => $pk, 'storage_location' => $object))) {
             $type = $table->cck;
         }
     }
     if ($table->pk > 0) {
         // -- Leave nothing behind
         if ($type != '') {
             require_once JPATH_LIBRARIES . '/cck/base/form/form.php';
             JPluginHelper::importPlugin('cck_field');
             JPluginHelper::importPlugin('cck_storage');
             JPluginHelper::importPlugin('cck_storage_location');
             $config = array('pk' => $table->pk, 'storages' => array(), 'type' => $table->cck);
             $dispatcher = JDispatcher::getInstance();
             $parent = JCckDatabase::loadResult('SELECT parent FROM #__cck_core_types WHERE name = "' . $type . '"');
             $fields = CCK_Form::getFields(array($type, $parent), 'all', -1, '', true);
             if (count($fields)) {
                 foreach ($fields as $field) {
                     $Pt = $field->storage_table;
                     $value = '';
                     /* Yes but, .. */
                     if ($Pt && !isset($config['storages'][$Pt])) {
                         $config['storages'][$Pt] = '';
                         $dispatcher->trigger('onCCK_Storage_LocationPrepareDelete', array(&$field, &$config['storages'][$Pt], $pk, &$config));
                     }
                     $dispatcher->trigger('onCCK_StoragePrepareDelete', array(&$field, &$value, &$config['storages'][$Pt], &$config));
                     $dispatcher->trigger('onCCK_FieldDelete', array(&$field, $value, &$config, array()));
                 }
             }
         }
         // -- Leave nothing behind
         $table->delete();
     }
     // Processing
     JLoader::register('JCckToolbox', JPATH_PLATFORM . '/cms/cck/toolbox.php');
     if (JCckToolbox::getConfig()->get('processing', 0)) {
         $event = 'onContentAfterDelete';
         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
         if (isset($processing[$event])) {
             foreach ($processing[$event] as $p) {
                 if (is_file(JPATH_SITE . $p->scriptfile)) {
                     include_once JPATH_SITE . $p->scriptfile;
                     /* Variables: $id, $pk, $type */
                 }
             }
         }
     }
     $tables = JCckDatabase::loadColumn('SHOW TABLES');
     $prefix = JFactory::getConfig()->get('dbprefix');
     if (in_array($prefix . 'cck_store_item_' . $base, $tables)) {
         $table = JCckTable::getInstance('#__cck_store_item_' . $base, 'id', $pk);
         if ($table->id) {
             $table->delete();
         }
     }
     if (in_array($prefix . 'cck_store_form_' . $type, $tables)) {
         $table = JCckTable::getInstance('#__cck_store_form_' . $type, 'id', $pk);
         if ($table->id) {
             $table->delete();
         }
     }
     return true;
 }
Ejemplo n.º 7
0
}
if ($app->isSite() && $hashed !== NULL && $hash != $hashed) {
    $config = array('pk' => 0, 'options' => '', 'url' => @$preconfig['url'], 'validate' => '');
    $app->enqueueMessage(JText::_('COM_CCK_ERROR_DATA_INTEGRITY_CHECK_FAILED'), 'error');
    return 0;
}
require_once JPATH_PLUGINS . '/cck_field_validation/required/required.php';
$lang->load('plg_cck_field_validation_required', JPATH_ADMINISTRATOR, null, false, true);
JPluginHelper::importPlugin('cck_field');
JPluginHelper::importPlugin('cck_field_restriction');
JPluginHelper::importPlugin('cck_storage_location');
$dispatcher = JDispatcher::getInstance();
$integrity = array();
$processing = array();
if (JCckToolbox::getConfig()->get('processing', 0)) {
    $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
}
$storages = array();
$config = array('author' => 0, 'client' => $client, 'doTranslation' => JCck::getConfig_Param('language_jtext', 0), 'doValidation' => JCck::getConfig_Param('validation', '2'), 'error' => false, 'fields' => array(), 'id' => $preconfig['id'], 'isNew' => $isNew, 'Itemid' => $preconfig['itemId'], 'message' => $preconfig['message'], 'message_style' => '', 'options' => '', 'pk' => $id, 'post' => $post, 'process' => array(), 'stage' => -1, 'storages' => array(), 'task' => $task, 'type' => $preconfig['type'], 'url' => $preconfig['url'], 'validate' => '');
CCK_Form::applyTypeOptions($config);
$stage = -1;
$stages = isset($config['options']['stages']) ? $config['options']['stages'] : 1;
if ($stages > 1) {
    $stage = $preconfig['stage'];
}
$parent = JCckDatabase::loadResult('SELECT parent FROM #__cck_core_types WHERE name = "' . $preconfig['type'] . '"');
$fields = CCK_Form::getFields(array($preconfig['type'], $parent), $client, $stage, '', true);
if (count($fields)) {
    foreach ($fields as $field) {
        $name = $field->name;
        $field->state = '';
Ejemplo n.º 8
0
 public function onContentPrepareForm($form, $data)
 {
     if (JCckToolbox::getConfig()->get('processing', 0)) {
         $event = 'onContentPrepareForm';
         $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
         if (isset($processing[$event])) {
             foreach ($processing[$event] as $p) {
                 if (is_file(JPATH_SITE . $p->scriptfile)) {
                     include_once JPATH_SITE . $p->scriptfile;
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
Archivo: cck.php Proyecto: hamby/SEBLOD
 protected function _process()
 {
     $args = func_get_args();
     if (count($args)) {
         $i = 0;
         $keys = array_shift($args);
         if (count($keys)) {
             foreach ($args as $arg) {
                 ${$keys[$i++]} = $arg;
             }
         }
     }
     $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile, options FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
     unset($args);
     if (isset($processing[$event])) {
         foreach ($processing[$event] as $p) {
             if (is_file(JPATH_SITE . $p->scriptfile)) {
                 $options = new JRegistry($p->options);
                 include_once JPATH_SITE . $p->scriptfile;
             }
         }
     }
 }