本文整理汇总了PHP中PclErrorCode函数的典型用法代码示例。如果您正苦于以下问题:PHP PclErrorCode函数的具体用法?PHP PclErrorCode怎么用?PHP PclErrorCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PclErrorCode函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pluginProcessUpload
function pluginProcessUpload()
{
if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
exit;
}
$fl = e107::getFile();
$data = $fl->getUploaded(e_TEMP);
$mes = e107::getMessage();
if (empty($data[0]['error'])) {
if ($fl->unzipArchive($data[0]['name'], 'plugin')) {
$mes->addSuccess(EPL_ADLAN_43);
} else {
$mes->addError(EPL_ADLAN_97);
}
}
// $data = process_uploaded_files(e_TEMP);
// print_a($data);
echo $mes->render();
return;
// ----------------- Everything below is unused.
extract($_FILES);
/* check if e_PLUGIN dir is writable ... */
if (!is_writable(e_PLUGIN)) {
// still not writable - spawn error message
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_39);
} else {
// e_PLUGIN is writable
require_once e_HANDLER . "upload_handler.php";
$fileName = $file_userfile['name'][0];
$fileSize = $file_userfile['size'][0];
$fileType = $file_userfile['type'][0];
if (strstr($file_userfile['type'][0], "gzip")) {
$fileType = "tar";
} else {
if (strstr($file_userfile['type'][0], "zip")) {
$fileType = "zip";
} else {
// not zip or tar - spawn error message
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_41);
return false;
}
}
if ($fileSize) {
$uploaded = file_upload(e_PLUGIN);
$archiveName = $uploaded[0]['name'];
// attempt to unarchive
if ($fileType == "zip") {
require_once e_HANDLER . "pclzip.lib.php";
$archive = new PclZip(e_PLUGIN . $archiveName);
$unarc = $fileList = $archive->extract(PCLZIP_OPT_PATH, e_PLUGIN, PCLZIP_OPT_SET_CHMOD, 0666);
} else {
require_once e_HANDLER . "pcltar.lib.php";
$unarc = $fileList = PclTarExtract($archiveName, e_PLUGIN);
}
if (!$unarc) {
// unarc failed ...
if ($fileType == "zip") {
$error = EPL_ADLAN_46 . " '" . $archive->errorName(TRUE) . "'";
} else {
$error = EPL_ADLAN_47 . PclErrorString() . ", " . EPL_ADLAN_48 . intval(PclErrorCode());
}
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_42 . " " . $archiveName . " " . $error);
require_once "footer.php";
exit;
}
// ok it looks like the unarc succeeded - continue */
// get folder name ...
$folderName = substr($fileList[0]['stored_filename'], 0, strpos($fileList[0]['stored_filename'], "/"));
if (file_exists(e_PLUGIN . $folderName . "/plugin.php") || file_exists(e_PLUGIN . $folderName . "/plugin.xml")) {
/* upload is a plugin */
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_43);
} elseif (file_exists(e_PLUGIN . $folderName . "/theme.php") || file_exists(e_PLUGIN . $folderName . "/theme.xml")) {
/* upload is a menu */
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_45);
} else {
/* upload is unlocatable */
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_98 . ' ' . $fileList[0]['stored_filename']);
}
/* attempt to delete uploaded archive */
@unlink(e_PLUGIN . $archiveName);
}
}
}
示例2: errorCode
function errorCode()
{
if (PCLZIP_ERROR_EXTERNAL == 1) {
return PclErrorCode();
} else {
return $this->error_code;
}
}
示例3: pluginProcessUpload
function pluginProcessUpload()
{
if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
exit;
}
extract($_FILES);
/* check if e_PLUGIN dir is writable ... */
if (!is_writable(e_PLUGIN)) {
/* still not writable - spawn error message */
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_39);
} else {
/* e_PLUGIN is writable - continue */
require_once e_HANDLER . "upload_handler.php";
$fileName = $file_userfile['name'][0];
$fileSize = $file_userfile['size'][0];
$fileType = $file_userfile['type'][0];
if (strstr($file_userfile['type'][0], "gzip")) {
$fileType = "tar";
} else {
if (strstr($file_userfile['type'][0], "zip")) {
$fileType = "zip";
} else {
/* not zip or tar - spawn error message */
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_41);
require_once "footer.php";
exit;
}
}
if ($fileSize) {
$uploaded = file_upload(e_PLUGIN);
$archiveName = $uploaded[0]['name'];
/* attempt to unarchive ... */
if ($fileType == "zip") {
require_once e_HANDLER . "pclzip.lib.php";
$archive = new PclZip(e_PLUGIN . $archiveName);
$unarc = $fileList = $archive->extract(PCLZIP_OPT_PATH, e_PLUGIN, PCLZIP_OPT_SET_CHMOD, 0666);
} else {
require_once e_HANDLER . "pcltar.lib.php";
$unarc = $fileList = PclTarExtract($archiveName, e_PLUGIN);
}
if (!$unarc) {
/* unarc failed ... */
if ($fileType == "zip") {
$error = EPL_ADLAN_46 . " '" . $archive->errorName(TRUE) . "'";
} else {
$error = EPL_ADLAN_47 . PclErrorString() . ", " . EPL_ADLAN_48 . intval(PclErrorCode());
}
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_42 . " " . $archiveName . " " . $error);
require_once "footer.php";
exit;
}
/* ok it looks like the unarc succeeded - continue */
/* get folder name ... */
$folderName = substr($fileList[0]['stored_filename'], 0, strpos($fileList[0]['stored_filename'], "/"));
if (file_exists(e_PLUGIN . $folderName . "/plugin.php") || file_exists(e_PLUGIN . $folderName . "/plugin.xml")) {
/* upload is a plugin */
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_43);
} elseif (file_exists(e_PLUGIN . $folderName . "/theme.php") || file_exists(e_PLUGIN . $folderName . "/theme.xml")) {
/* upload is a menu */
e107::getRender()->tablerender(EPL_ADLAN_40, EPL_ADLAN_45);
} else {
/* upload is unlocatable */
e107::getRender()->tablerender(EPL_ADLAN_40, 'Unknown file: ' . $fileList[0]['stored_filename']);
}
/* attempt to delete uploaded archive */
@unlink(e_PLUGIN . $archiveName);
}
}
}
示例4: PclTarHandleExtension
function PclTarHandleExtension($p_tarname)
{
TrFctStart(__FILE__, __LINE__, "PclTarHandleExtension", "tar={$p_tarname}");
// ----- Look for file extension
if (substr($p_tarname, -7) == ".tar.gz" || substr($p_tarname, -4) == ".tgz") {
TrFctMessage(__FILE__, __LINE__, 2, "Archive is a gzip tar");
$v_tar_mode = "tgz";
} else {
if (substr($p_tarname, -4) == ".tar") {
TrFctMessage(__FILE__, __LINE__, 2, "Archive is a tar");
$v_tar_mode = "tar";
} else {
// ----- Error log
PclErrorLog(-9, "Invalid archive extension");
TrFctMessage(__FILE__, __LINE__, PclErrorCode(), PclErrorString());
$v_tar_mode = "";
}
}
// ----- Return
TrFctEnd(__FILE__, __LINE__, $v_tar_mode);
return $v_tar_mode;
}
示例5: extractArchive
function extractArchive()
{
global $mosConfig_absolute_path;
$base_Dir = $this->pathName($mosConfig_absolute_path . "/media/");
$archivename = $base_Dir . $this->installArchive();
$tmpdir = uniqid("install_");
if ($this->isWindows()) {
$extractdir = str_replace('/', '\\', $this->pathName($base_Dir . "{$tmpdir}"));
$archivename = str_replace('/', '\\', $archivename);
} else {
$extractdir = str_replace('\\', '/', $this->pathName($base_Dir . "{$tmpdir}"));
$archivename = str_replace('\\', '/', $archivename);
}
$this->unpackDir($extractdir);
// Find the extension of the file
$fileext = substr(strrchr(basename($this->installArchive()), '.'), 1);
if ($fileext == "gz" || $fileext == "tar") {
PclTarExtract($archivename, $extractdir);
if (PclErrorCode() != 1) {
echo "<font color=\"red\">" . PclErrorString() . "<br />Updater - error</font>";
TrDisplay();
exit;
}
$this->installDir($extractdir);
} else {
$zipfile = new PclZip($archivename);
if ($this->isWindows()) {
define('OS_WINDOWS', 1);
} else {
define('OS_WINDOWS', 0);
}
$ret = $zipfile->extract(PCLZIP_OPT_PATH, $extractdir);
if ($ret == 0) {
$this->setError(1, "Unrecoverable error '" . $zipfile->errorName(true) . "'", "Updater - error");
return false;
}
$this->installDir($extractdir);
}
// Try to find the correct install dir. in case that the package have subdirs
// Save the install dir for later cleanup
$filesindir = $this->readDirectory($this->installDir(), "");
if (count($filesindir) == 1) {
if (is_dir($extractdir . $filesindir[0])) {
$this->installDir($extractdir . $filesindir[0]);
}
}
return true;
}
示例6: PclTarHandlerDirCheck
function PclTarHandlerDirCheck($p_dir)
{
$v_result = 1;
TrFctStart(__FILE__, __LINE__, "PclTarHandlerDirCheck", "{$p_dir}");
// ----- Check the directory availability
if (is_dir($p_dir) || $p_dir == "") {
TrFctEnd(__FILE__, __LINE__, "'{$p_dir}' is a directory");
return 1;
}
// ----- Look for file alone
/*
if (!strstr("$p_dir", "/"))
{
TrFctEnd(__FILE__, __LINE__, "'$p_dir' is a file with no directory");
return 1;
}
*/
// ----- Extract parent directory
$p_parent_dir = dirname($p_dir);
//TrFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");
// ----- Just a check
if ($p_parent_dir != $p_dir) {
// ----- Look for parent directory
if ($p_parent_dir != "") {
if (($v_result = PclTarHandlerDirCheck($p_parent_dir)) != 1) {
TrFctEnd(__FILE__, __LINE__, $v_result);
return $v_result;
}
}
}
// ----- Create the directory
//TrFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
if (!@mkdir($p_dir, 0777)) {
// ----- Error log
PclErrorLog(-8, "Unable to create directory '{$p_dir}'");
// ----- Return
TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());
return PclErrorCode();
}
// ----- Return
TrFctEnd(__FILE__, __LINE__, $v_result, "Directory '{$p_dir}' created");
return $v_result;
}
示例7: extractArchive
/**
* Extracts the package archive file
* @return boolean True on success, False on error
*/
function extractArchive()
{
global $mosConfig_absolute_path;
// Common functions for the installer(s)
// Extract functions
require_once $mosConfig_absolute_path . '/administrator/includes/pcl/pclzip.lib.php';
require_once $mosConfig_absolute_path . '/administrator/includes/pcl/pclerror.lib.php';
require_once $mosConfig_absolute_path . '/administrator/includes/pcl/pcltrace.lib.php';
require_once $mosConfig_absolute_path . '/administrator/includes/pcl/pcltar.lib.php';
$base_Dir = mosPathName($mosConfig_absolute_path . '/media');
$archivename = $base_Dir . $this->installArchive();
$tmpdir = uniqid('install_');
$extractdir = mosPathName($base_Dir . $tmpdir);
$archivename = mosPathName($archivename, false);
$this->unpackDir($extractdir);
// Find the extension of the file
$fileext = substr(strrchr(basename($this->installArchive()), '.'), 1);
if ($fileext == 'gz' || $fileext == 'tar') {
$result = PclTarExtract($archivename, $extractdir);
if (!$result) {
$this->setError(1, 'Tar Extract Error "' . PclErrorString() . '" Code ' . intval(PclErrorCode()));
return false;
}
$this->installDir($extractdir);
} else {
$zipfile = new PclZip($archivename);
if ($this->isWindows()) {
define('OS_WINDOWS', 1);
} else {
define('OS_WINDOWS', 0);
}
$ret = $zipfile->extract(PCLZIP_OPT_PATH, $extractdir);
if ($ret == 0) {
$this->setError(1, 'Unrecoverable error "' . $zipfile->errorName(true) . '"');
return false;
}
$this->installDir($extractdir);
}
// Try to find the correct install dir. in case that the package have subdirs
// Save the install dir for later cleanup
$filesindir = mosReadDirectory($this->installDir(), '');
if (count($filesindir) == 1) {
if (is_dir($extractdir . $filesindir[0])) {
$this->installDir(mosPathName($extractdir . $filesindir[0]));
}
}
return true;
}
示例8: position
}
# TODO: This should be a regex to make sure the file is in the right position (<pluginname>/<pluginname>.yaml)
if (strpos($value,$u_plugin_name.'.yaml')!==false){
$yaml_index = $key;
}
}
# TODO: We should extract the yaml file if it exists and validate it.
if ($yaml_index===false){
$rejected = true;
$rej_reason = $lang['plugins-rejmetadata'];
}
if (!$rejected){
if (!(is_array(PclTarExtract($tmp_file, '../../plugins/')))){
#TODO: If the new plugin is already activated we should update the DB with the new yaml info.
$rejected = true;
$rej_reason = $lang['plugins-rejarchprob'].' '.PclErrorString(PclErrorCode());
}
}
}
}
else {
$rejected = true;
$rej_reason = $lang['plugins-rejfileprob'];
}
}
}
else {
$rejected = true;
$rej_reason = $lang['plugins-rejfileprob'];
}
示例9: themeUpload
function themeUpload()
{
if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
exit;
}
$mes = e107::getMessage();
$ns = e107::getRender();
extract($_FILES);
if (!is_writable(e_THEME)) {
// $ns->tablerender(TPVLAN_16, TPVLAN_20);
$mes->add(TPVLAN_20, E_MESSAGE_INFO);
return FALSE;
} else {
require_once e_HANDLER . "upload_handler.php";
$fileName = $file_userfile['name'][0];
$fileSize = $file_userfile['size'][0];
$fileType = $file_userfile['type'][0];
if (strstr($file_userfile['type'][0], "gzip")) {
$fileType = "tar";
} else {
if (strstr($file_userfile['type'][0], "zip")) {
$fileType = "zip";
} else {
$mes->add(TPVLAN_17, E_MESSAGE_ERROR);
// $ns->tablerender(TPVLAN_16, TPVLAN_17);
// require_once("footer.php");
return FALSE;
}
}
if ($fileSize) {
$uploaded = file_upload(e_THEME);
$archiveName = $uploaded[0]['name'];
if ($fileType == "zip") {
require_once e_HANDLER . "pclzip.lib.php";
$archive = new PclZip(e_THEME . $archiveName);
$unarc = $fileList = $archive->extract(PCLZIP_OPT_PATH, e_THEME, PCLZIP_OPT_SET_CHMOD, 0666);
} else {
require_once e_HANDLER . "pcltar.lib.php";
$unarc = $fileList = PclTarExtract($archiveName, e_THEME);
}
if (!$unarc) {
if ($fileType == "zip") {
$error = TPVLAN_46 . " '" . $archive->errorName(TRUE) . "'";
} else {
$error = TPVLAN_47 . PclErrorString() . ", " . TPVLAN_48 . intval(PclErrorCode());
}
$mes->add(TPVLAN_18 . " " . $archiveName . " " . $error, E_MESSAGE_ERROR);
// $ns->tablerender(TPVLAN_16, TPVLAN_18." ".$archiveName." ".$error);
return FALSE;
}
$folderName = substr($fileList[0]['stored_filename'], 0, strpos($fileList[0]['stored_filename'], "/"));
$mes->add(TPVLAN_19, E_MESSAGE_SUCCESS);
if (varset($_POST['setUploadTheme'])) {
$themeArray = $this->getThemes();
$this->id = $themeArray[$folderName]['id'];
$this->setTheme();
}
// $ns->tablerender(TPVLAN_16, "<div class='center'>".TPVLAN_19."</div>");
@unlink(e_THEME . $archiveName);
}
}
}
示例10: privDirCheck
function privDirCheck($p_dir, $p_is_dir=false)
{
$v_result = 1;
PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");
// ----- Remove the final '/'
if (($p_is_dir) && (substr($p_dir, -1)=='/'))
{
$p_dir = substr($p_dir, 0, strlen($p_dir)-1);
}
PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");
// ----- Check the directory availability
if ((is_dir($p_dir)) || ($p_dir == ""))
{
PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");
return 1;
}
// ----- Extract parent directory
$p_parent_dir = dirname($p_dir);
PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");
// ----- Just a check
if ($p_parent_dir != $p_dir)
{
// ----- Look for parent directory
if ($p_parent_dir != "")
{
if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
{
PclTraceFctEnd(__FILE__, __LINE__, $v_result);
return $v_result;
}
}
}
// ----- Create the directory
PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
if (!@mkdir($p_dir, 0777))
{
// ----- Error log
PclErrorLog(-8, "Unable to create directory '$p_dir'");
// ----- Return
PclTraceFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());
return PclErrorCode();
}
// ----- Return
PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");
return $v_result;
}
示例11: PclTarHandleExtension
function PclTarHandleExtension($p_tarname)
{
TrFctStart(__FILE__, __LINE__, "PclTarHandleExtension", "tar={$p_tarname}");
// ----- Look for file extension
// NET2FTP
// This is because net2ftp adds a .txt extension to all uploaded files while they reside on the *web* server
$p_tarname = substr($p_tarname, 0, strlen($p_tarname) - 4);
if (substr($p_tarname, -7) == ".tar.gz" || substr($p_tarname, -4) == ".tgz") {
TrFctMessage(__FILE__, __LINE__, 2, "Archive is a gzip tar");
$v_tar_mode = "tgz";
} else {
if (substr($p_tarname, -4) == ".tar") {
TrFctMessage(__FILE__, __LINE__, 2, "Archive is a tar");
$v_tar_mode = "tar";
} else {
// ----- Error log
PclErrorLog(-9, "Invalid archive extension");
TrFctMessage(__FILE__, __LINE__, PclErrorCode(), PclErrorString());
$v_tar_mode = "";
}
}
// ----- Return
TrFctEnd(__FILE__, __LINE__, $v_tar_mode);
return $v_tar_mode;
}
示例12: errorCode
public function errorCode()
{
if (self::ERROR_EXTERNAL == 1) {
return PclErrorCode();
} else {
return $this->error_code;
}
}