// Check if it is an allowed extension.
if (count($arAllowed) > 0 && !in_array($sExtension, $arAllowed) || count($arDenied) > 0 && in_array($sExtension, $arDenied)) {
    SendResults('202');
}
$sErrorNumber = '0';
$sFileUrl = '';
// Initializes the counter used to rename the file, if another one with the same name already exists.
$iCounter = 0;
// The the target directory.
$sServerDir = GetRootPath() . $Config["UserFilesPath"];
while (true) {
    // Compose the file path.
    $sFilePath = $sServerDir . $sFileName;
    // If a file with that name already exists.
    if (is_file($sFilePath)) {
        $iCounter++;
        $sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension;
        $sErrorNumber = '201';
    } else {
        move_uploaded_file($oFile['tmp_name'], $sFilePath);
        if (is_file($sFilePath)) {
            $oldumask = umask(0);
            chmod($sFilePath, 0777);
            umask($oldumask);
        }
        $sFileUrl = $Config["UserFilesPath"] . $sFileName;
        break;
    }
}
SendResults($sErrorNumber, $sFileUrl, $sFileName);
Example #2
0
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = '';
/**#@+
 * Custom configs for XOOPS
 *
 **/
$current_path = str_replace(DIRECTORY_SEPARATOR, "/", dirname(__FILE__));
$fckeditor_root_path = substr($current_path, 0, stripos($current_path, "/fckeditor/fckeditor/editor/"));
$file = $fckeditor_root_path . "/xoopseditor.inc.php";
if (!@(include $file)) {
    SendResults(1, '', '', "Editor init file is not found: xoopseditor.inc.php");
    exit;
}
if (!defined("XOOPS_UPLOAD_PATH")) {
    SendResults(1, '', '', "XOOPS_UPLOAD_PATH is not defined!");
    exit;
}
$uploadPath = defined("XOOPS_FCK_FOLDER") ? preg_replace("/[^a-z0-9_\\-]/i", "", XOOPS_FCK_FOLDER) : "fckeditor";
// SECURITY: You must explicitly enable this "connector". (Set it to "true").
// WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only
//		authenticated users can access this file or use some kind of session checking.
$Config['Enabled'] = true;
// Path to uploaded files relative to the document root.
$Config['UserFilesPath'] = XOOPS_UPLOAD_URL . "/" . $uploadPath . "/";
// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Usefull if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = XOOPS_UPLOAD_PATH . "/" . $uploadPath . "/";
/**#@-*/
        if (!empty($s_invalid)) {
            $s_error .= "recipients: {$s_invalid}\r\n";
        }
        if (!empty($s_invalid_cc)) {
            $s_error .= "cc: {$s_invalid_cc}\r\n";
        }
        if (!empty($s_invalid_bcc)) {
            $s_error .= "bcc: {$s_invalid_bcc}\r\n";
        }
        if (!empty($s_error)) {
            SendAlert(GetMessage(MSG_INV_EMAIL, array("ERRORS" => $s_error)));
        }
        //
        // send the actual results
        //
        if (!SendResults($aFieldOrder, $aCleanedValues, $s_valid_recipients, $s_valid_cc, $s_valid_bcc, $aRawDataValues)) {
            Error("mail_failed", GetMessage(MSG_FAILED_SEND));
        }
        //
        // Hook system: after sending emails
        //
        if ($HOOK_DIR !== "") {
            if (!@(include "{$HOOK_DIR}/fmhookpostemail.inc.php")) {
                @(include "{$HOOK_DIR}/fmhookpostemail.inc");
            }
        }
    }
}
//
// Process autoresponse
//
Example #4
0
<?php

@set_time_limit(0);
include_once dirname(__FILE__) . "./../general.inc.php";
include_once M_ROOT . "./include/upload.cls.php";
$c_upload = new cls_upload();
$uploadfile = $c_upload->local_upload('Newfile', $_GET['type']);
unset($c_upload);
if ($uploadfile['error']) {
    SendResults('202');
} else {
    $sErrorNumber = '0';
    SendResults('0', tag2atm($uploadfile['remote']));
}
function SendResults($errorNumber, $fileUrl = '', $fileName = '', $customMsg = '')
{
    echo '<script type="text/javascript">';
    echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . str_replace('"', '\\"', $fileUrl) . '","' . str_replace('"', '\\"', $fileName) . '","' . str_replace('"', '\\"', $customMsg) . '");';
    echo '</script>';
    mexit();
}