Advertisement
Guest User

Untitled

a guest
Jan 5th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.25 KB | None | 0 0
  1.     //Validation formulaire et affichage du message succes ou erreur dans la facebox.
  2.     echo "<script type=\"text/javascript\">\n"
  3.     . "$(\"#form_upload\").submit(function(e)\n"
  4.     . "{\n"      
  5.     . "    var formObj = $(this);\n"
  6.     . "    var formURL = formObj.attr(\"action\");\n"
  7.     . "    var formData = new FormData(this);\n"
  8.     . "    $.ajax({\n"
  9.     . "        url: $('index.php?file=Forum&amp;nuked_nude=index&amp;op=up_img_confirm'),\n"
  10.     . "    type: 'POST',\n"
  11.     . "        data:  formData,\n"
  12.     . "    mimeType:\"multipart/form-data\",\n"
  13.     . "    contentType: false,\n"
  14.     . "        cache: false,\n"
  15.     . "        processData:false,\n"
  16.     . "    success: function (up_img_confirm)\n"
  17.     . "    {\n"
  18.     . " jQuery.facebox(up_img_confirm);\n"
  19.     . "    },\n"
  20.     . "     error: function (up_img_confirm)\n"  
  21.     . "     {\n"
  22.     . "  $.facebox('Il y a une erreur.');\n"
  23.     . "     }\n"          
  24.     . "    });\n"
  25.     . "    e.preventDefault();\n"  //Prevent Default action.
  26.     . "    e.unbind();\n"
  27.     . "});\n"  
  28.     . "$(\"index.php?file=Forum&amp;nuked_nude=index&amp;op=up_img_confirm\").submit()\n" //Submit the form;
  29.     . "</script>\n";
  30.  
  31.     if ($image != "") {
  32.         $url_image = "upload/ImageForum/" . $image;
  33.     } else {
  34.         $url_image = "";
  35.     }
  36.  
  37.     echo "<div><form method=\"post\" id=\"form_upload\" action=\"index.php?file=Forum&amp;nuked_nude=index&amp;op=up_img_confirm\" enctype=\"multipart/form-data\">\n"
  38.     . "<table  style=\"margin-left: auto;margin-right: auto;text-align: left;\">\n"
  39.     . "<div style=\"text-align: center;\"><tr><td>Saisissez une URL:</td></tr></div>\n"
  40.     . "<tr><td><b>" . _URLIMG . " : </b><input id=\"url_img\" type=\"text\" name=\"image\" value=\"" . $url_image . "\" size=\"39\" /> <input type=\"button\" name=\"ok\" value=\"OK\" onclick=\"ajout_up_img('" . $textarea . "');parent.close();\" /></td></tr>\n"
  41.     . "<div style=\"text-align: center;\"><tr><td>Ou cliquez sur Parcourir pour ajouter une image (6Mo max):</td></tr></div>\n"
  42.     . "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"819200\" />\n"
  43.     . "<tr><td><b>" . _UPIMG . " : </b><input type=\"file\" name=\"fichiernom\" size=\"25\" /> <input type=\"submit\" name=\"Submit\" value=\"" . _SEND . "\" /></td></tr>\n"
  44.     . "<tr><input type=\"hidden\" name=\"textarea\" value=\"" . $textarea . "\" /></td></tr></table></form>\n";
  45.  
  46. }
  47.  // affiche message de confirmation de l'upload.
  48.  
  49. function up_img_confirm()
  50. {
  51.  
  52.     global $nuked, $theme, $bgcolor3, $language, $bgcolor2, $textarea, $image;
  53.     translate("lang/" . $language . ".lang.php");
  54.  
  55.     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
  56.     . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n"
  57.     . "<head><title>" . _BSCREEN  . "</title>\n"
  58.     . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n"
  59.     . "<meta http-equiv=\"content-style-type\" content=\"text/css\" />\n"
  60.     . "<link title=\"style\" type=\"text/css\" rel=\"stylesheet\" href=\"themes/" . $theme . "/style.css\" /></head>\n"
  61.     . "<script type=\"text/javascript\" src=\"js/bbcode.js\"></script>\n";
  62.    
  63.     if (isset ($_FILES['fichiernom']))
  64. {
  65.  
  66.     if ($_FILES['fichiernom']['error'] > 0)
  67.     {
  68.         if ($_FILES['fichiernom']['error'] == UPLOAD_ERR_NO_FILE)
  69.         {
  70.             echo "<table width=\"392\" border=\"0\" align=\"center\"><tr><td width=\"32\"><img src=\"images/icones/erreur32px.png\" width=\"32\" height=\"32\" /></td><td width=\"334\"><strong><font color='red'>Pas de fichier sélectionné</font></strong></td></tr></table>";
  71.         }
  72.  
  73.         elseif ($_FILES['fichiernom']['error'] == UPLOAD_ERR_FORM_SIZE)
  74.         {
  75.             echo "<table width=\"392\" border=\"0\" align=\"center\"><tr><td width=\"32\"><img src=\"images/icones/erreur32px.png\" width=\"32\" height=\"32\" /></td><td width=\"334\"><strong><font color='red'>" . _UPLOAD_ERR_FORM_SIZE . "</font></strong></td></tr></table>";
  76.         }
  77.         elseif ($_FILES['fichiernom']['error'] == UPLOAD_ERR_EXTENSION)
  78.         {
  79.             echo "mauvaise extension";
  80.         }
  81.  
  82.         else
  83.         {
  84.             echo "ERREUR INCONNUE";
  85.         }
  86.     }
  87.     if ($_FILES['fichiernom' ]['error'] == 0)
  88.     {
  89.         // Testons si l'extension est autorisée
  90.         $infosfichier = pathinfo($_FILES['fichiernom']['name']);
  91.         $extension_upload = $infosfichier['extension'];
  92.         $extensions_autorisees = array('jpg', 'jpeg', 'gif', 'png', 'JPG');
  93.         $filesize = $_FILES['fichiernom']['size'] / 819200;
  94.         $name = $infosfichier['filename'];
  95.         $file = '' .time(). '.' .$extension_upload;
  96.         $upload = move_uploaded_file($_FILES['fichiernom']['tmp_name'], 'upload/ImageForum/' . $file);
  97.        
  98.        
  99.             if ($upload == true)
  100.             {
  101.                 echo "<table width=\"350\" border=\"0\" align=\"center\"><tr><td width=\"32\"><img src=\"images/icones/valider32px.png\" width=\"32\" height=\"32\" /></td><td width=\"334\"><strong><font color='green'>" . _UPLOAD_OK . "</font></strong></td></tr></table>";
  102.                 redirect("index.php?file=Forum&nuked_nude=index&op=up_img&textarea=" . $textarea . "&image=" . $file, 3);  
  103.             }
  104.            
  105.     }
  106.     echo "<div style=\"text-align: center;\"><a href=\"#\" onclick=\"javascript:window.close()\"><b>" . _CLOSEWINDOW . "</b></a><br /></div></div></body></html>";
  107.     }
  108. }
  109. // Fin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement