Пример #1
0
 /**
  * Sets the post ids to load media for
  * 
  * @param	array		List of postids
  */
 public function set_uniques($uniques)
 {
     if ($this->debug) {
         goldbrick_debug('PostIDs', $postids);
     }
     /*if (is_array($uniques))
     		{
     			$this->media = $this->fetch_media_from_cache(implode(',', $postids));
     		}
     		
     		else
     		{
     			$this->media = $this->fetch_media($fetch_hash);
     		}*/
     if (!($this->media = $this->fetch_media($uniques))) {
         return null;
     }
     return $this->media;
     if ($this->debug) {
         goldbrick_debug('Fetched Media', $this->media);
     }
 }
Пример #2
0
/**
 * Fetches all old content from the database, and checks if it's still active.
 * If it's not, it will be reverted to its [url] form.
 * 
 * @param	integer		Expiration period
 */
function goldbrick_exec_cleanup($hashes)
{
    global $vbulletin;
    require_once DIR . '/goldbrick/includes/class_goldbrick_cache.php';
    $goldbrick = new Goldbrick_Cache($vbulletin);
    $media = $goldbrick->fetch_expired_media($hashes);
    $to_revert = array();
    $to_remove = array();
    $to_bump = array();
    foreach ($media as $link) {
        if (empty($link['postids'])) {
            $to_remove[] = $link['hash'];
            continue;
        }
        if ($goldbrick->is_inactive($link['url'])) {
            $to_revert[] = $link;
            $to_remove[] = $link['hash'];
            continue;
        }
        $to_bump[] = $link;
    }
    if (defined('GOLDBRICK_DEBUG_CLEANUP')) {
        goldbrick_debug('revert, remove, bump', $to_revert, $to_remove, $to_bump);
    }
    if (!empty($to_revert)) {
        $goldbrick->revert_posts($to_revert);
    }
    if (!empty($to_remove)) {
        $goldbrick->remove($to_remove);
    }
    if (!empty($to_bump)) {
        $goldbrick->bump($to_bump);
    }
}
Пример #3
0
 public function fetch_expired_media($hashes)
 {
     $hashes = implode(',', array_map(array($this->registry->db, 'sql_prepare'), $hashes));
     $cutoff = 1;
     #$this->registry->options['gb_expiration_period'] * 86400;
     $result = $this->registry->db->query_read("\n\t\t\tSELECT cache.url, cache.hash, group_concat(media.postid) as postids\n\t\t\tFROM " . TABLE_PREFIX . "gb_cache as cache\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "gb_media as media USING (hash)\n\t\t\tWHERE hash IN ({$hashes}) and cache.dateline + {$cutoff} < " . TIMENOW . "\n\t\t\tGROUP BY cache.hash\n\t\t\tORDER BY cache.dateline ASC\n\t\t");
     $media = array();
     while ($link = $this->registry->db->fetch_array($result)) {
         $media[] = $link;
     }
     if (defined('GOLDBRICK_DEBUG_CLEANUP')) {
         goldbrick_debug('fetched expired media', $media);
     }
     $this->registry->db->free_result($result);
     return $media;
 }
Пример #4
0
 /**
  * Delivers the HTML for a given media tag.
  * This is the BBCode callback function (wrapped in a public callback, rather).
  * 
  * @param	string		URL to deliver
  * @param	string		Options to customize delivery
  * 
  * @return	string		HTML output
  */
 public function deliver($url, $options)
 {
     global $vbphrase, $stylevar;
     $url = unhtmlspecialchars($url);
     if (!($info = $this->media[$url])) {
         if ($this->debug) {
             goldbrick_debug('Media Cache', $this->media);
             goldbrick_debug('Requested URL', $url);
             trigger_error('URL not pre-cached!', E_USER_WARNING);
         }
         $url = htmlspecialchars_uni($url);
         return "<a href=\"{$url}\" target=\"_blank\">{$url}</a>";
     }
     $info['unique'] = substr($info['hash'], 0, 8);
     if ($info['site'] !== 0) {
         //$info['profile'] = $this->get_config_profile($info['site']);
     } else {
         $info['profile'] = $this->get_config_ext_profile($info['profile']);
     }
     if (is_integer($url)) {
         $info = array_merge($info, $this->parse_media_options($options));
     }
     eval('$content = "' . fetch_template('gb_player') . '";');
     if ($this->debug) {
         goldbrick_debug('Delivering Media', $url);
         echo $content . '<hr />';
     }
     $cutoff = 1;
     #$this->registry->options['gb_expiration_period'] * 86400;
     // cleanup
     if ($info['dateline'] + $cutoff < TIMENOW) {
         if (empty($this->expired)) {
             goldbrick_inject_plugin('global_complete', "require_once(DIR . '/goldbrick/plugins/global_complete.php');");
         }
         $this->expired[] = md5($url);
     }
     return $content;
 }