Ejemplo n.º 1
0
 function getLink($f, $l, $t, $d, $pg = '')
 {
     $ext = '.' . $GLOBALS['MAC']['app']['suffix'];
     $rgext = $ext;
     $v = $GLOBALS['MAC']['view'][$f . $l];
     $r = $GLOBALS['MAC']['rewrite'][$f . $l];
     $p = $GLOBALS['MAC']['path'][$f . $l];
     if ($pg != '') {
         $strpg = '-pg-' . $pg;
     }
     $vi = $GLOBALS['MAC']['view']['vodindex'];
     $is = $vi == 2 ? 'index.php' : '';
     if (is_array($t)) {
         if ($t['t_pid'] > 0) {
             $tp = $GLOBALS['MAC_CACHE'][$f . 'type'][$t['t_pid']];
         }
     }
     switch ($l) {
         case 'index':
             $str = '?m=' . $f . '-index';
             if ($v > 0) {
                 $str = $v == 1 ? $r : $p;
                 if ($v == 1 && empty($pg)) {
                     $pg = 1;
                 }
             }
             if ($f == 'art' && $v < 1) {
                 $str = $is . $str;
             }
             break;
         case 'map':
             $str = $is . '?m=' . $f . '-map';
             if ($v > 0) {
                 $str = $v == 1 ? $r : $p;
             }
             break;
         case 'search':
             $str = 'index.php?m=' . $f . '-search';
             if ($v > 0) {
                 $str = $r;
             }
             $strpg = '';
             $colarr = array('pg', 'wd', 'year', 'starring', 'directed', 'pinyin', 'letter', 'ids', 'area', 'lang', 'tag', 'typeid', 'classid', 'order', 'by');
             $valarr = array();
             foreach ($colarr as $k => $v) {
                 $c = $colarr[$k];
                 $valarr[$c] = $this->P[$c];
             }
             foreach ($d as $k => $v) {
                 $valarr[$k] = $v;
             }
             foreach ($colarr as $k => $v) {
                 $c = $colarr[$k];
                 $vv = $valarr[$c];
                 if ($vv != '') {
                     if ($vv != '{' . $c . '}') {
                         $vv = urlencode($vv);
                     }
                     if (strpos($str, '-' . $c . '-') <= 0) {
                         $str .= '-' . $c . '-' . $vv;
                     }
                     $str = str_replace('{' . $c . '}', $vv, $str);
                 }
             }
             if ($valarr['wd'] == '') {
                 $str = str_replace('-wd-{wd}', '', $str);
             }
             break;
         case 'list':
             $strpg = '';
             $str = 'index.php?m=' . $f . '-list-id-{id}-pg-{pg}-order-{order}-by-{by}';
             if ($f == 'vod') {
                 $str .= '-class-{class}-year-{year}-letter-{letter}-area-{area}-lang-{lang}';
             }
             if ($v > 0) {
                 $str = $r;
             }
             $colarr = array('{id}', '{pg}', '{order}', '{by}', '{class}', '{year}', '{letter}', '{area}', '{lang}');
             $valarr = array('id' => $this->P['id'], 'pg' => '1', 'order' => $this->P['order'], 'by' => $this->P['by'], 'class' => $this->P['class'], 'year' => $this->P['year'], 'letter' => $this->P['letter'], 'area' => $this->P['area'], 'lang' => $this->P['lang']);
             foreach ($d as $k => $v) {
                 $valarr[$k] = $v;
             }
             $str = str_replace($colarr, $valarr, $str);
             break;
         case 'type':
             $str = $is . '?m=' . $f . '-type-id-' . $t['t_id'];
             if (!empty($GLOBALS['m']) && $au) {
                 $v = 0;
             }
             if ($v > 0) {
                 $str = str_replace(array('{id}', '{en}', '{md5}', '{p_id}', '{p_en}', '{p_md5}'), array($t['t_id'], $t['t_enname'], md5($t['t_id']), $tp['t_id'], $tp['t_enname'], md5($tp['t_id'])), $v == 1 ? $r : $p);
                 if ($v == 1 && empty($pg)) {
                     $pg = 1;
                 }
             }
             break;
         case 'topicindex':
             $str = $is . '?m=' . $f . '-topicindex';
             if ($v > 0) {
                 $str = $v == 1 ? $r : $p;
             }
             break;
         case 'topic':
             $str = $is . '?m=' . $f . '-topic-id-' . $t['t_id'];
             if ($v > 0) {
                 $str = str_replace(array("{id}", "{en}", "{md5}"), array($t['t_id'], $t['t_enname'], md5($t['t_id'])), $v == 1 ? $r : $p);
             }
             break;
         case 'detail':
             $pre = $f == 'art' ? 'a_' : 'd_';
             $str = $is . '?m=' . $f . '-detail-id-' . $d[$pre . 'id'];
             if ($v > 0) {
                 $str = str_replace(array("{type_id}", "{type_en}", "{type_pid}", "{type_pen}", "{id}", "{md5}"), array($t['t_id'], $t['t_enname'], $tp['t_id'], $tp['t_enname'], $d[$pre . 'id'], md5($d[$pre . 'id'])), $v == 1 ? $r : $p);
                 if (strpos("," . $str, "{en}")) {
                     $str = str_replace("{en}", repSpecialChar($d[$pre . 'enname']), $str);
                 }
                 if (strpos("," . $str, "{year}")) {
                     $str = str_replace("{year}", getDatet("Y", $d[$pre . 'addtime']), $str);
                 }
                 if (strpos("," . $str, "{month}")) {
                     $str = str_replace("{month}", getDatet("m", $d[$pre . 'addtime']), $str);
                 }
                 if (strpos("," . $str, "{day}")) {
                     $str = str_replace("{day}", getDatet("d", $d[$pre . 'addtime']), $str);
                 }
             }
             break;
         case 'play':
         case 'down':
             $pre = 'd_';
             if ($GLOBALS['app]']['isopen'] == 0) {
                 $jstart = "";
                 $jend = "";
             } else {
                 $jstart = "javascript:MAC.Open('";
                 $jend = "',mac_widthpop,mac_heightpop);";
             }
             $str = $is . "?m=vod-" . $l . "-id-" . $d['d_id'] . "-src-{src}-num-{num}";
             if ($v > 0) {
                 $str = str_replace(array("{type_id}", "{type_en}", "{type_pid}", "{type_pen}", "{id}", "{md5}"), array($t['t_id'], $t['t_enname'], $tp['t_id'], $tp['t_enname'], $d[$pre . 'id'], md5($d[$pre . 'id'])), $v == 1 ? $r : $p);
                 if (strpos("," . $str, "{en}")) {
                     $str = str_replace("{en}", repSpecialChar($d['d_enname']), $str);
                 }
                 if (strpos("," . $str, "{year}")) {
                     $str = str_replace("{year}", getDatet("Y", $d['d_addtime']), $str);
                 }
                 if (strpos("," . $str, "{month}")) {
                     $str = str_replace("{month}", getDatet("m", $d['d_addtime']), $str);
                 }
                 if (strpos("," . $str, "{day}")) {
                     $str = str_replace("{day}", getDatet("d", $d['d_addtime']), $str);
                 }
                 if ($v == 2) {
                     $str .= $ext . "?" . $d['d_id'] . "-{src}-{num}";
                     $ext = '';
                 } elseif ($v == 3) {
                     $str .= "-{src}-{num}" . $ext;
                     $ext = '';
                 } elseif ($v == 4) {
                     $str .= "-{src}-1" . $ext . "?" . $d['d_id'] . "-{src}-{num}";
                     $ext = '';
                 }
             }
             break;
         case 'gbook':
             $str = 'index.php?m=gbook-show';
             if ($v > 0) {
                 $str = $r;
             }
             if (empty($pg)) {
                 $pg = 1;
             }
             break;
         case 'comment':
             $str = 'index.php?m=comment-show-aid-' . $this->C["siteaid"] . '-vid-' . ($f == 'art' ? $d['a_id'] : $d['d_id']);
             if ($v > 0) {
                 $str = $r;
             }
             if (empty($pg)) {
                 $pg = 1;
             }
             break;
         case 'rss':
         case 'baidu':
         case 'google':
             $v = $GLOBALS['MAC']['view']['rss'];
             $str = 'index.php?m=map-' . $l;
             if ($v == 1) {
                 $str = $GLOBALS['MAC']['rewrite']['rss'];
                 if (empty($pg)) {
                     $pg = 1;
                 }
             } elseif ($v == 2) {
                 $str = $l;
                 $ext = '.xml';
             }
             $str = str_replace('{method}', $l, $str);
             break;
         case 'label':
             $v = $GLOBALS['MAC']['view']['label'];
             $path = trim($f);
             $f = substr($path, 0, strpos($path, '.'));
             $ext = '.' . substr($path, strpos($path, '.') + 1, strlen($path) - strpos($path, '.'));
             $str = 'index.php?m=label-' . $f;
             if ($v > 0) {
                 $r = $GLOBALS['MAC']['rewrite']['label'];
                 if ($v == 1 && empty($pg)) {
                     $pg = 1;
                 }
                 $str = $v == 1 ? str_replace('{label}', $f, $r) : str_replace('$$', '/', $f);
             }
             break;
     }
     if (strpos($str, '{pg}')) {
         $str = str_replace('{pg}', $pg, $str);
         $strpg = '';
     }
     $str = $jstart . MAC_PATH . $str . $strpg . $ext . $jend;
     return str_replace(array('//', '/index' . $rgext), array('/', '/'), $str);
 }
