independent and unofficial
Prince fan community
Welcome! Sign up or enter username and password to remember me
Forum jump
Forums > prince.org site discussion > New orgNote policy in effect, now, spinning flowers should be fixed
« Previous topic  Next topic »
  New topic   Printable     (Log in to 'subscribe' to this topic)
Author

Tweet     Share

Message
Thread started 10/14/03 5:08am

ben

Founder

avatar

moderator

New orgNote policy in effect, now, spinning flowers should be fixed

Title says most of it. Your notes that got deleted, (and maybe even some that didn't), basically all notes that were 30+ days old in your account, can be downloaded *for a limited time*.

Go to your orgnote page (http://www.prince.org/notes/) and you'll see the new link in the box, near the top, to download a .zip file of your orgnotes (it's one big text file zipped up). This should include all of the notes that were removed from your account. This is a one-time thing, the downloadable archive.

The zipfiles will be deleted in a month or so--so grab it while you can...

The new orgnote policy will be enforced (old notes deleted) on at least a weekly basis now, so get into good habits about reading and deleting, or they'll go poof smile
ben -- "the prince.org guy"
  - E-mail - orgNote - Report post to moderator
Reply #1 posted 10/15/03 3:15pm

cloud9mission

avatar

thanx for the zip file dude. Was worried I would lose all my notes. But tell me, you cant have created a zip file for every member manually, how do you create zip files on the fly like that??
  - E-mail - orgNote - Report post to moderator
Reply #2 posted 10/15/03 11:33pm

ben

Founder

avatar

moderator

They aren't created on the fly--they were created in batch, for all the users who had notes to be deleted, using a quick and dirty CLI script I wrote... here's some of the guts of it, if you're curious... (I've omitted some of the more "sensitive" parts)

[pre:1:ca49da9746]
#!/usr/bin/php

include_once('db.inc');

define('NOTES_ARCHIVE_AGE', 30);
define('ZIP', '/usr/bin/zip');
define('DEBUG', 1);

function export_notes(&$db, $userid, $age = NOTES_ARCHIVE_AGE) {
$old = time() - (86400 * $age);
if (DEBUG) echo "Exporting notes for userid=$userid, age=$age days:\n";
$q = "SELECT from_name, sent_date, subject, msg FROM ... (rest of query omitted but you get the idea...) ";
$notes = $db->fetchAll($q);
if (!is_array($notes)) { return ''; }
$p = '';
$tn = 0;
foreach ($notes as $n) {
$d = date('D M j Geyes T Y', $n['sent_date']);
$msg = wordwrap($n['msg']);
++$tn;
$p .= "

---
From: $n[from_name]
Subj: $n[subject]
Date: $d

$msg

";
}
if (0 == $tn) { if (DEBUG) { echo " (no eligible orgnotes)\n"; } return true; }
// make DOS line endings
$p = preg_replace("|\r|s", '', $p);
$p = preg_replace("|\n|s", "\r\n", $p);
if (DEBUG) echo " retrieved $tn orgNotes\n";
$tn = '/tmp/orgnotes.txt';
@unlink($tn);
$fp = fopen($tn, 'w');
if (!$fp) { return false; }
if (!fwrite($fp, $p)) { return false; }
fclose($fp);
$fs = filesize($tn);
if (DEBUG) echo " $fs bytes written to $tn\n";
$tn2 = tempnam('/tmp', 'onaz') . '.zip';
$cmd = ZIP ." -j $tn2 $tn";
if (DEBUG) echo " zipping with $cmd\n";
`$cmd`;
$inf = $db->fetchSingle("SELECT ... (some tokens to make a secure hash)...");
do {
$rand = rand();
$key = md5($rand . (...more tokens...) . $rand);
} while ($db->fetchSingle("SELECT userid FROM notes_archive WHERE file_key='$key'"));
if (DEBUG) echo " key selected: $key\n";
$ffn = (...full path omitted...) . $key . '.zip';
if (!copy($tn2, $ffn)) { return false; }
if (!$db->execute("REPLACE INTO notes_archive (userid, file_key) VALUES ($userid, '$key')")) { return false; }
if (DEBUG) echo " copied to $ffn and DB updated\n";
unlink($tn);
unlink($tn2);
if (DEBUG) echo " cleanup complete.\n";
return true;
}


$db = new DBConn('CLI');

$unc = $db->fetchAll( -- sql query here to get user ids with orgnotes -- );
foreach ($unc as $userid) {
$res = export_notes($db, $userid);
if (!$res) { echo "failed for $userid!"; }
}
?>
[/pre:1:ca49da9746]
ben -- "the prince.org guy"
  - E-mail - orgNote - Report post to moderator
Reply #3 posted 10/16/03 5:24am

teller

avatar

omfg

Man...maybe it's me, but PHP seems really cryptic-looking.

<---ASP
Fear is the mind-killer.
  - E-mail - orgNote - Report post to moderator
  New topic   Printable     (Log in to 'subscribe' to this topic)
« Previous topic  Next topic »
Forums > prince.org site discussion > New orgNote policy in effect, now, spinning flowers should be fixed