Наследование: extends Cache
Пример #1
0
 function sync_data()
 {
     hg_flushMsg('开始同步数据');
     $sql = "SELECT COUNT(*) as total FROM " . DB_PREFIX . "nums";
     $total = $this->db->query_first($sql);
     $total = $total['total'];
     $offset = 0;
     $count = 10000;
     //查询存在的分表
     include_once CUR_CONF_PATH . 'lib/cache.class.php';
     $cache = new CacheFile();
     while ($offset < $total) {
         hg_flushMsg('开始同步第' . $offset . '到' . ($offset + $count) . '条');
         $table = $cache->get_cache('access_table_name');
         $table = convert_table_name($table);
         $table_str = '';
         if ($table) {
             $table_str = implode(',', $table);
         }
         $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
         $this->db->query($sql);
         //查询存在的分表
         $sql = "SELECT app_bundle, module_bundle, cid, title FROM " . DB_PREFIX . "nums WHERE 1 ORDER BY id ASC LIMIT " . $offset . ", " . $count;
         $q = $this->db->query($sql);
         while (($row = $this->db->fetch_array($q)) != false) {
             $sql = "UPDATE " . DB_PREFIX . "merge SET title = '" . $row['title'] . "'\n                        WHERE app_bundle='" . $row['app_bundle'] . "' AND module_bundle = '" . $row['module_bundle'] . "' AND cid='" . $row['cid'] . "'";
             //                hg_flushMsg($sql);
             $this->db->query($sql);
         }
         $offset += $count;
     }
     hg_flushMsg('数据同步完成');
 }
Пример #2
0
 /**
  *
  * @param $language Sprache
  *            für den Place-Holder-Text
  * @return CacheFile
  */
 public function newCacheFileForPlaceholder($language)
 {
     $otherCacheFilename = $this->displayWidth . $this->displayHeight . "{$language}-placeholder.jpg";
     $cachefile = new CacheFile($this->imageProperties(), $this->config, $this->proportion, $this->bgcolor, $this->origWidth(), $this->origHeight());
     $cachefile->setDisplaySize($this->displayWidth, $this->displayHeight);
     $cachefile->cacheFilename = $this->scrambleFilename($otherCacheFilename, $this->config->getScrambleFilename());
     return $cachefile;
 }
Пример #3
0
 public function writeWatermarkInfo(&$sourcefileId, $thumbnailMode, CacheFile $cacheFile)
 {
     if (!$this->config->isUsedWatermark() || $thumbnailMode) {
         return;
     }
     static $disable_alpha_warning;
     $watermarkfile = $this->config->getWatermarkFile();
     $align = $this->config->getWatermarkLeft();
     $valign = $this->config->getWatermarkTop();
     if ($this->config->getWatermarkTransparencyType() == 'alpha') {
         $transcolor = FALSE;
     } else {
         $transcolor = $this->config->getWatermarkTransparentColor();
     }
     $transparency = $this->config->getWatermarkTransparency();
     try {
         $watermarkfile_id = $this->loadWatermarkFile($watermarkfile);
     } catch (Exception $e) {
         return false;
     }
     @imageAlphaBlending($watermarkfile_id, false);
     $result = @imageSaveAlpha($watermarkfile_id, true);
     if (!$result) {
         if (!$disable_alpha_warning) {
             $msg = "Watermark problem: your server does not support alpha blending (requires GD 2.0.1+)";
             JLog::add($msg, JLog::WARNING);
         }
         $disable_alpha_warning = true;
         imagedestroy($watermarkfile_id);
         return false;
     }
     $offset_w = $cacheFile->offsetX();
     $offset_h = $cacheFile->offsetY();
     $w = $cacheFile->displayWidth();
     $h = $cacheFile->displayHeight();
     $watermarkfileWidth = imageSX($watermarkfile_id);
     $watermarkfileHeight = imageSY($watermarkfile_id);
     $watermarkOffsetX = $this->calcXOffsetForWatermark($align, $watermarkfileWidth, $offset_w, $w);
     $watermarkOffsetY = $this->calcYOffsetForWatermark($valign, $watermarkfileHeight, $offset_h, $h);
     $fileType = strtolower(pathinfo($watermarkfile, PATHINFO_EXTENSION));
     $sourcefileId = $this->upsampleImageIfNecessary($fileType, $sourcefileId);
     if ($transcolor !== false) {
         $transcolAsInt = intval(str_replace('#', '', $transcolor), 16);
         imagecolortransparent($watermarkfile_id, $transcolAsInt);
         // use transparent color
         imagecopymerge($sourcefileId, $watermarkfile_id, $watermarkOffsetX, $watermarkOffsetY, 0, 0, $watermarkfileWidth, $watermarkfileHeight, $transparency);
     } else {
         imagecopy($sourcefileId, $watermarkfile_id, $watermarkOffsetX, $watermarkOffsetY, 0, 0, $watermarkfileWidth, $watermarkfileHeight);
         // True
         // alphablend
     }
     imagedestroy($watermarkfile_id);
     return true;
 }
