public function eventRmcommonLoadRightWidgets($widgets) { global $xoopsModule; if (!isset($xoopsModule) || $xoopsModule->getVar('dirname') != 'system' && $xoopsModule->getVar('dirname') != 'mywords') { return $widgets; } // Check edition $id = RMHttpRequest::request('id', 'integer', 0); $op = RMHttpRequest::request('op', 'string', ''); $edit = $op == 'edit' ? 1 : 0; $post = null; if ($edit) { //Verificamos que el software sea válido if ($id <= 0) { $params = ''; } $post = new MWPost($id); } if (defined("RMCSUBLOCATION") && RMCSUBLOCATION == 'new_post') { include_once '../widgets/widget-publish.php'; $widgets[] = mywords_widget_publish($post); include_once '../widgets/widget-post-type.php'; $widgets[] = mywords_widget_post_type($post); include_once '../widgets/widget-image.php'; $widgets[] = mywords_widget_image($post); include_once '../widgets/widget-categories.php'; $widgets[] = mywords_widget_categories($post); include_once '../widgets/widget-tags.php'; $widgets[] = mywords_widget_addtags($post); } return $widgets; }
public function eventRmcommonXoopsCommonEnd() { $w = RMHttpRequest::get('twop6', 'string', ''); if ($w == '') { return; } if ($w == 'colortest') { include_once XOOPS_ROOT_PATH . '/include/cp_functions.php'; RMTemplate::get()->header(); require RMCPATH . '/themes/twop6/include/test-color.php'; RMTemplate::get()->footer(); die; } if ($w == 'about') { include_once XOOPS_ROOT_PATH . '/include/cp_functions.php'; RMTemplate::get()->header(); require RMCPATH . '/themes/twop6/include/about.php'; RMTemplate::get()->footer(); die; } }
/** * Provides a widget to specify the default image for posts */ function mywords_widget_image($post = null) { global $xoopsSecurity, $xoopsModuleConfig, $xoopsUser, $rm_config; $type = RMHttpRequest::request('type', 'string', ''); $widget = array(); $widget['title'] = __('Default Image', 'mywords'); $util = new RMUtilities(); if (isset($post) && is_a($post, 'MWPost')) { if ($post->isNew()) { $params = ''; } else { $params = $post->getVar('image', 'e'); } } else { $params = ''; } $widget['content'] = '<form name="frmDefimage" id="frm-defimage" method="post">'; $widget['content'] .= $util->image_manager('image', 'image', $params, array('accept' => 'thumbnail', 'multiple' => 'no')); $widget['content'] .= '</form>'; return $widget; }
/** * Save current model data with a new registry */ public function save() { $attributes = $this->attributes; $fields = array(); /** * Name to get post/get/put vars */ $vars_container = get_class($this); /** * Determinamos si se trata de un objeto existente * o un objeto nuevo en base a la clave principal. * Si el contenedor de la variables cuenta con un * índice nombrado igual que la clave principal entonces * es un objeto existente, si no, se trata de un objeto * nuevo. * Importante: el valor del índice nombrado como la clave * principal siempre debe ser numérico. */ if (isset($vars_container[$this->db->primary_key])) { $action_type = 'update'; } else { $action_type = 'new'; } $this->data = RMHttpRequest::post($vars_container, 'array', array()); foreach ($this->columns as $column => $data) { /** * Si se trata de un objeto nuevo evitamos la verificación * de la clave principal. */ if ($column == $this->db->primary_key && $action_type == 'new') { continue; } /** * Verificamos la integridad de los datos proporcionados. */ if (!$this->verify_http_data($column)) { return false; } $fields[$column] = isset($rules[$column]) ? $rules[$column]($attributes) : (isset($attributes[$column]) ? $attributes[$column] : null); } return $this->db->database->queryF($this->db->getInsert($fields)); }
/** * This function allows to insert a new block in database */ function insert_block() { global $xoopsSecurity; $mod = RMHttpRequest::post('module', 'string', ''); $id = RMHttpRequest::post('block', 'string', ''); $token = RMHttpRequest::post('XOOPS_TOKEN_REQUEST', 'string', ''); $canvas = RMHttpRequest::post('canvas', 'integer', 0); if (!$xoopsSecurity->check()) { response(__('Sorry, you are not allowed to view this page', 'rmcommon'), array(), 1, 0); } if ($mod == '' || $id == '') { response(__('The block specified seems to be invalid. Please try again.', 'rmcommon'), array(), 1, 0); } $module = RMModules::load_module($mod); if (!$module) { response(__('The specified module does not exists!', 'rmcommon'), array(), 1, 0); } $module->loadInfoAsVar($mod); $blocks = $module->getInfo('blocks'); $ms = $module->name() . '<br />'; $found = false; foreach ($blocks as $bk) { $str = isset($bk['show_func']) ? $bk['show_func'] : ''; $str .= isset($bk['edit_func']) ? $bk['edit_func'] : ''; $str .= isset($bk['dir']) ? $bk['dir'] : $mod; $idb = md5($str); if ($idb == $id) { $found = true; break; } } if (!$found) { response(__('The specified block does not exists, please verify your selection.', 'rmcommon'), array(), 1, 1); } $block = new RMInternalBlock(); if ($canvas <= 0) { $db = XoopsDatabaseFactory::getDatabaseConnection(); // Get a default side $sql = "SELECT id_position FROM " . $db->prefix("mod_rmcommon_blocks_positions") . " ORDER BY id_position LIMIT 0, 1"; $result = $db->query($sql); if ($result) { list($canvas) = $db->fetchRow($result); } else { $canvas = ''; } } $block->setReadGroups(array(0)); $block->setVar('name', $bk['name']); $block->setVar('element', $mod); $block->setVar('element_type', $bk['type'] == '' ? 'module' : ($bk['type'] == 'theme' || $bk['type'] == 'plugin' ? $bk['type'] : 'module')); $block->setVar('canvas', $canvas); $block->setVar('visible', 0); $block->setVar('type', $bk['type']); $block->setVar('isactive', 1); $block->setVar('dirname', isset($bk['dirname']) ? $bk['dirname'] : $mod); $block->setVar('file', $bk['file']); $block->setVar('show_func', $bk['show_func']); $block->setVar('edit_func', $bk['edit_func']); $block->setVar('description', $bk['description']); $block->setVar('widget', $id); $block->setVar('options', is_array($bk['options']) ? serialize($bk['options']) : serialize(explode("|", $bk['options']))); $block->setVar('template', $bk['template']); $block->sections(array(0)); if (!$block->save()) { response(__('Block could not be created. Please try again!', 'rmcommon'), array('error' => $block->errors()), 1, 1); } RMEvents::get()->run_event('rmcommon.block.added', $block); $pos = RMBlocksFunctions::block_positions(); $ret = array('id' => $block->id(), 'title' => $block->getVar('name'), 'module' => $block->getVar('element'), 'description' => $block->getVar('description'), 'canvas' => $pos[$canvas], 'weight' => $block->getVar('weight'), 'visible' => $block->getVar('visible')); response(sprintf(__('Block "%s" was added successfully! Please configure it.', 'rmcommon'), $block->getVar('name')), array('block' => $ret), 0, 1); die; }
* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * ------------------------------------------------------------- * @copyright Red Mexico (http://www.redmexico.com.mx) * @license GNU GPL 2 * @package mywords * @author Eduardo Cortés (AKA bitcero) <*****@*****.**> * @link http://www.redmexico.com.mx * @link http://www.eduardocortes.mx */ define('RMCLOCATION', 'importer'); require 'header.php'; $importer = new MWImporter(); $action = RMHttpRequest::request('action', 'string', ''); switch ($action) { case 'collect': $importer->collect(); break; case 'import-category': $importer->category(); break; case 'import-article': $importer->article(); break; case 'close': $importer->close(); break; default: $importer->panel();
/** * RSS Management */ public function eventCoreIncludeCommonEnd() { global $xoopsOption; if (defined('RMC_CHECK_UPDATES') && $xoopsOption['pagetype'] == 'admin') { global $xoopsSecurity, $rmTpl; $rmTpl->add_head_script('var xoToken = "' . $xoopsSecurity->createToken() . '";'); } // Process notifications $current = explode("?", RMUris::relative_url(RMUris::current_url())); if ($current[0] == '/notifications.php') { $page = RMHttpRequest::post('page', 'string', ''); if ('cu-notification-subscribe' == $page) { include RMCPATH . '/include/notifications.php'; } $page = RMHttpRequest::get('page', 'string', ''); if ('cu-notification-list' == $page) { include RMCPATH . '/include/notifications.php'; } } RMEvents::get()->run_event('rmcommon.xoops.common.end'); }
/** * @desc Activa o desactiva un foro */ function bx_activate_forums($status = 1) { global $xoopsDB, $xoopsSecurity; if (!$xoopsSecurity->check()) { RMUris::redirect_with_message(__('Session token expired! Try again.', 'bxpress'), 'forums.php', RMMSG_ERROR); } $forums = RMHttpRequest::post('ids', 'array', null); if (!is_array($forums) || empty($forums)) { RMUris::redirect_with_message(__('No forum has been selected.', 'bxpress'), 'forums.php', RMMSG_ERROR); } $sql = "UPDATE " . $xoopsDB->prefix("mod_bxpress_forums") . " SET active='{$status}' WHERE "; $sql1 = ''; foreach ($forums as $k => $v) { $sql1 .= $sql1 == '' ? "id_forum='{$v}' " : "OR id_forum='{$v}' "; } $xoopsDB->queryF($sql . $sql1); RMUris::redirect_with_message(__('Database updated successfully!', 'bxpress'), 'forums.php', RMMSG_INFO); }
function module_uninstall_now() { global $xoopsSecurity, $xoopsConfig, $rmTpl, $xoopsDB; $dir = RMHttpRequest::post('module', 'string', ''); if (!$xoopsSecurity->check()) { redirectMsg('modules.php', __('Sorry, this operation could not be completed!', 'rmcommon'), 1); die; } $module_handler = xoops_gethandler('module'); if (!($mod = $module_handler->getByDirname($dir))) { redirectMsg('modules.php', sprintf(__('Module %s is not installed yet!', 'rmcommon'), $mod), 1); die; } $file = XOOPS_ROOT_PATH . '/modules/system/language/' . $xoopsConfig['language'] . '/admin/modulesadmin.php'; if (file_exists($file)) { include_once $file; } else { include_once str_replace($xoopsConfig['language'], 'english', $file); } include_once XOOPS_ROOT_PATH . '/modules/system/admin/modulesadmin/modulesadmin.php'; RMEvents::get()->run_event('rmcommon.uninstalling.module', $mod); $module_log = xoops_module_uninstall($dir); // Remove comments $sql = "DELETE FROM " . $xoopsDB->prefix("mod_rmcommon_comments") . " WHERE id_obj='{$dir}'"; if ($xoopsDB->queryF($sql)) { $module_log .= '<br><span class="text-success"><span class="fa fa-check"></span> Comments deleted successfully!</span>'; } else { $module_log .= '<br><span class="text-danger"><span class="fa fa-exclamation-triangle"></span> Comments could not be deleted: ' . $xoopsDB->error() . '</span>'; } // Remove notifications $sql = "DELETE FROM " . $xoopsDB->prefix("mod_rmcommon_notifications") . " WHERE element='{$dir}' AND `type`='module'"; if ($xoopsDB->queryF($sql)) { $module_log .= '<br><span class="text-success"><span class="fa fa-check"></span> Notifications deleted successfully!</span>'; } else { $module_log .= '<br><span class="text-danger"><span class="fa fa-exclamation-triangle"></span> Notifications could not be deleted: ' . $xoopsDB->error() . '</span>'; } $module_log = RMEvents::get()->run_event('rmcommon.module.uninstalled', $module_log, $mod); //RMFunctions::create_toolbar(); RMTemplate::get()->add_style('modules.min.css', 'rmcommon'); RMBreadCrumb::get()->add_crumb(__('Modules Management', 'rmcommon'), 'modules.php'); RMBreadCrumb::get()->add_crumb(sprintf(__('%s install log', 'rmcommon'), $mod->getVar('name'))); $rmTpl->assign('xoops_pagetitle', sprintf(__('%s install log', 'rmcommon'), $mod->getVar('name'))); xoops_cp_header(); $module = new XoopsModule(); $module->loadInfo($mod, false); $log_title = sprintf(__('Uninstall log for %s', 'rmcommon'), $module ? $module->getInfo('name') : $mod); $action = rmc_server_var($_POST, 'action', ''); include RMTemplate::get()->get_template('rmc-modules-log.php', 'module', 'rmcommon'); xoops_cp_footer(); }
/** * Process subscription to an event by getting url parameters */ public function subscribe() { global $cuSettings, $xoopsUser; $this->prepare_ajax_response(); $event = RMHttpRequest::post('event', 'string', ''); $status = RMHttpRequest::post('status', 'integer', 1); if (!$xoopsUser) { $this->add_error(__('No user has been specified', 'rmcommon')); return false; } if ('' == $event) { $this->add_error(__('No event name has been specified', 'rmcommon')); return false; } include_once RMCPATH . '/class/crypt.php'; $crypt = new Crypt(null, $cuSettings->secretkey); $event = $crypt->decrypt($event); $event = json_decode($event); $event->uid = $xoopsUser->uid(); // Include controller file if ('plugin' == $event->type) { $file = XOOPS_ROOT_PATH . '/modules/rmcommon/plugins/' . $event->element . '/class/' . strtolower($event->element) . '.notifications.class.php'; } elseif ('theme' == $event->type) { $file = XOOPS_ROOT_PATH . '/themes/' . $event->element . '/class/' . strtolower($event->element) . '.notifications.class.php'; } else { $file = XOOPS_ROOT_PATH . '/modules/' . $event->element . '/class/' . strtolower($event->element) . '.notifications.class.php'; } include_once $file; $class = ucfirst($event->element) . '_Notifications'; if (!class_exists(ucfirst($event->element) . '_Notifications')) { $this->add_error(__('There are not a notifications controller for this element', 'rmcommon')); return false; } // Verify if event is a valid and existing event in module $notification = $class::get(); if (!$notification->is_valid($event->event)) { $this->add_error(__('Specified event is not valid for this element', 'rmcommon')); return false; } $subscribed = $this->is_subscribed($event->event, $event->element, $event->type, $event->params); $event->status = $status ? 'subscribed' : 'removed'; if ($status && $subscribed) { return $event; } if (!$status && $subscribed) { if ($this->unsubscribe($event)) { return $event; } else { return false; } } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "INSERT INTO " . $db->prefix("mod_rmcommon_notifications") . " (`event`,`element`,`params`,`uid`,`type`,`date`)\n VALUES ('{$event->event}', '{$event->element}', '{$event->params}', '" . $xoopsUser->uid() . "',\n '{$event->type}', now())"; if ($db->queryF($sql)) { return $event; } else { $this->add_error($db->error()); } return false; }
function update_locally() { global $xoopsSecurity, $xoopsLogger, $xoopsConfig; $xoopsLogger->activated = false; if (!$xoopsSecurity->check()) { jsonReturn(__('Wrong action!', 'rmcommon'), 1, array(), 0); } $dir = RMHttpRequest::post('module', 'string', ''); $type = RMHttpRequest::post('type', 'string', ''); if ('' == $dir || '' == $type) { jsonReturn(__('Data not valid!', 'rmcommon')); } if ('module' == $type) { if (!is_dir(XOOPS_ROOT_PATH . '/modules/' . $dir)) { jsonReturn(__('Module does not exists!', 'rmcommon')); } xoops_loadLanguage('admin', 'system'); $file = XOOPS_ROOT_PATH . '/modules/system/language/' . $xoopsConfig['language'] . '/admin/modulesadmin.php'; if (file_exists($file)) { include_once $file; } else { include_once str_replace($xoopsConfig['language'], 'english', $file); } include_once XOOPS_ROOT_PATH . '/modules/system/admin/modulesadmin/modulesadmin.php'; $log = xoops_module_update($dir); jsonReturn(__('Module updated locally', 'rmcommon'), 0, array('log' => $log)); } elseif ('plugin' == $type) { if (!is_dir(XOOPS_ROOT_PATH . '/modules/rmcommon/plugins/' . $dir)) { jsonReturn(__('Plugin does not exists!', 'rmcommon')); } $plugin = new RMPlugin($dir); if ($plugin->isNew()) { jsonReturn(__('Plugin does not exists!', 'rmcommon')); } if (!$plugin->on_update()) { jsonReturn(sprintf(__('Plugins manager could not update the plugin: %s', 'rmcommon'), $plugin->errors())); } jsonReturn(__('Plugin updated locally', 'rmcommon'), 0); } }
die; } // Object type $type = rmc_server_var($_POST, 'type', ''); if (trim($type) == '') { redirect_header($uri, 2, __('Object type missing!', 'rmcommon')); die; } // Object name $object = strtolower(rmc_server_var($_POST, 'object', '')); if (trim($object) == '') { redirect_header($uri, 2, __('Object name missing!', 'rmcommon')); die; } // Text $text = RMHttpRequest::post('comment_text', 'string', ''); if (trim($text) == '') { redirect_header($uri, 2, __('You must write a message!', 'rmcommon')); die; } $kses = new RMKses(); $text = $kses->filter($text, 'reduced'); RMEvents::get()->run_event('rmcommon.comment.postdata', $uri); // Save comment user $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($xoopsUser) { $sql = "SELECT id_user FROM " . $db->prefix("mod_rmcommon_comments_assignations") . " WHERE xuid=" . $xoopsUser->uid(); } else { $sql = "SELECT id_user FROM " . $db->prefix("mod_rmcommon_comments_assignations") . " WHERE email='{$email}'"; } $result = $db->query($sql);
} $image = new RMImage($id); if ($image->isNew()) { images_send_json(array('message' => __('Specified image does not exists', 'rmcommon'), 'error' => 1, 'token' => $xoopsSecurity->createToken())); } $author = new RMUser($image->uid); $original = pathinfo($image->get_files_path() . '/' . $image->file); $dimensions = getimagesize($image->get_files_path() . '/' . $image->file); $mimes = (include XOOPS_ROOT_PATH . '/include/mimetypes.inc.php'); $category_sizes = $cat->getVar('sizes'); $sizes = array(); foreach ($category_sizes as $i => $size) { if ($size['width'] <= 0) { continue; } $tfile = $image->get_files_path() . '/sizes/' . $original['filename'] . '-' . $size['name'] . '.' . $original['extension']; if (!is_file($tfile)) { continue; } $t_dim = getimagesize($tfile); $sizes[] = array('width' => $t_dim[0], 'height' => $t_dim[1], 'url' => $image->get_files_url() . '/sizes/' . $original['filename'] . '-' . $size['name'] . '.' . $original['extension'], 'name' => $size['name']); } $sizes[] = array('width' => $dimensions[0], 'height' => $dimensions[1], 'url' => $image->getOriginal(), 'name' => __('Original', 'rmcommon')); $links = array('none' => array('caption' => __('None', 'rmcommon'), 'value' => ''), 'file' => array('caption' => __('File URL', 'rmcommon'), 'value' => XOOPS_UPLOAD_URL . '/' . date('Y', $image->getVar('date')) . '/' . date('m', $image->getVar('date')) . '/' . $image->getVar('file'))); $links = RMEvents::get()->run_event('rmcommon.image.insert.links', $links, $image, RMHttpRequest::post('url', 'string', '')); // Image data $data = array('id' => $image->id(), 'title' => $image->title, 'date' => formatTimestamp($image->date, 'l'), 'description' => $image->getVar('desc', 'n'), 'author' => array('uname' => $author->uname, 'uid' => $author->uid, 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $author->email, 40), 'url' => XOOPS_URL . '/userinfo.php?uid=' . $author->email), 'medium' => $image->get_by_size(300), 'url' => $image->get_files_url(), 'original' => array('file' => $original['basename'], 'url' => $image->getOriginal(), 'size' => RMFormat::bytes_format(filesize($image->get_files_path() . '/' . $image->file)), 'width' => $dimensions[0], 'height' => $dimensions[1]), 'mime' => isset($mimes[$original['extension']]) ? $mimes[$original['extension']] : 'application/octet-stream', 'sizes' => $sizes, 'links' => $links); $data = RMEvents::get()->run_event('rmcommon.loading.image.details', $data, $image, RMHttpRequest::request('url', 'string', '')); $data['token'] = $xoopsSecurity->createToken(); images_send_json($data); }
<?php // $Id: edit.php 1034 2012-09-06 02:30:13Z i.bitcero $ // -------------------------------------------------------------- // bXpress Forums // An simple forums module for XOOPS and Common Utilities // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- define('BB_LOCATION', 'posts'); include '../../mainfile.php'; $op = RMHttpRequest::request('op', 'string', ''); $id = RMHttpRequest::request('id', 'integer', 0); if ($id <= 0) { redirect_header('./', 2, __('No post has been specified!', 'bxpress')); die; } $post = new bXPost($id); if ($post->isNew()) { redirect_header('./', 2, __('Specified post does not exists!', 'bxpress')); die; } $topic = new bXTopic($post->topic()); $forum = new bXForum($topic->forum()); // Verificamos si el usuario tiene permisos de edición en el foro if (!$xoopsUser || !$forum->isAllowed($xoopsUser->getGroups(), 'edit')) { redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('You don\'t have permission to edit this post!', 'bxpress')); die; } // Verificamos si el usuario tiene permiso de edición para el post
/** * Install specified theme */ function xt_install_theme() { global $xoopsConfig, $xtFunctions, $xtAssembler; $current = $xtAssembler->theme()->getInfo('dir'); $dir = RMHttpRequest::get('dir', 'string', ''); if ($dir == '') { redirectMsg('themes.php', __('No theme has been specified!', 'xthemes'), RMMSG_ERROR); } $theme_dir = XOOPS_THEME_PATH . '/' . $dir; if (!is_file($theme_dir . '/theme.html')) { redirectMsg('themes.php', __('Specified directory does not contain a valid theme!', 'xthemes'), RMMSG_WARN); } $db = XoopsDatabaseFactory::getDatabaseConnection(); if (is_file($theme_dir . '/assemble/' . $dir . '.theme.php')) { // Install a xThemes Theme include_once $theme_dir . '/assemble/' . $dir . '.theme.php'; $class = ucfirst($dir); if (!class_exists($class)) { redirectMsg('themes.php', __('Specified theme is not a valid xThemes theme!', 'xthemes'), RMMSG_WARN); } $theme = new $class(); $theme->setVar('date', time()); if (!$theme->on_install()) { RMUris::redirect_with_message(__('Theme could not be activated!', 'xthemes') . '<br>' . implode('<br>', $theme->errors()), 'themes.php', RMMSG_ERROR); } if (!$theme->save() && $theme->isNew()) { redirectMsg('themes.php', __('Sorry, theme could not be installed!', 'xthemes') . $theme->errors(), RMMSG_ERROR); } // Notify to current theme $xtFunctions->notify_deactivation($current); // Configuration options if (!$xtFunctions->insertOptions($theme)) { redirectMsg('themes.php', __('Sorry, theme could not be installed!', 'xthemes') . $theme->errors(), RMMSG_ERROR); } // Create blocks positions if (!$xtFunctions->insertPositions($theme)) { showMessage(__('The blocks positions could not be installed.', 'xthemes'), 'themes.php', RMMSG_WARN); } } $sql = "UPDATE " . $db->prefix("config") . " SET conf_value='{$dir}' WHERE conf_modid=0 AND conf_catid=1 AND conf_name='theme_set'"; if (!$db->queryF($sql)) { redirectMsg('themes.php', __('Theme could not be activated', 'xthemes') . $db->getError(), RMMSG_ERROR); } $sql = "UPDATE " . $db->prefix("config") . " SET conf_value='" . serialize(array($dir)) . "' WHERE conf_modid=0 AND conf_catid=1 AND conf_name='theme_set_allowed'"; $db->queryF($sql); redirectMsg('themes.php', __('Theme installed and activated successfully!', 'xthemes'), RMMSG_SUCCESS); }
/** * Imports a single article from Publisher */ public function article() { global $xoopsSecurity, $xoopsDB; $this->prepare_ajax_response(); $functions = MWFunctions::get(); if (!$xoopsSecurity->check(true, false, 'CUTOKEN')) { $this->ajax_response(__('Session token not valid!', 'mywords'), 1, 0); } $id = RMHttpRequest::post('id', 'integer', 0); if ($id <= 0) { $this->ajax_response(sprintf(__('Article ID %u is not valid!', 'mywords'), $id), 0, 1, ['result' => 'error']); } $sql = "SELECT * FROM " . $xoopsDB->prefix("publisher_items") . " WHERE itemid = {$id}"; $result = $xoopsDB->query($sql); if ($xoopsDB->getRowsNum($result)) { if ($id <= 0) { $this->ajax_response(sprintf(__('Article with ID %u was not found!', 'mywords'), $id), 0, 1, ['result' => 'error']); } } $row = $xoopsDB->fetchArray($result); $cache = $this->loadCache(); $post = new MWPost(); $post->setVar('title', $row['title']); $post->setVar('shortname', TextCleaner::getInstance()->sweetstring($row['title'])); $post->setVar('content', $row['body']); switch ($row['status']) { case 1: case 4: $status = 'pending'; break; case 2: $status = 'publish'; break; case 3: $status = 'draft'; break; } $post->setVar('status', $status); $post->setVar('visibility', 'public'); $post->setVar('author', $row['uid']); $post->setVar('comstatus', 1); $post->setVar('pubdate', $row['datesub']); $post->setVar('created', $row['datesub']); $post->setVar('reads', $row['counter']); $post->setVar('description', $row['summary']); $post->setVar('keywords', $row['meta_keywords']); $post->setVar('format', 'post'); if (isset($cache['categories'][$row['categoryid']])) { $post->add_categories($cache['categories'][$row['categoryid']]); } unset($row); if (!$post->save()) { $this->ajax_response(sprintf(__('Article %s could not be saved!', 'mywords'), $post->title), 0, 1, ['result' => 'error']); } $this->ajax_response(sprintf(__('Article %s imported successfully!', 'mywords'), '<strong>' . $post->title . '</strong>'), 0, 1, ['result' => 'success']); }
function delete_group_data() { global $xoopsSecurity, $xoopsDB; $ajax = new Rmcommon_Ajax(); $ajax->prepare_ajax_response(); if (!$xoopsSecurity->validateToken(false, true, 'CUTOKEN')) { $ajax->ajax_response(__('Session token expired!', 'rmcommon'), 1, 0, array('action' => 'reload')); } $ids = RMHttpRequest::post('ids', 'array', array()); if (empty($ids)) { $ajax->ajax_response(__('You must select at least one group. Please, try again.', 'rmcommon'), 1, 1); } $to_delete = array_search(XOOPS_GROUP_ADMIN, $ids); if (FALSE !== $to_delete) { unset($ids[$to_delete]); } $to_delete = array_search(XOOPS_GROUP_USERS, $ids); if (FALSE !== $to_delete) { unset($ids[$to_delete]); } $to_delete = array_search(XOOPS_GROUP_ANONYMOUS, $ids); if (FALSE !== $to_delete) { unset($ids[$to_delete]); } if (empty($ids)) { $ajax->ajax_response(__('No valid groups has been selected. Note that system groups could not be deleted.', 'rmcommon'), 1, 1); } $errors = ''; // Eliminar permisos del grupo $sql = "DELETE FROM " . $xoopsDB->prefix("group_permission") . " WHERE gperm_groupid IN (" . implode(",", $ids) . ")"; if (!$xoopsDB->queryF($sql)) { $errors .= $xoopsDB->error(); } // Eliminar permisos específicos $sql = "DELETE FROM " . $xoopsDB->prefix("mod_rmcommon_permissions") . " WHERE `group` IN (" . implode(",", $ids) . ")"; if (!$xoopsDB->queryF($sql)) { $errors .= '<br>' . $xoopsDB->error(); } // Eliminar relaciones con usuarios $sql = "DELETE FROM " . $xoopsDB->prefix("groups_users_link") . " WHERE `groupid` IN (" . implode(",", $ids) . ")"; if (!$xoopsDB->queryF($sql)) { $errors .= '<br>' . $xoopsDB->error(); } // Eliminar datos del grupo $sql = "DELETE FROM " . $xoopsDB->prefix("groups") . " WHERE `groupid` IN (" . implode(",", $ids) . ")"; if (!$xoopsDB->queryF($sql)) { $errors .= '<br>' . $xoopsDB->error(); } if ('' == $errors) { showMessage(__('Selected groups has been deleted.', 'rmcommon'), RMMSG_SUCCESS, 'fa fa-remove-circle'); $ajax->ajax_response('', 0, 1, array('reload' => true)); } else { $ajax->ajax_response(__('Errors ocurred while trying to delete selected groups.', 'rmcommon') . "\n" . $errors, 1, 1); } }
$img = new RMImage(); $img->load_from_params($post->getVar('image', 'e')); if (!$img->isNew()) { $image = '<img src="' . $img->url() . '" alt="' . $post->getVar('title') . '" /><br />'; } else { $image = ''; } $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($image . $post->content(true), ENT_QUOTES)); $item['pubdate'] = formatTimestamp($post->getVar('pubdate'), 'rss'); $item['guid'] = $post->permalink(); $rss_items[] = $item; } break; case 'author': include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mweditor.class.php'; $id = RMHttpRequest::get('author', 'integer', 0); if ($id <= 0) { redirect_header('backend.php', 1, __('Sorry, specified author was not foud!', 'mywords')); die; } $ed = new MWEditor($id); if ($ed->isNew()) { redirect_header('backend.php', 1, __('Sorry, specified author was not foud!', 'mywords')); die; } $rss_channel['title'] = sprintf(__('Posts by %s in %s', 'mywords'), $ed->name != '' ? $ed->name : $ed->shortname, $xoopsConfig['sitename']); $rss_channel['link'] = $ed->permalink(); $rss_channel['description'] = sprintf(__('Posts published by %s.', 'mywords'), $ed->getVar('name')) . ' ' . htmlspecialchars(strip_tags($ed->getVar('bio')), ENT_QUOTES); $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss'); $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true); $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true);
protected function getParameter($name, $type = 'string', $default = '') { if (isset($this->parameters[$name])) { return RMHttpRequest::array_value($name, $this->parameters, $type, $default); } else { return RMHttpRequest::request($name, $type, $default); } }
function activate_position($status) { global $xoopsSecurity, $xoopsDB; if (!$xoopsSecurity->check()) { RMUris::redirect_with_message(__('Session token is not valid!', 'rmcommon'), 'blocks.php', RMMSG_ERROR); } $ids = RMHttpRequest::post('ids', 'array', array()); if (!is_array($ids) || empty($ids)) { RMUris::redirect_with_message(__('No position id has been provided', 'rmcommon'), 'blocks.php', RMMSG_WARN); } $sql = "UPDATE " . $xoopsDB->prefix("mod_rmcommon_blocks_positions") . " SET active = " . ($status == 'active' ? 1 : 0) . "\n WHERE id_position IN (" . implode(',', $ids) . ")"; if ($xoopsDB->queryF($sql)) { RMUris::redirect_with_message(__('Database updated successully!', 'rmcommon'), 'blocks.php', RMMSG_SUCCESS); } else { RMUris::redirect_with_message(__('Errors ocurrs while trying to update data:', 'rmcommon') . $xoopsDB->error(), 'blocks.php', RMMSG_ERROR); } }
/** * Save module settings */ function save_module_settings() { global $xoopsSecurity, $xoopsDB; $mod = RMHttpRequest::post('mod', 'string', ''); $via_ajax = RMHttpRequest::post('via_ajax', 'integer', 0); if ($via_ajax) { $ajax = new AjaxResponse(); $ajax->prepare_ajax_response(); } if ($mod == '') { RMUris::redirect_with_message(__('A module has not been specified!', 'rmcommon'), 'settings.php', RMMSG_ERROR); } //echo RMHttpRequest::request('CUTOKEN_REQUEST', 'string', '') . ' ' . print_r($_SESSION['CUTOKEN_SESSION'], true); die(); if (!$xoopsSecurity->check(true, false, $via_ajax ? 'CUTOKEN' : 'XOOPS_TOKEN')) { if ($via_ajax) { $ajax->ajax_response(__('Session token expired. Please try again.', 'rmcommon'), 1, 0); } else { RMUris::redirect_with_message(__('Session token expired. Please try again.', 'rmcommon'), 'settings.php', RMMSG_WARN); } } $module = RMModules::load_module($mod); if (!$module) { if ($via_ajax) { $ajax->ajax_response(__('The specified module does not exists.', 'rmcommon'), 1, 1); } else { RMUris::redirect_with_message(__('The specified module does not exists.', 'rmcommon'), 'settings.php', RMMSG_ERROR); } } $current_settings = (array) RMSettings::module_settings($module->getVar('dirname')); $new_settings = RMHttpRequest::post(ucfirst($module->getVar('dirname')), 'array', array()); $configs = $module->getInfo('config'); $fields = array(); // Container for all fields and values foreach ($configs as $option) { $id = $option['name']; $field = new stdClass(); $field->id = $id; $field->value = isset($values->{$id}) ? $values->{$id} : $option['default']; $field->caption = defined($option['title']) ? constant($option['title']) : $option['title']; $field->description = defined($option['description']) ? constant($option['description']) : $option['description']; $field->field = $option['formtype']; $field->type = $option['valuetype']; $field->options = isset($option['options']) ? $option['options'] : null; $category = isset($option['category']) ? $option['category'] : 'all'; $fields[$id] = $field; } /** * This keys already exists in database */ $to_save = array_intersect_key($new_settings, $current_settings); /** * This settings will be added to database beacause don't exists in table */ $to_add = array_diff_key($new_settings, $current_settings); /** * This keys has been removed from xoops_version.php file and then * must be removed from table */ $to_delete = array_diff_key($current_settings, $new_settings); $errors = ''; // Errors ocurred while saving /** * First for all, remove unused items */ $keys = array_keys($to_delete); if (!empty($keys)) { $sql = "DELETE FROM " . $xoopsDB->prefix("config") . " WHERE conf_modid = " . $module->mid() . " AND (conf_name = '" . implode("' OR conf_name='", $keys) . "')"; if (!$xoopsDB->queryF($sql)) { $errors .= $xoopsDB->error() . '<br>'; } } /** * Save existing items */ if (!empty($to_save)) { foreach ($to_save as $name => $value) { $item = new Rmcommon_Config_Item($name, $module->mid()); if (isset($fields[$name])) { $item->setVar('conf_valuetype', $fields[$name]->type); $item->setVar('conf_title', $fields[$name]->caption); $item->setVar('conf_desc', $fields[$name]->description); $item->setVar('conf_formtype', $fields[$name]->field); } $item->set_value($value, $item->getVar('conf_valuetype')); $item->save(); } } /** * Add new items */ if (!empty($to_add)) { foreach ($to_add as $name => $value) { $item = new Rmcommon_Config_Item($name, $module->mid()); if (isset($fields[$name])) { $item->setVar('conf_modid', $module->mid()); $item->setVar('conf_name', $name); $item->setVar('conf_valuetype', $fields[$name]->type); $item->setVar('conf_title', $fields[$name]->caption); $item->setVar('conf_desc', $fields[$name]->description); $item->setVar('conf_formtype', $fields[$name]->field); } $item->set_value($value, $item->getVar('conf_valuetype')); $item->save(); } } /** * Notify to system events */ RMEvents::get()->trigger('rmcommon.saved.settings', $module->dirname(), $to_save, $to_add, $to_delete); if ($module->getInfo('hasAdmin')) { $goto = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/' . $module->getInfo('adminindex'); } else { $goto = 'settings.php'; } if ($via_ajax) { $ajax->ajax_response(__('Settings saved successfully!', 'rmcommon'), 0, 1, array('closeWindow' => '#cu-settings-form', 'notify' => array('icon' => 'svg-rmcommon-ok-circle', 'type' => 'alert-success'))); } else { RMUris::redirect_with_message(__('Settings saved successfully!', 'rmcommon'), $goto, RMMSG_SUCCESS, 'fa fa-check'); } }
/** * @desc Activa o desactiva una categoría **/ function activeCatego($act = 0) { global $xoopsSecurity; $cats = RMHttpRequest::request('ids', 'array', array()); //Verificamos si se ha proporcionado una categoría if (empty($cats)) { RMUris::redirect_with_message(__('You must select at least one category', 'bxpress'), './categories.php', RMMSG_WARN); die; } if (!$xoopsSecurity->check()) { RMUris::redirect_with_message(__('Session token expired!', 'bxpress'), 'categories.php', RMMSG_ERROR); die; } $errors = ''; foreach ($cats as $k) { //Verificamos que la categoría sea válida if ($k <= 0) { $errors .= sprintf(__('Category ID %s is not valid!', 'bxpress'), '<strong>' . $k . '</strong>') . '<br />'; continue; } //Verificamos que categoría exista $cat = new bXCategory($k); if ($cat->isNew()) { $errors .= sprintf(_AS_BB_ERRCATNOEXIST, $k); continue; } $cat->setStatus($act); if (!$cat->save()) { $errors .= sprintf(_AS_BB_ERRCATNOSAVE, $k); } } if ($errors != '') { RMUris::redirect_with_message(__('Errors ocurred while trying to change status', 'bxpress') . $errors, './categories.php', RMMSG_ERROR); die; } else { RMUris::redirect_with_message(__('Database updated successfully!', 'bxpress'), './categories.php', RMMSG_SUCCESS); die; } }
<?php /** * $Id$ * -------------------------------------------------------------- * Common Utilities * Author: Eduardo Cortes * Email: i.bitcero@gmail.com * License: GPL 2.0 * URI: http://www.redmexico.com.mx */ require dirname(dirname(dirname(dirname(__FILE__)))) . '/include/cp_header.php'; $ajax = new Rmcommon_Ajax(); $ajax->prepare_ajax_response(); $dirname = RMHttpRequest::get('module', 'string', ''); if ($dirname == '') { $ajax->ajax_response(__('Please specify a valid module dirname!', 'rmcommon'), 1, 0); } $module = RMModules::load_module($dirname); if (!$module) { $ajax->ajax_response(__('Specified module is not installed!', 'rmcommon'), 1, 0); } $url = $module->getInfo('updateurl'); $url .= false === strpos($url, '?') ? '?' : '&'; $url .= 'action=data&id=' . $module->dirname(); echo file_get_contents($url);