public function getSQLValue($name = '') { global $PRJ_DIR; $name = $name ? $name : $this->getName(); $ret = CUtils::_postVar($name . '_oldValue'); if ($ret && CUtils::_postVar($name . '_delete')) { if ($ret != '/img/lib/empty_photo.gif' && $ret != '') { @unlink($PRJ_DIR . $ret); if (isset($this->props['sizes'])) { $path_parts = pathinfo($PRJ_DIR . $ret); $asizes = explode(',', $this->props['sizes']); foreach ($asizes as $sz) { $asz = explode('|', $sz); if (sizeof($asz) == 2) { @unlink($path_parts['dirname'] . '/' . $asz[0] . '_' . $path_parts['basename']); } } } } $ret = ''; } if (is_array($_FILES) && sizeof($_FILES) > 0 && isset($_FILES[$name]) && $_FILES[$name]['name'] != '') { if ($ret && $ret != '/img/lib/empty_photo.gif') { @unlink($PRJ_DIR . $ret); if (isset($this->props['sizes'])) { $path_parts = pathinfo($PRJ_DIR . $ret); $asizes = explode(',', $this->props['sizes']); foreach ($asizes as $sz) { $asz = explode('|', $sz); if (sizeof($asz) == 2) { @unlink($path_parts['dirname'] . '/' . $asz[0] . '_' . $path_parts['basename']); } } } } $dest = CUtils::getNextFileName('/upload/' . strtolower(CUtils::translitStr($_FILES[$name]['name']))); @move_uploaded_file($_FILES[$name]['tmp_name'], $PRJ_DIR . $dest); $ret = $dest; $this->afterUpload($ret); } return $ret; }
public function getSQLValue($name = '') { global $PRJ_DIR; $name = $name ? $name : $this->getName(); $ret = $_REQUEST[$name . '_oldValue']; if ($ret && CUtils::_postVar($name . '_delete')) { @unlink($PRJ_DIR . $ret); $ret = ''; } if (is_array($_FILES) && sizeof($_FILES) > 0 && isset($_FILES[$name]) && $_FILES[$name]['name'] != '') { if ($ret) { @unlink($PRJ_DIR . $ret); } $dest = CUtils::getNextFileName('/upload/' . strtolower(CUtils::translitStr($_FILES[$name]['name']))); move_uploaded_file($_FILES[$name]['tmp_name'], $PRJ_DIR . $dest); $ret = $dest; $this->afterUpload($ret); } return $ret; }
public function getSQLValue($name = '') { global $VERSION_QUANTITY, $PRJ_DIR; $name = $name ? $name : $this->getName(); $ret = CUtils::_postVar($name . '_oldValue'); $date_stamp = date('Y_m_d_H_i_s'); $values = ''; if ($ret && CUtils::_postVar($name . '_delete')) { $backup_ret = str_replace('/templates/', '/templates/backup/', $ret); @copy($PRJ_DIR . $ret, $PRJ_DIR . $backup_ret . $date_stamp . '.bak'); @unlink($PRJ_DIR . $ret); $values = "'" . $this->props['cls'] . "','" . $this->getName() . "'," . $this->dbId . ",NOW(),'" . $backup_ret . $date_stamp . '.bak' . "'"; $ret = ''; } elseif ($ret && CUtils::_postVar($name . '_version', true, 0)) { $backup_ret = str_replace('/templates/', '/templates/backup/', $ret); @copy($PRJ_DIR . $ret, $PRJ_DIR . $backup_ret . $date_stamp . '.bak'); @unlink($PRJ_DIR . $ret); $values = "'" . $this->props['cls'] . "','" . $this->getName() . "'," . $this->dbId . ",NOW(),'" . $backup_ret . $date_stamp . '.bak' . "'"; $ver = $GLOBALS['db']->getItem('templates_version', "SELECT * FROM templates_version WHERE id=" . CUtils::_postVar($name . '_version', true, 0)); @copy($PRJ_DIR . $ver['file'], $PRJ_DIR . $ret); } elseif ($ret) { $f = fopen($PRJ_DIR . $ret . '_new', 'w'); fwrite($f, $_POST[$name . '_temp']); fclose($f); if (md5_file($PRJ_DIR . $ret . '_new') != md5_file($PRJ_DIR . $ret)) { $backup_ret = str_replace('/templates/', '/templates/backup/', $ret); @copy($PRJ_DIR . $ret, $PRJ_DIR . $backup_ret . $date_stamp . '.bak'); $values = "'" . $this->props['cls'] . "','" . $this->getName() . "'," . $this->dbId . ",NOW(),'" . $backup_ret . $date_stamp . '.bak' . "'"; @copy($PRJ_DIR . $ret . '_new', $PRJ_DIR . $ret); } @unlink($PRJ_DIR . $ret . '_new'); } if (CUtils::_postVar($name . '_cre')) { $ret = CUtils::_postVar($name); if (trim($ret) != '') { $dest = CUtils::getNextFileName('/templates' . (isset($this->props['basepath']) ? $this->props['basepath'] : '') . '/' . CUtils::translitStr($ret)); $ret = $dest; $f = fopen($PRJ_DIR . $ret, 'w'); fwrite($f, $_POST[$name . "_temp"]); fclose($f); chmod($PRJ_DIR . $ret, 0666); } } elseif (is_array($_FILES) && sizeof($_FILES) > 0 && isset($_FILES[$name]) && $_FILES[$name]['name'] != '') { if ($ret) { $backup_ret = str_replace('/templates/', '/templates/backup/', $ret); @copy($PRJ_DIR . $ret, $PRJ_DIR . $backup_ret . $date_stamp . '.bak'); @unlink($PRJ_DIR . $ret); $values = "'" . $this->props['cls'] . "','" . $this->getName() . "'," . $this->dbId . ",NOW(),'" . $backup_ret . $date_stamp . '.bak' . "'"; } $dest = CUtils::getNextFileName('/templates' . (isset($this->props['basepath']) ? $this->props['basepath'] : '') . '/' . $_FILES[$name]['name']); move_uploaded_file($_FILES[$name]['tmp_name'], $PRJ_DIR . $dest); chmod($PRJ_DIR . $dest, 0666); $ret = $dest; } if ($values) { $vers = $GLOBALS['db']->getItems('select_version', "SELECT * FROM templates_version WHERE cls='" . $this->props['cls'] . "' AND fld='" . $this->getName() . "' AND rc=" . $this->dbId . ' ORDRER BY id'); if (sizeof($vers) >= __VERSION_QUANTITY) { $GLOBALS['db']->execQuery('templates_version', 'DELETE FROM templates_version WHERE id=' . $vers[0]['id']); } $db_ret = $GLOBALS['db']->execQuery('add_version', 'INSERT INTO templates_version(cls,fld,rc,credate,file) VALUES(' . $values . ')'); //var_dump($db_ret, 'INSERT INTO templates_version(cls,fld,rc,credate,file) VALUES('.$values.')'); //die(); } return $ret; }
} if (isset($_FILES["File1"])) { if (isset($_POST["inpCurrFolder2"])) { $currFolder = $_POST['inpCurrFolder2']; } if (isset($_REQUEST["inpFilter"])) { $ffilter = $_REQUEST["inpFilter"]; } if ($MaxFileSize && $_FILES['File1']['size'] > $MaxFileSize) { $sMsg = "The file exceeds the maximum size allowed."; } elseif (!isTypeAllowed($_FILES['File1']['name'])) { $sMsg = "The File Type is not allowed."; } elseif (move_uploaded_file($_FILES['File1']['tmp_name'], $currFolder . "/" . basename(strtolower(CUtils::translitStr($_FILES['File1']['name']))))) { $sMsg = ""; $sUploadedFile = CUtils::translitStr($_FILES['File1']['name']); @chmod($currFolder . "/" . basename(strtolower(CUtils::translitStr($_FILES['File1']['name']))), 0644); } else { $sMsg = "Upload failed."; } } else { if (isset($_GET["inpCurrFolder"])) { $currFolder = $_GET['inpCurrFolder']; } if (isset($_REQUEST["ffilter"])) { $ffilter = $_REQUEST["ffilter"]; } } if (isset($_POST["inpFileToDelete"])) { $filename = pathinfo($_POST["inpFileToDelete"]); $filename = $filename['basename']; if ($filename != "") {