dokeos-metadata
[ class tree: dokeos-metadata ] [ index: dokeos-metadata ] [ all elements ]

Source for file importmanifest.php

Documentation is available at importmanifest.php

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

Documentation generated on Thu, 12 Jun 2008 13:48:25 -0500 by phpDocumentor 1.4.1