Пример #4
0
 function show()
 {
     if ($this->input['id']) {
         $cond = ' AND id=' . intval($this->input['id']);
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "ranking_sort WHERE status = 1{$cond} ORDER BY last_time ASC LIMIT 10";
     $qq = $this->db->query($sql);
     include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
     $this->publishcontent = new publishcontent();
     include CUR_CONF_PATH . 'lib/access.class.php';
     $this->obj = new access();
     include_once CUR_CONF_PATH . 'lib/cache.class.php';
     $cache = new CacheFile();
     $exists_table = $cache->get_cache('access_table_name');
     while ($info = $this->db->fetch_array($qq)) {
         $params = array('start_time' => $info['start_time'], 'duration' => $info['duration'], 'last_time' => $info['last_time'], 'column_id' => $info['column_id'], 'type' => $info['type'], 'output_type' => $info['output_type'], 'count' => $info['limit_num'], 'title' => $info['k'], 'publish_duration' => $info['publish_duration']);
         $rankingCon = $this->obj->get_content($params);
         $sql = "DELETE FROM " . DB_PREFIX . "ranking_cont WHERE sort_id = " . $info['id'];
         $this->db->query($sql);
         if (!empty($rankingCon)) {
             //查询发布到发布库的内容标识,用于判断内容是否是发布库数据
             $content_type = $this->publishcontent->get_all_content_type();
             $pub_content_bundle = array();
             foreach ((array) $content_type as $k => $v) {
                 $pub_content_bundle[] = $v['bundle_id'];
             }
             $rankingChunk = array_chunk($rankingCon, 30, true);
             foreach ($rankingChunk as $key => $val) {
                 $sql = "INSERT INTO " . DB_PREFIX . "ranking_cont(sort_id,cid,app_bundle,title,url,count) VALUES";
                 $space = '';
                 foreach ($val as $k => $v) {
                     //非发布库数据标题使用库里存储内容
                     //从merge表统计出来如果没有title,到nums表查询标题
                     //merge表结构不好更改,更改后客户升级也比较麻烦 所以临时解决方案 到nums表再查询一次
                     if (!$v['title'] && $v['app_bundle'] && !in_array($v['app_bundle'], $pub_content_bundle)) {
                         $sql_nums = "SELECT title FROM " . DB_PREFIX . "nums WHERE app_bundle = '" . $v['app_bundle'] . "' AND cid=" . $v['cid'];
                         $nums_q = $this->db->query_first($sql_nums);
                         $v['title'] = $nums_q['title'];
                     }
                     !$v['url'] && ($v['url'] = $v['refer_url']);
                     $sql .= $space . "('{$info['id']}','{$v['cid']}','{$v['app_bundle']}','{$v['title']}','{$v['url']}','{$v['num']}')";
                     $space = ',';
                 }
                 $this->db->query($sql);
             }
         }
         $sql = "UPDATE " . DB_PREFIX . "ranking_sort SET last_time = " . TIMENOW . " WHERE id = " . $info['id'];
         $this->db->query($sql);
         echo $info['title'] . "<br/>";
         flush();
         ob_flush();
     }
     exit;
 }
Пример #5
0
 public static function buildHtmlForImage(&$lightbox, CacheFile &$mosthumbProperties, CacheFile &$mosimageProperties, ImageProperties &$imgProperties, &$config, $param)
 {
     $accessLevel = $imgProperties->getAccessLevel();
     $user = JFactory::getUser();
     if ($user->guest && $accessLevel > 1) {
         $img = '';
     } else {
         $lightboxRel = $lightbox->getRel();
         $thumbSize = ' width="' . $mosthumbProperties->displayWidth() . '" height="' . $mosthumbProperties->displayHeight() . '"';
         $image = '<a href="' . $mosimageProperties->getCacheFileUrl() . '"';
         $image .= ' rel="' . $lightboxRel . '"';
         $image .= ' class="' . $lightbox->getCssClassForImageLink() . '"';
         $image .= ' title="' . ($config->isViewCaptionTextForFullsize() ? $imgProperties->getCaptionText() : '') . '"';
         $image .= '>';
         $image .= '<img class="mosimgage-inner" src="' . $mosthumbProperties->getCacheFileUrl() . '"';
         $image .= $thumbSize;
         $image .= $imgProperties->getImageAlignAsHtml();
         $image .= ' alt="' . $imgProperties->getAltText() . '"';
         $image .= ' title="' . $imgProperties->getCaptionText() . '"';
         $image .= ' border="' . $imgProperties->getBorderWidth() . '"';
         $image .= ' /></a>';
         $caption = '';
         $widthInner = $mosthumbProperties->displayWidth();
         $widthOuter = $mosthumbProperties->displayWidth();
         // + 26 - 12; // -12 img.mosimgage-inner margin- = 0px
         if ($imgProperties->isCaptionTextEmpty()) {
             $cssDisplay = " visibility: hidden;";
         } else {
             $cssDisplay = '';
         }
         $cssClassOuter = $imgProperties->getOuterCssClass();
         $img = '<span class="' . $cssClassOuter . '" style="width: ' . $widthOuter . 'px;border-width:' . $imgProperties->getBorderWidth() . 'px;">';
         if ($imgProperties->isViewCaptionTextForThumbnail()) {
             $caption_valign = $imgProperties->getCaptionPosition();
             $cssWidh = 'width: ' . $widthInner . 'px;';
             $caption = '<span class="mosimgage-inner-' . $caption_valign . '" style="' . $cssWidh . $cssDisplay . '" ';
             $caption .= '>';
             $caption .= $imgProperties->getCaptionText();
             $caption .= '</span>';
             if ($caption_valign == 'top' && $caption) {
                 $img .= $caption;
             }
             $img .= $image;
             if ($caption_valign == 'bottom' && $caption) {
                 $img .= $caption;
             }
         } else {
             $img .= $image;
         }
         $img .= '</span>';
     }
     $addHtml = self::getHtmlForFloat($param);
     return $addHtml . $img;
 }
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
Пример #7
0
 public function GetMenuByParentID($ParentID, $force = false)
 {
     $Cache = new CacheFile();
     if (!$ParentID) {
         $ParentID = $this->TopID();
     }
     $CacheID = '/Moudles/Menus/' . $ParentID;
     $result = $Cache->Get($CacheID);
     if ($result == CacheFile::NOCACHE || $force) {
         $DB = $this->__InitDB();
         $sql = 'SELECT * FROM `' . $this->TableName . '` WHERE `' . $this->ParentID . '`=' . $ParentID . ' AND Property<2 ORDER BY `' . $this->GlobalDisplayOrder . '` ASC';
         $result = $DB->Select($sql);
         if ($result) {
             $Cache->Save($CacheID, $result, CacheFile::__OneYearSeconds__);
         }
     }
     return $result;
 }
Пример #8
0
 /**
  * Tests CacheFile->set()
  */
 public function testSetException()
 {
     @rmdir("/tmp/shindig/te");
     $this->assertTrue(touch("/tmp/shindig/te"));
     $this->setExpectedException("CacheException");
     try {
         $this->CacheFile->set("test", "testing");
     } catch (Exception $e) {
         $this->assertTrue(unlink("/tmp/shindig/te"));
         throw $e;
     }
 }
Пример #9
0
 function show()
 {
     $cid = urldecode($this->input['cid']);
     if (!$cid) {
         $this->errorOutput('no cid');
     }
     $sql = "UPDATE " . DB_PREFIX . "nums SET del = 1 WHERE cid IN(" . $cid . ")";
     $this->db->query($sql);
     include_once CUR_CONF_PATH . 'lib/cache.class.php';
     $cache = new CacheFile();
     $table = $cache->get_cache('access_table_name');
     $table = convert_table_name($table);
     if ($table) {
         $table_str = implode(',', $table);
     }
     $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
     $this->db->query($sql);
     $sql = "UPDATE " . DB_PREFIX . "merge SET del = 1 WHERE cid IN(" . $cid . ")";
     $this->db->query($sql);
     exit('sucess');
 }
Пример #10
0
 private function flushServers($force = false)
 {
     $fileCache = new CacheFile();
     if ($force) {
         # del cache this configuration file
         $fileCache->delete('bee2:redis3.configuration.nodes');
     }
     // retrieve this configuration from cache
     if (false === ($servers = $fileCache->get('bee2:redis3.configuration.nodes'))) {
         $res = $this->getConnection()->rawCommand('CLUSTER', 'NODES');
         if (empty($res)) {
             return false;
         }
         $servers = array();
         $_slave_server = array();
         $res = explode("\n", $res);
         foreach ($res as $v) {
             if (empty($v)) {
                 continue;
             }
             $item = explode(' ', $v);
             if (false === strpos($item[2], 'master')) {
                 $_slave_server[$item[3]] = $item;
                 continue;
             }
             $server = array('id' => $item[0], 'master' => $item[1]);
             $min_max = explode('-', end($item));
             if (count($min_max) == 2) {
                 $slot['min'] = $min_max[0];
                 $slot['max'] = $min_max[1];
             } else {
                 $slot['min'] = $min_max[0];
                 $slot['max'] = $min_max[0];
             }
             $server['slots'] = $slot;
             $servers[$slot['min']] = $server;
         }
         ksort($servers);
         if (empty($servers)) {
             return false;
         }
         $_servers = $servers;
         $servers = array();
         foreach ($_servers as $_k => $_server) {
             $_server['slave'] = $_slave_server[$_server['id']][1];
             $servers[] = $_server;
         }
         $fileCache->set('bee2:redis3.configuration.nodes', $servers);
     }
     $this->_master_servers = $servers;
     return true;
 }
Пример #11
0
 function get_content()
 {
     if ($this->settings['cache_expire_time']) {
         /**先从缓存读取数据 缓存不存在或过期时再从表中查询*/
         include_once ROOT_PATH . 'lib/class/cache/cache.class.php';
         $cache_factory = cache_factory::get_instance();
         $cache_type = $this->settings['cache_type'] ? $this->settings['cache_type'] : 'file';
         $cache_driver = $cache_factory->get_cache_driver($cache_type);
         $input = $this->input;
         unset($input['access_token'], $input['lpip']);
         $cache_id = md5(serialize($input));
         $data = $cache_driver->get($cache_id);
         if ($data) {
             $this->addItem($data);
             $this->output();
         }
         /**先从缓存读取数据 缓存不存在或过期时再从表中查询*/
     }
     //$condition = $this->get_condition();
     $offset = $this->input['page'] ? $this->input['page_num'] * ($this->input['page'] - 1) : 0;
     $count = $this->input['page_num'] ? intval($this->input['page_num']) : 20;
     $con = $con_count = $this->con_process();
     $con['offset'] = $offset;
     $con['count'] = $count;
     $content = $this->obj->get_content($con);
     include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
     $this->publishcontent = new publishcontent();
     $content_type = $this->publishcontent->get_all_content_type();
     $pub_content_bundle = array();
     foreach ((array) $content_type as $k => $v) {
         $pub_content_bundle[] = $v['bundle_id'];
     }
     include_once ROOT_PATH . 'lib/class/auth.class.php';
     $this->auth = new Auth();
     $app_info = $this->auth->get_app();
     $module = array();
     foreach ((array) $app_info as $k => $v) {
         if (!empty($v)) {
             $module[$v['bundle']] = $v['name'];
         }
     }
     $cidArr = array();
     $conArr = array();
     $other_content = array();
     foreach ((array) $content as $row) {
         if (!in_array($row['app_bundle'], $pub_content_bundle)) {
             $row['bundle_name'] = $module[$row['app_bundle']];
             if (!$row['bundle_name']) {
                 $row['bundle_name'] = $this->settings["App_{$row['app_bundle']}"]['name'];
             }
             if (!$row['bundle_name']) {
                 $row['bundle_name'] = $row['app_bundle'];
             }
             $row['content_url'] = $row['url'];
             $row['access_nums'] = $row['num'];
             $other_content[] = $row;
         } else {
             $cidArr[] = $row['cid'];
             $conArr[$row['cid']] = array('access_nums' => $row['num']);
         }
     }
     $cidStr = implode(',', $cidArr);
     $ret = $this->publishcontent->get_content_by_cid($cidStr);
     if (!is_array($ret)) {
         //return array();
     }
     $ret = (array) $ret;
     $arExistIds = array();
     foreach ($ret as $k => $v) {
         $arExistIds[] = $v['cid'];
         $ret[$k]['bundle_name'] = $module[$v['bundle_id']];
         if (!$ret[$k]['bundle_name']) {
             $ret[$k]['bundle_name'] = $this->settings["App_{$v['bundle_id']}"]['name'];
         }
         if (!$ret[$k]['bundle_name']) {
             $ret[$k]['bundle_name'] = $v['bundle_id'];
         }
         $ret[$k] = array_merge($ret[$k], $conArr[$k]);
     }
     $ret = array_merge($ret, $other_content);
     //发布库删除没有更新统计时条数不准确 下面代码为解决此bug
     //对比cid差集
     $delCid = array_diff($cidArr, $arExistIds);
     //更新已经不存在的内容
     if (!empty($delCid)) {
         $cid = implode(',', $delCid);
         $sql = "UPDATE " . DB_PREFIX . "nums SET del = 1 WHERE cid IN(" . $cid . ")";
         $this->db->query($sql);
         include_once CUR_CONF_PATH . 'lib/cache.class.php';
         $cache = new CacheFile();
         $table = $cache->get_cache('access_table_name');
         $table = convert_table_name($table);
         if ($table) {
             $table_str = implode(',', $table);
         }
         $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
         $this->db->query($sql);
         $sql = "UPDATE " . DB_PREFIX . "merge SET del = 1 WHERE cid IN(" . $cid . ")";
         $this->db->query($sql);
     }
     $ret = hg_array_sort($ret, 'access_nums', 'DESC');
     $pagearr = $this->obj->get_content($con_count, 1);
     $pagearr['page_num'] = $count;
     $pagearr['total_num'] = $pagearr['total'];
     $pagearr['total_page'] = ceil($pagearr['total'] / $count);
     $pagearr['current_page'] = floor($offset / $count) + 1;
     $ret = array('content' => array_values($ret), 'page' => $pagearr);
     if ($this->settings['cache_expire_time']) {
         /*将数据写入缓存*/
         $cache_driver->set($cache_id, $ret, $this->settings['cache_expire_time']);
         /*将数据写入缓存*/
     }
     $this->addItem($ret);
     $this->output();
 }
Пример #12
0
    /**
     * Retrieve body html
     *
     * Retrieves markup to include in the main content body of item show pages
     *
     * @return string Html to include in the header, 
     * linking to stylesheets and javascript libraries
     */
    public function getBodyHtml($params)
    {
        $params = $this->_filterCssParams($params, array('width', 'height'));
        if (empty($params['cacheFileName'])) {
            throw new Exception('Item cannot be displayed. No cache file specified for Ohms Viewer.');
            return;
        }
        $libDir = dirname(dirname(dirname(__FILE__))) . '/libraries/ohmsviewer/';
        $config = parse_ini_file($libDir . "config/config.ini", true);
        $cachefile = isset($params['cacheFileName'][0]) ? $params['cacheFileName'][0] : $params['cacheFileName'];
        $cachefile = isset($cachefile['path']) ? $cachefile['path'] : $cachefile;
        require_once dirname(dirname(dirname(__FILE__))) . '/libraries/ohmsviewer/lib/CacheFile.class.php';
        //$plugin_dir = dirname(dirname(dirname(__FILE__)));
        $plugin_dir = dirname($_SERVER["SCRIPT_FILENAME"]) . '/plugins/MultimediaDisplay';
        $cacheFile = CacheFile::getInstance($cachefile, dirname(dirname($plugin_dir)) . '/files', $config);
        //$cacheFile = CacheFile::getInstance($cachefile,'/var/www/html/omeka/files',$config);
        //dirname(dirname(dirname(dirname(__FILE__)))).'/files'
        ob_start();
        ?>
        <script type="text/javascript">
		var jumpToTime = null;
		if(location.href.search('#segment') > -1)
		{
			var jumpToTime = parseInt(location.href.replace(/(.*)#segment/i, ""));
			if(isNaN(jumpToTime))
			{
				jumpToTime = 0;
			}
		}
	</script>
        <div id="audio-panel">
        <?php 
        //include_once dirname(dirname(dirname(__FILE__))).'/libraries/ohmsviewer/tmpl/player_'.$cacheFile->playername.'.tmpl.php';
        include_once dirname(dirname(dirname(__FILE__))) . '/libraries/ohmsviewer/tmpl/player_legacy.tmpl.php';
        ?>
        </div>
        <div id="ohms-main">
          <h2>Transcript</h2>
          <div id="ohms-main-panels">
            <div id="content-panel">
              <div id="transcript-panel">
                <?php 
        echo $cacheFile->transcript;
        ?>
              </div>
              <div id="index-panel">
                <?php 
        echo $cacheFile->index;
        ?>
              </div>
            </div>
            <div id="searchbox-panel">
              <?php 
        include_once dirname(dirname(dirname(__FILE__))) . '/libraries/ohmsviewer/tmpl/search.tmpl.php';
        ?>
</div>
            </div>
          </div>
        </div>
              
        <div style="clear:both; color:white; margin-top:30px;text-align:left;">
          <p>
<?php 
        if ($cacheFile->rights) {
            echo '<span><h3>Rights Statement:</h3>';
            echo $cacheFile->rights;
            echo '</span>';
        }
        ?>
          </p>
          <p>
<?php 
        if ($cacheFile->usage) {
            echo '<span><h3>Usage Statement:</h3>';
            echo $cacheFile->usage;
            echo '</span>';
        }
        ?>
          </p>
        </div>
            <script type="text/javascript">
            jQuery(document).ready(function() {

                jQuery('a.indexSegmentLink').on('click', function(e) {
                    var linkContainer = '#segmentLink' + jQuery(e.target).data('timestamp');

                    e.preventDefault();
                    if(jQuery(linkContainer).css("display") == "none")
                        {
                            jQuery(linkContainer).fadeIn(1000);
                        }
                    else
                        {
                            jQuery(linkContainer).fadeOut();
                        }
				
                    return false;
                });
		   
                jQuery('.segmentLinkTextBox').on('click', function() {
                    jQuery(this).select();
                });
	
                if(jumpToTime !== null)
                    {
                        jQuery('div.point').each(function(index) {
                            if(parseInt(jQuery(this).find('a.indexJumpLink').data('timestamp')) == jumpToTime)
                                {
                                    jumpLink = jQuery(this).find('a.indexJumpLink');
                                    jQuery('#accordionHolder').accordion({active: index});
                                    var interval = setInterval(function() {
						
                                        if(Math.floor(jQuery('#subjectPlayer').data('jPlayer').status.currentTime) == jumpToTime)  {
                                            clearInterval(interval);
                                        }
                                        else
                                            {
                                                jumpLink.click();
                                            }
                                    }, 500);
                                    jQuery(this).find('a.indexJumpLink').click();
                                }
                        });
                    }
        jQuery(".fancybox").fancybox();
        jQuery(".various").fancybox({
            //  maxWidth : width,
            // maxHeight : height,
            fitToView : false,
            width : '70%',
            height : '70%',
            autoSize : false,
            closeClick : false,
            openEffect : 'none',
            closeEffect : 'none'
            });
        jQuery('.fancybox-media').fancybox({
            openEffect : 'none',
            closeEffect : 'none',
            width : '80%',
            height : '80%',
            fitToView : true,
            helpers : {
      media : {}
    }
    });
        jQuery(".fancybox-button").fancybox({
      prevEffect : 'none',
            nextEffect : 'none',
            closeBtn : false,
            helpers : {
      title : { type : 'inside' },
            buttons : {}
    }
    });
    });

            var cachefile = '<?php 
        echo $cacheFile->cachefile;
        ?>
';
            jQuery('#content').find('h1').after(jQuery("#audio-panel"));
            jQuery("#audio-panel").after(jQuery('#ohms-main'));
      </script>
      <style>
        #ohms-main {
           width:<?php 
        echo $params['width'];
        ?>
;
        }
        #ohms-main #transcript-panel {
           height:<?php 
        echo $params['height'];
        ?>
;
        }

      </style>
<?php 
        return ob_get_clean();
    }
Пример #13
0
    /**
     * 叮当内容统计add
     */
    public function dingdoneAddNums()
    {
        $id = intval($this->input['id']);
        $content_fromid = intval($this->input['content_fromid']);
        if (!$id) {
            $this->errorOutput(NOID);
        }
        $rec = intval($this->input['rec']);
        $appunid = addslashes($this->input['app_uniqueid']);
        $modunid = addslashes($this->input['mod_uniqueid']);
        //叮当原有数据兼容
        $old_sql = 'SELECT id, access_nums, is_sync,url, last_sync_time, create_time, title
				FROM ' . DB_PREFIX . "nums\r\n\t\t\tWHERE app_bundle='{$appunid}' AND module_bundle='{$modunid}' AND cid='{$id}' AND content_fromid = 0";
        $old_row = $this->db->query_first($old_sql);
        if ($old_row && is_array($old_row)) {
            $count = intval($old_row['access_nums']);
            //删除此数据
            $delete_old_sql = "delete from " . DB_PREFIX . "nums where cid =" . $id;
            $this->db->query($delete_old_sql);
        } else {
            $sql = 'SELECT id, access_nums, is_sync,url, last_sync_time, create_time, title
				FROM ' . DB_PREFIX . "nums\r\n\t\t\t\t\t\t\tWHERE app_bundle='{$appunid}' AND module_bundle='{$modunid}' AND content_fromid='{$content_fromid}'";
            $row = $this->db->query_first($sql);
            $count = intval($row['access_nums']);
            $delete_new_sql = "delete from " . DB_PREFIX . "nums where content_fromid =" . $content_fromid . "";
            $this->db->query($delete_new_sql);
        }
        if ($rec) {
            $title = $this->input['title'];
            if (!$title && !$row['title']) {
                include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
                $this->publishcontent = new publishcontent();
                $content_type = $this->publishcontent->get_all_content_type();
                $this->pub_content_bundle = $pub_content_bundle = array();
                foreach ((array) $content_type as $k => $v) {
                    $this->pub_content_bundle[] = $pub_content_bundle[] = $v['bundle_id'];
                }
                if ($appunid && in_array($appunid, $pub_content_bundle)) {
                    //统计时如果没有传并且库里没有标题,去发布库查询标题,用户统计后台搜索
                    include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
                    $this->publishtcontent = new publishcontent();
                    $content = $this->publishtcontent->get_content_by_cid($id);
                    $title = $content[$id]['title'];
                }
            }
            $title = $title ? addslashes($title) : addslashes($row['title']);
            $reffer = addslashes($this->input['reffer']);
            $type = intval($this->input['type']);
            $columnid = intval($this->input['column_id']);
            // 			if((TIMENOW - $row['last_sync_time']) >= SYNC_SPACE * 3600)
            // 			{
            $count = $count + 1;
            // 			}
            $ip = hg_getip();
            $time = date('Ym', TIMENOW);
            if (!$row['id']) {
                $row['create_time'] = TIMENOW;
            }
            $tableName = "record_" . $time;
            //			$sql = "SHOW TABLES LIKE '" . DB_PREFIX . $tableName. "'";
            //			$this->db->query($sql);
            //			if(!$this->db->affected_rows())
            ### 读取已经存在的表验证新表是否已经存在
            include_once CUR_CONF_PATH . 'lib/cache.class.php';
            $cache = new CacheFile();
            $oldTable = $cache->get_cache('access_table_name');
            if (!in_array($tableName, $oldTable)) {
                $sql = "CREATE TABLE " . DB_PREFIX . $tableName . " LIKE " . DB_PREFIX . "record";
                $this->db->query($sql);
                // 				###保存已建的表 关联时验证表是否存在
                $newTable = array($tableName);
                $allTable = array_merge($oldTable, $newTable);
                $allTable = array_unique($allTable);
                $cache->set_cache('access_table_name', $allTable);
                // 				###保存结束
            }
            $sql = 'INSERT INTO ' . DB_PREFIX . "record_" . $time . " (app_bundle, module_bundle, type, content_fromid ,cid, column_id, refer_url, ip, access_time, appid, appname,user_id, user_name, title) VALUES\r\n\t\t\t('{$appunid}', '{$modunid}', '{$type}', {$content_fromid} ,'{$id}', '{$columnid}', '{$reffer}', '{$ip}', " . TIMENOW . ", '{$this->user['appid']}', '{$this->user['appname']}', '{$this->user['user_id']}', '{$this->user['user_name']}', '{$title}')";
            $this->db->query($sql);
            if (!$row['url']) {
                $row['url'] = $reffer;
            }
            $sql = 'INSERT INTO ' . DB_PREFIX . "nums (app_bundle, module_bundle, content_fromid,cid, title, access_nums, last_sync_time, is_sync, url, create_time, update_time) VALUES\r\n\t\t\t('{$appunid}', '{$modunid}', '{$content_fromid}', '{$id}' ,'{$title}', " . $count . ", '{$row['last_sync_time']}', '{$row['is_sync']}', '{$row['url']}', '{$row['create_time']}', " . TIMENOW . ")";
            $this->db->query($sql);
            $this->dingdoneSync($content_fromid, $row['last_sync_time'], $row['create_time'], $count, $appunid, $modunid);
        }
        if (isset($this->settings['default_number']) && $this->settings['default_number']) {
            @srand($id);
            $min = $max = 0;
            list($min, $max) = @split(',', $this->settings['default_number']);
            $count += @rand($min, $max);
        }
        $this->addItem($count);
        $this->output();
    }
Пример #14
0
 /**
  * Method sendErrorByMail
  * @access static
  * @param mixed $debug_msg 
  * @param string $attachment_file 
  * @param string $error_log_file [default value: error_send_by_mail.log]
  * @param mixed $cache_time [default value: CacheFile::CACHE_TIME_2MIN]
  * @since 1.0.100
  */
 public static function sendErrorByMail($debug_msg, $attachment_file = "", $error_log_file = "error_send_by_mail.log", $cache_time = CacheFile::CACHE_TIME_2MIN)
 {
     if (defined('SEND_ERROR_BY_MAIL') && SEND_ERROR_BY_MAIL == true && !isLocalDebug()) {
         $caching_file = new CacheFile(dirname(__FILE__) . "/../cache/" . $error_log_file, $cache_time);
         if ($caching_file->readCache() == false) {
             $debug_mail = $debug_msg;
             $page_object = Page::getInstance($_GET['p']);
             $debug_mail .= "<br/><b>General information:</b><br/>";
             $debug_mail .= "URL : " . $page_object->getCurrentUrl() . "<br/>";
             $debug_mail .= "Referer : " . $page_object->getRefererURL() . "<br/>";
             $debug_mail .= "IP : <a href='http://www.infosniper.net/index.php?ip_address=" . $page_object->getRemoteIP() . "' target='_blank'>" . $page_object->getRemoteIP() . "</a><br/>";
             $debug_mail .= "Browser : ";
             if (!isset($_SESSION['browser_info']) || $page_object->getBrowserName() == "Default Browser" || $page_object->getBrowserName() == "") {
                 $debug_mail .= $page_object->getBrowserUserAgent();
             } else {
                 $debug_mail .= $page_object->getBrowserName() . " (version: " . $page_object->getBrowserVersion() . ")";
             }
             $debug_mail .= "<br/>";
             if (isset($_SESSION['browser_info'])) {
                 $debug_mail .= "Crawler : " . ($page_object->isCrawlerBot() ? "true" : "false") . "<br/>";
             }
             $caching_file->writeCache($debug_mail);
             try {
                 $mail = new SmtpMail(SEND_ERROR_BY_MAIL_TO, __(SEND_ERROR_BY_MAIL_TO), "ERROR on " . __(SITE_NAME) . " !!!", __($debug_mail), SMTP_MAIL, __(SMTP_NAME));
                 $mail->setPriority(SmtpMail::PRIORITY_HIGH);
                 if ($attachment_file != "" && is_file($attachment_file)) {
                     $mail->addAttachment($attachment_file, basename(str_replace(".cache", ".txt", $attachment_file)));
                 }
                 if (($send_result = $mail->send()) != true) {
                     $caching_file->writeCache("Error when sent mail: " . $send_result . "\nMail: " . $debug_mail);
                     //echo $send_result;
                 }
             } catch (Exception $e) {
                 $caching_file->writeCache("\n\nMail sending error:\n" . $e);
             }
             $caching_file->close();
         }
     }
 }
Пример #15
0
function freshports_NonPortDescription($db, $element_record)
{
    global $TableWidth;
    global $FreshPortsTitle;
    $Debug = 1;
    freshports_ConditionalGet(freshports_LastModified());
    header("HTTP/1.1 200 OK");
    $Title = preg_replace('|^/?ports/|', '', $element_record->element_pathname);
    $FileName = preg_replace('|^/?ports/|', '', $element_record->element_pathname);
    require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php';
    freshports_Start($Title, "{$FreshPortsTitle} - new ports, applications", "FreeBSD, index, applications, ports");
    ?>

	<?php 
    echo freshports_MainTable();
    ?>

	<tr><td valign="top" width="100%">

	<?php 
    echo freshports_MainContentTable();
    ?>
<TR>
<?php 
    echo freshports_PageBannerText('non port: ' . $Title);
    ?>
</TR>
<tr><td>
<a HREF="<?php 
    echo FRESHPORTS_FREEBSD_SVN_URL . $element_record->element_pathname;
    ?>
?view=log">SVNWeb</a>
</td></tr>

<?php 
    global $User;
    # these two options must be the last on the line.  And as such are mutually exclusive
    define('BYPASSCACHE', 'bypasscache=1');
    # do not read the cache for display
    define('REFRESHCACHE', 'refreshcache=1');
    # refresh the cache
    $BypassCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(BYPASSCACHE)) == BYPASSCACHE;
    $RefreshCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(REFRESHCACHE)) == REFRESHCACHE;
    $PageNumber = 1;
    if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
        parse_str($_SERVER['REDIRECT_QUERY_STRING'], $query_parts);
        if (isset($query_parts['page']) && Is_Numeric($query_parts['page'])) {
            $PageNumber = intval($query_parts['page']);
            if ($PageNumber != $query_parts['page'] || $PageNumber < 1) {
                $PageNumber = 1;
            }
        }
    }
    $NumCommitsPerPage = $User->page_size;
    $Cache = new CacheFile();
    $Cache->PageSize = $User->page_size;
    $result = $Cache->Retrieve($FileName, $PageNumber);
    if (!$result && !$BypassCache && !$RefreshCache) {
        if ($Debug) {
            echo "found something from the cache<br>\n";
        }
        $HTML = $Cache->CacheDataGet();
        #
        # we need to know the element_id of this port
        # and the whether or not it is on the person's watch list
        # let's create a special function for that!
        #
        $EndOfFirstLine = strpos($HTML, "\n");
        if ($EndOfFirstLine == false) {
            die('Internal error: I was expecting an ElementID and found nothing');
        }
        # extract the ElementID from the cache
        $ElementID = intval(substr($HTML, 0, $EndOfFirstLine));
        if ($ElementID == 0) {
            syslog(LOG_ERR, "Extract of ElementID from cache failed.  Is cache corrupt/deprecated? port was {$category}/{$port}");
            die('sorry, I encountered a problem with the cache.  Please send the URL and this message to the webmaster.');
        }
        if ($User->id) {
            $OnWatchList = freshports_OnWatchList($db, $User->id, $ElementID);
        } else {
            $OnWatchList = 0;
        }
        $HTML = substr($HTML, $EndOfFirstLine + 1);
    } else {
        if ($Debug) {
            echo "found NOTHING in cache<br>\n";
        }
        $HTML = '';
        $Commits = new CommitsByTreeLocation($db);
        $Commits->SetLimit($Cache->PageSize);
        $Commits->Debug = $Debug;
        $Commits->UserIDSet($User->id);
        $Commits->TreePathConditionSet("= '" . $element_record->element_pathname . "'");
        #
        # get the count without excuting the whole query
        # we don't want to pull back all the data.
        #
        $NumCommits = $Commits->GetCountCommits();
        $params = array('mode' => 'Sliding', 'perPage' => $NumCommitsPerPage, 'delta' => 5, 'totalItems' => $NumCommits, 'urlVar' => 'page', 'currentPage' => $PageNumber, 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1, 'append' => false, 'path' => '/' . preg_replace('|^/?ports/|', '', $element_record->element_pathname), 'fileName' => '?page=%d', 'altFirst' => 'First Page', 'firstPageText' => 'First Page', 'altLast' => 'Last Page', 'lastPageText' => 'Last Page');
        $Pager =& Pager::factory($params);
        $links = $Pager->GetLinks();
        $NumCommitsHTML = '<tr><td><p align="left">Number of commits found: ' . $NumCommits;
        $Offset = 0;
        $PageLinks = $links['all'];
        $PageLinksHTML = str_replace('/?page=1"', '"', $PageLinks);
        $PageLinksHTML = str_replace('/?page=', '?page=', $PageLinksHTML);
        if ($PageLinksHTML != '') {
            $offset = $Pager->getOffsetByPageId();
            $NumOnThisPage = $offset[1] - $offset[0] + 1;
            $Offset = $offset[0] - 1;
            $NumCommitsHTML .= " (showing only {$NumOnThisPage} on this page)";
            unset($offset);
        }
        if ($PageNumber > 1) {
            $Commits->SetOffset($Offset);
        }
        $NumCommitsHTML .= '</p>';
        if ($PageLinksHTML != '') {
            $PageLinksHTML = '<p align="center">' . $PageLinksHTML . '</p>';
        }
        $NumCommitsHTML .= $PageLinksHTML . '</td></tr>';
        $HTML = $NumCommitsHTML;
        if ($Commits->Debug) {
            echo "PageNumber='{$PageNumber}'<br>Offset='{$Offset}'<br>";
        }
        $NumFetches = $Commits->Fetch();
        $DisplayCommit = new DisplayCommit($db, $Commits->LocalResult);
        $HTML .= $DisplayCommit->CreateHTML();
        $HTML .= $NumCommitsHTML;
        # If we are not reading
        if (!$BypassCache || $RefreshCache) {
            $Cache->CacheDataSet($element_record->{'id'} . "\n" . $HTML);
            $Cache->Add($FileName, $PageNumber);
        }
    }
    echo $HTML;
    echo "</table>\n";
    ?>

