We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51347
    • 82 Posts
    i read today my 22mb error-log of my Site (MODx Revolution 2.5.4). And get everytime the same error:

    [2017-01-23 14:14:17] (ERROR @ /.../core/cache/includes/elements/modsnippet/123.include.cache.php : 29) PHP warning: copy(): The first argument to copy() function cannot be a directory
    


    123.include.cache.php = ist the Snippet "RezImgCrop"


    What is wrong here?

    <?php
    /**
     * RezImgCrop
     * Copyright 2011 by Artdevue.com  <[email protected]>
     * Arguings at a forum http://community.modx-cms.ru/
     * @package rezimgcrop
     */
    /**
     * RezImgCrop
     * A dynamic form processing Snippet for MODx Revolution 2.0.
     *
     * @package rezimgcrop
     */
    
    $output = trim($input);
    $serve = $modx->getOption('base_path');
    $opt = explode(',',$options);
    if (count($opt) >= 1) {
      $trans = array("-"=>"", "x"=>"", ","=>"");
      $m_name = strip_tags(strtr($options, $trans));
      $images_name = basename($output);
      $images_dir = dirname($output);
      $imagprev = $images_dir{0} == '/' ? '' : '/';
      $images_dir = $imagprev.$images_dir;
      $dir_new = $images_dir.'/rezcrop/'; 
      if (!file_exists($serve.$dir_new.$m_name.'_'.$images_name)) {    
        if(!file_exists($serve.$dir_new)) mkdir($serve.$dir_new, 0777);
        $newimg = $dir_new.$m_name.'_'.$images_name;
        if (!copy($serve.$imagprev.$output, $serve.$newimg)) {
          return $output;
    }
        $col = count($opt)-1;
        for ($x=0; $x<=$col;){
          $frc = explode('-',$opt[$x]);
          $par = explode('x',$frc[1]);
          if($frc[0] == 'r') {
            if(!$par[1]){
                list($w, $h) = getimagesize($serve.$newimg);
                if ($w < $h) {
                    $parnol = $par[0];
                    $par[0] = '';
                    $par[1] = $parnol;
                }
            }
    	$modx->runSnippet('RezImg',array(
       'file_input' => $serve.$newimg,
    	  'file_output' => $serve.$newimg,
    	  'w_o' => $par[0],
    	  'h_o' => $par[1]
    ));
          }
          if($frc[0] == 'c') {
    	list($w, $h) = getimagesize($serve.$newimg);
        		$ym = $xm = 0;
        		$ym = ($h - $par[1])/2;
                $xm = ($w - $par[0])/2;
    	$modx->runSnippet('CropImg',array(
       'file_input' => $serve.$newimg,
    	  'file_output' => $serve.$newimg,
    	  'crop' => array($xm,$ym,$par[0]+$xm,$par[1]+$ym)
    ));
          }
          if($frc[0] == 'g') {	
    	$modx->runSnippet('GrayscaleImg',array(
       'file_input' => $serve.$newimg,
    	  'file_output' => $serve.$newimg
    ));
    }
          if ($frc[0] == 'min') {
            list($w, $h) = getimagesize($serve.$newimg);
            if($w < $h){
                $maxwo = $frc[1];
                $maxho = '';
            }else{
                $maxwo = '';
                $maxho = $frc[1];
            }
            $modx->runSnippet('RezImg',array(
       'file_input' => $serve.$newimg,
    	  'file_output' => $serve.$newimg,
    	  'w_o' => $maxwo,
    	  'h_o' => $maxho
    ));
          }
          $x++;
        }
      }
      $output = $dir_new.$m_name.'_'.$images_name;
      return $output;
    }
    return $output;
    return;