importmanifest.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <?php /* <!-- Dokeos metadata/importmanifest.php -->
  2. <!-- 2005/09/20 -->
  3. <!-- Copyright (C) 2005 rene.haentjens@UGent.be - see metadata/md_funcs.php -->
  4. */
  5. /**
  6. ==============================================================================
  7. * Dokeos Metadata: create and manage table entries for SCORM package
  8. *
  9. * @package dokeos.metadata
  10. ==============================================================================
  11. */
  12. // PRELIMS -------------------------------------------------------------------->
  13. $getpostvars = array('sdisub','workWith','sdi','smo'); require('md_funcs.php');
  14. define('EID_TYPE', 'Scorm'); define('TPLEN', strlen(EID_TYPE) + 1);
  15. require('md_' . strtolower(EID_TYPE) . '.php');
  16. $langFile = 'md_' . strtolower(EID_TYPE);
  17. include('../inc/global.inc.php');
  18. $nameTools = get_lang('Tool');
  19. if (!isset($sdisub)) $sdisub = '';
  20. $sdisub = substr(ereg_replace("[^0-9A-Za-z]", "", $sdisub), 0, 4);
  21. define('MFFNAME', 'imsmanifest'); define('MFFDEXT', '.xml');
  22. define('MFF', MFFNAME . $sdisub . MFFDEXT);
  23. define('HTF', 'mdp_scorm.htt');
  24. // $sdisub is for split manifests - Scorm.NNN.$sdisub_xxx e.g. Scorm.3.1979_12
  25. ($nameTools && get_lang('Sorry')) or give_up(
  26. 'Language file ' . $langFile . " doesn't define 'Tool' and 'Sorry'");
  27. $_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry'));
  28. $is_allowed_to_edit = isset($_uid) && $is_courseMember && is_allowed_to_edit();
  29. if (!$is_allowed_to_edit) give_up(get_lang('Denied'));
  30. $mdStore = new mdstore($is_allowed_to_edit); // create table if needed
  31. require(api_get_path(LIBRARY_PATH) . 'xmd.lib.php');
  32. require(api_get_path(LIBRARY_PATH) . 'xht.lib.php');
  33. require(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
  34. $baseWorkDir = get_course_path() . ($courseDir = $_course['path'] . '/scorm');
  35. require('md_phpdig.php');
  36. // SET CURRENT SCORM DIRECTORY - HEADER --------------------------------------->
  37. if (isset($workWith)) // explicit in URL, or selected at bottom of screen
  38. {
  39. $scormdocument = Database::get_course_table(SCORMDOC_TABLE);
  40. $result = api_sql_query("SELECT id FROM $scormdocument WHERE path='" .
  41. addslashes($workWith) . "'", __FILE__, __LINE__);
  42. if (mysql_num_rows($result) == 1)
  43. if (($row = mysql_fetch_array($result))) $sdi = $row['id'];
  44. }
  45. if (isset($sdi) && is_numeric($sdi) && $sdi > 0 && $sdi == (int) $sdi)
  46. {
  47. $mdObj = new mdobject($_course, $sdi); $workWith = $mdObj->mdo_path;
  48. $hdrInfo = ' ' . get_lang('WorkOn') . ' ' .
  49. ($workWith ? htmlspecialchars($workWith) . ', ' : '') .
  50. 'SD-id= ' . htmlspecialchars($sdi) .
  51. ($sdisub ? ' (' . htmlspecialchars($sdisub) . ')' : '');
  52. }
  53. else
  54. {
  55. unset($sdi); $mdObj = new mdobject($_course, 0);
  56. if ($workWith) $hdrInfo = ' (' . htmlspecialchars($workWith) .
  57. ': ' . get_lang('NotInDB') . ')'; unset($workWith);
  58. }
  59. $originalHdrInfo = $hdrInfo;
  60. if (isset($workWith)) // now checked to be a valid path in scormdocument
  61. {
  62. if ($mdObj->mdo_filetype == 'folder') // a folder with a manifest?
  63. {
  64. if (file_exists($fmff = $baseWorkDir . $workWith . '/' . MFF))
  65. {
  66. if (($mfContents = @fgc($fmff)))
  67. {
  68. set_time_limit(120); // for analyzing the manifest file
  69. $xht_doc = new xmddoc(explode("\n", $mfContents));
  70. if ($xht_doc->error)
  71. {
  72. $hdrInfo .= ' ' . get_lang('ManifestSyntax') . ' ' .
  73. htmlspecialchars($xht_doc->error);
  74. unset($mfContents);
  75. } // else keep $mfContents, meaning manifest file is OK
  76. }
  77. else
  78. {
  79. $hdrInfo .= ' ' . get_lang('EmptyManifest');
  80. }
  81. }
  82. else
  83. {
  84. $hdrInfo .= ' ' . get_lang('NoManifest');
  85. }
  86. }
  87. else
  88. {
  89. $hdrInfo .= ' ' . get_lang('NotFolder'); unset($sdi);
  90. }
  91. }
  92. $mdObj->mdo_add_breadcrump_nav(); // see 'md_' . EID_TYPE . '.php'
  93. if (isset($sdi)) $interbreadcrumb[]= array(
  94. 'url' => $_SERVER['PHP_SELF'] . '?sdi=' . urlencode($sdi) .
  95. ($sdisub ? '&sdisub=' . urlencode($sdisub) : ''),
  96. 'name'=> get_lang('Continue') . ' ' . $sdi .
  97. ($sdisub ? ' (' . $sdisub . ')' : ''));
  98. $htmlHeadXtra[] = '
  99. <link rel="stylesheet" type="text/css" href="md_styles.css">
  100. <script type="text/javascript" src="md_script.js"></script>
  101. ';
  102. Display::display_header($nameTools);
  103. // OPERATIONS ----------------------------------------------------------------->
  104. if (isset($smo)) echo '<h3>', $smo, '</h3>', "\n"; // selected manifest op
  105. if (isset($smo))
  106. if ($smo == get_lang('UploadMff'))
  107. {
  108. if (is_uploaded_file($filespec = $_FILES['import_file']['tmp_name']) &&
  109. filesize($filespec) && ($myFile = @fopen($filespec, 'r')))
  110. {
  111. fclose($myFile);
  112. if (move_uploaded_file($filespec,
  113. $baseWorkDir . $workWith . '/' . MFF))
  114. {
  115. echo get_lang('MffOk'); $hdrInfo = $originalHdrInfo;
  116. // note: duplicate code below: remove or put in function?
  117. if (file_exists($fmff = $baseWorkDir . $workWith . '/' . MFF))
  118. {
  119. if (($mfContents = @fgc($fmff)))
  120. {
  121. set_time_limit(120); // for analyzing the manifest file
  122. $xht_doc = new xmddoc(explode("\n", $mfContents));
  123. if ($xht_doc->error)
  124. {
  125. $hdrInfo .= ' ' . get_lang('ManifestSyntax') . ' ' .
  126. htmlspecialchars($xht_doc->error);
  127. unset($mfContents);
  128. } // else keep $mfContents, meaning manifest file is OK
  129. }
  130. else
  131. {
  132. $hdrInfo .= ' ' . get_lang('EmptyManifest');
  133. }
  134. }
  135. else
  136. {
  137. $hdrInfo .= ' ' . get_lang('NoManifest');
  138. }
  139. }
  140. else echo get_lang('MffNotOk');
  141. }
  142. else echo get_lang('MffFileNotFound');
  143. }
  144. elseif ($smo == get_lang('UploadHtt'))
  145. {
  146. if (is_uploaded_file($filespec = $_FILES['import_file']['tmp_name']) &&
  147. filesize($filespec) && ($myFile = @fopen($filespec, 'r')))
  148. {
  149. fclose($myFile); if (move_uploaded_file($filespec,
  150. $baseWorkDir . $workWith . '/' . HTF))
  151. echo get_lang('HttOk');
  152. else echo get_lang('HttNotOk');
  153. }
  154. else echo get_lang('HttFileNotFound');
  155. }
  156. elseif ($smo == get_lang('RemoveHtt'))
  157. {
  158. @unlink($fhtf = $baseWorkDir . $workWith . '/' . HTF);
  159. if (file_exists($fhtf))
  160. echo get_lang('HttRmvNotOk');
  161. else echo get_lang('HttRmvOk');
  162. }
  163. elseif ($smo == get_lang('Import'))
  164. {
  165. define('TREETOP', 'organizations/organization');
  166. define('TITLE', 'title');
  167. define('SUBITEM', 'item');
  168. define('IDENTIF', 'identifier');
  169. define('ITEMID', '@'.IDENTIF);
  170. define('SUBIT', SUBITEM.'/'.ITEMID);
  171. define('RESOURCE', 'resources/resource');
  172. define('WHERE', ITEMID);
  173. define('ISITEM', '@identifierref');
  174. define('HREF', 'href');
  175. define('WEBF', '@'.HREF);
  176. define('FILE', 'file');
  177. define('THUMB', FILE.'[1]/'.WEBF);
  178. function resource_for($elem)
  179. {
  180. global $xht_doc;
  181. $resForItem = $xht_doc->xmd_select_elements_where(RESOURCE,
  182. WHERE, $xht_doc->xmd_value(ISITEM, $elem));
  183. return (count($resForItem) == 0) ? -1 : $resForItem[0];
  184. }
  185. function store_md_and_traverse_subitems($mfdocId, $level, $counter,
  186. $contextElem, $treeElem, $parentElem)
  187. {
  188. global $_uid, $xht_doc, $mdStore, $mdObj, $sdisub;
  189. // $contextElem -> @identifier, metadata/lom
  190. // $treeElem -> title, items
  191. $itemId = $xht_doc->xmd_value(ITEMID, $contextElem);
  192. if ($sdisub && $level == 1 && $sdisub != $itemId) return;
  193. // <item level=... number=... identifier=...>:
  194. // <title>...</title>
  195. // <parent identifier=... /> <previous ... /> <next ... />
  196. // <child identifier=... /> <child identifier=... /> ...
  197. // <resource href=...>
  198. // <file href=... /> <file href=... /> ...
  199. // </resource>
  200. // <metadata>...</metadata>
  201. // </item>
  202. set_time_limit(30); // again 30 seconds from here on...
  203. $mddoc = new xmddoc('<item/>'); // version, name ?
  204. $mddoc->xmd_set_attribute(0, 'level', $level, FALSE);
  205. $mddoc->xmd_set_attribute(0, 'number', $counter, FALSE);
  206. $mddoc->xmd_set_attribute(0, IDENTIF, $itemId, FALSE);
  207. if ($level == 0)
  208. {
  209. $mddoc->xmd_set_attribute(0, 'created', date('Y/m/d H:i:s'), FALSE);
  210. $mddoc->xmd_set_attribute(0, 'by', $_uid, FALSE);
  211. }
  212. $mddoc->xmd_add_text_element(TITLE,
  213. $xht_doc->xmd_value(TITLE, $treeElem));
  214. if (($ppnId = $xht_doc->xmd_value(ITEMID, $parentElem))) $mddoc->
  215. xmd_add_element('parent', 0, array(IDENTIF => $ppnId));
  216. if (($ppnId = $xht_doc->xmd_value('-'.SUBIT, $treeElem))) $mddoc->
  217. xmd_add_element('previous', 0, array(IDENTIF => $ppnId));
  218. if (($ppnId = $xht_doc->xmd_value('+'.SUBIT, $treeElem))) $mddoc->
  219. xmd_add_element('next', 0, array(IDENTIF => $ppnId));
  220. if (($srcElem = resource_for($treeElem)) > 0)
  221. {
  222. // change stuff below to xmd_copy_foreign_child ?
  223. $resElem = $mddoc->xmd_add_element('resource', 0,
  224. array(HREF => $xht_doc->xmd_value(WEBF, $srcElem)));
  225. foreach ($xht_doc->xmd_select_elements(FILE, $srcElem) as $fileElem)
  226. $mddoc->xmd_add_element(FILE, $resElem,
  227. array(HREF => $xht_doc->xmd_value(WEBF, $fileElem)));
  228. }
  229. $mddoc->xmd_copy_foreign_child($xht_doc,
  230. $xht_doc->xmd_select_single_element('metadata', $contextElem));
  231. foreach ($xht_doc->xmd_select_elements(SUBITEM, $treeElem) as $subElem)
  232. $mddoc->xmd_add_element('child', 0,
  233. array(IDENTIF => $xht_doc->xmd_value(ITEMID, $subElem)));
  234. $mdt = $mddoc->xmd_xml();
  235. $xhtDoc = $mdObj->mdo_define_htt();
  236. $xhtDoc->xht_xmldoc = $mddoc; // $xhtDoc->xht_param['xxx'] = 'yyy';
  237. $mdStore->mds_put($eid = EID_TYPE . '.' . $mfdocId . '.' . $itemId,
  238. $mdt, 'mdxmltext', '?');
  239. $mdStore->mds_put($eid, $ixt =
  240. $xhtDoc->xht_fill_template('INDEXABLETEXT'), 'indexabletext');
  241. if ($level == 0) // store a copy as 'Scorm.nnn'
  242. {
  243. $mdStore->mds_put(EID_TYPE . '.' . $mfdocId, $mdt, 'mdxmltext', '?');
  244. $mdStore->mds_put(EID_TYPE . '.' . $mfdocId, $ixt, 'indexabletext');
  245. }
  246. echo htmlspecialchars($level.'/ '.$itemId), '<br>';
  247. flush(); $loopctr = 0;
  248. foreach ($xht_doc->xmd_select_elements(SUBITEM, $treeElem) as $subElem)
  249. {
  250. store_md_and_traverse_subitems($mfdocId, $level + 1, ++$loopctr,
  251. $subElem, $subElem, $contextElem);
  252. // note: replacing this recursion by queue+loop makes it slower!
  253. }
  254. }
  255. function content_for_index_php($scid)
  256. {
  257. // 'if {}' and 'else {}' are string literals spanning several lines
  258. return '<?php' .
  259. '
  260. // This PHP file has been generated by metadata/importmanifest.php
  261. if (isset($_GET["th"]) && ($th = str_replace("..", "",
  262. get_magic_quotes_gpc() ? stripslashes($_GET["th"]) : $_GET["th"])))
  263. {
  264. if (strtolower(substr($th, -4)) != ".jpg") exit; // other ext?
  265. $thf = $_SERVER["PHP_SELF"];
  266. if(!is_file($thf = $_SERVER["DOCUMENT_ROOT"] .
  267. substr($thf, 0, strrpos($thf, "/")) . "/" . $th)) exit;
  268. header("Content-disposition: filename=".basename($th));
  269. header("Content-Type: image/jpeg");
  270. header("Expires: ".gmdate("D, d M Y H:i:s",time()+10)." GMT");
  271. header("Last-Modified: ".gmdate("D, d M Y H:i:s",time()+10)." GMT");
  272. $fp = fopen($thf, "rb"); fpassthru($fp); fclose($fp);
  273. }
  274. '
  275. . str_replace('$rootSys', api_get_path(SYS_PATH),
  276. str_replace('$scid', $scid,
  277. '
  278. else
  279. {
  280. $drs = "$rootSys"; $scormid = "$scid";
  281. require($drs. "main/metadata/playscormmdset.inc.php");
  282. }
  283. ' )) . '?' . '>';
  284. }
  285. if ($mfContents)
  286. {
  287. store_md_and_traverse_subitems($sdi, 0, 1, 0,
  288. $xht_doc->xmd_select_single_element(TREETOP), -1);
  289. $playIt = $baseWorkDir . $workWith . '/index.php';
  290. $fileHandler = @fopen($playIt, 'w');
  291. @fwrite($fileHandler, content_for_index_php($sdi));
  292. @fclose($fileHandler);
  293. echo htmlspecialchars($workWith);
  294. if (file_exists($playIt)) echo '/index.php ',
  295. htmlspecialchars(date('Y/m/d H:i:s', filemtime($playIt)));
  296. }
  297. }
  298. elseif ($smo == get_lang('Remove') && $sdisub)
  299. {
  300. $screm = EID_TYPE . '.' . $sdi . '.' . $sdisub;
  301. $mdStore->mds_delete_offspring($screm, '\_'); // SQL LIKE underscore
  302. echo htmlspecialchars($screm . '_*: ' . mysql_affected_rows()), '<br>';
  303. }
  304. elseif ($smo == get_lang('Remove'))
  305. {
  306. $mdStore->mds_delete($screm = EID_TYPE . '.' . $sdi);
  307. echo htmlspecialchars($screm . ': ' . mysql_affected_rows()), '<br>';
  308. $mdStore->mds_delete_offspring($screm);
  309. echo htmlspecialchars($screm . '.*: ' . mysql_affected_rows()), '<br><br>',
  310. '<b>' . get_lang('AllRemovedFor') . ' ' . $screm . '</b><br>';
  311. }
  312. elseif ($smo == get_lang('Index') && file_exists($phpDigIncCn) &&
  313. ereg('^http://([^/]+)/(.+)/index\.php$', $mdObj->mdo_url, $regs))
  314. {
  315. $result = $mdStore->mds_get_many('eid,mdxmltext,indexabletext',
  316. "eid LIKE '" . EID_TYPE . "." . $sdi .
  317. ($sdisub ? "." . $sdisub . "\_%'" : ".%'")); // SQL LIKE underscore
  318. while ($row = mysql_fetch_array($result)) // load indexabletexts in memory
  319. {
  320. // URL: index.php[?sid=xxx[&thumb=yyy]] (file[1]/@href: pptslnnn_t.jpg)
  321. $th = ''; $indtxt = $row['indexabletext'];
  322. if (($fh = strpos($rx = $row['mdxmltext'], 'file href="')) !== FALSE)
  323. if (($cq = strpos($rx, '"', $fh += 11)) !== FALSE)
  324. if (ereg('^pptsl[0-9]+_t\.jpg$', $thwf = substr($rx, $fh, $cq - $fh)))
  325. $th = '&thumb=' . urlencode($thwf);
  326. if ($th == '' && ($sclvl = strpos($indtxt, 'scorm-level-')) !== FALSE)
  327. $th = '&thumb=scorm-level-' . $indtxt{$sclvl + 12} . '.jpg';
  328. $idt[($dotpos = strpos($ri = $row['eid'], '.', TPLEN)) !== FALSE ?
  329. ('index.php?sid=' . urlencode(substr($ri, $dotpos+1)) . $th) :
  330. 'index.php'] = $indtxt;
  331. }
  332. require($phpDigIncCn); // switch to PhpDig DB
  333. if (($site_id = remove_engine_entries('http://' . $regs[1] .'/', $path =
  334. $regs[2] . '/', $sdisub ? 'index.php?sid=' . $sdisub . '_' : '')))
  335. {
  336. echo '<table>', "\n";
  337. foreach ($idt as $url => $text)
  338. {
  339. set_time_limit(30); // again 30 seconds from here on...
  340. index_words($site_id, $path, $url,
  341. get_first_words($text, $path, $url), get_keywords($text));
  342. }
  343. echo '</table>', "\n";
  344. }
  345. // possible enhancement: UPDATE spider record for still existing pages
  346. if(isset($db)) mysql_select_db($mainDbName, $db); // back to Dokeos
  347. }
  348. elseif ($smo == get_lang('Index'))
  349. {
  350. echo 'Problem! PhpDig connect.php has gone or else URL "' .
  351. htmlspecialchars($mdObj->mdo_url) .
  352. '" is not like "http://xxxx/yyy.../zzz/index.php"';
  353. }
  354. // STATISTICS ----------------------------------------------------------------->
  355. echo '<h3>', get_lang('Statistics'), '</h3>', "\n";
  356. $result = $mdStore->mds_get_many('eid', "eid LIKE '" . EID_TYPE . ".%'");
  357. echo get_lang('TotalMDEs'), mysql_num_rows($result), "\n";
  358. while ($row = mysql_fetch_array($result))
  359. {
  360. $eid_id = substr($eid = $row['eid'], TPLEN);
  361. if (($dotpos = strpos($eid_id, '.')))
  362. $eid_id = substr($eid_id, 0, $dotpos);
  363. else
  364. $mdtmain[$eid_id] = $mdStore->mds_get($eid);
  365. $perId[$eid_id] = ($pi = $perId[$eid_id]) ? $pi + 1 : 1;
  366. }
  367. if (isset($sdi))
  368. {
  369. $mdo = new mdobject($_course, $sdi);
  370. echo '<br>', htmlspecialchars($mdo->mdo_path), ', SD-id ', $sdi, ': ',
  371. ($perId[$sdi] ? $perId[$sdi] : '0'), ' ',
  372. ($mdtmain[$sdi] ? '- <span class="lbs" onClick="' .
  373. "makeWindow('index.php?eid=" . EID_TYPE . '.' .$sdi . "', '', '')\">" .
  374. get_lang('MainMD') . '</span>' : ''), "\n";
  375. }
  376. if (count($perId))
  377. {
  378. foreach ($perId as $id => $number)
  379. {
  380. $mdo = new mdobject($_course, $id);
  381. if (!($pth = $mdo->mdo_path))
  382. {
  383. $pth = $mdtmain[$id]; // fetch something simple without parsing
  384. if ($ttopen = strpos($pth, '<title>'))
  385. if ($ttclose = strpos($pth, '</title>', $ttopen))
  386. $pth = ' ' . html_entity_decode
  387. (substr($pth, $ttopen+7, $ttclose-$ttopen-7));
  388. else $pth = ' ' . substr($pth, $ttopen+7, 30);
  389. else $pth = ' ' . substr($pth, 0, 30);
  390. }
  391. $pathId[$pth] = $id;
  392. }
  393. echo '<br><br><table>', "\n"; ksort($pathId); $wwl = strlen($workWith);
  394. foreach ($pathId as $pth => $id) if ($wwl == 0 ||
  395. ($wwl < strlen($pth) && substr($pth, 0, $wwl) == $workWith))
  396. {
  397. $tmfdt = file_exists($tfmff = $baseWorkDir . $pth . '/' . MFF) ?
  398. date('Y/m/d H:i:s', filemtime($tfmff)) : '-';
  399. echo '<tr><td>', htmlspecialchars($tmfdt), '</td>',
  400. '<td>', htmlspecialchars($pth),
  401. '</td><td align="right">(SD-id ', $id,
  402. '):</td><td align="right">', $perId[$id], '</td></tr>', "\n";
  403. }
  404. echo '</table>', "\n";
  405. }
  406. if ($mfContents)
  407. {
  408. echo $workWith, '/', MFF, ': ',
  409. htmlspecialchars(date('Y/m/d H:i:s', filemtime($fmff))) , ", \n",
  410. substr_count($mfContents, "\n") + 1,
  411. ' ' . get_lang('Lines') . '.', "\n";
  412. if (!$sdisub && ($dh = opendir($baseWorkDir . $workWith)))
  413. {
  414. $nsplit = array();
  415. while (FALSE !== ($file = readdir($dh)))
  416. if (ereg('^'.MFFNAME.'(.+)\\'.MFFDEXT .'$', $file, $regs))
  417. {
  418. $nsplit []= $regs[1];
  419. }
  420. closedir($dh);
  421. if (count($nsplit))
  422. {
  423. echo '<br>', get_lang('SplitData'); sort($nsplit);
  424. foreach ($nsplit as $ns)
  425. {
  426. $result = $mdStore->mds_get_many('eid', "eid LIKE '" .
  427. EID_TYPE . "." . $sdi . "." . $ns . "\_%'");
  428. $nns = mysql_num_rows($result);
  429. echo $ns, $nns ? '_ ' . $nns : '', '; ';
  430. }
  431. echo '<br>';
  432. }
  433. }
  434. }
  435. if (file_exists($baseWorkDir . $workWith . '/index.php'))
  436. echo "<span class=\"lbs\" onClick=\"makeWindow('" .
  437. $mdObj->mdo_url . "', '', '')\">" . get_lang('Play'), '</span>', "\n";
  438. if (file_exists($fhtf = $baseWorkDir . $workWith . '/' . HTF))
  439. echo '<br>', $workWith, '/', HTF, ': ',
  440. htmlspecialchars(date('Y/m/d H:i:s', filemtime($fhtf))) , "\n";
  441. // SELECT & FOOTER ------------------------------------------------------------>
  442. if ($mfContents || $xht_doc->error)
  443. {
  444. echo '<h3>', get_lang('UploadMff'), "</h3>\n\n",
  445. '<form action="' . $_SERVER['PHP_SELF'] . '?sdi=' . urlencode($sdi) .
  446. ($sdisub ? '&sdisub=' . urlencode($sdisub) : '') .
  447. '" enctype="multipart/form-data" method="post">', "\n",
  448. '<input type="hidden" name="MAX_FILE_SIZE" value="32768">', "\n",
  449. '<input type="file" name="import_file" size="30">', "\n",
  450. '<input type="submit" name="smo" value="', get_lang('UploadMff'),
  451. '">' . "\n</form>\n";
  452. }
  453. echo '<h3>', get_lang('UploadHtt'), file_exists($fhtf) ?
  454. (' + ' . get_lang('RemoveHtt')) : '', "</h3>\n\n",
  455. '<form action="' . $_SERVER['PHP_SELF'] . '?sdi=' . urlencode($sdi) .
  456. ($sdisub ? '&sdisub=' . urlencode($sdisub) : '') .
  457. '" enctype="multipart/form-data" method="post">', "\n",
  458. '<input type="hidden" name="MAX_FILE_SIZE" value="32768">', "\n",
  459. '<input type="file" name="import_file" size="30">', "\n",
  460. '<input type="submit" name="smo" value="', get_lang('UploadHtt'), '">';
  461. if (file_exists($fhtf)) echo
  462. '<input type="submit" name="smo" value="', get_lang('RemoveHtt'), '">';
  463. echo "\n</form>\n";
  464. echo '<h3>', $nameTools, $hdrInfo, '</h3>', "\n";
  465. if ($mfContents || $perId[$sdi]) // buttons for manifest operations
  466. {
  467. echo '<form action="' . $_SERVER['PHP_SELF'] . '?sdi=' . urlencode($sdi) .
  468. ($sdisub ? '&sdisub=' . urlencode($sdisub) : '') .
  469. '" method="post">', "\n";
  470. if ($mfContents) echo
  471. '<input type="submit" name="smo" value="', get_lang('Import'), '">', "\n";
  472. if ($perId[$sdi]) echo
  473. '<input type="submit" name="smo" value="', get_lang('Remove'), '">', "\n";
  474. if ($mfContents && $perId[$sdi] && file_exists($phpDigIncCn)) echo
  475. '<input type="submit" name="smo" value="', get_lang('Index'), '">', "\n";
  476. echo
  477. '</form>', "\n";
  478. }
  479. else
  480. {
  481. echo '(', get_lang('NonePossible'), '...)';
  482. }
  483. function showSelectForm($label, $specifics)
  484. {
  485. echo '<tr><td align="right" class="alternativeBgDark">', "\n",
  486. '<form action="', $_SERVER['PHP_SELF'], '" method="post">', "\n",
  487. get_lang($label), ' :', "\n", $specifics, "\n",
  488. '<input type="submit" value="', get_lang('Ok'), '" />', "\n",
  489. '</form></td></tr>', "\n";
  490. }
  491. echo '<h3>', get_lang('OrElse'), '</h3>', "\n<table>\n";
  492. $specifics = '<select name="workWith">' . "\n" .
  493. '<option value="" style="color:#999999">' . get_lang('Root') . "</option>\n";
  494. if (($dirList = index_and_sort_dir($baseWorkDir))) // fileManage.lib
  495. {
  496. $someDirs = array();
  497. foreach ($dirList as $pathValue)
  498. $someDirs[$pathValue] = file_exists($pathValue. '/'. MFFNAME. MFFDEXT);
  499. foreach ($someDirs as $pathValue => $mfExists) if ($mfExists)
  500. {
  501. while (($i = strrpos($pathValue, '/')))
  502. {
  503. $pathValue = substr($pathValue, 0, $i);
  504. if (!array_key_exists($pathValue, $someDirs)) break;
  505. $someDirs[$pathValue] = TRUE;
  506. }
  507. }
  508. $bwdL = strlen($baseWorkDir);
  509. foreach ($someDirs as $pathValue => $mfExists) if ($mfExists)
  510. {
  511. $pathValue = substr($pathValue, $bwdL);
  512. $specifics .= '<option value="' . $pathValue . '"' .
  513. ($pathValue == $workWith ? ' selected' : '') . '>' .
  514. str_repeat('&nbsp;&nbsp', substr_count($pathValue, '/')) . '>' .
  515. basename($pathValue) . '</option>' . "\n";
  516. }
  517. }
  518. showSelectForm('WorkWith', $specifics . '</select>');
  519. showSelectForm('SDI',
  520. '<input type="text" size="5" name="sdi" value="' .
  521. htmlspecialchars($sdi) . '" />' .
  522. '(<input type="text" size="4" name="sdisub" value="' .
  523. htmlspecialchars($sdisub) . '" />)' . "\n");
  524. echo '</table>', "\n";
  525. Display::display_footer();
  526. ?>