</TD>
  <TD VALIGN="top" WIDTH="*" ALIGN="center">
  <?php 
    echo freshports_SideBar();
    ?>
  </td>
</TR>

</TABLE>

<?php 
    echo freshports_ShowFooter();
    ?>

</body>
</html>

<?php 
}
 public function __construct($cacheFileName)
 {
     $this->config = parse_ini_file("config/config.ini", true);
     $this->cacheFile = CacheFile::getInstance($cacheFileName, $this->config['tmpDir'], $this->config);
     $this->cacheFileName = $cacheFileName;
 }
Пример #17
0
 public function get_content($params = array(), $get_count = false)
 {
     $timefield = 'create_time';
     if (!$params['start_time'] && !$params['duration'] && !$params['column_id']) {
         //不限制开始和时间和时长时表示所有查询所有内容 从汇总表 nums表查询
         if (!$get_count) {
             $sql = "SELECT cid, access_nums AS num, column_id, app_bundle, title, url FROM " . DB_PREFIX . "nums WHERE 1 AND del = 0";
         } else {
             $sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "nums WHERE 1 AND del = 0";
         }
     } else {
         $mergeall = false;
         if ($params['start_time']) {
             $start_time = $params['start_time'];
             if ($params['duration']) {
                 $time = $params['duration'] * 60;
                 $end_time = $params['start_time'] + $time;
             } else {
                 $timefield = 'create_time';
                 $end_time = TIMENOW;
             }
             if ($end_time < TIMENOW && $end_time < $params['last_time']) {
                 //continue;
             }
         } else {
             if ($params['duration']) {
                 $time = $params['duration'] * 60;
                 $start_time = TIMENOW - $time;
                 $end_time = $params['end_time'] ? $params['end_time'] : TIMENOW;
             } else {
                 $mergeall = true;
             }
         }
         //查询存在的分表
         include_once CUR_CONF_PATH . 'lib/cache.class.php';
         $cache = new CacheFile();
         $exists_table = $cache->get_cache('access_table_name');
         //查询存在的分表
         if (!$mergeall) {
             ###根据起始时间关联merge表
             $start_year = intval(date('Y', $start_time));
             $start_month = intval(date('m', $start_time));
             $end_year = intval(date('Y', $end_time));
             $end_month = intval(date('m', $end_time));
             $table = array();
             $i = $start_year;
             $j = $start_month;
             while ($i < $end_year || $j <= $end_month) {
                 if ($i > $end_year) {
                     //年份大于等于当前年份时跳出循环
                     break;
                 }
                 $j = strlen($j) != 2 ? '0' . $j : $j;
                 $table_name = "record_" . $i . $j;
                 if (in_array($table_name, $exists_table)) {
                     $table[] = $table_name;
                 }
                 if ($j == 12) {
                     $i++;
                     $j = 1;
                 } else {
                     $j++;
                 }
             }
         } else {
             $table = $exists_table;
         }
         $table = $this->convert_table_name($table);
         if ($table) {
             $table_str = implode(',', $table);
         }
         $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
         $this->db->query($sql);
         ###关联结束
         if (!$get_count) {
             $sql = "SELECT cid,count(*) AS num, column_id, app_bundle, refer_url AS url FROM " . DB_PREFIX . "merge WHERE 1 AND del = 0";
         } else {
             $sql = "SELECT COUNT(*) AS total FROM ( SELECT cid,count(*) AS num FROM " . DB_PREFIX . "merge WHERE 1 AND del = 0";
         }
         if ($start_time) {
             $sql .= " AND {$timefield} >= " . $start_time;
         }
         if ($end_time) {
             $sql .= " AND {$timefield} <= " . $end_time;
         }
     }
     if ($params['column_id']) {
         include_once ROOT_PATH . 'lib/class/publishconfig.class.php';
         $this->publish_column = new publishconfig();
         $ret = $this->publish_column->get_column_by_ids('id,childs', $params['column_id']);
         $idArr = array();
         if ($ret && is_array($ret)) {
             foreach ($ret as $k => $v) {
                 $idArr[] = $v['childs'];
             }
         }
         $idStr = implode(",", $idArr);
         if ($idStr) {
             $sql .= " AND column_id IN(" . $idStr . ")";
         }
     }
     if ($params['type']) {
         $params['type'] = explode(',', $params['type']);
         $params['type'] = implode("','", $params['type']);
         $sql .= " AND app_bundle IN('" . $params['type'] . "')";
     }
     if ($params['title']) {
         $sql .= ' AND title LIKE \'%' . trim(urldecode($params['title'])) . '%\'';
     }
     if ($params['cid']) {
         $params['cid'] = explode(",", $params['cid']);
         $params['cid'] = implode("','", $params['cid']);
         $sql .= " AND cid IN('" . $params['cid'] . "')";
     }
     /** begin zbb 2015-4-20 加了一个筛选条件publish_duration **/
     /*
     if($params['publish_duration'] > 0){
         $sql .= ' AND publish_time > ' . (TIMENOW - $params['publish_duration'] * 60);
     }
     */
     /** end **/
     ###从merge表查询需要group by cid
     if ($params['output_type'] == 1) {
         //统计栏目
         $sql .= " GROUP BY column_id ";
     } else {
         $sql .= $params['start_time'] || $params['duration'] || $params['column_id'] ? " GROUP BY cid " : "";
     }
     if (!$get_count) {
         $sql .= " ORDER BY num DESC ";
         if ($params['count']) {
             $sql .= " LIMIT " . intval($params['offset']) . "," . intval($params['count']);
         }
         $q = $this->db->query($sql);
         $rankingCon = array();
         while ($row = $this->db->fetch_array($q)) {
             $params['output_type'] == 1 && ($row['cid'] = $row['column_id']);
             //排行类型为栏目时 记录column_id
             $rankingCon[] = $row;
         }
         return $rankingCon;
     } else {
         if ($params['start_time'] || $params['duration']) {
             $sql .= " ) AS a";
         }
         $q = $this->db->query_first($sql);
         return $q;
     }
 }
Пример #18
0
 function show()
 {
     $id = intval($this->input['sort_id']);
     $column_id = $this->input['column_id'];
     $exclude_column_id = $this->input['exclude_column_id'];
     if ($id) {
         $sql = "SELECT status,output_type,column_id FROM " . DB_PREFIX . "ranking_sort WHERE id = " . $id;
         $sort = $this->db->query_first($sql);
         if (empty($sort) || $sort['status'] != 1) {
             $this->errorOutput("unexist or unaudited");
         }
         include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
         $this->publishcontent = new publishcontent();
         $content_type = $this->publishcontent->get_all_content_type();
         $pub_content_bundle = array();
         foreach ((array) $content_type as $k => $v) {
             $pub_content_bundle[] = $v['bundle_id'];
         }
         $offset = intval($this->input['offset']) ? intval($this->input['offset']) : 0;
         $count = intval($this->input['count']) ? intval($this->input['count']) : 30;
         $data_limit = " LIMIT " . $offset . ", " . $count;
         $sql = "SELECT * FROM " . DB_PREFIX . "ranking_cont WHERE sort_id = " . $id . " ORDER BY count DESC " . $data_limit;
         $q = $this->db->query($sql);
         $cidArr = array();
         $conArr = array();
         $other_content = array();
         while ($row = $this->db->fetch_array($q)) {
             if ($row['app_bundle'] && !in_array($row['app_bundle'], $pub_content_bundle)) {
                 $row['update_time'] = date('Y-m-d H:i:s', $row['update_time']);
                 $row['content_url'] = $row['url'];
                 $other_content[] = $row;
             } else {
                 $cidArr[] = $row['cid'];
                 $conArr[$row['cid']] = $row['count'];
             }
         }
         $cidStr = implode(',', $cidArr);
         $blDirectReturn = $this->input['direct_return'] && $this->input['direct_return'] != 'false' ? 1 : 0;
         if ($blDirectReturn) {
             $this->addItem($cidStr);
         } else {
             if ($cidStr) {
                 if ($sort['output_type'] == 1) {
                     include_once ROOT_PATH . 'lib/class/publishconfig.class.php';
                     $this->publishconfig = new publishconfig();
                     $ret = $this->publishconfig->get_column_info_by_ids($cidStr);
                 } else {
                     include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
                     $this->publishtcontent = new publishcontent();
                     $useColumn = array();
                     if ($column_id) {
                         $sort['column_id'] = $column_id;
                     }
                     if ($exclude_column_id) {
                         $exclude_column_id = explode(',', $exclude_column_id);
                         $sort['column_id'] = explode(',', $sort['column_id']);
                         $sort['column_id'] = array_diff($sort['column_id'], $exclude_column_id);
                         $sort['column_id'] = implode(',', $sort['column_id']);
                     }
                     foreach ($cidArr as $cv) {
                         $useColumn[$cv] = $sort['column_id'];
                     }
                     $ret = $this->publishtcontent->get_content_by_cid($cidStr, $useColumn);
                 }
                 $arExistIds = array();
                 if (is_array($ret) && count($ret) > 0) {
                     foreach ($ret as $k => $v) {
                         $arExistIds[] = $sort['output_type'] == 1 ? $v['id'] : $v['cid'];
                         //栏目时统计记录的是id  内容统计记录的是cid
                         $ret[$k]['count'] = $sort['output_type'] == 1 ? $conArr[$v['id']] : $conArr[$v['cid']];
                     }
                 }
                 //发布库删除没有更新统计时条数不准确 下面代码为解决此bug
                 //对比cid差集
                 $cidStr = explode(',', $cidStr);
                 $delCid = array_diff($cidStr, $arExistIds);
                 //更新已经不存在的内容
                 if (0 && !empty($delCid)) {
                     $cid = implode(',', $delCid);
                     $sql = "UPDATE " . DB_PREFIX . "nums SET del = 1 WHERE cid IN(" . $cid . ")";
                     $this->db->query($sql);
                     include_once CUR_CONF_PATH . 'lib/cache.class.php';
                     $cache = new CacheFile();
                     $table = $cache->get_cache('access_table_name');
                     $table = convert_table_name($table);
                     if ($table) {
                         $table_str = implode(',', $table);
                     }
                     $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
                     $this->db->query($sql);
                     $sql = "UPDATE " . DB_PREFIX . "merge SET del = 1 WHERE cid IN(" . $cid . ")";
                     $this->db->query($sql);
                     $sql = "DELETE FROM " . DB_PREFIX . "ranking_cont WHERE sort_id=" . $id . " AND cid IN(" . $cid . ")";
                     $this->db->query($sql);
                 }
                 //
                 $ret = (array) $ret;
                 $ret = array_merge($other_content, $ret);
                 if (is_array($ret) && count($ret)) {
                     $ret = hg_array_sort($ret, 'count', 'DESC');
                     foreach ($ret as $k => $v) {
                         if ($sort['output_type'] == 1) {
                             $v['title'] = $v['name'];
                         }
                         $this->addItem($v);
                     }
                 }
             }
         }
     } else {
         $sql = "SELECT * FROM " . DB_PREFIX . "ranking_sort WHERE status = 1 ";
         $q = $this->db->query($sql);
         $ret = array();
         while ($row = $this->db->fetch_array($q)) {
             $ret[] = $row;
         }
         if ($ret) {
             foreach ($ret as $k => $v) {
                 $this->addItem($v);
             }
         }
     }
     $this->output();
 }
 /**
  * Tests CacheFile->set()
  */
 public function testSet()
 {
     $this->CacheFile->set("test", "testing");
     $this->assertEquals("testing", $this->CacheFile->get("test"));
 }
Пример #20
0
 private function debug(CacheFile $cacheFile, $msg)
 {
     if ($this->config->isDebug()) {
         $filename = $cacheFile->getCacheFilename();
         echo "[{$filename}] {$msg}<br />";
     }
     return;
 }
Пример #21
0
 public function GetUserGroup($UserGroupID, $force = false)
 {
     $DB = new DB();
     $Cache = new CacheFile();
     $CacheID = '/Users/UserGroupID/' . $UserGroupID;
     $result = $Cache->Get($CacheID);
     if ($result == CacheFile::NOCACHE || $force) {
         $Sql = 'SELECT * FROM tbl_usergroups WHERE UserGroupID=' . $UserGroupID;
         $result = $DB->GetOne($Sql);
         if ($result) {
             $Cache->Save($CacheID, $result, CacheFile::__OneYearSeconds__);
         }
     }
     return $result;
 }