function getSerializedRequestsFromPost()
 {
     $ret = array();
     $myts =& MyTextSanitizer::getInstance();
     // text fields
     foreach ($_POST as $key => $val) {
         if (strncmp($key, PICO_EXTRA_FIELDS_PREFIX, strlen(PICO_EXTRA_FIELDS_PREFIX)) === 0) {
             $ret[substr($key, strlen(PICO_EXTRA_FIELDS_PREFIX))] = $this->stripSlashesGPC($val);
         } elseif (strncmp($key, PICO_EXTRA_FIELDS_PREFIX_SHORT, strlen(PICO_EXTRA_FIELDS_PREFIX_SHORT)) === 0) {
             $ret[substr($key, strlen(PICO_EXTRA_FIELDS_PREFIX_SHORT))] = $this->stripSlashesGPC($val);
         }
     }
     // process $_FILES (only adminormod )
     if ($this->canUploadImages() && !empty($_FILES) && is_array($_FILES)) {
         $this->uploadImages($ret);
     }
     return pico_common_serialize($ret);
 }
예제 #2
0
 function getBlankContentRow($categoryObj)
 {
     $mod_config = $categoryObj->getOverriddenModConfig();
     $cat_data = $categoryObj->getData();
     $uid = is_object(@$GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
     return array('content_id' => 0, 'permission_id' => 0, 'vpath' => '', 'cat_id' => 0, 'weight' => 0, 'created_time' => time(), 'modified_time' => time(), 'expiring_time' => 0x7fffffff, 'last_cached_time' => 0, 'poster_uid' => $uid, 'poster_ip' => '', 'modifier_uid' => $uid, 'modifier_ip' => '', 'subject' => '', 'subject_waiting' => '', 'locked' => 0, 'visible' => 1, 'approval' => $cat_data['post_auto_approved'], 'use_cache' => 0, 'allow_comment' => 1, 'show_in_navi' => 1, 'show_in_menu' => 1, 'viewed' => 0, 'votes_sum' => 0, 'votes_count' => 0, 'comments_count' => 0, 'htmlheader' => '', 'htmlheader_waiting' => '', 'body' => '', 'body_waiting' => '', 'body_cached' => '', 'filters' => $mod_config['filters'], 'tags' => '', 'extra_fields' => pico_common_serialize(array()), 'redundants' => '', 'for_search' => '');
 }
 function storeDB()
 {
     $db =& Database::getInstance();
     $content_id = intval($this->content4disp['id']);
     $extra_type4sql = addslashes('smarty_plugin::' . $this->mypluginname);
     $data4sql = addslashes(pico_common_serialize($this->form_processor->renderForDB()));
     $sql = "INSERT INTO " . $db->prefix($this->mydirname . "_content_extras") . " SET `content_id`={$content_id}, `extra_type`='{$extra_type4sql}', `data`='{$data4sql}', created_time=UNIX_TIMESTAMP(), modified_time=UNIX_TIMESTAMP()";
     $db->queryF($sql);
 }
 function getBlankCategoryRow($parentObj)
 {
     $mod_config = $parentObj->getOverriddenModConfig();
     $pcat_data = $parentObj->getData();
     $uid = is_object(@$GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
     return array('cat_id' => -1, 'cat_permission_id' => 0, 'cat_vpath' => '', 'pid' => $pcat_data['id'], 'cat_title' => '', 'cat_desc' => '', 'cat_depth_in_tree' => 0, 'cat_order_in_tree' => 0, 'cat_path_in_tree' => '', 'cat_unique_path' => '', 'cat_weight' => 0, 'cat_options' => '', 'cat_created_time' => time(), 'cat_modified_time' => time(), 'cat_vpath_mtime' => 0, 'cat_extra_fields' => pico_common_serialize(array()), 'cat_redundants' => '');
 }
function pico_get_requests4category($mydirname, $cat_id = null)
{
    $myts =& MyTextSanitizer::getInstance();
    $db =& Database::getInstance();
    $picoPermission =& PicoPermission::getInstance();
    $permissions = $picoPermission->getPermissions($mydirname);
    // First, fetch $pid of the targetted category
    if ($cat_id === 0) {
        // top category
        $cat_vpath = null;
        $pid = 0xffff;
        $baseCategoryObj =& new PicoCategory($mydirname, 0, $permissions);
    } else {
        // normal category
        $cat_vpath = trim($myts->stripSlashesGPC(@$_POST['cat_vpath']));
        $pid = intval(@$_POST['pid']);
        $parentCategoryObj =& new PicoCategory($mydirname, $pid, $permissions);
        if ($parentCategoryObj->isError()) {
            redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php", 2, _MD_PICO_ERR_READCATEGORY);
            exit;
        }
        if (empty($cat_id)) {
            $baseCategoryObj =& $parentCategoryObj;
        } else {
            $baseCategoryObj =& new PicoCategory($mydirname, $cat_id, $permissions);
            if ($baseCategoryObj->isError()) {
                redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php", 2, _MD_PICO_ERR_READCATEGORY);
                exit;
            }
        }
    }
    // recheck permissions and reload $config
    $mod_config = $baseCategoryObj->getOverriddenModConfig();
    $cat_data = $baseCategoryObj->getData();
    // fetch cat_options of the targetted category for overriding
    include dirname(dirname(__FILE__)) . '/include/configs_can_override.inc.php';
    $cat_options = array();
    foreach ($mod_config as $key => $val) {
        if (empty($pico_configs_can_be_override[$key])) {
            continue;
        }
        foreach (explode("\n", @$_POST['cat_options']) as $line) {
            if (preg_match('/^' . $key . '\\:(.{1,100})$/', $line, $regs)) {
                switch ($pico_configs_can_be_override[$key]) {
                    case 'templates':
                        $cat_options[$key] = preg_replace('/[^0-9a-zA-Z._:,-]/', '', $regs[1]);
                        break;
                    case 'template':
                        $cat_options[$key] = preg_replace('/[^0-9a-zA-Z._:-]/', '', $regs[1]);
                        break;
                    case 'class':
                        $cat_options[$key] = preg_replace('/[^0-9a-zA-Z_]/', '', $regs[1]);
                        break;
                    case 'text':
                        $cat_options[$key] = trim($regs[1]);
                        break;
                    case 'int':
                        $cat_options[$key] = intval($regs[1]);
                        break;
                    case 'bool':
                        $cat_options[$key] = intval($regs[1]) > 0 ? 1 : 0;
                        break;
                }
            }
        }
    }
    // extra_fields (read ef class and create the object)
    $ef_class = empty($mod_config['extra_fields_cat_class']) ? 'PicoExtraFieldsCat' : $mod_config['extra_fields_cat_class'];
    require_once dirname(dirname(__FILE__)) . '/extra_fields/' . $ef_class . '.class.php';
    $ef_obj =& new $ef_class($mydirname, $baseCategoryObj, 0);
    return array('cat_title' => $myts->stripSlashesGPC(@$_POST['cat_title']), 'cat_desc' => $myts->stripSlashesGPC(@$_POST['cat_desc']), 'cat_weight' => intval(@$_POST['cat_weight']), 'cat_vpath' => $cat_vpath, 'pid' => $pid, 'cat_options' => pico_common_serialize($cat_options), 'cat_extra_fields' => $ef_obj->getSerializedRequestsFromPost());
}
예제 #6
0
function pico_get_requests4category($mydirname, $cat_id = null)
{
    $myts =& MyTextSanitizer::getInstance();
    $db =& Database::getInstance();
    include dirname(dirname(__FILE__)) . '/include/configs_can_override.inc.php';
    $cat_options = array();
    foreach ($GLOBALS['xoopsModuleConfig'] as $key => $val) {
        if (empty($pico_configs_can_be_override[$key])) {
            continue;
        }
        foreach (explode("\n", @$_POST['cat_options']) as $line) {
            if (preg_match('/^' . $key . '\\:(.{1,100})$/', $line, $regs)) {
                switch ($pico_configs_can_be_override[$key]) {
                    case 'text':
                        $cat_options[$key] = trim($regs[1]);
                        break;
                    case 'int':
                        $cat_options[$key] = intval($regs[1]);
                        break;
                    case 'bool':
                        $cat_options[$key] = intval($regs[1]) > 0 ? 1 : 0;
                        break;
                }
            }
        }
    }
    if ($cat_id === 0) {
        // top category
        $cat_vpath = null;
        $pid = 0xffff;
    } else {
        // normal category
        $cat_vpath = trim($myts->stripSlashesGPC(@$_POST['cat_vpath']));
        $pid = intval(@$_POST['pid']);
        // check $pid
        if ($pid) {
            $sql = "SELECT * FROM " . $db->prefix($mydirname . "_categories") . " c WHERE c.cat_id={$pid}";
            if (!($crs = $db->query($sql))) {
                die(_MD_PICO_ERR_SQL . __LINE__);
            }
            if ($db->getRowsNum($crs) <= 0) {
                die(_MD_PICO_ERR_READCATEGORY);
            }
        }
    }
    return array('cat_title' => $myts->stripSlashesGPC(@$_POST['cat_title']), 'cat_desc' => $myts->stripSlashesGPC(@$_POST['cat_desc']), 'cat_weight' => intval(@$_POST['cat_weight']), 'cat_vpath' => $cat_vpath, 'pid' => $pid, 'cat_options' => pico_common_serialize($cat_options));
}