HEX
Server: Apache
System: Linux hostingsrv18.dondominio.com 6.12.90+deb13.1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.90-2 (2026-05-27) x86_64
User: (335769)
PHP: 8.1.34
Disabled: system,passthru,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,exec,ini_alter,show_source,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,mail,eval
Upload Files
File: /hosting/www/kipepeo.es/public/Fotos/upchunk.php
<?php
/**************************
  Coppermine Photo Gallery
 **************************
  Copyright (c) 2003-2016 Coppermine Dev Team
  v1.0 originally written by Gregory Demar

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.

 ************************************
  Coppermine version: 1.6.03
  $HeadURL$
 ************************************/

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

class UpChunkObj
{
	protected $ckid;
	protected $ckpath;
	protected $dstpath;
	protected $filename;
	protected $totalchunks;

	public function __construct ($p)
	{
		global $CONFIG;

		$this->ckid = $p->getEscaped('identifier');
		$this->filename = $p->getEscaped('filename');
		$this->totalchunks = $p->getInt('totalChunks');
		$this->dstpath = $CONFIG['fullpath'] . $CONFIG['userpics'] . (USER_ID + FIRST_USER_CAT) . '/';
		$this->ckpath = $this->dstpath . $this->ckid;

		// create the temporary directory
		if ($this->ckid && !is_dir($this->ckpath)) {
			mkdir($this->ckpath, 0777, true);
			upldLog('created chunk dir: '.$this->ckpath);
		}
	}

	public function addChunk ($file, $cnkn)
	{
		$dest = $this->ckpath.'/'.$this->filename.'.part'.$cnkn;
		if (!move_uploaded_file($file, $dest)) {
			upldLog('failed to place chunk: '.$dest);
			errorOut(sprintf($GLOBALS['lang_plugin_upload_h5a']['muf_err'], $cnkn, $this->filename, $file, $dest));
		}
		upldLog('placed chunk: '.$dest);

		if ($cnkn == $this->totalchunks) {

			// count all the parts of this file
			$total_files = 0;
			foreach(scandir($this->ckpath) as $filepart) {
				if (stripos($filepart, $this->filename) !== false) {
					$total_files++;
				}
			}

			if ($total_files !== $this->totalchunks) errorOut($GLOBALS['lang_plugin_upload_h5a']['miss_chnk']);
			return true;
		}

		return false;
	}

	public function combineTo ($dest)
	{
		// create the final destination file
		if (($fp = @fopen($dest, 'w')) !== false) {
			for ($i=1; $i<=$this->totalchunks; $i++) {
				fwrite($fp, file_get_contents($this->ckpath.'/'.$this->filename.'.part'.$i));
			}
			fclose($fp);
		} else {
			upldLog('failed to open destination file: '.$dest);
			errorOut(sprintf($GLOBALS['lang_plugin_upload_h5a']['dest_fail'], $dest));
		}

		upldLog('combined chunks: '.$dest);
	}

	public function cleanup ()
	{
		if ($this->ckid) $this->rrmdir($this->ckpath);
		upldLog('chunks cleared: '.$this->ckpath);
	}

	private function rrmdir ($dir) {
		if (is_dir($dir)) {
			$objects = scandir($dir);
			foreach ($objects as $object) {
				if ($object != '.' && $object != '..') {
					if (filetype($dir . '/' . $object) == 'dir') {
						$this->rrmdir($dir . '/' . $object); 
					} else {
						unlink($dir . '/' . $object);
					}
				}
			}
			reset($objects);
			rmdir($dir);
		}
	}

}
//EOF