Пример #1
0
$res = sql_query($qry);
sl_open_fileoperations();
while ($row = sql_fetch_assoc($res)) {
    $recipients = getReportRecipients($row['id_filter']);
    if (count($recipients) > 0) {
        $data = unserialize($row['filter_data']);
        $query_report = "SELECT class_name, file_name, report_name " . " FROM %lms_report " . " WHERE id_report = '" . $data['id_report'] . "'";
        $re_report = sql_query($query_report);
        if ($re_report && sql_num_rows($re_report)) {
            list($class_name, $file_name, $report_name) = sql_fetch_row($re_report);
            require_once _lms_ . '/admin/modules/report/' . $file_name;
            $temp = new $class_name($data['id_report']);
            $temp->author = $row['author'];
            $tmpfile = adaptFileName($row['filter_name']) . '.xls';
            //rand(0, 9).rand(0, 9).rand(0, 9).rand(0, 9).rand(0, 9).rand(0, 9).'';
            $file = sl_fopen('/tmp/' . $tmpfile, "w");
            fwrite($file, $temp->getXLS($data['columns_filter_category'], $data));
            fclose($file);
            $mailer->Subject = 'Sending scheduled report : ' . $row['filter_name'];
            $subject = 'Sending scheduled report : ' . $row['filter_name'];
            $body = date('Y-m-d H:i:s');
            if (!$mailer->SendMail(Get::sett('sender_event'), $recipients, $subject, $body, $path . $tmpfile, $row['filter_name'] . '.xls', false)) {
                docebo_cout('<b>' . $row['filter_name'] . '</b> Error while sending mail.' . $mailer->ErrorInfo . '<br />');
                //: '.$mailer->getError?
            } else {
                docebo_cout('<b>' . $row['filter_name'] . '</b> Mail sent to : ' . implode(',', $recipients) . '<br />');
            }
            //delete temp file
            unlink($path . $tmpfile . '');
        } else {
            docebo_cout('"' . $row['id_report'] . '" ' . '<br />');
Пример #2
0
 function send_certificate($id_certificate, $id_user, $id_course, $array_substituton = false, $download = true, $from_multi = false)
 {
     $id_meta = Get::req('idmeta', DOTY_INT, 0);
     if (!isset($_GET['idmeta'])) {
         $query_certificate = "\r\n\t\t\tSELECT cert_file\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate_assign\r\n\t\t\tWHERE id_certificate = '" . $id_certificate . "'\r\n\t\t\t\t AND id_course = '" . $id_course . "'\r\n\t\t\t\t AND id_user = '******' ";
     } else {
         $query_certificate = "\r\n\t\t\tSELECT cert_file\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign\r\n\t\t\tWHERE idUser = '******'\r\n\t\t\tAND idMetaCertificate = '" . $id_meta . "'";
     }
     $re = sql_query($query_certificate);
     echo mysql_error();
     if (mysql_num_rows($re) > 0) {
         if (!$download) {
             return;
         }
         require_once _base_ . '/lib/lib.download.php';
         list($cert_file) = sql_fetch_row($re);
         sendFile(CERTIFICATE_PATH, $cert_file);
         return;
     }
     $query_certificate = "\r\n\t\tSELECT name, cert_structure, base_language, orientation, bgimage\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate\r\n\t\tWHERE id_certificate = '" . $id_certificate . "'";
     list($name, $cert_structure, $base_language, $orientation, $bgimage) = sql_fetch_row(sql_query($query_certificate));
     require_once _base_ . '/lib/lib.upload.php';
     if ($array_substituton !== false) {
         $cert_structure = str_replace(array_keys($array_substituton), $array_substituton, $cert_structure);
     }
     $cert_structure = fillSiteBaseUrlTag($cert_structure);
     $cert_file = $id_course . '_' . $id_certificate . '_' . $id_user . '_' . time() . '_' . $name . '.pdf';
     sl_open_fileoperations();
     if (!($fp = sl_fopen(CERTIFICATE_PATH . $cert_file, 'w'))) {
         sl_close_fileoperations();
         return false;
     }
     if (!fwrite($fp, $this->getPdf($cert_structure, $name, $bgimage, $orientation, false, false, true))) {
         sl_close_fileoperations();
         return false;
     }
     fclose($fp);
     sl_close_fileoperations();
     //save the generated file in database
     if (!isset($_GET['idmeta'])) {
         $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_certificate_assign " . " ( id_certificate, id_course, id_user, on_date, cert_file ) " . " VALUES " . " ( '" . $id_certificate . "', '" . $id_course . "', '" . $id_user . "', '" . date("Y-m-d H:i:s") . "', '" . addslashes($cert_file) . "' ) ";
     } else {
         $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign " . " ( idUser, idMetaCertificate, idCertificate, on_date, cert_file ) " . " VALUES " . " ('" . $id_user . "', '" . $id_meta . "', '" . $id_certificate . "', '" . date("Y-m-d H:i:s") . "', '" . addslashes($cert_file) . "' ) ";
     }
     if (!sql_query($query)) {
         return false;
     }
     if ($from_multi) {
         return;
     }
     $this->getPdf($cert_structure, $name, $bgimage, $orientation, $download, false);
 }
Пример #3
0
 function privDuplicate($p_archive_filename)
 {
     $v_result = 1;
     // ----- Look if the $p_archive_filename exists
     if (!sl_is_file($p_archive_filename)) {
         // ----- Nothing to duplicate, so duplicate is a success.
         $v_result = 1;
         // ----- Return
         return $v_result;
     }
     // ----- Open the zip file
     if (($v_result = $this->privOpenFd('wb')) != 1) {
         // ----- Return
         return $v_result;
     }
     // ----- Open the temporary file in write mode
     if (($v_zip_temp_fd = @sl_fopen($p_archive_filename, 'rb')) == 0) {
         $this->privCloseFd();
         PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \'' . $p_archive_filename . '\' in binary write mode');
         // ----- Return
         return PclZip::errorCode();
     }
     // ----- Copy the files from the archive to the temporary file
     // TBC : Here I should better append the file and go back to erase the central dir
     $v_size = sl_filesize($p_archive_filename);
     while ($v_size != 0) {
         $v_read_size = $v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE;
         $v_buffer = fread($v_zip_temp_fd, $v_read_size);
         @fwrite($this->zip_fd, $v_buffer, $v_read_size);
         $v_size -= $v_read_size;
     }
     // ----- Close
     $this->privCloseFd();
     // ----- Close the temporary file
     @fclose($v_zip_temp_fd);
     // ----- Return
     return $v_result;
 }