Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- location: /
- */
- include "configs/base.php";
- include_once "functions/_main.php";
- echo "<div>RUN :".date("d/m/y H:i:s")."</div>";
- $ar = [
- "folder" => "comic/100",
- "filename" => "他の世界", //sensitive
- "allows" => ["jpg", "png", "pdf", "画像"], //allowed
- //'date'=>"2025-01-25"
- ];
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 2 folder (lama)", $encrypted_string);
- $ar = [
- "folder" => "comic/100",
- "filename" => "他の世界", //sensitive
- "allows" => ["jpg", "png", "pdf", "画像"], //allowed
- "date" => "2025-01-25", //data date
- "num" => "002",
- ];
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- ?>
- <div>upload 2 folder (baru)
- <input type='file' id='fileAjax002' param='<?=$encrypted_string
- ?>' />
- <button type='button' onclick='saveFile("002")'>Upload</button><br/>
- <span id='infoFileAjax002'>
- <?=viewAttachment($ar["folder"], $filename = $ar["filename"], $tanggalData = $ar["date"], "002") ?>
- </span>
- </div>
- <div>folder: comicZ</div>
- <?php
- //----------1 folder------------
- $ar = [
- "folder" => "comicZ",
- "filename" => "他の世界", //sensitive
- "allows" => ["jpg", "png", "pdf", "画像"], //allowed
- "date" => "2025-01-25", //data date
- ];
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 1 folder (baru)", $encrypted_string);
- $ar["filename"] = "1";
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 1 folder (baru)", $encrypted_string);
- $ar["filename"] = "2";
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 1 folder (baru)", $encrypted_string);
- unset($ar["date"]);
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 1 folder tanpa tanggal (lama)", $encrypted_string);
- $ar["filename"] = "他の世界";
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 1 folder (lama)", $encrypted_string);
- ?>
- <div>Folder: comicZ/101</div>
- <?php
- $ar = [
- "folder" => "comicZ/101",
- "filename" => "10", //sensitive
- "allows" => ["jpg", "png", "pdf", "画像"], //allowed
- "date" => "2025-01-25", //data date
- ];
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 1 folder (baru)", $encrypted_string);
- $ar["filename"] = "11";
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 1 folder (baru)", $encrypted_string);
- $ar["filename"] = "20";
- unset($ar["date"]);
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 1 folder tanpa tanggal (lama)", $encrypted_string);
- $ar["filename"] = "21";
- $string_to_encrypt = json_encode($ar);
- $encrypted_string = encryptData($string_to_encrypt);
- divImageAjax("upload 1 folder tanpa tanggal (lama)", $encrypted_string);
- ?>
- <script>
- function downloadFile(params){
- var form = document.createElement("form");
- var element1 = document.createElement("input");
- form.method = "POST";
- form.action = "ajax/viewFile.php";
- form.target = "baru";
- element1.value=params;
- element1.name="params";
- form.appendChild(element1);
- document.body.appendChild(form);
- form.submit();
- form.remove();
- }
- function deleteFile(num, params){
- if( confirm("Are you want to delete file?") ){
- deleteFileAction(num, params);
- }
- return false;
- }
- async function deleteFileAction(num, params){
- let formData = new FormData();
- var infoDelete=-1;
- let nameViewObj = "infoFileAjax" + num;
- var objViewAjax = document.getElementById(nameViewObj);
- try {
- (async () => {
- formData.append("params", params);
- resp = await fetch('/ajax/deleteFile.php', {method: "POST", body: formData});
- try {
- var jobj = await resp.json();
- }catch(e){
- jobj = {};
- }
- if(typeof jobj.error !== 'undefined'){
- if(jobj.error==0){
- console.log(jobj,objViewAjax,num);
- if(typeof jobj.html !== 'undefined' && typeof objViewAjax.innerHTML !== 'undefined' ){
- objViewAjax.innerHTML = jobj.html;/*hapus tampilan*/
- }
- if(typeof jobj.message !== 'undefined'){
- setTimeout(function (){
- alert(jobj.message);
- infoUpload=1;
- }, 1000);
- }else{
- }
- }else if(typeof jobj.message !== 'undefined'){
- alert(jobj.message);
- infoUpload=2;
- }else{
- alert("undefined error");
- infoUpload=3;
- }
- }else{
- alert("please try again");
- infoUpload=4;
- }
- })();
- }
- catch(err) {
- alert("undefined error");
- infoDelete=3;
- }
- finally{
- if(infoDelete==0){
- alert("Delete success");
- }
- }
- }
- async function saveFile(num)
- {
- let formData = new FormData();
- let nameObj = "fileAjax" + num;
- let objAjax = document.getElementById(nameObj);
- let nameViewObj = "infoFileAjax" + num;
- let objViewAjax = document.getElementById(nameViewObj);
- let strBefore = objViewAjax.innerHTML;
- let params = objAjax.getAttributeNode("param").value;
- let infoUpload=-1;
- try {
- strWaiting='';//🕐
- for(iWait=36;iWait<48;iWait++){
- strWaiting+="ԃ"+iWait+";";
- }
- objViewAjax.innerHTML = strWaiting;
- (async () => {
- formData.append("file", objAjax.files[0]);
- formData.append("params", params);
- resp = await fetch('/ajax/uploadFile.php', {method: "POST", body: formData});
- try {
- console.log(resp);
- var jobj = await resp.json();
- }catch(e){
- jobj = {};
- }
- if(typeof jobj.error !== 'undefined'){
- if(jobj.error==0){
- if(typeof jobj.message !== 'undefined'){
- setTimeout(function (){
- alert("info:"+jobj.message);
- infoUpload=1;
- if(typeof jobj.html !== 'undefined'){
- objViewAjax.innerHTML = jobj.html;
- }
- }, 1000);
- }else{
- }
- }else if(typeof jobj.message !== 'undefined'){
- alert(jobj.message);
- infoUpload=2;
- objViewAjax.innerHTML = strBefore;
- }else{
- alert("undefined error");
- infoUpload=3;
- objViewAjax.innerHTML = strBefore;
- }
- }else{
- alert("please try again");
- infoUpload=4;
- objViewAjax.innerHTML = strBefore;
- }
- })();
- }
- catch(err) {
- alert("undefined error");
- infoUpload=3;
- objViewAjax.innerHTML = strBefore;
- }
- finally{
- if(infoUpload==0){
- alert("upload success");
- }
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement