Ejemplo n.º 1
0
$log->info('Starting Dropbox Upload');
$accessToken = "mcWxFEgcVbIAAAAAAAACgctpLBLkmojYc8kXY4IJDgQvtBdKiPXaUBT5bRDoj9Mu";
$appInfo = dbx\AppInfo::loadFromJsonFile($includes . "dropbox-sdk/Dropbox/app-info.json");
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
$accountInfo = $dbxClient->getAccountInfo();
$log->info('Starting CSV File Upload');
$dropbox_student_list = "/Apps/Attendance2/student_list.csv";
$log->info('Starting Dropbox Upload');
$CVSFileHandle = fopen($CVSFilePath, "rb");
if (!$CVSFileHandle) {
    $log->error('Could not Open CSV file');
    failed();
    exit;
}
$DropboxFileUploadResult = $dbxClient->uploadFile("/Apps/Attendance2/student_list.csv", dbx\WriteMode::force(), $CVSFileHandle);
if (!$DropboxFileUploadResult) {
    $log->error('Could not Upload CSV file to Dropbox');
    failed();
    exit;
}
$log->info('CSV File Uploaded to dropbox');
fclose($CVSFileHandle);
$log->info('Starting Drobox Picture upload');
$f = fopen($uploadedImage, "rb");
if ($f) {
    $result = $dbxClient->uploadFile("/Apps/Attendance2/{$dropboxImageName}", dbx\WriteMode::force(), $f);
    fclose($f);
}
/*******************************************************************************************************************************
********************************************************************************************************************************
Ejemplo n.º 2
0
         echo "<p>Error Number: " . mysqli_errno($conn) . "</p>";
         echo "<p>Basically, could not retrieve data to update the excel file of the students</p>";
         $error = 1;
     } else {
         if (!write_result_to_csv($output_file, $result)) {
             echo "<p>Could not create the excel file of students<p>";
             $error = 1;
         }
         mysqli_free_result($result);
     }
     //Update the dropbox
     if (!$error) {
         $dropbox_student_list = "/Apps/Attendance2/student_list.csv";
         $f = fopen($output_file, "rb");
         if ($f) {
             $result = $dbxClient->uploadFile("/Apps/Attendance2/student_list.csv", dbx\WriteMode::force(), $f);
             fclose($f);
         } else {
             echo "<p>There was an error updating the dropbox, but the student was updated</p>";
             $error = 1;
         }
     }
     if ($error) {
         echo "<p>Please try again, if the problem persists, please email the webmaster</p>";
     } else {
         echo "Success! Returning... Please Wait";
         echo '<meta http-equiv="refresh" content="0; URL=http://campuslifeohs.com/?p=49">';
     }
 } else {
     echo "<p style=\"color: red;margin: 20px\">There was an error retrieving the data. Please try again.</p>";
     echo "<p>Error code: " . mysqli_errno($conn) . "</p>";