Advertisement
Zenk

[PRIVATE] Latest XThreads YouTube Videos (edited)

May 27th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.57 KB | None | 0 0
  1. <?php
  2. if(!defined('IN_MYBB')){
  3.     die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  4. }
  5.  
  6. function xtlatest_videos_info(){
  7.     return array(
  8.         'name'          => 'Latest XThreads YouTube Videos (edited)',
  9.         'description'   => 'Latest vids.',
  10.         'website'       => 'http://mybbhacks.zingaburga.com',
  11.         'author'        => 'XThreads Mania',
  12.         'authorsite'    => 'http://mybbhacks.zingaburga.com',
  13.         'version'       => '1.0',
  14.         'compatibility' => '1*',
  15.         'guid'          => ''
  16.     );
  17. }
  18.  
  19. function xtlatest_videos_activate(){
  20.     global $db;
  21.     $template = array(
  22.         'title'     => 'xtlatest_videos',
  23.         'template'  => $db->escape_string('{$xtlatest_videos_video}'),
  24.         'sid'       => -1
  25.     );
  26.     $db->insert_query('templates', $template);
  27.     $template = array(
  28.         'title'     => 'xtlatest_videos_video',
  29.         'template'  => $db->escape_string('<a class="filmoteka tipTip" style="background:url(http://img.youtube.com/vi/{$mnxtivid_video_id}/default.jpg) no-repeat center center;" href="{$mnxtivid_links}" title="{$mnxtivid_subject_text}"></a>'),
  30.         'sid'       => -1
  31.     );
  32.     $db->insert_query('templates', $template);
  33. }
  34.  
  35. function xtlatest_videos_deactivate(){
  36.     global $db;
  37.      $db->delete_query('templates', 'title IN("xtlatest_videos", "xtlatest_videos_video")');
  38. }
  39.  
  40. $plugins->add_hook('global_start', 'xtlatest_videos_tcache');
  41. function xtlatest_videos_tcache(){
  42.     global $templatelist;
  43.     //global $current_page, $templatelist;
  44.     //if($current_page == 'index.php'){
  45.         if(isset($templatelist)){
  46.             $templatelist .= ',xtlatest_videos,xtlatest_videos_video';
  47.         }
  48.     //}
  49. }
  50.  
  51. $plugins->add_hook('global_start', 'xtlatest_videos_run', 'global_end');
  52. function xtlatest_videos_run(){
  53.     global $db, $templates;
  54.     $query = $db->query('
  55.         SELECT t.tid, t.subject, td.ytvgalid
  56.         FROM '.TABLE_PREFIX.'threads t
  57.         LEFT JOIN '.TABLE_PREFIX.'threadfields_data td ON (td.tid=t.tid)
  58.         WHERE t.fid=7 AND t.visible=1 AND t.closed NOT LIKE "moved|%"
  59.         ORDER BY t.dateline DESC
  60.         LIMIT 0,4
  61.     ');
  62.     if($db->num_rows($query)){
  63.         global $theme, $xtlatest_videos;
  64.         while($mnxtivid = $db->fetch_array($query)){
  65.             $mnxtivid_links = get_thread_link($mnxtivid['tid']);
  66.             $mnxtivid_subject_text = htmlspecialchars_uni($mnxtivid['subject']);
  67.             if(preg_match('#(?:([a-zA-Z0-9_\-+]{8,16})$|http\://(?:[a-z]{1,4}\.)?youtube\.com/watch\?v=([a-zA-Z0-9_\-+]{8,16}))#', $mnxtivid['ytvgalid'], $matches)){
  68.                 $mnxtivid_video_id = $matches[1].$matches[2];
  69.                 eval('$xtlatest_videos_video .= "'.$templates->get('xtlatest_videos_video').'";');
  70.             }
  71.         }
  72.         eval('$xtlatest_videos = "'.$templates->get('xtlatest_videos').'";');
  73.     }
  74. }
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement