/**
  * Create an object from a path
  * @param string $objectPath
  * @param string $name
  * @param string $content
  * @return boolean|string
  */
 public function createObject($objectPath, $name, $content)
 {
     $success = false;
     $path = $this->getPath($objectPath);
     $tempPath = $this->xpdo->getOption(xPDO::OPT_CACHE_PATH) . 'dropbox/' . uniqid() . '/';
     if (!file_exists($tempPath)) {
         $this->xpdo->cacheManager->writeTree($tempPath);
     }
     $fileName = $tempPath . $name;
     if (!$this->xpdo->cacheManager->writeFile($fileName, $content)) {
         $this->addError('file', $this->xpdo->lexicon('file_err_create'));
         return false;
     }
     $response = null;
     try {
         # $response = $this->getClient()->putFile($container, $fileName);
         $f = fopen($fileName, "rb");
         $response = $this->getClient()->uploadFile($path . '/' . $name, dbx\WriteMode::add(), $f);
         fclose($f);
     } catch (Exception $e) {
         $error = $this->lexicon('uploadObjectsToContainer', array('path' => $path, 'message' => $e->getMessage()), 'error');
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $error);
         $this->addError('file', $error);
         return $success;
     }
     @unlink($fileName);
     if ($response) {
         $success = true;
     }
     #
     # die('public function createObject');
     return $success;
 }
Ejemplo n.º 2
0
    $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);
}
/*******************************************************************************************************************************
********************************************************************************************************************************
														Funtions
********************************************************************************************************************************
*******************************************************************************************************************************/
function failed()
{
    $to = $errorEmail;
    $subject = 'Creating CVS Failed on CampuslifeOHS';
    $message = $r;
    $headers = 'From: Cvsmaker@Campuslifeohs.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    mail($to, $subject, $message, $headers);
}
Ejemplo n.º 3
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>";