Exemple #1
0
function tryGetDefaultByType($type)
{
    $ext;
    switch ($type) {
        case "document":
            $ext = ".docx";
            break;
        case "spreadsheet":
            $ext = ".xlsx";
            break;
        case "presentation":
            $ext = ".pptx";
            break;
        default:
            return;
    }
    $demoName = "demo" . $ext;
    $demoFilename = GetCorrectName($demoName);
    if (!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . "app_data" . DIRECTORY_SEPARATOR . $demoName, getStoragePath($demoFilename))) {
        sendlog("Copy file error to " . getStoragePath($demoFilename), "logs/common.log");
        //Copy error!!!
    }
    return $demoFilename;
}
function track()
{
    sendlog("Track START", "logs/webedior-ajax.log");
    sendlog("_GET params: " . serialize($_GET), "logs/webedior-ajax.log");
    global $_trackerStatus;
    $data;
    if (($body_stream = file_get_contents('php://input')) === FALSE) {
        $result["error"] = "Bad Request";
        return $result;
    }
    $data = json_decode($body_stream, TRUE);
    //json_decode - PHP 5 >= 5.2.0
    if ($data === NULL) {
        $result["error"] = "Bad Response";
        return $result;
    }
    sendlog("InputStream data: " . serialize($data), "logs/webedior-ajax.log");
    $status = $_trackerStatus[$data["status"]];
    switch ($status) {
        case "MustSave":
        case "Corrupted":
            $userAddress = $_GET["userAddress"];
            $fileName = $_GET["fileName"];
            $storagePath = getStoragePath($fileName, $userAddress);
            $downloadUri = $data["url"];
            $saved = 1;
            if (($new_data = file_get_contents($downloadUri)) === FALSE) {
                $saved = 0;
            } else {
                file_put_contents($storagePath, $new_data, LOCK_EX);
            }
            $result["c"] = "saved";
            $result["status"] = $saved;
            break;
    }
    sendlog("track result: " . serialize($result), "logs/webedior-ajax.log");
    return $result;
}
Exemple #3
0
/**
*  Generate validate key for editor by documentId
*
* LFJ7 or "http://helpcenter.onlyoffice.com/content/GettingStarted.pdf"
*
* @param string $document_revision_id     Key for caching on service, whose used in editor
* @param bool   $add_host_for_validate    Add host address to the key
*
* @return Validation key
*/
function GenerateValidateKey($document_revision_id, $add_host_for_validate = true)
{
    if (empty($document_revision_id)) {
        return '';
    }
    $document_revision_id = GenerateRevisionId($document_revision_id);
    $keyId = servConvGetKey();
    $primaryKey = NULL;
    $ms = number_format(round(microtime(true) * 1000), 0, '.', '');
    if ($add_host_for_validate) {
        $userIp = getClientIp();
        if (!empty($userIp)) {
            $primaryKey = "{\"expire\":\"\\/Date(" . $ms . ")\\/\",\"key\":\"" . $document_revision_id . "\",\"key_id\":\"" . $keyId . "\",\"user_count\":0,\"ip\":\"" . $userIp . "\"}";
        }
    }
    if ($primaryKey == NULL) {
        $primaryKey = "{\"expire\":\"\\/Date(" . $ms . ")\\/\",\"key\":\"" . $document_revision_id . "\",\"key_id\":\"" . $keyId . "\",\"user_count\":0}";
    }
    sendlog("GenerateValidateKey. primaryKey = " . $primaryKey, "logs/common.log");
    return signature_Create($primaryKey, servConvGetSKey());
}
Exemple #4
0
function getVirtualPath()
{
    $storagePath = trim(str_replace(array('/', '\\'), '/', $GLOBALS['STORAGE_PATH']), '/');
    $storagePath = $storagePath != "" ? $storagePath . '/' : "";
    $virtPath = rtrim(WEB_ROOT_URL, '/') . '/' . $storagePath . getCurUserHostAddress() . '/';
    sendlog("getVirtualPath virtPath: " . $virtPath, "logs/common.log");
    return $virtPath;
}