Пример #1
0
require "../config/preferences.php";
require_once NSSDROPBOX_LIB_DIR . "Smartyconf.php";
require_once NSSDROPBOX_LIB_DIR . "NSSDropoff.php";
if ($theDropbox = new NSSDropbox($NSSDROPBOX_PREFS)) {
    //
    // This page handles the listing of dropoffs made by an
    // authenticated user.  If the user is NOT authenticated,
    // then an error is presented.
    //
    $theDropbox->SetupPage();
    if ($theDropbox->authorizedUser()) {
        //
        // Returns an array of all NSSDropoff instances belonging to
        // this user.
        //
        $allDropoffs = NSSDropoff::dropoffsFromCurrentUser($theDropbox);
        //
        // Start the web page and add some Javascript to automatically
        // fill-in and submit a pickup form when a dropoff on the page
        // is clicked.
        //
        $iMax = count($allDropoffs);
        $totalsize = 0;
        $smarty->assign('countDropoffs', $iMax);
        if ($allDropoffs && $iMax > 0) {
            $outputDropoffs = array();
            $i = 0;
            foreach ($allDropoffs as $dropoff) {
                $outputDropoffs[$i] = array();
                $outputDropoffs[$i]['claimID'] = $dropoff->claimID();
                $outputDropoffs[$i]['senderName'] = $dropoff->senderName();
Пример #2
0
$smarty->assign('progress_id', uniqid(""));
function generateEmailTable($aDropbox, $label = 1)
{
    global $smarty;
    $smarty->assign('recipEmailNum', $label);
}
if ($theDropbox = new NSSDropbox($NSSDROPBOX_PREFS)) {
    if ($_POST['Action'] == "dropoff") {
        //
        // Posted form data indicates that a dropoff form was filled-out
        // and submitted; if posted from data is around, creating a new
        // dropoff instance creates a new dropoff using said form data.
        //
        $theDropbox->SetupPage();
        $template = 'show_dropoff.tpl';
        if ($theDropoff = new NSSDropoff($theDropbox)) {
            // Allow HTMLWrite to over-ride the template file if it wants to
            $template2 = $theDropoff->HTMLWrite();
            if ($template2 != "") {
                $template = $template2;
            }
        }
        $smarty->display($template);
    } else {
        //
        // We need to present the dropoff form.  This page will include some
        // JavaScript that does basic checking of the form prior to submission
        // as well as the code to handle the attachment of multiple files.
        // After all that, we start the page body and write-out the HTML for
        // the form.
        //
Пример #3
0
    // creation date:
    //
    printf("\nNSSDropbox Cleanup of zendto for preference file:\n  %s\n\n", $argv[1]);
    printf("Gathering dropoffs with creation timestamps before: %s\n", timestampForTime(time() - $theDropbox->retainDays() * 24 * 60 * 60));
    $oldDropoffs = NSSDropoff::dropoffsOutsideRetentionTime($theDropbox);
    if ($oldDropoffs && ($iMax = count($oldDropoffs))) {
        $i = 0;
        while ($i < $iMax) {
            printf("- Removing [%s] %s <%s>\n", $oldDropoffs[$i]->claimID(), $oldDropoffs[$i]->senderName(), $oldDropoffs[$i]->senderEmail());
            $oldDropoffs[$i]->removeDropoff();
            $i++;
        }
    } else {
        print "No dropoffs have expired.\n\n";
    }
    //
    // Do a orphan purge, too:
    //
    printf("Purging orphaned dropoffs:\n");
    NSSDropoff::cleanupOrphans($theDropbox);
    //
    // Now prune the auth table of old keys
    //
    printf("Purging old sender verification data:\n");
    $theDropbox->PruneAuthData();
    //
    // Now prune the req table of old keys
    //
    printf("Purging old request data:\n");
    $theDropbox->PruneReqData();
}
Пример #4
0
// configuration!
//
require "../config/preferences.php";
require_once NSSDROPBOX_LIB_DIR . "MyZendTo.Smartyconf.php";
require_once NSSDROPBOX_LIB_DIR . "NSSDropoff.php";
//
// This is pretty straightforward; depending upon the form data coming
// into this PHP session, creating a new dropoff object will either
// display the claimID-and-claimPasscode "dialog" (no form data or
// missing/invalid passcode); display the selected dropoff if the
// claimID and claimPasscode are valid OR the recipient matches the
// authenticate user -- it's all built-into the NSSDropoff class.
//
if ($theDropbox = new NSSDropbox($NSSDROPBOX_PREFS, TRUE)) {
    $theDropbox->SetupPage();
    if ($thePickup = new NSSDropoff($theDropbox)) {
        $claimID = $thePickup->claimID();
        $smarty->assign('claimID', $claimID);
        $success = $thePickup->removeDropoff();
        # If next=="index" then redirect them to the autoHome page without delay
        if ($success && $_POST['next'] == "index") {
            Header("HTTP/1.1 302 Moved Temporarily");
            Header("Location: " . $NSSDROPBOX_URL);
            exit;
        }
        $smarty->assign('success', $success);
        $smarty->assign('autoHome', TRUE);
        if (!$success) {
            NSSError("Unable to remove the dropoff.  Please contact the system administrator.", "Unable to remove " . $claimID);
        }
    }
Пример #5
0
//
//
// Include the dropbox preferences -- we need this to have the
// dropbox filepaths setup for us, beyond simply needing our
// configuration!
//
require "../config/preferences.php";
require_once NSSDROPBOX_LIB_DIR . "Smartyconf.php";
require_once NSSDROPBOX_LIB_DIR . "NSSDropoff.php";
//
// This is pretty straightforward; depending upon the form data coming
// into this PHP session, creating a new dropoff object will either
// display the claimID-and-claimPasscode "dialog" (no form data or
// missing/invalid passcode); display the selected dropoff if the
// claimID and claimPasscode are valid OR the recipient matches the
// authenticate user -- it's all built-into the NSSDropoff class.
//
if ($theDropbox = new NSSDropbox($NSSDROPBOX_PREFS)) {
    $theDropbox->SetupPage();
    if ($thePickup = new NSSDropoff($theDropbox)) {
        $claimID = $thePickup->claimID();
        $smarty->assign('claimID', $claimID);
        $success = $thePickup->resendDropoff();
        $smarty->assign('success', $success);
        $smarty->assign('autoHome', TRUE);
        if (!$success) {
            NSSError("Unable to re-send the dropoff.  Please contact the system administrator.", "Unable to re-send " . $claimID);
        }
    }
}
$smarty->display('resend.tpl');
Пример #6
0
require "../config/preferences.php";
require_once NSSDROPBOX_LIB_DIR . "MyZendTo.Smartyconf.php";
require_once NSSDROPBOX_LIB_DIR . "NSSDropoff.php";
if ($theDropbox = new NSSDropbox($NSSDROPBOX_PREFS, TRUE)) {
    //
    // This page handles the listing of an authenticated user's
    // dropoffs.  If the user is NOT authenticated, then an error
    // is presented.
    //
    $theDropbox->SetupPage();
    if ($theDropbox->authorizedUser() && $theDropbox->authorizedUserData('grantAdminPriv')) {
        //
        // Returns an array of all NSSDropoff instances belonging to
        // this user.
        //
        $allDropoffs = NSSDropoff::allDropoffs($theDropbox);
        //
        // Start the web page and add some Javascript to automatically
        // fill-in and submit a pickup form when a dropoff on the page
        // is clicked.
        //
        $iMax = count($allDropoffs);
        $totalsize = 0;
        $smarty->assign('countDropoffs', $iMax);
        if ($allDropoffs && $iMax > 0) {
            $outputDropoffs = array();
            $i = 0;
            foreach ($allDropoffs as $dropoff) {
                $outputDropoffs[$i] = array();
                $outputDropoffs[$i]['claimID'] = $dropoff->claimID();
                $outputDropoffs[$i]['senderName'] = $dropoff->senderName();
Пример #7
0
//
//
//
// Include the dropbox preferences -- we need this to have the
// dropbox filepaths setup for us, beyond simply needing our
// configuration!
//
require "../config/preferences.php";
require_once NSSDROPBOX_LIB_DIR . "MyZendTo.Smartyconf.php";
require_once NSSDROPBOX_LIB_DIR . "NSSDropoff.php";
//
// This is pretty straightforward; depending upon the form data coming
// into this PHP session, creating a new dropoff object will either
// display the claimID-and-claimPasscode "dialog" (no form data or
// missing/invalid passcode); display the selected dropoff if the
// claimID and claimPasscode are valid OR the recipient matches the
// authenticate user -- it's all built-into the NSSDropoff class.
//
if ($theDropbox = new NSSDropbox($NSSDROPBOX_PREFS, TRUE)) {
    $theDropbox->SetupPage();
    if ($thePickup = new NSSDropoff($theDropbox)) {
        //
        // Start the page and add some Javascript for automatically
        // filling-in the download form and submitting it when the
        // user clicks on a file in the displayed dropoff.
        //
        $theDropbox->SetupPage($thePickup->HTMLOnLoadJavascript());
        $output = $thePickup->HTMLWrite();
    }
}
$smarty->display($output ? $output : 'error.tpl');
Пример #8
0
// The necessary authentication is all handled by:
//
//   (1) When the dropbox instance is created, the page's cookie is
//       consulted and authentication may be pulled from that.
//   (2) When the pickup instance is created, the authenticated
//       username itself may imply authorization; otherwise, posted
//       form data (claimID and claimPasscode) will provide the
//       authorization.
//
// Also, once the pickup instance has been created, check for an AuthData
// record that matches the posted form data and IP it's being posted from.
// Unless they are an authenticated user, in which case don't check AuthData.
//
if ($theDropbox = new NSSDropbox($NSSDROPBOX_PREFS)) {
    $theDropbox->SetupPage();
    $thePickup = new NSSDropoff($theDropbox);
    // If not an authenticated user, go and get their AuthData record from
    // the posted hash. Even if they are presetnt, check the name matches
    // their IP address.
    // If anything fails, use NSSError to post an error message saying they
    // have failed checks and should click again on the link they were sent.
    if ($theDropbox->humanDownloads() && !$theDropbox->authorizedUser() && $theDropbox->captcha() !== 'disabled') {
        // AYAH $theDropbox->recaptchaPrivateKey() !== 'disabled') {
        $authIP = '';
        $authEmail = '';
        $authOrganization = '';
        $authExpiry = 0;
        $auth = $_POST['auth'] ? $_POST['auth'] : $_GET['auth'];
        $result = $theDropbox->ReadAuthData($auth, $authIP, $authEmail, $authOrganization, $authExpiry);
        if (!$result) {
            $theDropbox->SetupPage();
Пример #9
0
if (count($argv) < 2) {
    printf("\n  usage:\n  \n   %s <ZendTo preferences.php file> <email address>\n  \n   The ZendTo preferences.php file path should be canonical, not relative.\n   Alternatively, do\n     export ZENDTOPREFS=<full file path of preferences.php>\n     %s <email address>\n\n   If no email address is provided, the summary is displayed on stdout.\n\n", $argv[0], $argv[0]);
    return 0;
}
if (!preg_match('/^\\/.+/', $argv[1])) {
    echo "ERROR:  You must provide a canonical path to the preferences.php file.\n";
    return 1;
}
include $argv[1];
include_once NSSDROPBOX_LIB_DIR . "Smartyconf.php";
include_once NSSDROPBOX_LIB_DIR . "NSSDropoff.php";
if ($theDropbox = new NSSDropbox($NSSDROPBOX_PREFS)) {
    //
    // Get all drop-offs for the past 24 hours:
    //
    $newDropoffs = NSSDropoff::dropoffsCreatedToday($theDropbox);
    $totalFiles = 0;
    $totalBytes = 0.0;
    if ($newDropoffs && ($iMax = count($newDropoffs))) {
        $i = 0;
        $message = "Dropoff summary for " . timestampForTime(time() - 24 * 60 * 60) . " - " . timestampForTime(time()) . " :\n\n";
        $message .= "=========================================================================================\n";
        $message .= sprintf("%-18s %22s  %s\n", "Claim ID", "Total Files & Size", "Sender");
        $message .= "=========================================================================================\n";
        while ($i < $iMax) {
            //  Get a file list:
            $files = $newDropoffs[$i]->files();
            if ($files && ($fileCount = $files['totalFiles'])) {
                $totalFiles += $fileCount;
                $totalBytes += floatval($files['totalBytes']);
                $message .= sprintf("[%s] %3d file%s   %10s  %s <%s>\n", $newDropoffs[$i]->claimID(), $fileCount, $fileCount != 1 ? "s" : " ", NSSFormattedMemSize($files['totalBytes']), $newDropoffs[$i]->senderName(), $newDropoffs[$i]->senderEmail());
Пример #10
0
             // Write failed.
             NSSError("Database failure writing authentication key. Please contact your system administrator.", "Internal Error");
             displayPickupCheck($theDropbox, $smarty, $ayah, $auth);
             exit(0);
         }
     } else {
         // The CAPTCHA response was wrong, so re-present the page with an error
         NSSError($smarty->getConfigVariable('ErrorNotPerson'), "Test failed");
         displayPickupCheck($theDropbox, $smarty, $ayah, $auth);
         exit(0);
     }
     // They have passed the test and we have written their AuthData record.
     $theDropbox->SetupPage();
     $smarty->assign('auth', $auth);
     // And save their auth key!
     if ($thePickup = new NSSDropoff($theDropbox)) {
         //
         // Start the page and add some Javascript for automatically
         // filling-in the download form and submitting it when the
         // user clicks on a file in the displayed dropoff.
         //
         $theDropbox->SetupPage($thePickup->HTMLOnLoadJavascript());
         $smarty->display($thePickup->HTMLWrite());
     } else {
         $smarty->display('error.tpl');
     }
 } else {
     // It's not a pickup attempt, it's going to display the CAPTCHA form
     // instead which will pass us back to me again.
     displayPickupCheck($theDropbox, $smarty, $ayah, '');
 }
Пример #11
0
 public static function cleanupOrphans($aDropbox)
 {
     $qResult = $aDropbox->database->DBDropoffsAll();
     $scrubCount = 0;
     if ($qResult && ($iMax = count($qResult))) {
         //
         //  Build a list of claim IDs and walk the dropoff directory
         //  to remove any directories that aren't in the database:
         //
         $dropoffDir = $aDropbox->dropboxDirectory();
         if ($dirRes = opendir($dropoffDir)) {
             $i = 0;
             $validClaimIDs = array();
             while ($i < $iMax) {
                 $nextClaim = $qResult[$i]['claimID'];
                 //  If there's no directory, then we should scrub this entry
                 //  from the database:
                 if (!is_dir($dropoffDir . "/" . $nextClaim)) {
                     if ($aDropoff = new NSSDropoff($aDropbox, $qResult[$i])) {
                         $aDropoff->removeDropoff(FALSE);
                         echo "- Removed orphaned record:             {$nextClaim}\n";
                     } else {
                         echo "- Unable to remove orphaned record:    {$nextClaim}\n";
                     }
                     $scrubCount++;
                 } else {
                     $validClaimIDs[] = $nextClaim;
                 }
                 $i++;
             }
             while ($nextDir = readdir($dirRes)) {
                 //  Each item is a NAME, not a PATH.  Test whether it's a directory
                 //  and no longer in the database:
                 if ($nextDir != '.' && $nextDir != '..' && is_dir($dropoffDir . "/" . $nextDir) && !in_array($nextDir, $validClaimIDs)) {
                     if (rmdir_r($dropoffDir . "/" . $nextDir)) {
                         echo "- Removed orphaned directory:          {$nextDir}\n";
                     } else {
                         echo "- Unable to remove orphaned directory: {$nextDir}\n";
                     }
                     $scrubCount++;
                 }
             }
             closedir($dirRes);
         }
     }
     if ($scrubCount) {
         printf("%d orphan%s removed.\n\n", $scrubCount, $scrubCount == 1 ? "" : "s");
     } else {
         echo "No orphans found.\n\n";
     }
 }