Example #1
0
 function clearText($doc)
 {
     //$doc = rawurlencode($doc);
     $file = "docs/" . base64urlencode($doc);
     if (file_exists($file)) {
         $fp = fopen($file, "a");
         flock($fp, LOCK_EX);
         unlink($file);
         $fp = fopen($file, "a");
         flock($fp, LOCK_UN);
         return fclose($fp);
     } else {
         $fp = fopen($file, "a");
         return fclose($fp);
     }
 }
Example #2
0
    if (!is_dir("docs")) {
        mkdir("docs");
    }
    $file = "docs/" . base64urlencode($name);
    if (!file_exists($file) || is_writable($file)) {
        die(file_put_contents($file, $text));
    } else {
        die;
    }
}
$name = "Title";
$text = "";
$writable = "true";
if (isset($_GET['name']) && $_GET['name'] != "") {
    $name = rawurlencode($_GET['name']);
    $file = "docs/" . base64urlencode($name);
    if (file_exists($file)) {
        $text = rawurlencode(file_get_contents($file));
        $writable = is_writable($file) ? "true" : "false";
    }
}
?>
<!DOCTYPE html>
<html>

<head>
  <title>Online Text Editor <?php 
echo $ver;
?>
</title>
  <meta charset="UTF-8">
Example #3
0
<?php

/****** Simple Instant Message ******/
$version = "2.2";
header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
require "base64url.php";
if (isset($_GET['doc'])) {
    //$doc = rawurlencode($_GET['doc']);
    $doc = $_GET['doc'];
    $file = "docs/" . base64urlencode($doc);
    $pos = intval($_GET['pos']);
    if (function_exists("inotify_init")) {
        $fd = inotify_init();
        while (true) {
            while (!file_exists($file)) {
                usleep(200000);
            }
            $fp = fopen($file, "r");
            flock($fp, LOCK_SH);
            clearstatcache();
            if (filesize($file) > $pos) {
                fseek($fp, $pos);
                $data = "";
                while (!feof($fp)) {
                    $data .= fread($fp, 8192);
                }
                $pos = ftell($fp);
                $data = rawurlencode($data);
                echo "data: {$data}\n";
                echo "\n";
Example #4
0
function uploadfile($filename)
{
    global $master_key, $root_id;
    $data = file_get_contents($filename);
    $size = strlen($data);
    $ul_url = api_req(array('a' => 'u', 's' => $size));
    $ul_url = $ul_url->p;
    $ul_key = array(0, 1, 2, 3, 4, 5);
    for ($i = 0; $i < 6; $i++) {
        $ul_key[$i] = rand(0, 4294967295.0);
    }
    $data_crypted = aes_ctr_encrypt($data, a32_to_str(array_slice($ul_key, 0, 4)), a32_to_str(array($ul_key[4], $ul_key[5], 0, 0)));
    $completion_handle = post($ul_url, $data_crypted);
    $data_mac = cbc_mac($data, array_slice($ul_key, 0, 4), array_slice($ul_key, 4, 2));
    $meta_mac = array($data_mac[0] ^ $data_mac[1], $data_mac[2] ^ $data_mac[3]);
    $attributes = array('n' => basename($filename));
    $enc_attributes = enc_attr($attributes, array_slice($ul_key, 0, 4));
    $key = array($ul_key[0] ^ $ul_key[4], $ul_key[1] ^ $ul_key[5], $ul_key[2] ^ $meta_mac[0], $ul_key[3] ^ $meta_mac[1], $ul_key[4], $ul_key[5], $meta_mac[0], $meta_mac[1]);
    return api_req(array('a' => 'p', 't' => $root_id, 'n' => array(array('h' => $completion_handle, 't' => 0, 'a' => base64urlencode($enc_attributes), 'k' => a32_to_base64(encrypt_key($key, $master_key))))));
}