From e8ec458da4d83897bd02b87f63f4d766e41e881f Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Wed, 19 Sep 2018 15:36:57 +0200
Subject: [PATCH] FIX #8346 fix upload file tmp convert

---
 .../indexing_searching/choose_file.php        | 145 +++++++++---------
 1 file changed, 73 insertions(+), 72 deletions(-)

diff --git a/apps/maarch_entreprise/indexing_searching/choose_file.php b/apps/maarch_entreprise/indexing_searching/choose_file.php
index a9a3e24c660..f4855c03249 100755
--- a/apps/maarch_entreprise/indexing_searching/choose_file.php
+++ b/apps/maarch_entreprise/indexing_searching/choose_file.php
@@ -37,22 +37,23 @@ $core_tools->load_html();
 $core_tools->load_header('', true, false);
 $upFileOK = false;
 $_SESSION['with_file'] = false;
-?>
-    <body>
+$_SESSION['upfile']['fileNamePdfOnTmp'] = '';
+?>
+    <body>
     <?php
     $_SESSION['upfile']['error'] = 0;
     if (isset($_FILES['file']['error']) && $_FILES['file']['error'] == 1) {
         $_SESSION['upfile']['error'] = $_FILES['file']['error'];
         if ($_SESSION['upfile']['error'] == 1) {
-            ?>
-            <script language="javascript" type="text/javascript">
-                var test = window.top.document.getElementById('file_iframe');
-                if (test != null)
-                {
+            ?>
+            <script language="javascript" type="text/javascript">
+                var test = window.top.document.getElementById('file_iframe');
+                if (test != null)
+                {
                     test.src = '<?php
-                        echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&dir=indexing_searching&page=file_iframe&#navpanes=0';
-                }
-            </script>
+                        echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&dir=indexing_searching&page=file_iframe&#navpanes=0';
+                }
+            </script>
             <?php
         }
     } elseif (!empty($_FILES['file']['tmp_name']) && $_FILES['file']['error'] != 1) {
@@ -112,96 +113,96 @@ $_SESSION['with_file'] = false;
         $upFileOK = true;
     }
     //if ($upFileOK) {
-        ?>
-        <script language="javascript" type="text/javascript">
-            function refreshFrame(frameId) {
+        ?>
+        <script language="javascript" type="text/javascript">
+            function refreshFrame(frameId) {
                 frameId.src = '<?php
                     echo $_SESSION['config']['businessappurl'];
-                    ?>index.php?display=true&dir=indexing_searching&page=file_iframe';
-            }
-
-            var test = window.top.document.getElementById('file_iframe');
+                    ?>index.php?display=true&dir=indexing_searching&page=file_iframe';
+            }
+
+            var test = window.top.document.getElementById('file_iframe');
             if (test.src == '<?php
                 echo $_SESSION['config']['businessappurl'];
-                ?>index.php?display=true&dir=indexing_searching&page=file_iframe&#navpanes=0') {
-                //test.location.refresh();
-                //test.src = '';
-                refreshFrame(test);
-            }
-
-            if (test != null) {
-                //fix pb with toolbar of pdf
+                ?>index.php?display=true&dir=indexing_searching&page=file_iframe&#navpanes=0') {
+                //test.location.refresh();
+                //test.src = '';
+                refreshFrame(test);
+            }
+
+            if (test != null) {
+                //fix pb with toolbar of pdf
                 test.src = '<?php
                     echo $_SESSION['config']['businessappurl'];
-                    ?>index.php?display=true&dir=indexing_searching&page=file_iframe&#navpanes=0';
-            }
-        </script>
+                    ?>index.php?display=true&dir=indexing_searching&page=file_iframe&#navpanes=0';
+            }
+        </script>
         <?php
     //}
-    ?>
+    ?>
     <form name="select_file_form" id="select_file_form" method="get" enctype="multipart/form-data" action="<?php
         echo $_SESSION['config']['businessappurl'];
