Example #1
0
 public function get($hash)
 {
     $infohash_filelist = $this->fetch($hash);
     $infohash = $infohash_filelist['infohash'];
     $filelist = $infohash_filelist['filelist'];
     // 404
     if (empty($infohash)) {
         echo $this->app->notFound();
     }
     $view_data = ['name' => getattr($infohash, 'name'), 'total_size' => pretty_size($infohash['total_size']), 'magnet' => 'magnet:?xt=urn:btih:' . getattr($infohash, 'hash'), 'creation_date' => getattr($infohash, 'creation_date'), 'filelist' => $filelist];
     if ($this->app->request->headers->get('X-PJAX')) {
         echo $this->app->render('detail_pjax.php', $view_data);
         return;
     } else {
         echo $this->app->render('detail.php', $view_data);
     }
 }
Example #2
0
 public function post($return = false)
 {
     if (!$return and !$this->app->request->isAjax()) {
         return false;
     }
     $query = trim($this->app->request->params('q', ''));
     $page = (int) $this->app->request->params('p', 1);
     if ($page <= 0) {
         $page = 1;
     }
     $limit = 30;
     $fetch_search = $this->fetch($query, $page, $limit);
     $view_data['q'] = $query;
     $view_data['p'] = $page;
     $view_data['total'] = $total = $fetch_search['sphinx']['total'];
     if ($total <= 0) {
         $view_data['result'] = [];
         $view_data['has_more'] = false;
     } else {
         $view_data['result'] = $fetch_search['db'];
         // 匹配到的关键字生成样式
         if (!empty($view_data['result'])) {
             $keywords = explode(' ', $query);
             $pattern = '#';
             foreach ($keywords as $k2 => $v2) {
                 $pattern .= '(' . $v2 . ')|';
             }
             $pattern = rtrim($pattern, '|') . '#i';
             foreach ($view_data['result'] as $k => $v) {
                 $view_data['result'][$k]['name'] = preg_replace($pattern, '<span class="keyword">\\0</span>', $v['name']);
                 $view_data['result'][$k]['magnet'] = 'magnet:?xt=urn:btih:' . strtoupper($v['hash']);
                 $view_data['result'][$k]['pretty_size'] = pretty_size(getattr($v, 'total_size', 0));
             }
         }
         $view_data['has_more'] = $total > $limit * $page;
     }
     if ($return) {
         return $view_data;
     } else {
         header('Content-Type: application/json');
         $view_data['code'] = 0;
         echo json_encode($view_data);
     }
 }
