PageRenderTime 55ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/install/step7.php

https://github.com/jinzora/jinzora3
PHP | 364 lines | 310 code | 22 blank | 32 comment | 46 complexity | 2e0ae6d5eb32ec53118d7d84d520de8e MD5 | raw file
  1. <?php if (!defined(JZ_SECURE_ACCESS)) die ('Security breach detected.');
  2. if (isset($_POST['readTags'])) {
  3. setcookie("jz_read_tags",$_POST['readTags']);
  4. } else {
  5. setcookie("jz_read_tags","false");
  6. }
  7. echo '<body onLoad="setup8.media_path.focus();"></body>';
  8. // Let's figure out the path stuff so we'll know how/where to include from
  9. $form_action = setThisPage() . "install=step7";
  10. $form_action2 = setThisPage() . "install=step8";
  11. // Now let's include the left
  12. include_once($include_path. 'install/leftnav.php');
  13. ?>
  14. <script language="JavaScript">
  15. <!--
  16. function browseMedia(){
  17. var sw = screen.width;
  18. var sh = screen.height;
  19. var winOpt = "width=250,height=300,left=" + ((sw - 300) / 2) + ",top=" + ((sh - 300) / 2) + ",menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no";
  20. thisWin = window.open('<?php echo $include_path; ?>install/browse.php?lang=<?php echo $_POST["jz_lang_file"]; ?>&readTags=<?php echo $_POST["readTags"]; ?>','AddMedia',winOpt);
  21. }
  22. function importMedia(){
  23. if (document.setup8.media_path.value !== ""){
  24. document.setup8.submit();
  25. } else {
  26. alert("<?php echo $word_empty_import_error; ?>");
  27. }
  28. }
  29. function skipImport(){
  30. document.skipform.submit();
  31. }
  32. // -->
  33. </script>
  34. <?php
  35. function readAllDirs3($dirName, &$readCtr){
  36. global $audio_types, $video_types, $word_files_analyzed;
  37. // Let's up the max_execution_time
  38. ini_set('max_execution_time','6000');
  39. // Let's look at the directory we are in
  40. if (@is_dir($dirName)){
  41. $d = @dir($dirName);
  42. if (@is_object($d)){
  43. while($entry = $d->read()) {
  44. // Let's make sure we are seeing real directories
  45. if ($entry == "." || $entry == "..") { continue;}
  46. if ($readCtr % 100 == 0){
  47. ?>
  48. <script language="javascript">
  49. fc.innerHTML = '<b><?php echo $readCtr. " ". $word_files_analyzed; ?></b>';
  50. -->
  51. </SCRIPT>
  52. <?php
  53. @flush(); @ob_flush();
  54. }
  55. // Now let's see if we are looking at a directory or not
  56. if (filetype($dirName. "/". $entry) <> "file"){
  57. // Ok, that was a dir, so let's move to the next directory down
  58. readAllDirs3($dirName. "/". $entry, $readCtr);
  59. } else {
  60. if (preg_match("/\.($audio_types|$video_types)$/i", $entry)){
  61. $readCtr++;
  62. $_SESSION['jz_full_counter']++;
  63. }
  64. }
  65. }
  66. // Now let's close the directory
  67. $d->close();
  68. }
  69. }
  70. }
  71. ?>
  72. <div id="main">
  73. <a href="http://www.jinzora.com" target="_blank"><img src="<?php echo $include_path; ?>install/logo.gif" border="0" align="right" vspace="5" hspace="0"></a>
  74. <h1><?php echo $word_import_media; ?></h1>
  75. <p>
  76. <?php echo $word_import_media_note; ?>
  77. <form action="<?php echo $form_action; ?>" name="setup8" method="post">
  78. <?php
  79. if (isset($_POST['media_path'])){
  80. if (substr($_POST['media_path'],-1) == '/') {
  81. $_POST['media_path'] = substr($_POST['media_path'],0,-1);
  82. }
  83. if (isset($_POST['all_media_paths'])) {
  84. $_POST['all_media_paths'] .= "|" . $_POST['media_path'];
  85. }
  86. else {
  87. $_POST['all_media_paths'] = $_POST['media_path'];
  88. }
  89. }
  90. $PostArray = $_POST;
  91. foreach ($PostArray as $key => $val) {
  92. if (!stristr($key,"submit") and !stristr($key, "media_path")){
  93. echo '<input type="hidden" name="' . htmlentities($key) . '" value="' . htmlentities($val) .'">'. "\n";
  94. }
  95. }
  96. // Did they want to import media?
  97. if (isset($_POST['media_path'])){
  98. ?>
  99. <div class="go">
  100. <span class="goToNext">
  101. <?php echo $word_importing_media; ?>
  102. </span>
  103. </div>
  104. <?php
  105. echo $word_wait_import;
  106. echo '<br><br>';
  107. echo '<strong>';
  108. $media_dir = str_replace("//","/",str_replace("\\","/",$_POST['media_path']));
  109. echo $word_importing_media_from. " ". $media_dir;
  110. echo '</strong><br>';
  111. ob_flush(); flush();
  112. $_POST['media_path'] = stripSlashes($_POST['media_path']);
  113. // Now we need to track ALL the media paths they enter
  114. if (!isset($_SESSION['all_media_paths'])){ $_SESSION['all_media_paths'] = "";}
  115. // Now let's make sure that's a valid path and is readable
  116. if (is_dir($_POST['media_path']) and !stristr($_SESSION['all_media_paths'],$_POST['media_path'])){
  117. $_SESSION['all_media_paths'] .= $_POST['media_path']. "|";
  118. }
  119. // actually import it:
  120. // Now let's set the media types for the import
  121. $default_art = "folder|cover|mainArt";
  122. $audio_types = "mp3|ogg|wma|wav|midi|mid|flac|aac|mp4|rm|mpc|m4a|wv";
  123. $video_types = "avi|wmv|mpeg|mov|mpg|rv";
  124. $ext_graphic = "jpg|gif|png|jpeg";
  125. // First let's get a listing of ALL files so we'll be able to estimate how long this will take
  126. // Was this set from the popup?
  127. if ($_POST['media_length'] <> ""){
  128. $len = $_POST['media_length'];
  129. } else {
  130. //echo "<br><strong>". $word_analyzing_import. '</strong>';
  131. echo '<div id="filecount"></div>';
  132. ?>
  133. <script language="javascript">
  134. fc = document.getElementById("filecount");
  135. -->
  136. </SCRIPT>
  137. <?php
  138. $readCtr = 0; $_SESSION['jz_full_counter'] = 0;
  139. readAllDirs3($media_dir, $readCtr);
  140. // Now let's see how long we think it will take
  141. $len = $_SESSION['jz_full_counter'];
  142. }
  143. if ($len == 0){$len=1;}
  144. $_SESSION['jz_import_full_ammount'] = $len;
  145. $_SESSION['jz_import_start_time'] = time();
  146. $_SESSION['jz_install_timeLeft'] = 0;
  147. ?>
  148. <script language="javascript">
  149. fc.innerHTML = '&nbsp;';
  150. -->
  151. </SCRIPT>
  152. <?php
  153. // Now let's import
  154. echo '<div id="importProgress"></div>';
  155. echo '<div id="importStatus"></div>';
  156. // Now let's know when we started
  157. $startTime = time();
  158. if ($media_dir == "" || !is_dir($media_dir)){
  159. echo "<strong>". $word_dir_invalid. "</strong>";
  160. $error = true;
  161. } else {
  162. if (!@include_once($include_path. 'settings.php')) {
  163. $str = file_get_contents($include_path. 'install/defaults.php');
  164. /*
  165. eval(str_replace("<?php","",str_replace("?>","",$str)));
  166. eval($content);
  167. */
  168. }
  169. // Let's setup the object for the HTML updates
  170. ?>
  171. <script language="javascript">
  172. d = document.getElementById("importStatus");
  173. p = document.getElementById("importProgress");
  174. -->
  175. </SCRIPT>
  176. <?php
  177. // Now let's setup the backend
  178. $backend = $_POST['backend'];
  179. $hierarchy = $_POST['hierarchy'];
  180. $default_importer = $_POST['importer'];
  181. require_once($include_path. 'backend/backend.php');
  182. $jzUSER = new jzUser();
  183. $root = &new jzMediaNode();
  184. set_time_limit(0);
  185. // Now let's update the cache
  186. $_SESSION['jz_import_progress'] = 1;
  187. $_SESSION['jz_import_full_progress'] = 0;
  188. $readTags = true;
  189. if ($_POST['readTags'] == "false"){
  190. $readTags = false;
  191. }
  192. updateNodeCache($root, true, true, false, $readTags, $media_dir);
  193. }
  194. ?>
  195. <script language="javascript">
  196. d = document.getElementById("importStatus");
  197. p = document.getElementById("importProgress");
  198. p.innerHTML = '<b><?php echo $word_import_complete; ?></b>';
  199. d.innerHTML = '&nbsp;';
  200. -->
  201. </SCRIPT>
  202. <strong><?php echo $word_import_complete; ?></strong> (<?php echo round(((time() - $startTime)/60),2). " ". $word_minutes; ?>)
  203. <br><br>
  204. <?php
  205. // Now let's show them how much they imported
  206. $backend = $_POST['backend'];
  207. $hierarchy = $_POST['hierarchy'];
  208. $frontend = $_POST['frontend'];
  209. // Now let's get the backend data
  210. require_once($include_path. 'backend/backend.php');
  211. $root_node = &new jzMediaNode();
  212. if (distanceTo('genre') !== false)
  213. $genres = $root_node->getSubNodeCount('nodes',distanceTo('genre'));
  214. if (distanceTo('artist') !== false)
  215. $artists = $root_node->getSubNodeCount('nodes',distanceTo('artist'));
  216. if (distanceTo('album') !== false)
  217. $albums = $root_node->getSubNodeCount('nodes',distanceTo('album'));
  218. if (distanceTo('track') !== false)
  219. $disks = $root_node->getSubNodeCount('nodes',distanceTo('track'));
  220. $tracks = $root_node->getSubNodeCount('tracks',-1);
  221. $genres = isset($genres) ? $genres : "false";
  222. $artists = isset($artists) ? $artists : "false";
  223. $albums = isset($albums) ? $albums : "false";
  224. $tracks = isset($tracks) ? $tracks : "false";
  225. $disks = isset($disks) ? $disks : "false";
  226. echo $word_genres. ": ". $genres. "<br>";
  227. echo $word_artists. ": ". $artists. "<br>";
  228. echo $word_albums. ": ". $albums. "<br>";
  229. echo $word_tracks. ": ". $tracks. "<br><br>";
  230. echo $word_complete_message;
  231. ?>
  232. <?php
  233. echo str_replace("|","<br>",$_SESSION['all_media_paths']);
  234. }
  235. if (isset($_POST['database_server']) and !isset($_POST['media_path'])){
  236. ?>
  237. <div class="go">
  238. <span class="goToNext">
  239. <?php echo $word_database_connection; ?>
  240. </span>
  241. </div>
  242. <br>
  243. <table width="100%" cellspacing="0" cellpadding="3" border="0">
  244. <tr>
  245. <td class="td" width="40%" align="left" valign="top">
  246. <?php echo $word_verifying_connection; ?>
  247. </td>
  248. <td class="td" width="1">&nbsp;</td>
  249. <td class="td" width="60%" align="left">
  250. <font color="green"><?php echo $word_successful; ?></font>
  251. </td>
  252. </tr>
  253. <tr>
  254. <td class="td" width="40%" align="left" valign="top">
  255. <?php echo $word_creating_database; ?>
  256. </td>
  257. <td class="td" width="1">&nbsp;</td>
  258. <td class="td" width="60%" align="left">
  259. <font color="green"><?php echo $word_already_exists; ?></font>
  260. </td>
  261. </tr>
  262. <tr>
  263. <td class="td" width="40%" align="left" valign="top">
  264. <?php echo $word_creating_tables; ?>
  265. </td>
  266. <td class="td" width="1">&nbsp;</td>
  267. <td class="td" width="60%" align="left">
  268. <font color="green"><?php echo $word_already_exists; ?></font>
  269. </td>
  270. </tr>
  271. </table>
  272. <?php
  273. }
  274. ?>
  275. <div class="go">
  276. <span class="goToNext">
  277. <?php echo $word_import_media; ?>
  278. </span>
  279. </div>
  280. <br>
  281. <table width="100%" cellspacing="0" cellpadding="3" border="0">
  282. <tr>
  283. <td class="td" width="25%" align="left" valign="top">
  284. <?php echo $word_server_directory; ?>
  285. </td>
  286. <td class="td" width="1">&nbsp;</td>
  287. <td class="td" width="75%" align="left">
  288. <input type="text" name="media_path" size="30">
  289. <?php
  290. // Let's make sure we're not in CPGNuke mode...
  291. if ($_POST['cms_type'] <> "cpgnuke"){
  292. echo '<input onClick="browseMedia();" type="button" value="Browse">';
  293. }
  294. ?>
  295. <input type="hidden" name="media_length" value="">
  296. <br>
  297. <?php echo $word_server_directory_note; ?>
  298. </td>
  299. </tr>
  300. </table>
  301. <br><br>
  302. <div class="go">
  303. <span class="goToNext">
  304. &nbsp; <input type="button" onClick="importMedia();" name="import_media" class="submit" value="<?php echo $word_import_media; ?>">
  305. </form>
  306. <form action="<?php echo $form_action2; ?>" name="setup9" method="post">
  307. <?php
  308. $PostArray = $_POST;
  309. foreach ($PostArray as $key => $val) {
  310. if (!stristr($key,"submit") and !stristr($key, "media_path")){
  311. echo '<input type="hidden" name="' . htmlentities($key) . '" value="' . htmlentities($val) .'">'. "\n";
  312. }
  313. }
  314. // Now let's make sure they have imported at least SOME media
  315. if (isset($_POST['media_path'])){
  316. echo '<br>&nbsp; <input type="submit" name="submit_step8" class="submit" value="'. $word_proceed_save_config. '">';
  317. } else {
  318. ?>
  319. <!--
  320. <form action="<?php echo $form_action2; ?>" name="skipform" method="post">
  321. &nbsp; <input type="button" onClick="skipImport();" name="skip_import" class="submit" value="<?php echo $word_skip_import_media; ?>" onmouseover="return overlib('<?php echo $word_skip_import_message; ?>');" onmouseout="return nd();">
  322. <?php
  323. $PostArray = $_POST;
  324. foreach ($PostArray as $key => $val) {
  325. if (!stristr($key,"submit") and !stristr($key, "media_path")){
  326. echo '<input type="hidden" name="' . htmlentities($key) . '" value="' . htmlentities($val) .'">'. "\n";
  327. }
  328. }
  329. ?>
  330. </form>
  331. -->
  332. <?php
  333. }
  334. ?>
  335. </form>
  336. </span>
  337. </div>
  338. </div>
  339. <?php
  340. // Now let's include the top
  341. include_once($include_path. 'install/footer.php');
  342. ?>