search-reindex.html.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php if (!defined('HTMLY')) die('HTMLy'); ?>
  2. <!DOCTYPE html>
  3. <html lang="<?php echo blog_language();?>">
  4. <head>
  5. <?php echo head_contents();?>
  6. <title><?php echo $title;?></title>
  7. <meta name="description" content="<?php echo $description; ?>"/>
  8. <link rel="canonical" href="<?php echo $canonical; ?>" />
  9. </head>
  10. <body>
  11. <div id="progress" style="border:1px solid #ccc;"></div>
  12. <div id="information" style="width:100%"></div>
  13. </body>
  14. </html>
  15. <?php
  16. $search = $search;
  17. $tmp = array();
  18. foreach ($search as $k => $v) {
  19. $tmp[] = $v;
  20. }
  21. // Loop through process
  22. for($i = 0, $size = count($tmp); $i < $size; ++$i) {
  23. $content = file_get_contents($tmp[$i][1]);
  24. add_search_index('post_' . $tmp[$i][0], $content);
  25. // Calculate the percentage
  26. $percent = intval($i/$size * 100)."%";
  27. // Progress bar and information
  28. echo '<script language="javascript">
  29. document.getElementById("progress").innerHTML="<div style=\"width:'.$percent.';background-color:#ddd;\">&nbsp;</div>";
  30. document.getElementById("information").innerHTML="File <strong>'.$tmp[$i][1].'</strong> processed.";
  31. </script>';
  32. // Buffer
  33. echo str_repeat(' ',1024*64);
  34. // Send output to browser
  35. ob_flush();
  36. // Sleep one second
  37. // sleep(1);
  38. }
  39. // The process is completed
  40. echo '<script language="javascript">
  41. document.getElementById("progress").innerHTML="<div style=\"width:100%;background-color:#ddd;\">&nbsp;</div>";
  42. document.getElementById("information").innerHTML="Process completed";
  43. </script>';
  44. echo '<a href="' . site_url() .'admin/search">'. i18n('back_to') . ' ' . i18n('search_index') .'</a>';
  45. // Redir
  46. echo '<script language="javascript">window.location.href = "' .site_url() . 'admin/search"</script>';
  47. ?>