-        ?>index.php?display=true&dir=indexing_searching&page=choose_file" class="forms">
-        <input type="hidden" name="display" value="true" />
-        <input type="hidden" name="dir" value="indexing_searching" />
-        <input type="hidden" name="page" value="choose_file" />
-        <p>
-            <label for="file" style="width:90%;margin-right: -12px;margin-top: -2px">
+        ?>index.php?display=true&dir=indexing_searching&page=choose_file" class="forms">
+        <input type="hidden" name="display" value="true" />
+        <input type="hidden" name="dir" value="indexing_searching" />
+        <input type="hidden" name="page" value="choose_file" />
+        <p>
+            <label for="file" style="width:90%;margin-right: -12px;margin-top: -2px">
             <?php
             if (!empty($_SESSION['upfile']['local_path']) && empty($_SESSION['error'])) {
-                ?>
-                <i class="fa fa-check-square fa-2x" title="<?php echo _DOWNLOADED_FILE; ?>"></i>
-                <input type="button" id="fileButton" onclick="$j('#file').click();" class="button"
+                ?>
+                <i class="fa fa-check-square fa-2x" title="<?php echo _DOWNLOADED_FILE; ?>"></i>
+                <input type="button" id="fileButton" onclick="$j('#file').click();" class="button"
                        value="<?php if ($_REQUEST['with_file'] == 'true') {
                     echo _WITHOUT_FILE;
                 } else {
                     echo _DOWNLOADED_FILE;
-                } ?>"
-                       style="width: 90%;margin: 0px;margin-top: -2px;font-size: 15px;text-align: center;">
+                } ?>"
+                       style="width: 90%;margin: 0px;margin-top: -2px;font-size: 15px;text-align: center;">
             <?php
             } else {
-                ?>
-                <i class="fa fa-times fa-2x" title="<?php echo _NO_FILE_SELECTED; ?>"></i>
-                <input type="button" id="fileButton" onclick="$j('#file').click()" class="button" value="<?php echo _CHOOSE_FILE; ?>" style="width: 90%;margin: 0px;margin-top: -2px;font-size: 15px;text-align: center;">
+                ?>
+                <i class="fa fa-times fa-2x" title="<?php echo _NO_FILE_SELECTED; ?>"></i>
+                <input type="button" id="fileButton" onclick="$j('#file').click()" class="button" value="<?php echo _CHOOSE_FILE; ?>" style="width: 90%;margin: 0px;margin-top: -2px;font-size: 15px;text-align: center;">
             <?php
-            } ?>
-            </label>
+            } ?>
+            </label>
             <?php
             if ($_REQUEST['with_file'] == 'true') {
-                ?>
-                <i class="fa fa-ban fa-2x" id="with_file_icon" onclick="$j('#with_file').click();" title="<?php echo _WITHOUT_FILE; ?> (actif)" style="cursor:pointer;"></i>
+                ?>
+                <i class="fa fa-ban fa-2x" id="with_file_icon" onclick="$j('#with_file').click();" title="<?php echo _WITHOUT_FILE; ?> (actif)" style="cursor:pointer;"></i>
             <?php
             } else {
-                ?>
-                <i class="fa fa-ban fa-2x" id="with_file_icon" onclick="$j('#with_file')[0].value='true';$j('#with_file2').click();" title="<?php echo _WITHOUT_FILE; ?>" style="cursor:pointer;"></i>
+                ?>
+                <i class="fa fa-ban fa-2x" id="with_file_icon" onclick="$j('#with_file')[0].value='true';$j('#with_file2').click();" title="<?php echo _WITHOUT_FILE; ?>" style="cursor:pointer;"></i>
             <?php
-            } ?>
-
-            <input type="file" name="file" id="file" onchange="$j('#with_file')[0].value='false';this.form.method = 'post';this.form.submit();"
+            } ?>
+
+            <input type="file" name="file" id="file" onchange="$j('#with_file')[0].value='false';this.form.method = 'post';this.form.submit();"
                    value="<?php $_REQUEST['with_file'] = 'false';
                             if (isset($_SESSION['file_path'])) {
                                 echo $_SESSION['file_path'];
-                            } ?>"
-                   style="width:200px;margin-left:33px;display:none;" />
-        </p>
-        <p style="display:none;">
-            <label for="with_file">
-                <?php echo _WITHOUT_FILE; ?>
-            </label>
-            <div align="center" style="display:none;">
-                <?php echo _YES; ?>
+                            } ?>"
+                   style="width:200px;margin-left:33px;display:none;" />
+        </p>
+        <p style="display:none;">
+            <label for="with_file">
+                <?php echo _WITHOUT_FILE; ?>
+            </label>
+            <div align="center" style="display:none;">
+                <?php echo _YES; ?>
                 <input <?php if ($_REQUEST['with_file'] == 'true') {
                                 echo 'checked="checked"';
-                            } ?>
-                    type="radio" name="with_file" id="with_file2" value="true" onclick="this.form.method = 'post';this.form.submit();" />
-                <?php echo _NO; ?>
+                            } ?>
+                    type="radio" name="with_file" id="with_file2" value="true" onclick="this.form.method = 'post';this.form.submit();" />
+                <?php echo _NO; ?>
                 <input <?php if ($_REQUEST['with_file'] == 'false' || $_REQUEST['with_file'] == '') {
                                 echo 'checked="checked"';
-                            } ?>
-                    type="radio" name="with_file" id="with_file" value="false" onclick="this.form.method = 'post';this.form.submit();" />
-            </div>
-        </p>
-    </form>
-    <?php $core_tools->load_js();?>
-    </body>
-</html>
+                            } ?>
+                    type="radio" name="with_file" id="with_file" value="false" onclick="this.form.method = 'post';this.form.submit();" />
+            </div>
+        </p>
+    </form>
+    <?php $core_tools->load_js();?>
+    </body>
+</html>
-- 
GitLab