Ejemplo n.º 1
0
function setConfigItem($configPath, $key, $value)
{
    $key = sanitiseStringToAlphaNumeric($key);
    $value = sanitiseToIniValue($value);
    $currentValue = getConfigItem($configPath, $key);
    if (!is_writable($configPath)) {
        webServiceError('&error-config-file-not-writable;', 500, array('path' => $configPath));
    }
    $newConfigItemLine = $key . '="' . $value . '"';
    if ($currentValue === null) {
        $iniFilePointer = fopen($configPath, 'a');
        fwrite($iniFilePointer, "\n" . $newConfigItemLine . "\n");
        fclose($iniFilePointer);
        chmod($configPath, 0600);
        //security!
        return;
    }
    $iniLines = file($configPath);
    $newIniLines = array();
    $replaceExistingLine = False;
    foreach ($iniLines as $iniLine) {
        if (stringStartsWith($iniLine, $key) && ($currentValue == null || containsString($iniLine, $currentValue))) {
            $newIniLines[] = $newConfigItemLine . "\n";
        } elseif (trim($iniLine) != '') {
            $newIniLines[] = $iniLine;
        }
    }
    file_put_contents($configPath, implode('', $newIniLines));
    chmod($configPath, 0600);
    //security!
}
Ejemplo n.º 2
0
function deleteUploadLocation($uploadId)
{
    //todo sanitise $nam
    $uploadId = sanitiseStringToAlphaNumeric($uploadId);
    $uploadLocationPath = getConfigDirectory() . 'upload-' . $uploadId . '.conf';
    if (file_exists($uploadLocationPath)) {
        unlink($uploadLocationPath);
    }
}
Ejemplo n.º 3
0
p {font-size:x-small;}
.errorMessages {margin:5px;padding:5px;border: solid 2px #cccccc;font-size:x-small;background:#eeeeee}
</style>
</head>
<body>
<?php 
$appDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
define('DOCVERT_DIR', $appDir);
define('DOCVERT_CLIENT_TYPE', 'web');
include_once DOCVERT_DIR . 'core' . DIRECTORY_SEPARATOR . 'lib.php';
include_once DOCVERT_DIR . 'core' . DIRECTORY_SEPARATOR . 'ftp.php';
include_once DOCVERT_DIR . 'core' . DIRECTORY_SEPARATOR . 'http.php';
include_once DOCVERT_DIR . 'core' . DIRECTORY_SEPARATOR . 'blogger-api.php';
include_once DOCVERT_DIR . 'core' . DIRECTORY_SEPARATOR . 'upload-locations.php';
if (isset($_POST['uploadto']) && isset($_POST['id'])) {
    $previewId = sanitiseStringToAlphaNumeric($_POST['id']);
    $uploadId = $_POST['uploadto'];
    $remoteDirectory = '';
    if (isset($_POST['remoteDirectory'])) {
        $remoteDirectory = $_POST['remoteDirectory'];
    }
    $uploadLocation = getUploadLocation($uploadId);
    if ($uploadLocation === null) {
        webServiceError('&error-upload-location-does-not-exist;');
    }
    $previewDirectory = realpath('writable' . DIRECTORY_SEPARATOR . $previewId);
    if (!file_exists($previewDirectory)) {
        webServiceError('&error-upload-no-preview-directory;', 500, array('previewDirectory' => $previewDirectory));
    }
    $errorHtml = uploadToUploadLocation($uploadLocation, $previewDirectory, $remoteDirectory);
    if (!$errorHtml) {