ImageManager
[ class tree: ImageManager ] [ index: ImageManager ] [ all elements ]

Source for file editor.php

Documentation is available at editor.php

  1. <?php
  2. /**
  3.  * The PHP Image Editor user interface.
  4.  * @author $Author: Wei Zhuo $
  5.  * @author $Author: Paul Moers <mail@saulmade.nl> $ - watermarking and replace code + several small enhancements <http://fckplugins.saulmade.nl>
  6.  * @version $Id: editor.php 26 2004-03-31 02:35:21Z Wei Zhuo $
  7.  * @package ImageManager
  8.  */
  9.  
  10. require_once('config.inc.php');
  11. require_once('Classes/ImageManager.php');
  12. require_once('Classes/ImageEditor.php');
  13.  
  14. $manager new ImageManager($IMConfig);
  15. $editor new ImageEditor($manager$IMConfig);
  16.  
  17. $img_url Security::remove_XSS($_GET['img']);
  18. //@TODO: the following path should be checked using the Security::check_rel_path() method but for this we need to know under which dir this path lives
  19. $img_dir dirname($_GET['img'])
  20.  
  21. ?>
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  23.  
  24. <html>
  25. <head>
  26. <title>edit image</title>
  27. <link href="assets/editor.css" rel="stylesheet" type="text/css" />    
  28.  
  29. <script type="text/javascript">
  30. /*<![CDATA[*/
  31.  
  32.     window.resizeTo(673, 531);
  33.  
  34.     // find language object
  35.     if(window.opener)
  36.     {
  37.         if (window.opener.I18N)
  38.         {
  39.             I18N = window.opener.I18N;
  40.         }
  41.         // direct edit
  42.         else if (window.opener.ImageManager && window.opener.ImageManager.I18N)
  43.         {
  44.             I18N = window.opener.ImageManager.I18N;
  45.         }
  46.     }
  47.  
  48.     // language object not found?
  49.     if (!this.I18N)
  50.     {
  51.         // Read it now - copy in next script block
  52.         document.write('<script type="text/javascript" src="lang/' + window.opener._editor_lang + '.js"><\/script>');
  53.     }
  54.  
  55. /*]]>*/
  56. </script>
  57.  
  58. <script type="text/javascript">
  59. /*<![CDATA[*/
  60.  
  61.     // now copy the language object of the included script - needed a seperate new script block to be able to do so
  62.     if (!this.I18N)
  63.     {
  64.         I18N = this.ImageManager.I18N;
  65.     }
  66.  
  67. /*]]>*/
  68. </script>
  69.  
  70. <script type="text/javascript" src="assets/slider.js"></script>
  71. <script type="text/javascript" src="assets/popup.js"></script>
  72. <script type="text/javascript" src="assets/editor.js"></script>
  73.  
  74. </head>
  75.  
  76. <body>
  77. <div id="indicator">
  78. <img src="img/spacer.gif" id="indicator_image" height="20" width="20" alt="" />
  79. </div>
  80. <div id="tools">
  81.     <div id="tools_replace" style="display:none;">
  82.         <div id="tool_inputs">
  83.         <table>
  84.         <tr>
  85.             <td>
  86.                 <form action="editorFrame.php?img=<?php echo $img_url?>&action=replace" target='editor' id="uploadForm" method="post" enctype="multipart/form-data">
  87.                     &nbsp;<input type="file" name="upload" id="upload"/>
  88.                     <input type="hidden" name="dir" id="dir" value="<?php echo $img_dir?>" />
  89.                 </form>
  90.             </td>
  91.             <td>
  92.                 <img src="img/div.gif" height="30" width="2" class="div" alt="|" />
  93.             </td>
  94.         </tr>
  95.         </table>
  96.         </div>    
  97.         <a href="javascript: doUpload(); document.getElementById('uploadForm').submit();" class="buttons" title="OK"><img src="img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
  98.     </div>    
  99.     <div id="tools_watermark" style="display:none;">
  100.         <div id="watermarkControls">
  101.             <div id="tool_inputs">
  102.                 <label for="watermark_file">Watermark</label>: <select name="watermark_file" id="watermark_file" style="vertical-align: middle;" onchange="changeWatermark(this)"><!-- populated in editorFrame.php --></select>
  103.  
  104.                 <label style="margin-left: 15px;">Opacity:</label>
  105.                 <table style="display: inline; vertical-align: middle;" cellpadding="0" cellspacing="0">
  106.                     <tr>
  107.                     <td>
  108.                         <div id="slidercasingwatermark" class="slidercasing"> 
  109.                     <div id="slidertrackwatermark" class="slidertrack" style="width:100px"><img src="img/spacer.gif" width="1" height="1" border="0" alt="track"></div>
  110.                 <div id="sliderbarwatermark" class="sliderbar" style="left:100px" onmousedown="captureStart('watermark');"><img src="img/spacer.gif" width="1" height="1" border="0" alt="track"></div>
  111.                 </div>    
  112.                     </td>
  113.                     </tr>
  114.                 </table>                
  115.                 <input type="text" id="sliderfieldwatermark" onchange="updateSlider(this.value, 'watermark')" style="width: 2em;" value="100"/>
  116.                 <table style="display: inline; vertical-align: bottom; margin: 0px 5px 0px 20px;" cellpadding="0" cellspacing="0">
  117.                     <tr>
  118.                     <td>
  119.                         <div style="cursor: pointer; cursor: hand; background-image: url(img/watermarkAlign.gif); vertical-align: middle; width: 24px; height: 24px; position: relative;">
  120.                             <div style="position: absolute; left: 1px; top: 1px; width: 4px; height: 4px; overflow: hidden;" onmouseover="this.style.backgroundColor='#BE3545'" onmouseout="this.style.backgroundColor='transparent'" onclick="moveWatermark(0, 0);"></div>
  121.                             <div style="position: absolute; left: 10px; top: 1px; width: 4px; height: 4px; overflow: hidden;" onmouseover="this.style.backgroundColor='#BE3545'" onmouseout="this.style.backgroundColor='transparent'" onclick="moveWatermark(0.5, 0);"></div>
  122.                             <div style="position: absolute; left: 19px; top: 1px; width: 4px; height: 4px; overflow: hidden;" onmouseover="this.style.backgroundColor='#BE3545'" onmouseout="this.style.backgroundColor='transparent'" onclick="moveWatermark(1, 0);"></div>
  123.                             <div style="position: absolute; left: 1px; top: 10px; width: 4px; height: 4px; overflow: hidden;" onmouseover="this.style.backgroundColor='#BE3545'" onmouseout="this.style.backgroundColor='transparent'" onclick="moveWatermark(0, 0.5);".5></div>
  124.                             <div style="position: absolute; left: 10px; top: 10px; width: 4px; height: 4px; overflow: hidden;" onmouseover="this.style.backgroundColor='#BE3545'" onmouseout="this.style.backgroundColor='transparent'" onclick="moveWatermark(0.5, 0.5);"></div>
  125.                             <div style="position: absolute; left: 19px; top: 10px; width: 4px; height: 4px; overflow: hidden;" onmouseover="this.style.backgroundColor='#BE3545'" onmouseout="this.style.backgroundColor='transparent'" onclick="moveWatermark(1, 0.5);"></div>
  126.                             <div style="position: absolute; left: 1px; top: 19px; width: 4px; height: 4px; overflow: hidden;" onmouseover="this.style.backgroundColor='#BE3545'" onmouseout="this.style.backgroundColor='transparent'" onclick="moveWatermark(0, 1);"></div>
  127.                             <div style="position: absolute; left: 10px; top: 19px; width: 4px; height: 4px; overflow: hidden;" onmouseover="this.style.backgroundColor='#BE3545'" onmouseout="this.style.backgroundColor='transparent'" onclick="moveWatermark(0.5, 1);"></div>
  128.                             <div style="position: absolute; left: 19px; top: 19px; width: 4px; height: 4px; overflow: hidden;" onmouseover="this.style.backgroundColor='#BE3545'" onmouseout="this.style.backgroundColor='transparent'" onclick="moveWatermark(1, 1);"></div>
  129.                         </div>
  130.                     </td>
  131.                     </tr>
  132.                 </table>        
  133.                 <table style="display: inline; vertical-align: bottom; margin: 0px 10px 0px 5px;" cellpadding="0" cellspacing="0">
  134.                     <tr>
  135.                     <td>
  136.                         <div style="cursor: pointer; cursor: hand; background-image: url(img/watermarkColor.gif); vertical-align: middle; width: 18px; height: 26px; position: relative;">
  137.                             <div style="position: absolute; left: 1px; top: 1px; width: 6px; height: 3px; overflow: hidden;" onclick="colorWatermarkBG('');"></div>
  138.                             <div style="position: absolute; left: 11px; top: 1px; width: 6px; height: 3px; overflow: hidden;" onclick="colorWatermarkBG('grid');"></div>
  139.                             <div style="position: absolute; left: 1px; top: 8px; width: 6px; height: 3px; overflow: hidden;" onmouseover="this.style.backgroundColor='#FFFFFF'" onmouseout="this.style.backgroundColor='transparent'" onclick="colorWatermarkBG('#FFFFFF');"></div>
  140.                             <div style="position: absolute; left: 11px; top: 8px; width: 6px; height: 3px; overflow: hidden;" onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='transparent'" onclick="colorWatermarkBG('#000000');"></div>
  141.                             <div style="position: absolute; left: 1px; top: 15px; width: 6px; height: 3px; overflow: hidden;" onmouseover="this.style.backgroundColor='#FF0000'" onmouseout="this.style.backgroundColor='transparent'" onclick="colorWatermarkBG('#FF0000');"></div>
  142.                             <div style="position: absolute; left: 11px; top: 15px; width: 6px; height: 3px; overflow: hidden;" onmouseover="this.style.backgroundColor='#00FF00'" onmouseout="this.style.backgroundColor='transparent'" onclick="colorWatermarkBG('#00FF00');"></div>
  143.                             <div style="position: absolute; left: 1px; top: 22px; width: 6px; height: 3px; overflow: hidden;" onmouseover="this.style.backgroundColor='#0000FF'" onmouseout="this.style.backgroundColor='transparent'" onclick="colorWatermarkBG('#0000FF');"></div>
  144.                             <div style="position: absolute; left: 11px; top: 22px; width: 6px; height: 3px; overflow: hidden;" onmouseover="this.style.backgroundColor='#FFFF00'" onmouseout="this.style.backgroundColor='transparent'" onclick="colorWatermarkBG('#FFFF00');"></div>
  145.                         </div>
  146.                     </td>
  147.                     </tr>
  148.                 </table>        
  149.                 <img src="img/div.gif" height="30" width="2" class="div" alt="|" />
  150.             </div>    
  151.             <a href="javascript: editor.doSubmit('watermark');" class="buttons" title="OK"><img src="img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
  152.         </div>    
  153.         <div id="watermarkMessage" style="display: none;">
  154.             <script>document.write("<div id=\"tool_inputs\" style=\"text-align: center; width: 90%; color: #474767;\"><label style=\" font-weight: bold; letter-spacing: 3px;\">" + i18n("Watermarking is disabled.") + "</label><br /><label>" + i18n("No watermarks were found or all watermarks are to big for the target image.") + "</label></div>");</script>
  155.         </div>    
  156.     </div>    
  157.     <div id="tools_crop" style="display:none;">
  158.         <div id="tool_inputs">
  159.             <label for="cx">Start X:</label><input type="text" id="cx"  class="textInput" onchange="updateMarker('crop')"/>
  160.             <label for="cy">Start Y:</label><input type="text" id="cy" class="textInput" onchange="updateMarker('crop')"/>
  161.             <label for="cw">Width:</label><input type="text" id="cw" class="textInput" onchange="updateMarker('crop')"/>
  162.             <label for="ch">Height:</label><input type="text" id="ch" class="textInput" onchange="updateMarker('crop')"/>
  163.             <img src="img/div.gif" height="30" width="2" class="div" alt="|" />
  164.         </div>    
  165.         <a href="javascript: editor.doSubmit('crop');" class="buttons" title="OK"><img src="img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
  166.         <a href="javascript: editor.reset();" class="buttons" title="Cancel"><img src="img/btn_cancel.gif" height="30" width="30" alt="Cancel" /></a>        
  167.     </div>    
  168.     <div id="tools_scale" style="display:none;">
  169.         <div id="tool_inputs">
  170.             <label for="sw">Width:</label><input type="text" id="sw" class="textInput" onchange="checkConstrains('width')"/>
  171.             <a href="javascript:toggleConstraints();" title="Lock"><img src="img/islocked2.gif" id="scaleConstImg" height="14" width="8" alt="Lock" class="div" /></a><label for="sh">Height:</label>
  172.             <input type="text" id="sh" class="textInput" onchange="checkConstrains('height')"/>
  173.             <input type="checkbox" id="constProp" value="1" checked="checked" onclick="toggleConstraints()"/>
  174.             <label for="constProp">Constrain Proportions</label>
  175.             <img src="img/div.gif" height="30" width="2" class="div" alt="|" />
  176.         </div>    
  177.         <a href="javascript: editor.doSubmit('scale');" class="buttons" title="OK"><img src="img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
  178.         <a href="javascript: editor.reset();" class="buttons" title="Cancel"><img src="img/btn_cancel.gif" height="30" width="30" alt="Cancel" /></a>        
  179.     </div>    
  180.     <div id="tools_rotate" style="display:none;">
  181.         <div id="tool_inputs">
  182.             <select id="flip" name="flip" style="margin-left: 10px; vertical-align: middle;">
  183.               <option selected>Flip Image</option>
  184.               <option>-----------------</option>
  185.               <option value="hoz">Flip Horizontal</option>
  186.               <option value="ver">Flip Virtical</option>
  187.          </select>
  188.             <select name="rotate" onchange="rotatePreset(this)" style="margin-left: 20px; vertical-align: middle;">
  189.               <option selected>Rotate Image</option>
  190.               <option>-----------------</option>
  191.  
  192.               <option value="180">Rotate 180 &deg;</option>
  193.               <option value="90">Rotate 90 &deg; CW</option>
  194.               <option value="-90">Rotate 90 &deg; CCW</option>
  195.          </select>
  196.             <label for="ra">Angle:</label><input type="text" id="ra" class="textInput" />
  197.             <img src="img/div.gif" height="30" width="2" class="div" alt="|" />
  198.         </div>    
  199.         <a href="javascript: editor.doSubmit('rotate');" class="buttons" title="OK"><img src="img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
  200.     </div>        
  201.     <div id="tools_measure" style="display:none;">
  202.         <div id="tool_inputs">
  203.             <label id="xLabel">X:<input type="text" class="measureStats" id="sx" disabled /></label>
  204.             <label id="yLabel">Y:<input type="text" class="measureStats" id="sy" disabled /></label>
  205.             <img src="img/div.gif" height="30" width="2" class="div" alt="|" />
  206.             <label id="widthLabel">W:<input type="text" class="measureStats" id="mw" disabled /></label>
  207.             <label id="heightLabel">H:<input type="text" class="measureStats" id="mh" disabled /></label>
  208.             <img src="img/div.gif" height="30" width="2" class="div" alt="|" />
  209.             <label id="angleLabel">A:<input type="text" class="measureStats" id="ma" disabled /></label>
  210.             <label id="diagonalLabel">D:<input type="text" class="measureStats" id="md" disabled /></label>
  211.             <img src="img/div.gif" height="30" width="2" class="div" alt="|" />
  212.             <button type="button" onclick="editor.reset();" >Clear</button>
  213.  
  214.             <script>
  215.                 document.getElementById("xLabel").title = i18n("start x coordinate");
  216.                 document.getElementById("yLabel").title = i18n("start y coordinate");
  217.                 document.getElementById("widthLabel").title = i18n("width");
  218.                 document.getElementById("heightLabel").title = i18n("height");
  219.                 document.getElementById("angleLabel").title = i18n("angle");
  220.                 document.getElementById("diagonalLabel").title = i18n("diagonal length");
  221.             </script>
  222.         </div>    
  223.     </div>
  224.     <div id="tools_save" style="display:none;">
  225.  
  226. <?php if($IMConfig['demo'!= true?>
  227.  
  228.         <div id="tool_inputs">
  229.  
  230.     <?php if($IMConfig['allow_newFileName'== true?>
  231.             <label for="save_filename">Filename:</label><input type="text" id="save_filename" value="<?php if($IMConfig['allow_overwrite'== false)echo $editor->getDefaultSaveFile()}elseecho basename($_GET['img'])?>" />
  232.     <?php }else?>
  233.             <input type="hidden" id="save_filename" value="<?php echo basename($_GET['img'])?>" />
  234.     <?php ?>
  235.  
  236.     <?php
  237.     $pos strrpos($_GET['img']".");
  238.     $ext substr($_GET['img']$pos 1);
  239.     ?>
  240.             <select name="format" id="save_format" style="margin-left: 10px; vertical-align: middle; <?php if($IMConfig['allow_newFileName'!= true && $ext != "jpg" && $ext != "jpeg"{echo "display: none;";?>" onchange="updateFormat(this)">
  241.             <option value="" selected>Image Format</option>
  242.             <option value="">---------------------</option>
  243.             <option value="jpeg,85">JPEG High</option>
  244.             <option value="jpeg,60">JPEG Medium</option>
  245.             <option value="jpeg,35">JPEG Low</option>
  246.             <?php if($IMConfig['allow_newFileName'== true)?>
  247.             <option value="png">PNG</option>
  248.             <?php    if($editor->isGDGIFAble(!= -1?>
  249.             <option value="gif">GIF</option>
  250.             <?php    ?>
  251.             <?php ?>
  252.             </select>
  253.  
  254.             <label>Quality:</label>
  255.             <table style="display: inline; vertical-align: middle;" cellpadding="0" cellspacing="0">
  256.                 <tr>
  257.                 <td>
  258.                     <div id="slidercasingsave" class="slidercasing"> 
  259.                 <div id="slidertracksave" class="slidertrack" style="width:100px"><img src="img/spacer.gif" width="1" height="1" border="0" alt="track"></div>
  260.             <div id="sliderbarsave" class="sliderbar" style="left:85px" onmousedown="captureStart('save');"><img src="img/spacer.gif" width="1" height="1" border="0" alt="track"></div>
  261.             </div>    
  262.                 </td>
  263.                 </tr>
  264.             </table>                
  265.             <input type="text" id="sliderfieldsave" onchange="updateSlider(this.value, 'save')" style="width: 2em;" value="85"/>
  266.             <img src="img/div.gif" height="30" width="2" class="div" alt="|" />
  267.         </div>    
  268.         <a href="javascript: editor.doSubmit('save');" class="buttons" title="OK"><img src="img/btn_ok.gif" height="30" width="30" alt="OK" /></a>
  269.  
  270.     <?php }else?>
  271.  
  272.         <div id="tool_inputs" style="text-align: center; width: 90%; font-size: 150%; font-weight: bold; letter-spacing: 3px; color: #474767;">
  273.             <label>Demo</label>
  274.         </div>    
  275.  
  276.     <?php ?>
  277.  
  278.     </div>    
  279. </div>
  280. <div id="toolbar">
  281.     <div id="buttons">
  282.  
  283.         <a href="javascript:toggle('replace')" id="icon_replace" title="Replace" <?php if($IMConfig['allow_replace'== falseecho "style=\"display: none;\""?> ><img src="img/replace.gif" height="20" width="20" alt="Replace" /><span>Replace</span></a>
  284.         <a href="javascript:toggle('watermark')" id="icon_watermark" title="Watermark" <?php if(empty($IMConfig['watermarks'])) echo "style=\"display: none;\""?> ><img src="img/watermark.gif" height="20" width="20" alt="Watermark" /><span>Watermark</span></a>
  285.         <a href="javascript:toggle('crop')" id="icon_crop" title="Crop"><img src="img/crop.gif" height="20" width="20" alt="Crop" /><span>Crop</span></a>
  286.         <a href="javascript:toggle('scale')" id="icon_scale" title="Resize"><img src="img/scale.gif" height="20" width="20" alt="Resize" /><span>Resize</span></a>
  287.         <a href="javascript:toggle('rotate')" id="icon_rotate" title="Rotate"><img src="img/rotate.gif" height="20" width="20" alt="Rotate" /><span>Rotate</span></a>
  288.         <a href="javascript:toggle('measure')" id="icon_measure" title="Measure"><img src="img/measure.gif" height="20" width="20" alt="Measure" /><span>Measure</span></a>
  289.         <a href="javascript: toggleMarker();" title="Marker"><img id="markerImg" src="img/t_black.gif" height="20" width="20" alt="Marker" /><span>Marker</span></a>
  290.         <a href="javascript:toggle('save')" id="icon_save" title="Save"><img src="img/save.gif" height="20" width="20" alt="Save" /><span>Save</span></a>
  291.     </div>
  292. </div>
  293. <div id="contents">
  294. <div id="messages" style="display: none;"><span id="message"></span><img SRC="img/dots.gif" width="22" height="12" alt="..." /></div>
  295. <iframe src="editorFrame.php?img=<?php if(isset($_GET['img'])) echo rawurlencode(htmlentities($_GET['img']))?>" name="editor" id="editor" scrolling="auto" title="Image Editor" frameborder="0"></iframe>
  296. </div>
  297. <div id="bottom"></div>
  298. </body>
  299. </html>

Documentation generated on Thu, 12 Jun 2008 13:22:16 -0500 by phpDocumentor 1.4.1