Example #3
0
     $editvalue['catid'] = $categorylist[$editvalue['catid']]['name'];
     $editvalue['subjectimage'] = !empty($editvalue['subjectimage']) ? B_URL . '/' . getattachurl($editvalue['subjectimage']) : '';
     $editvalue['grade'] = lang('grade_' . $editvalue['grade']);
     $editvalue['validity_start'] = date("Y-m-d", !empty($_SGLOBAL['panelinfo']['validity_start']) ? $_SGLOBAL['panelinfo']['validity_start'] : time());
     $editvalue['validity_end'] = date("Y-m-d", $editvalue['validity_end']);
     $editvalue['isdiscount'] = $editvalue['isdiscount'] ? lang('yes') : lang('no');
 }
 if ($mname != 'shop') {
     $editvalue['subjectimage'] = !empty($editvalue['subjectimage']) ? B_URL . '/' . getattachurl($editvalue['subjectimage']) : '';
     if ($editvalue['grade'] == 0 || $editvalue['grade'] == 3) {
         $editvalue['grade'] = '顯示';
     } elseif ($editvalue['grade'] == '2') {
         $editvalue['grade'] = '關閉';
     }
     require_once B_ROOT . '/batch.attribute.php';
     $attributes = getattr($_GET['itemid'], $editvalue['catid']);
     $categorylist = getmodelcategory($mname);
     $editvalue['catid'] = $categorylist[$editvalue['catid']]['name'];
     $editvalue['validity_start'] = date("Y-m-d", $editvalue['validity_start']);
     $editvalue['validity_end'] = date("Y-m-d", $editvalue['validity_end']);
 }
 shownav('infomanage', $mname . '_adminview');
 showsubmenu($mname . '_adminview');
 showtips($mname . '_adminview_tips');
 showformheader('batchmod&m=' . $mname . '&operation=passupdate');
 showtableheader();
 if ($mname == 'shop') {
     $allow_admin_view_fields = array('subject', 'letter', 'groupid', 'syncfid', 'catid', 'region', 'grade', 'validity_start', 'validity_end', 'message', 'subjectimage', 'banner', 'windowsimg', 'windowstext', 'tips', 'tel', 'address', 'forum', 'isdiscount', 'discount');
     $query = DB::query('SELECT fieldname,fieldtitle FROM ' . tname('modelcolumns') . ' WHERE mid = 2 order by displayorder');
     while ($value = DB::fetch($query)) {
         if (!preg_match('/^ext_|^applicant/', $value['fieldname'])) {
Example #4
0
    $attr_id = isset($_REQUEST['attr']) ? explode(',', $_REQUEST['attr']) : array();
    $number = isset($_REQUEST['number']) ? intval($_REQUEST['number']) : 1;
    if ($goods_id == 0) {
        $res['err_msg'] = $_LANG['err_change_attr'];
        $res['err_no'] = 1;
    } else {
        if ($number == 0) {
            $res['qty'] = $number = 1;
        } else {
            $res['qty'] = $number;
        }
        $shop_price = get_final_price($goods_id, $number, true, $attr_id);
        //$res['result'] = price_format($shop_price * $number);
        $res['result'] = "¥" . $shop_price * $number . ".";
        $res['result'] .= "<font size=\"6px\" style=\"vertical-align:top;\">00</font>";
        $free = getattr($attr_id);
        $res['cd'] = $free['cd'];
        $res['cj'] = $free['cj'];
    }
    die($json->encode($res));
}
/*------------------------------------------------------ */
//-- 商品购买记录ajax处理
/*------------------------------------------------------ */
if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'gotopage') {
    include 'includes/cls_json.php';
    $json = new JSON();
    $res = array('err_msg' => '', 'result' => '');
    $goods_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
    if (!empty($goods_id)) {
Example #5
0
								<span>
									<a href="<?php 
        echo getattr($v, 'magnet', '');
        ?>
">
										磁力链接
									</a>
								</span>
								<span>
									大小: <?php 
        echo $v['pretty_size'];
        ?>
								</span>
								<span>
									创建日期: <?php 
        echo getattr($v, 'creation_date', '0000-00-00 00:00:00');
        ?>
								</span>
							</div>
						</div>
					<?php 
    }
    ?>
					<?php 
}
?>
				</div>

			</div><!-- end id=search-result -->
		</div><!-- end id=main class=search-main -->
		<input type="hidden" name="q" id="input-q" value="<?php 
Example #6
0
 /**
  * @test
  */
 public function getattr_WithNonExistingObjVar_ShouldReturnUserProvidedDefault()
 {
     $obj = new \stdClass();
     $this->assertEquals('n/a', getattr($obj->somekey, 'n/a'));
 }
Example #7
0
 public function getHeader($key, $default = null)
 {
     return getattr($this->headers[$key], $default);
 }
 /**
  * Creates the DIContainer with the given configuration.
  * @param  array $config The dependency configuration
  * @return \Dispatcher\Common\DIContainer
  */
 protected function createContainer(array $config = array())
 {
     $container = new DIContainer();
     $containerCfg = getattr($config['container'], array());
     foreach ($containerCfg as $k => $v) {
         $container[$k] = $v;
     }
     $sharedContainerCfg = getattr($config['sharedContainer'], array());
     foreach ($sharedContainerCfg as $k => $v) {
         $container->share($k, $v);
     }
     return $container;
 }
 protected function applySerializationOn(array &$bundle, $contentType)
 {
     $data = getattr($bundle['data'], '');
     $bundle['data'] = is_array($data) || is_object($data) ? json_encode($data) : '';
 }