niammuddin

doc viewer wordpress

Sep 9th, 2014
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.26 KB | None | 0 0
  1. search.php
  2.  
  3. <?php
  4. /**
  5.  * The template for displaying Search Results pages
  6.  *
  7.  * @package WordPress
  8.  * @subpackage Twenty_Fourteen
  9.  * @since Twenty Fourteen 1.0
  10.  */
  11.  
  12. get_header(); ?>
  13.  
  14.     <section id="primary" class="content-area">
  15.         <div id="content" class="site-content" role="main">
  16.  
  17.             <?php if ( have_posts() ) : ?>
  18.  
  19.             <header class="page-header">
  20.                 <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyfourteen' ), get_search_query() ); ?></h1>
  21.             </header><!-- .page-header -->
  22.  
  23.                 <?php
  24.                     // Start the Loop.
  25.                     while ( have_posts() ) : the_post();
  26.  
  27.                         /*
  28.                          * Include the post format-specific template for the content. If you want to
  29.                          * use this in a child theme, then include a file called called content-___.php
  30.                          * (where ___ is the post format) and that will be used instead.
  31.                          */
  32.                         get_template_part( 'content', get_post_format() );
  33.  
  34.                     endwhile;
  35.                     // Previous/next post navigation.
  36.                     twentyfourteen_paging_nav();
  37.  
  38.                 else : ?>
  39.                
  40. <?php
  41. $rssbing  = simplexml_load_file('http://www.bing.com/search?q=filetype:pdf+'.urlencode($s).'&count=10&format=rss');
  42. ?>
  43. <?php
  44. foreach ($rssbing->channel->item as $itembing) {
  45. $random_karakter = random_karakter();
  46. echo  '<a href="'.$itembing->link.'"><h1>'.htmlspecialchars(strip_tags($itembing->title)).'</h1></a>';
  47. echo  '<p>'.htmlspecialchars(strip_tags($itembing->description)).'</p>';
  48. echo "<a target='_blank' href='goto?".base64_encode("pdf=".$itembing->link."=".$random_karakter)."'>View</a>";
  49. echo  '<p>'.$itembing->link.' - '.$itembing->pubDate.'</p>';
  50. }
  51. if (empty($itembing)) {
  52.   echo '<small>Not Found</small>';
  53. }
  54. ?>
  55.  
  56.  
  57. <?php               endif;
  58.             ?>
  59.         </div><!-- #content -->
  60.     </section><!-- #primary -->
  61.  
  62. <?php
  63. get_sidebar( 'content' );
  64. get_sidebar();
  65. get_footer();
  66.  
  67. header2.php
  68. <?php
  69. /**
  70.  * The Header for our theme
  71.  *
  72.  * Displays all of the <head> section and everything up till <div id="main">
  73.  *
  74.  * @package WordPress
  75.  * @subpackage Twenty_Fourteen
  76.  * @since Twenty Fourteen 1.0
  77.  */
  78. ?><!DOCTYPE html>
  79. <!--[if IE 7]>
  80. <html class="ie ie7" <?php language_attributes(); ?>>
  81. <![endif]-->
  82. <!--[if IE 8]>
  83. <html class="ie ie8" <?php language_attributes(); ?>>
  84. <![endif]-->
  85. <!--[if !(IE 7) & !(IE 8)]><!-->
  86. <html <?php language_attributes(); ?>>
  87. <!--<![endif]-->
  88. <head>
  89. <meta charset="<?php bloginfo( 'charset' ); ?>">
  90. <meta name="viewport" content="width=device-width">
  91. <meta name="robots" content="noindex,nofollow" />
  92.  
  93. <title><?php echo''.$title.''; ?> - <?php bloginfo( 'name' ); ?></title>
  94.  
  95.     <link rel="profile" href="http://gmpg.org/xfn/11">
  96.     <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
  97.     <!--[if lt IE 9]>
  98.     <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>
  99.     <![endif]-->
  100.     <?php wp_head(); ?>
  101. </head>
  102.  
  103. <body <?php body_class(); ?>>
  104. <div id="page" class="hfeed site">
  105.     <?php if ( get_header_image() ) : ?>
  106.     <div id="site-header">
  107.         <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
  108.             <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="">
  109.         </a>
  110.     </div>
  111.     <?php endif; ?>
  112.  
  113.     <header id="masthead" class="site-header" role="banner">
  114.         <div class="header-main">
  115.             <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
  116.  
  117.             <div class="search-toggle">
  118.                 <a href="#search-container" class="screen-reader-text"><?php _e( 'Search', 'twentyfourteen' ); ?></a>
  119.             </div>
  120.  
  121.             <nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation">
  122.                 <button class="menu-toggle"><?php _e( 'Primary Menu', 'twentyfourteen' ); ?></button>
  123.                 <a class="screen-reader-text skip-link" href="#content"><?php _e( 'Skip to content', 'twentyfourteen' ); ?></a>
  124.                 <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
  125.             </nav>
  126.         </div>
  127.  
  128.         <div id="search-container" class="search-box-wrapper hide">
  129.             <div class="search-box">
  130.                 <?php get_search_form(); ?>
  131.             </div>
  132.         </div>
  133.     </header><!-- #masthead -->
  134.  
  135.     <div id="main" class="site-main">
  136.  
  137. docviewers.php
  138. <?php
  139.     $decode_url = decode_url($_SERVER['REQUEST_URI']);
  140.     $cookie = base64_decode($_COOKIE[base64_encode('random_karakter')]);
  141.     $file = $decode_url['pdf'];
  142.     $rss = new DOMDocument();
  143.     $rss->load('http://www.bing.com/search?q=filetype:pdf+' . basename($file) . '&go=&form=QBLH&filt=all&format=rss');
  144.     $feed = array();
  145.     foreach ($rss->getElementsByTagName('item') as $node) {
  146.     $item = array (
  147.     'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
  148.     'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
  149.     );
  150.     array_push($feed, $item);
  151.     }
  152.     $limit = 1; // ini adalah jumlah yang di ambil dari feed bing
  153.     for($x=0;$x<$limit;$x++) {
  154.     $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
  155.     $link = $feed[$x]['link'];
  156. }
  157. ?>
  158. <?php
  159. /**
  160.  * Template Name: doc viewers
  161.  *
  162.  * @package WordPress
  163.  * @subpackage Twenty_Fourteen
  164.  * @since Twenty Fourteen 1.0
  165.  */
  166.  
  167. include(TEMPLATEPATH.'/header2.php'); ?>
  168.  
  169. <div id="main-content" class="main-content">
  170.  
  171. <?php
  172.     if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
  173.         // Include the featured content template.
  174.         get_template_part( 'featured-content' );
  175.     }
  176. ?>
  177.  
  178.     <div id="primary" class="content-area">
  179.         <div id="content" class="site-content" role="main">
  180. <?php
  181.     echo '<h1>'.$title.'</h1>';
  182.     echo ''.$link.'';
  183.     echo '<iframe src="http://docs.google.com/gview?url='.$link.'&embedded=true" width="100%" height="750px" frameborder="0"></iframe>';  
  184. ?>
  185.         </div><!-- #content -->
  186.     </div><!-- #primary -->
  187. </div><!-- #main-content -->
  188.  
  189. <?php
  190. get_sidebar();
  191. get_footer();
  192.  
  193. function.php
  194. <?php
  195.     function random_karakter(){
  196.      $karakter = array('a','A','b','B','c','C','d','D','e','E','f','F','g','G','h','H','i','I','j','J','k','K','l','L','m','M','n','N','o','O','p','P','q','Q','r','R','s','S','t','T','u','U','v','V','w','W','x','X','y','Y','z','Z','1','2','3','4','5','6','7','8','9','0');
  197.      $max = (count($karakter)-1);
  198.      srand(((double)microtime()*1000000));
  199.      $kar1 = $karakter[rand(0,$max)];
  200.      $kar2 = $karakter[rand(0,$max)];
  201.      $kar3 = $karakter[rand(0,$max)];
  202.      $kar4 = $karakter[rand(0,$max)];
  203.      $kar5 = $karakter[rand(0,$max)];
  204.      $kar6 = $karakter[rand(0,$max)];
  205.      $kar7 = $karakter[rand(0,$max)];
  206.      $kar8 = $karakter[rand(0,$max)];
  207.      $kar9 = $karakter[rand(0,$max)];
  208.      //Anda bisa menambahkan variabe nya seperti $kar10 sampai seterusnya
  209.      $random_karakter = $kar1.$kar2.$kar3.$kar4.$kar5.$kar6.$kar7.$kar8.$kar9;
  210.      return $random_karakter;
  211.     }
  212.     //Membuat fungsi decode_url() untuk memecah dan menerjemahkan Request URL
  213.     function decode_url($isi){
  214.      $explode_1 = explode('?', $isi);
  215.      $explode_2 = $explode_1[1];
  216.      $explode_3 = explode('&', base64_decode($explode_2));
  217.      for($i=0; $i<=count($explode_3)-1; $i++){
  218.      $explode_4 = explode('=', $explode_3[$i]);
  219.      $decode_url[$explode_4[0]] = $explode_4[1];
  220.             $decode_url = str_replace($bloginfo, '', $decode_url);
  221.         $decode_url = str_replace('/goto?=', '', $decode_url);
  222.      }
  223.      return $decode_url;
  224.     }
Add Comment
Please, Sign In to add comment