function PortalNotesFiles($file, &$PortalNotesFilesError)
{
    global $PortalNotesFilesPath;
    if (!$file || !is_uploaded_file($file['tmp_name'])) {
        //no file uploaded
        $PortalNotesFilesError = _('File not uploaded');
    }
    //Check the post_max_size & php_value upload_max_filesize values in the php.ini file
    //extensions white list
    $white_list = array('.doc', '.docx', '.txt', '.pdf', '.xls', '.xlsx', '.csv', '.jpg', '.jpeg', '.png', '.gif', '.zip', '.ppt', '.pptx', '.mp3', '.wav', '.avi', '.mp4', '.ogg');
    if (!in_array(mb_strtolower(mb_strrchr($file['name'], '.')), $white_list)) {
        $PortalNotesFilesError = _('Unauthorized file attached extension') . ': ' . mb_strtolower(mb_strrchr($file['name'], '.'));
    }
    if ($file['size'] > 10240000) {
        // file size must be < 10Mb
        $PortalNotesFilesError = _('File attached size') . ' > 10Mb: ' . $file['size'] / 1024 / 1024 . 'Mb';
    }
    //if current sYear folder doesnt exist, create it!
    if (!is_dir($PortalNotesFilesPath)) {
        if (!mkdir($PortalNotesFilesPath)) {
            $PortalNotesFilesError = _('Folder not created') . ': ' . $PortalNotesFilesPath;
        }
    }
    if (!is_writable($PortalNotesFilesPath)) {
        $PortalNotesFilesError = _('Folder not writable') . ': ' . $PortalNotesFilesPath;
    }
    //see PHP user rights
    if (!empty($PortalNotesFilesError)) {
        return '';
    }
    //store file
    $file_name = str_replace(' ', '_', trim($file['name']));
    //sanitize name
    $file_name = no_accents($file_name);
    $new_file = $PortalNotesFilesPath . $file_name;
    if (move_uploaded_file($file['tmp_name'], $new_file)) {
        return $new_file;
    }
    return '';
}
Exemplo n.º 2
0
         if ($CFG->smtppass) {
             $mail->Password = $CFG->smtppass;
         }
         foreach (array_unique($address_array) as $cellemail) {
             $mail->AddBCC($cellemail);
             //echo $cellemail . '<br>';
         }
         if ($CFG->noreplyaddress) {
             //if noreply isn't specified, use moodle default.
             $mail->From = $CFG->noreplyaddress;
         } else {
             $mail->From = 'noreply@' . get_host_from_url($CFG->wwwroot);
         }
         $mail->FromName = "noreply";
         $mail->Subject = no_accents($subjectcell);
         $mail->Body = no_accents($shortname . $fullname . $name);
         $mail->WordWrap = 75;
         $mail->CharSet = 'UTF-8';
         if ($mail->Send()) {
             echo '<div class="box generalbox" style="background-color: #73c376; font-weight: bold;"><p>' . get_string('textmessage_sent', 'block_cancelcourse') . '</p></div>';
             $text_success = true;
         } else {
             echo print_error('textmessage_notsent', 'block_cancelcourse' . $mail->ErrorInfo);
             $text_success = false;
         }
         $mail->SmtpClose();
     } else {
         //error!
         echo print_error('textmessage_configerror', 'block_cancelcourse');
     }
 } else {
Exemplo n.º 3
0
function is_correct($mot)
{
    $mot = no_accents(strtolower($mot));
    if ((ord($mot[0]) >= 97 and ord($mot[0]) <= 122 or ord($mot[0]) == 45) and (ord($mot[1]) >= 97 and ord($mot[1]) <= 122 or ord($mot[1]) == 45) and ord($mot[0]) != 60) {
        return true;
    } else {
        return false;
    }
}