Advertisement
carloslitho

form

May 27th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.63 KB | None | 0 0
  1. <?php defined("SYSPATH") or die("No direct script access.") ?>
  2. <script type="text/javascript" src="<?= url::file("lib/swfobject.js") ?>"></script>
  3. <script type="text/javascript" src="<?= url::file("lib/uploadify/jquery.uploadify.min.js") ?>"></script>
  4. <script type="text/javascript">
  5.   <? $flash_minimum_version = "9.0.24" ?>
  6.   var success_count = 0;
  7.   var error_count = 0;
  8.   var updating = 0;
  9.   $("#g-add-photos-canvas").ready(function () {
  10.     var update_status = function() {
  11.       if (updating) {
  12.         // poor man's mutex
  13.         setTimeout(function() { update_status(); }, 500);
  14.       }
  15.       updating = 1;
  16.       $.get("<?= url::site("uploader/status/_S/_E") ?>"
  17.             .replace("_S", success_count).replace("_E", error_count),
  18.           function(data) {
  19.             $("#g-add-photos-status-message").html(data);
  20.             updating = 0;
  21.           });
  22.     };
  23.  
  24.     if (swfobject.hasFlashPlayerVersion("<?= $flash_minimum_version ?>")) {
  25.       $("#g-uploadify").uploadify({
  26.         width: 298,
  27.         height: 32,
  28.         uploader: "<?= url::file("lib/uploadify/uploadify.swf.php") ?>",
  29.         script: "<?= url::site("uploader/add_photo/{$album->id}") ?>",
  30.         scriptData: <?= json_encode($script_data) ?>,
  31.         fileExt: "<?= implode(";", $extensions) ?>",
  32.         fileDesc: <?= t("Photos and movies")->for_js() ?>,
  33.         cancelImg: "<?= url::file("lib/uploadify/cancel.png") ?>",
  34.         simUploadLimit: <?= $simultaneous_upload_limit ?>,
  35.         sizeLimit: <?= $size_limit_bytes ?>,
  36.         wmode: "transparent",
  37.         hideButton: true, /* should be true */
  38.         auto: true,
  39.         multi: true,
  40.         onAllComplete: function(filesUploaded, errors, allbytesLoaded, speed) {
  41.           $("#g-upload-cancel-all")
  42.             .addClass("ui-state-disabled")
  43.             .attr("disabled", "disabled");
  44.           $("#g-upload-done")
  45.             .removeClass("ui-state-disabled")
  46.             .attr("disabled", null);
  47.           return true;
  48.         },
  49.         onClearQueue: function(event) {
  50.           $("#g-upload-cancel-all")
  51.             .addClass("ui-state-disabled")
  52.             .attr("disabled", "disabled");
  53.           $("#g-upload-done")
  54.             .removeClass("ui-state-disabled")
  55.             .attr("disabled", null);
  56.           return true;
  57.         },
  58.         onComplete: function(event, queueID, fileObj, response, data) {
  59.           var re = /^error: (.*)$/i;
  60.           var msg = re.exec(response);
  61.           $("#g-add-photos-status ul").append(
  62.             "<li id=\"q" + queueID + "\" class=\"g-success\"><span></span> - " +
  63.             <?= t("Completed")->for_js() ?> + "</li>");
  64.           $("#g-add-photos-status li#q" + queueID + " span").text(fileObj.name);
  65.           setTimeout(function() { $("#q" + queueID).slideUp("slow").remove() }, 5000);
  66.           success_count++;
  67.           update_status();
  68.           return true;
  69.         },
  70.         onError: function(event, queueID, fileObj, errorObj) {
  71.           if (errorObj.type == "HTTP") {
  72.             if (errorObj.info == "500") {
  73.               error_msg = <?= t("Unable to process this photo")->for_js() ?>;
  74.             } else if (errorObj.info == "404") {
  75.               error_msg = <?= t("The upload script was not found")->for_js() ?>;
  76.             } else if (errorObj.info == "400") {
  77.               error_msg = <?= t("This photo is too large (max is %size bytes)",
  78.                                 array("size" => $size_limit))->for_js() ?>;
  79.             } else {
  80.               msg += (<?= t("Server error: __INFO__ (__TYPE__)")->for_js() ?>
  81.                 .replace("__INFO__", errorObj.info)
  82.                 .replace("__TYPE__", errorObj.type));
  83.             }
  84.           } else if (errorObj.type == "File Size") {
  85.             error_msg = <?= t("This photo is too large (max is %size bytes)",
  86.                               array("size" => $size_limit))->for_js() ?>;
  87.           } else {
  88.             error_msg = <?= t("Server error: __INFO__ (__TYPE__)")->for_js() ?>
  89.                         .replace("__INFO__", errorObj.info)
  90.                         .replace("__TYPE__", errorObj.type);
  91.           }
  92.           msg = " - <a target=\"_blank\" href=\"http://codex.galleryproject.org/Gallery3:Troubleshooting:Uploading\">" +
  93.             error_msg + "</a>";
  94.  
  95.           $("#g-add-photos-status ul").append(
  96.             "<li id=\"q" + queueID + "\" class=\"g-error\"><span></span>" + msg + "</li>");
  97.           $("#g-add-photos-status li#q" + queueID + " span").text(fileObj.name);
  98.           $("#g-uploadify").uploadifyCancel(queueID);
  99.           error_count++;
  100.           update_status();
  101.         },
  102.         onSelect: function(event) {
  103.           if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) {
  104.             $("#g-upload-cancel-all")
  105.               .removeClass("ui-state-disabled")
  106.               .attr("disabled", null);
  107.             $("#g-upload-done")
  108.               .addClass("ui-state-disabled")
  109.               .attr("disabled", "disabled");
  110.           }
  111.           return true;
  112.         }
  113.       });
  114.     } else {
  115.       $(".requires-flash").hide();
  116.       $(".no-flash").show();
  117.     }
  118.   });
  119. </script>
  120.  
  121. <div class="requires-flash">
  122.   <? if ($suhosin_session_encrypt || (identity::active_user()->admin && !$movies_allowed)): ?>
  123.   <div class="g-message-block g-info">
  124.     <? if ($suhosin_session_encrypt): ?>
  125.     <p class="g-error">
  126.       <?= t("Error: your server is configured to use the <a href=\"%encrypt_url\"><code>suhosin.session.encrypt</code></a> setting from <a href=\"%suhosin_url\">Suhosin</a>.  You must disable this setting to upload photos.",
  127.           array("encrypt_url" => "http://www.hardened-php.net/suhosin/configuration.html#suhosin.session.encrypt",
  128.       "suhosin_url" => "http://www.hardened-php.net/suhosin/")) ?>
  129.     </p>
  130.     <? endif ?>
  131.  
  132.    
  133.   </div>
  134.   <? endif ?>
  135.  
  136.  
  137.  
  138.   <div id="g-add-photos-canvas">
  139.     <button id="g-add-photos-button" class="g-button ui-state-default ui-corner-all" href="#"><?= t("Select photos (%size max per file)...", array("size" => $size_limit)) ?></button>
  140.     <span id="g-uploadify"></span>
  141.   </div>
  142.   <div id="g-add-photos-status">
  143.     <ul id="g-action-status" class="g-message-block">
  144.     </ul>
  145.   </div>
  146. </div>
  147.  
  148. <div class="no-flash" style="display: none">
  149.   <p>
  150.     <?= t("Your browser must have Adobe Flash Player version %flash_minimum_version or greater installed to use this feature.", array("flash_minimum_version" => $flash_minimum_version)) ?>
  151.   </p>
  152.   <a href="http://www.adobe.com/go/getflashplayer">
  153.     <img src="<?= request::protocol() ?>://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
  154.          alt=<?= t("Get Adobe Flash Player")->for_js() ?> />
  155.   </a>
  156. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement