Пример #1
0
function plan_write_traditional($newplan, $planowner)
{
    include_once 'plan_read.php';
    include_once 'snoop.php';
    include_once 'spiel.php';
    include_once 'send.php';
    mb_detect_order("UTF-8, windows-1252");
    if (mb_detect_encoding($newplan) == "Windows-1252") {
        $newplan = mb_convert_encoding($newplan, UTF - 8, Windows - 1252);
    }
    $oldplan_fn = "{$_SERVER['PWUSERS_DIR']}/{$planowner}/plan/plan.txt";
    // current oldplan name
    $oldplan_fn_moved = $oldplan_fn . "." . filectime($oldplan_fn);
    // archival oldplan name
    $oldplan_array = explode("\n", $oldplan);
    $_SERVER['USER'] = '******';
    $old_snoop_array = snoop_find(plan_read_local($planowner), $planowner);
    exec("mv {$oldplan_fn} {$oldplan_fn_moved}");
    exec("gzip {$oldplan_fn_moved}");
    exec("rm -f {$_SERVER['FILE_ROOT']}/temp/{$planowner}*.cache");
    $oldplan_fn_moved .= ".gz";
    $newplan .= $_POST['nolinebreaks'];
    $newplan .= $_POST['markdown'];
    $newplan .= $_POST['nofeed'];
    if ($_POST['title']) {
        $newplan .= "<!--title {$_POST['title']}-->";
    }
    if ($_POST['tags']) {
        $newplan .= "<!--tags {$_POST['tags']}-->";
    }
    $newplan_fn = $oldplan_fn;
    $newplan_file = fopen($newplan_fn, 'w');
    fwrite($newplan_file, $newplan);
    fclose($newplan_file);
    $newplan_array = explode("\n", $newplan);
    $diffplan = implode('', array_diff($newplan_array, $oldplan_array));
    spiel_find($diffplan, $planowner, time());
    $new_snoop_array = snoop_find(plan_read_local($planowner), $planowner);
    snoop_clean(array_unique($old_snoop_array), $planowner);
    snoop_add(array_unique($new_snoop_array), $planowner);
    touch("{$_SERVER['PWUSERS_DIR']}/{$planowner}/stats/lastupdate");
    if (file_exists($newplan_fn) && (file_exists($oldplan_fn_moved) || !file_exists($oldplan_fn))) {
        redirect("/read/{$planowner}");
    } else {
        output("Error updating", "<div class='alert'>Your plan update failed:<br/><br/>{$newplan}</div>");
    }
}
Пример #2
0
function form_process_with_struct()
{
    include_once 'snoop.php';
    include_once 'plan_read.php';
    extract($_POST);
    unlink("{$_SERVER['FILE_ROOT']}/stats/planlocations.dat");
    unlink("{$_SERVER['FILE_ROOT']}/stats/plan_locations.dat");
    unlink("{$_SERVER['FILE_ROOT']}/stats/plan_failures.dat");
    foreach ($_FILES as $i => $file) {
        if ($file['size'] > 0) {
            move_uploaded_file($file['tmp_name'], "{$_SERVER['FILE_ROOT']}/resources/" . $file['name']);
        }
    }
    $olduserinfo = $_SERVER['USERINFO_ARRAY'];
    $form_definitions = unserialize(base64_decode($form_definitions));
    extract($form_definitions['form_disposition']);
    unset($form_definitions['form_disposition']);
    if ($storage_format == 'file') {
        $keys = array_keys($form_definitions);
        foreach ($keys as $key) {
            $output_array[$key] = $_POST[$key];
        }
        file_put_contents("{$storage_directory}/{$storage_filename}", serialize($output_array));
        // CHANGING PLAN TYPE
        if ($olduserinfo['journaling'] != $output_array['journaling'] && isset($output_array['journaling'])) {
            if ($olduserinfo['journaling']) {
                $plan_fn = "{$_SERVER['PWUSERS_DIR']}/{$olduserinfo['username']}/plan/plan.txt";
                @rename($plan_fn, $plan_fn . time());
                file_put_contents($plan_fn, $oldplan);
            }
            if ($output_array['journaling']) {
                $plan_fn = "{$_SERVER['PWUSERS_DIR']}/{$olduserinfo['username']}/plan/plan." . time() . ".txt";
                file_put_contents($plan_fn, $oldplan);
            }
        }
        // ADVERTISED LIST HANDLING
        $advlist = @file_get_contents("{$_SERVER['FILE_ROOT']}/stats/advertised.txt");
        if ($output_array['privacy'] == 1 && strpos($advlist, $output_array['username']) === FALSE) {
            file_put_contents("{$_SERVER['FILE_ROOT']}/stats/advertised.txt", "\n" . $output_array['username'], FILE_APPEND);
        }
        if ($output_array['privacy'] != 1 && strpos($advlist, $output_array['username']) !== FALSE) {
            file_put_contents("{$_SERVER['FILE_ROOT']}/stats/advertised.txt", str_replace("\n{$output_array['username']}", '', $advlist));
        }
        // private feed
        unlink("{$_SERVER['FILE_ROOT']}/resources/privatefeeds/{$olduserinfo['secretword']}.owner");
        file_put_contents("{$_SERVER['FILE_ROOT']}/resources/privatefeeds/{$output_array['secretfeedword']}.owner", "{$output_array['planusername']}");
        $oa_un = $output_array['username'];
        exec("rm -f {$_SERVER['FILE_ROOT']}/temp/*{$oa_un}*.cache");
        $_SERVER['PLAN_LOCATION_ARRAY'] = unserialize(file_get_contents("{$_SERVER['FILE_ROOT']}/stats/plan_locations.dat"));
        $_SERVER['PLAN_LOCATION_ARRAY'][$oa_un] = plan_get_real_location($output_array['planusername'] . str_replace(array('RSS', '@local'), '', $output_array['plantype']));
        file_put_contents("{$_SERVER['FILE_ROOT']}/stats/plan_locations.dat", serialize($_SERVER['PLAN_LOCATION_ARRAY']));
        // RENAMED USER HANDLING
        if ($output_array['username'] && $output_array['username'] != $_SERVER['USER']) {
            rename($storage_directory, str_replace($_SERVER['USER'], $output_array['username'], $storage_directory));
            // SNOOP STUFF
            if ($output_array['plantype'] == '@local') {
                if ($old_snoop_array != FALSE) {
                    $new_snoop_array = snoop_find(plan_read($output_array['username']));
                    snoop_clean(array_unique($old_snoop_array), $olduserinfo['username']);
                    snoop_add(array_unique($new_snoop_array), $output_array['username']);
                }
            }
            exec("ls {$_SERVER['PWUSERS_DIR']}/*/*list.txt", $list_list);
            foreach ($list_list as $list) {
                $list_data = file_get_contents($list);
                $list_data = str_replace($olduserinfo['username'], $output_array['username'], $list_data);
                file_put_contents($list, $list_data);
            }
            login($output_array['username'], $output_array['userpass']);
        } else {
            redirect('/');
        }
    }
}