⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 photos.php

📁 这是一个joomla系统的插件, 这是一个joomla系统的插件
💻 PHP
📖 第 1 页 / 共 3 页
字号:
        echo "<script> alert('Directory not writable: ". $mainframe->getCfg('absolute_path') . '/' . $eg_original_path . "'); window.history.go(-1); </script>\n";        exit;      }            if(!file_exists($mainframe->getCfg('absolute_path') . '/' . $eg_original_path . '/' . $cid)){        if(!mkdir($mainframe->getCfg('absolute_path') . '/' . $eg_original_path . '/' . $cid)){          echo "<script> alert('Failed to create gallery directory.'); window.history.go(-1); </script>\n";          exit;        }        mosChmod($mainframe->getCfg('absolute_path') . '/' . $eg_original_path . '/' . $cid, 0777);      }            if(!copy($filepath, $mainframe->getCfg('absolute_path') . '/' . $eg_original_path . '/' . $cid . '/' . $time . "_" . $filename)){        echo "<script> alert('Failed to copy original $filename to upload path.'); window.history.go(-1); </script>\n";        exit;      }    }        //make smaller image for image details and write that away as well..    $img = photos::resize($filepath, $filetype, $eg_max_height, $eg_max_width);    if($img !== false){      if($eg_ftp_disabled == 0){        if(!$ftp->mkDir($eg_image_path, $cid)){          echo "<script> alert('Failed to create gallery directory in resized directory.'); window.history.go(-1); </script>\n";          exit;        }                if(!$ftp->cd($eg_ftp_path . $eg_image_path . '/' . $cid)){          echo "<script> alert('Failed to change to resized directory: ". $eg_ftp_path . $eg_image_path . '/' . $cid . "'); window.history.go(-1); </script>\n";          exit;        }                if(!$ftp->copy($filepath, $time . "_" . $filename)){          echo "<script> alert('Failed to upload resized image.'); window.history.go(-1); </script>\n";          exit;        }      } else {        if(!is_writable($mainframe->getCfg('absolute_path') . '/' . $eg_image_path)){          echo "<script> alert('Directory not writable: ". $mainframe->getCfg('absolute_path') . '/' . $eg_image_path . "'); window.history.go(-1); </script>\n";          exit;        }                if(!file_exists($mainframe->getCfg('absolute_path') . '/' . $eg_image_path . '/' . $cid)){          if(!mkdir($mainframe->getCfg('absolute_path') . '/' . $eg_image_path . '/' . $cid)){            echo "<script> alert('Failed to create gallery directory in resized directory.'); window.history.go(-1); </script>\n";            exit;          }          mosChmod($mainframe->getCfg('absolute_path') . '/' . $eg_image_path . '/' . $cid, 0777);        }                if(!copy($filepath, $mainframe->getCfg('absolute_path') . '/' . $eg_image_path . '/' . $cid . '/' . $time . "_" . $filename)){          echo "<script> alert('Failed to upload resized image.'); window.history.go(-1); </script>\n";          exit;        }      }    }        //make thumpnail and write that away as well..    $img = photos::resize($filepath, $filetype, $eg_thumbnail_height, $eg_thumbnail_width);    if($img !== false){      if($eg_ftp_disabled == 0){        if(!$ftp->mkDir($eg_thumbnail_path, $cid)){          echo "<script> alert('Failed to create gallery directory in thumbnail directory.'); window.history.go(-1); </script>\n";          exit;        }                if(!$ftp->cd($eg_ftp_path . $eg_thumbnail_path . '/' . $cid)){          echo "<script> alert('Failed to change to thumbnail directory: ". $eg_ftp_path . $eg_thumbnail_path . '/' . $cid . "'); window.history.go(-1); </script>\n";          exit;        }                if(!$ftp->copy($filepath, $time . "_" . $filename)){          echo "<script> alert('Failed to upload thumbnail.'); window.history.go(-1); </script>\n";          exit;        }      } else {        if(!is_writable($mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path)){          echo "<script> alert('Directory not writable: ". $mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path . "'); window.history.go(-1); </script>\n";          exit;        }                if(!file_exists($mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path . '/' . $cid)){          if(!mkdir($mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path . '/' . $cid)){            echo "<script> alert('Failed to create gallery directory in thumbnail directory.'); window.history.go(-1); </script>\n";            exit;          }          mosChmod($mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path . '/' . $cid, 0777);        }                if(!copy($filepath, $mainframe->getCfg('absolute_path') . '/' . $eg_thumbnail_path . '/' . $cid . '/' . $time . "_" . $filename)){          echo "<script> alert('Failed to upload thumbnail.'); window.history.go(-1); </script>\n";          exit;        }      }    }        /** check if first image from this gallery **/    $query = 'SELECT COUNT(1) FROM #__easygallery WHERE cid = ' . (int) $cid;    $database->setQuery($query);    $count = $database->loadResult();        $row = new dbPhoto($database);    $row->name = (!empty($imagename) ? $imagename : $filename);    $row->ordering = 99999;    $row->description = $description;    $row->path = $cid . '/' . $time . "_" . $filename;    $row->cid = $cid;    if($count == 0){      $row->default = 1;    }    $row->state = $state;        if (!$row->check()) {			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";			exit();		}		if (!$row->store()) {			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";			exit();		}				if($eg_ftp_disabled == 0){  		//restore to original directory  		if(!$ftp->cd($eg_ftp_path . $eg_image_path)){  		  echo "<script> alert('Failed to change to original directory: ". $eg_ftp_path . $eg_image_path . "'); window.history.go(-1); </script>\n";        exit;  		}		}				$row->updateOrder('cid = ' . (int) $row->cid);  }    function sortFiles(&$array, $sort = 'name'){    if($sort == 'name'){ //sort by name      sort($array);    } else if($sort == 'rname'){ //sort by name - reversed      rsort($array);    } else if($sort == 'c_date'){ //sort by date created      $new_array = array();      for($i=0,$n=count($array);$i<$n;$i++){        $file = $array[$i];        $new_array[filectime($file)] = $file;      }      ksort($new_array);      $array = & array_values($new_array);    } else if($sort == 'm_date'){ //sort by date modified      $new_array = array();      for($i=0,$n=count($array);$i<$n;$i++){        $file = $array[$i];        $new_array[filemtime($file)] = $file;      }      ksort($new_array);      $array = & array_values($new_array);    }  }    /**   * Edit photo   *   * @param int $id   */  function editFront($id){    global $database, $my;        if(!$my->id && $my->gid != 2){      mosNotAuth();      return;    }        $row = new dbPhoto($database);    $row->load($id);        $categories = categories::getCategorieTree();  	  	$obj = new stdClass();  	$obj->id = 0;  	$obj->name = ' - select - ';  	  	array_unshift($categories, $obj);        $lists = array();  	$lists['cid'] = mosHTML::selectList($categories, 'cid', 'class="inputbox"', 'id', 'name', $row->cid);        HTML_easygallery::editPhoto($row, $lists);  }    /**   * Save photo changes   *   */  function saveFront(){    global $option, $database, $task, $my, $Itemid;        if(!$my->id && $my->gid != 2){      mosNotAuth();      return;    }        $row = new dbPhoto($database);    $row->bind($_POST);        $row->default = intval(mosGetParam($_REQUEST, 'default', 0));        if($row->default){		  $query = 'UPDATE #__easygallery SET `default` = 0 WHERE cid = ' . (int) $row->cid;		  $database->setQuery($query);		  $database->query();		  echo $database->getErrorMsg();		}        if(!$row->id){      $row->ordering = 999999999;    }        if (!$row->check()) {			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";			exit();		}		if (!$row->store()) {			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";			exit();		}				$row->updateOrder('cid = ' . (int) $row->cid);				switch ($task){		  case 'save':		    mosRedirect('index.php?option=' . $option . '&act=photos&cid=' . $row->id . '&Itemid=' . $Itemid);		    break;		  case 'apply':		    mosRedirect('index.php?option=' . $option . '&act=photos&task=edit&cid=' . $row->id . '&Itemid=' . $Itemid);		    break;		}  }    /**   * View photo in frontend   *   * @param int $id   */  function view($id, $params){    global $database, $my, $mainframe, $eg_original_path, $eg_max_height, $eg_max_width, $eg_image_path, $eg_ftp_disabled;    global $eg_ftp_path;        $row = new dbPhoto($database);    $row->load($id);        /** temp to handle old galleries **/    if(!file_exists($mainframe->getCfg('absolute_path') . $eg_image_path . '/' . $row->path)){      if(!is_writable($mainframe->getCfg('absolute_path') . '/media/')){        if(!is_writable('/tmp/')){          echo "<script> alert('/tmp is not writable'); document.location.href='index2.php?option=" . $option . "&act=photos&task=new'; </script>\n";    			exit();        } else {          $tmpdir = '/tmp/';        }      } else {        $tmpdir = $mainframe->getCfg('absolute_path') . '/media/';      }            $filename = substr($row->path, strlen($row->cid . '/'));      $filepath = $tmpdir . '/' . $filename;            if(!copy($mainframe->getCfg('absolute_path') . $eg_original_path . '/' . $row->path, $filepath)){        echo "<script> alert('Failed to copy original image image.'); window.history.go(-1); </script>\n";        exit;      }      $res = getimagesize($filepath);      $filetype = $res['mime'];            $img = photos::resize($filepath, $filetype, $eg_max_height, $eg_max_width);            $ftp = new egftp();      if($eg_ftp_disabled == 0){        if(!$ftp->mkDir($eg_image_path, $row->cid)){          echo "<script> alert('Failed to create gallery directory in resized directory.'); window.history.go(-1); </script>\n";          exit;        }        if(!$ftp->cd($eg_ftp_path . $eg_image_path . '/' . $row->cid)){          echo "<script> alert('Failed to change to resized directory: ". $eg_ftp_path . $eg_image_path . '/' . $row->cid . "'); window.history.go(-1); </script>\n";          exit;        }        if(!$ftp->copy($filepath, $filename)){          echo "<script> alert('Failed to upload resized image.'); window.history.go(-1); </script>\n";          exit;        }      } else {        if(!copy($filepath, $mainframe->getCfg('absolute_path') . '/' . $eg_image_path . '/' . $row->path)){          echo "<script> alert('Failed to upload resized image.'); window.history.go(-1); </script>\n";          exit;        }      }    }    /** end temp fix **/        $curr = @getimagesize($mainframe->getCfg('absolute_path') . $eg_original_path . '/' . $row->path);    $row->width = $curr[0];    $row->height = $curr[1];    $row->size = round(filesize($mainframe->getCfg('absolute_path') . $eg_original_path . '/' . $row->path) / 1024);        $cat = new mosCategory($database);    $cat->load($row->cid);        if(($cat->id > 0) && ($cat->access > $my->gid) || ($row->state < 1 && $my->gid != 2) || ($cat->published < 1 && $my->gid != 2 && $cat->id)){  		mosNotAuth();  		return;    }        $query = "SELECT g.id FROM #__easygallery AS g      WHERE cid = " . (int) $row->cid . " AND state = 1       ORDER BY ordering";    $database->setQuery($query);    $ids = $database->loadResultArray();        if ( !is_array($ids) ) {			$ids = array();		}        $row->prev = '';    $row->next = '';        $loc = array_search( $row->id, $ids );    if ( $loc - 1 >= 0 ) {			$row->prev = $ids[$loc - 1]; 		}		if ( ( $loc + 1 ) < count( $ids ) ) {			$row->next = $ids[$loc + 1];		}        HTML_easygallery::showPhoto($row, $params);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -