예제 #1
0
 function _genarateObjectLink($data, $scatFlag = '')
 {
     global $CONF, $manager, $blog;
     $ext = substr(serverVar('REQUEST_URI'), -4);
     if ($ext == '.rdf' || $ext == '.xml') {
         $CONF['URLMode'] = 'pathinfo';
     }
     if ($CONF['URLMode'] != 'pathinfo') {
         return;
     }
     $query = 'SELECT %s as result FROM %s WHERE %s = "%s"';
     switch ($data[0]) {
         case 'b':
             if ($data[2] == 'n') {
                 $bid = getBlogIDFromName($data[1]);
             } else {
                 $bid = $data[1];
             }
             $blog_id = intval($bid);
             $param = array('blog', 'bnumber', $blog_id);
             if (!$this->_isValid($param)) {
                 $url = _NOT_VALID_BLOG;
             } else {
                 $url = $this->_generateBlogLink($blog_id) . '/';
             }
             break;
         case 'c':
             if ($data[2] == 'n') {
                 $cid = getCatIDFromName($data[1]);
             } else {
                 $cid = $data[1];
             }
             $cat_id = intval($cid);
             $param = array('category', 'catid', $cat_id);
             if (!$this->_isValid($param)) {
                 $url = _NOT_VALID_CAT;
             } else {
                 $url = createCategoryLink($cat_id);
             }
             break;
         case 's':
             $mcategories = $this->pluginCheck('MultipleCategories');
             if ($mcategories) {
                 if ($data[2] == 'n') {
                     $temp = $this->quote_smart($data[1]);
                     $sque = sprintf($query, 'scatid', _C_SUBCAT_TABLE, 'sname', $temp);
                     $scid = quickQuery($sque);
                 } else {
                     $scid = $data[1];
                 }
                 $sub_id = intval($scid);
                 $param = array('plug_multiple_categories_sub', 'scatid', $sub_id);
                 if (!$this->_isValid($param)) {
                     $url = _NOT_VALID_SUBCAT;
                 } else {
                     $cqe = sprintf($query, 'catid', _C_SUBCAT_TABLE, 'scatid', $sub_id);
                     $cid = quickQuery($cqe);
                     $cid = intval($cid);
                     if (method_exists($mcategories, "getRequestName")) {
                         $subrequest = $mcategories->getRequestName();
                     }
                     if (!$subrequest) {
                         $subrequest = 'subcatid';
                     }
                     $linkParam = array($subrequest => $sub_id);
                     $url = createCategoryLink($cid, $linkParam);
                 }
             }
             break;
         case 'i':
             $param = array('item', 'inumber', intval($data[1]));
             if (!$this->_isValid($param)) {
                 $url = _NOT_VALID_ITEM;
             } else {
                 if ($scatFlag) {
                     global $catid, $subcatid;
                     if (!empty($catid)) {
                         $linkparams['catid'] = intval($catid);
                     }
                     if (!empty($subcatid)) {
                         $mcategories = $this->pluginCheck('MultipleCategories');
                         if ($mcategories) {
                             if (method_exists($mcategories, 'getRequestName')) {
                                 $subrequest = $mcategories->getRequestName();
                             } else {
                                 $subrequest = 'subcatid';
                             }
                         }
                         $linkparams[$subrequest] = intval($subcatid);
                     }
                     $url = createItemLink(intval($data[1]), $linkparams);
                 } else {
                     $blink = $this->_generateBlogLink(getBlogIDFromItemID(intval($data[1])));
                     $i_query = 'SELECT obj_name as result ' . 'FROM %s ' . 'WHERE obj_param = "item" ' . 'AND      obj_id = %d';
                     $i_query = sprintf($i_query, _CUSTOMURL_TABLE, intval($data[1]));
                     $path = quickQuery($i_query);
                     if ($path) {
                         if ($data[2] == 'path') {
                             $url = $path;
                         } else {
                             $url = $blink . '/' . $path;
                         }
                     } else {
                         if ($data[2] == 'path') {
                             $url = $CONF['ItemKey'] . '/' . intval($data[1]);
                         } else {
                             $url = $blink . '/' . $CONF['ItemKey'] . '/' . intval($data[1]);
                         }
                     }
                 }
             }
             break;
         case 'm':
             if ($data[2] == 'n') {
                 $data[1] = $this->quote_smart($data[1]);
                 $mque = sprintf($query, 'mnumber', sql_table('member'), 'mname', $data[1]);
                 $mid = quickQuery($mque);
             } else {
                 $mid = $data[1];
             }
             $member_id = intval($mid);
             $param = array('member', 'mnumber', $member_id);
             if (!$this->_isValid($param)) {
                 $url = _NOT_VALID_MEMBER;
             } else {
                 $url = createMemberLink($member_id);
             }
             break;
     }
     return $url;
 }
예제 #2
0
/**
 * Can take either a category ID or a category name (be aware that
 * multiple categories can have the same name)
 */
function selectCategory($cat)
{
    global $catid;
    if (!$catid) {
        if (is_numeric($cat)) {
            $catid = intval($cat);
        } else {
            $catid = getCatIDFromName($cat);
        }
    }
}