Ejemplo n.º 2
0
 function getVodPlayUrl($id, $name, $enname, $typeid, $typename, $typeenname, $sort, $num)
 {
     if (app_playisopen == 0) {
         $strJSstart = "";
         $strJSend = "";
     } else {
         $strJSstart = "javascript:OpenWindow1('";
         $strJSend = "',popenW,popenH);";
     }
     switch (app_vodplayviewtype) {
         case 1:
             $str = "vodplay/index.php?id=" . $id . "&sort=" . $sort . "&num=" . $num;
             break;
         case 2:
             $str = $str = replaceStr(app_vodplaypath, "{id}", $id) . "-" . $sort . "-" . $num . "." . app_vodsuffix;
             break;
         case 3:
         case 4:
         case 5:
         case 6:
             $str = replaceStr(app_vodplaypath, "{id}", $id);
             $str = replaceStr($str, "{name}", repSpecialChar($name));
             $str = replaceStr($str, "{enname}", repSpecialChar($enname));
             $str = replaceStr($str, "{typeid}", $typeid);
             $str = replaceStr($str, "{typename}", $typename);
             $str = replaceStr($str, "{typeenname}", $typeenname);
             if (strpos($str, "{md5}") > 0) {
                 $str = replaceStr($str, "{md5}", md5($id));
             }
             if (app_vodplayviewtype == 4) {
                 $str = $str . "-" . $sort . "-" . $num . "." . app_vodsuffix;
             } else {
                 if (app_vodplayviewtype == 5) {
                     $str = $str . "-" . $sort . "-1." . app_vodsuffix . "?" . $id . "-" . $sort . "-" . $num;
                 } else {
                     if (app_vodplayviewtype == 6) {
                         $str = "play." . app_vodsuffix . "?" . $id . "-" . $sort . "-" . $num;
                     } else {
                         $str = $str . "." . app_vodsuffix . "?" . $id . "-" . $sort . "-" . $num;
                     }
                 }
             }
             $str = replaceStr($str, "index." . app_vodsuffix, "");
             break;
         default:
             $str = "vodplay/?" . $id . "-" . $sort . "-" . $num . "." . app_vodsuffix;
             break;
     }
     return $strJSstart . app_installdir . $str . $strJSend;
 }