function plugin_filemanager_plugin_actions()
{
    global $myUser, $_, $conf;
    switch ($_['action']) {
        case 'plugin_filemanager_get':
            if (!$myUser->can('file', 'r')) {
                exit('permission denied');
            }
            $files = array();
            echo json_encode($files);
            break;
        case 'plugin_filemanager_edit':
            if (!$myUser->can('file', 'u')) {
                exit('permission denied');
            }
            require_once 'plugins/file/FileUploaded.class.php';
            $current = new FileUploaded();
            $current->date = time();
            $current->user = $myUser->getLogin();
            $current = isset($_['id']) && $_['id'] != '' ? $current->getById($_['id']) : $current;
            $current->save();
            break;
        case "plugin_filemanager_plugin_setting":
            if ($myUser->can('plugin_filemanager_validation', 'u')) {
                // $conf->put("plugin_filemanager_plugin_recipients",$_['mail']); // on enregistre le contenu des champs (adresses mails de destination) dans la bdd
                // $conf->put("plugin_filemanager_plugin_users",json_encode($_['users']));
                echo 'Enregistré.';
            } else {
                echo 'Permissions insuffisantes.';
            }
            break;
        case 'plugin_filemanager_delete':
            header('Content-type: application/json');
            if ($myUser->can('file', 'd')) {
                require_once 'plugins/file/FileUploaded.class.php';
                $response = array();
                try {
                    $current = new FileUploaded();
                    $current = $current->getById($_['id']);
                    @unlink($current->path);
                    if ($_['id'] != 0) {
                        $current->delete(array('id' => $_['id']));
                    }
                    $response['success'] = true;
                } catch (Exception $e) {
                    $response['message'] = 'Erreur : ' . $e->getMessage();
                }
                echo json_encode($response);
            }
            break;
        case 'plugin_filemanager_send_email_form':
            require_once 'plugins/file/FileUploaded.class.php';
            $file = new FileUploaded();
            if (isset($_['id'])) {
                $file = $file->getById($_['id']);
                if ($file->name != '') {
                    if ($file->checkPermission($myUser)) {
                        echo '<div class="label label-important">Attention, les permissions de de fichier seront modifiées en "acces public".</div><br/><br/>Destinaire : <input type="text" id="recipient" value=""><br/>

						  Fichier : <a target="_blank" href="' . $file->getUrl() . '">' . $file->name . '</a><br/>
						  <br/>Message<br/><textarea style="width:520px;" id="message">Veuillez trouver en pièce jointe le fichier : ' . $file->name . '</textarea><br/>';
                    }
                }
            }
            break;
        case 'plugin_filemanager_set_permission_form':
            require_once 'plugins/file/FileUploaded.class.php';
            $file = new FileUploaded();
            if (isset($_['id'])) {
                $file = $file->getById($_['id']);
                if ($file->name != '') {
                    if ($file->checkPermission($myUser)) {
                        $permissions = $file->getPermissions();
                        echo "\n\t\t\t\t\t<label class='checkbox'><input id='allow_internal' " . (in_array('$', $permissions) ? 'checked=checked' : '') . " type='checkbox'> Autoriser tous les utilisateurs ERP</label>\n\t\t\t\t\t<label class='checkbox'><input id='allow_all' " . (in_array('*', $permissions) ? 'checked=checked' : '') . " type='checkbox'> Autoriser tous le monde (même exterieur a l'erp)</label>\n\t\t\t\t\t<label>Autoriser les utilisateurs suivants (séparés par saut de ligne) </label>\n\n\t\t\t\t\t<textarea  style='width:510px;' placeholder='valentin.carruesco...' id='allow_user'>";
                        foreach ($permissions as $permission) {
                            if ($permission != '*' && $permission != '$') {
                                echo $permission . "\n";
                            }
                        }
                        echo "</textarea>";
                    }
                }
            }
            break;
        case 'plugin_filemanager_set_permission':
            header('Content-type: application/json');
            require_once 'plugins/file/FileUploaded.class.php';
            $response = array();
            $file = new FileUploaded();
            if (isset($_['id'])) {
                $file = $file->getById($_['id']);
                if ($file->name != '') {
                    $permissions = explode("\n", $_['allow_user']);
                    if ($_['allow_all'] == 'true') {
                        $permissions[] = '*';
                    }
                    if ($_['allow_internal'] == 'true') {
                        $permissions[] = '$';
                    }
                    $file->setPermissions($permissions);
                    $file->save();
                    $response['success'] = true;
                }
            }
            echo json_encode($response);
            break;
        case 'plugin_filemanager_send_mail':
            header('Content-type: application/json');
            require_once 'plugins/file/FileUploaded.class.php';
            $response = array();
            $file = new FileUploaded();
            if (isset($_['id']) && isset($_['recipient'])) {
                $file = $file->getById($_['id']);
                if ($file->name != '') {
                    if ($file->checkPermission($myUser)) {
                        $file->addPermission('*');
                        $file->save();
                        $mail = new Mail();
                        $mail->disableBorder();
                        $mail->setExpeditor('"' . $myUser->getFullName() . '" <' . $myUser->getMail() . '>');
                        $mail->setReply('"' . $myUser->getFullName() . '" <' . $myUser->getMail() . '>');
                        $mail->addRecipient($_['recipient']);
                        $mail->addAttachment($file->name . '|' . $file->mime, file_get_contents($file->path));
                        $mail->setTitle("Pièce jointe - " . $file->name, false);
                        $mail->setMessage($_['message']);
                        $mail->send();
                        $response['success'] = true;
                    }
                }
            }
            echo json_encode($response);
            break;
        case 'plugin_filemanager_search':
            require_once 'plugins/file/FileUploaded.class.php';
            $fileManager = new FileUploaded();
            $keyword = isset($_['keyword']) && $_['keyword'] != '' ? $_['keyword'] : '';
            $files = $fileManager->search($keyword);
            foreach ($files as $file) {
                if ($file->checkPermission($myUser)) {
                    ?>
			<div id="file_<?php 
                    echo $file->id;
                    ?>
" class="dz-preview dz-file-preview"> 
			  <div class="dz-details"> 
			    <div class="dz-filename"><a href="<?php 
                    echo $file->getUrl();
                    ?>
"><i class="fa fa-file-text-o"></i> <?php 
                    echo $file->name;
                    ?>
</a></div> - 
			    <div class="dz-size" data-dz-size><strong><?php 
                    echo $file->getSize();
                    ?>
</strong></div> 
			    <div class="dz-options"><ul class="dz-options"><li title="Envoyer par email" onclick="plugin_filemanager_send_mail_form(<?php 
                    echo $file->id;
                    ?>
);"><i class="fa fa-paper-plane-o"></i></li><li onclick="plugin_filemanager_set_permission_form('<?php 
                    echo $file->id;
                    ?>
');" title="Régler les permissions"><i class="fa fa-check-square-o"></i></li><li title="Supprimer" onclick="plugin_filemanager_delete(<?php 
                    echo $file->id;
                    ?>
)"><i class="fa fa-times"></i></li></ul></div> 
			    <div class="dz-tags"><span class="dz-tag label">Tags</span> <span class="dz-tag label label-inverse"><?php 
                    echo implode('</span> <span class="dz-tag label label-inverse">', $file->getTags());
                    ?>
</span></div> 
			  </div> 
			</div>
			<?php 
                }
            }
            break;
        case 'open_file':
            require_once 'plugins/file/FileUploaded.class.php';
            $file = new FileUploaded();
            if (isset($_['file'])) {
                $file = $file->getById($_['file']);
                if ($file->name != '') {
                    if ($file->checkPermission($myUser)) {
                        header('Content-type: ' . $file->mime);
                        header('Content-Transfer-Encoding: binary');
                        header('Expires: 0');
                        header('Cache-Control: must-revalidate');
                        header('Pragma: public');
                        ob_clean();
                        flush();
                        echo file_get_contents($file->path);
                    } else {
                        echo 'Acces interdit';
                    }
                }
            }
            break;
        case 'upload':
            require_once 'plugins/file/FileUploaded.class.php';
            header('Content-type: application/json');
            $response = array('error' => array());
            try {
                $max_size = 419430400;
                $allowed_ext = array('jpg', 'png', 'bmp', 'psd', 'doc', 'docx', 'xls', 'xlsx', 'mp3', 'mp4', 'ppt', 'txt', 'sql', 'pptx');
                $file = new FileUploaded($_FILES['file']);
                if (!$file->check('size', $max_size)) {
                    throw new Exception('Taille maximum dépassée, (autorisé : ' . $max_size . ' octets max) ');
                }
                if (!$file->check('extension', $allowed_ext)) {
                    throw new Exception('Extension non permise (autorisé : ' . implode(',', $allowed_ext) . ')');
                }
                $file->user = $myUser->getLogin();
                $file->permissions = '*';
                if (!$file->upload()) {
                    throw new Exception('Erreur lors de l\'envoi, merci de contacter un administrateur');
                }
                $response['file'] = array('id' => $file->id, 'url' => $file->url, 'name' => $file->name, 'ext' => $file->ext, 'tags' => $file->getTags(), 'size' => $file->getSize());
            } catch (Exception $e) {
                $response['error'][] = $e->getMessage();
            }
            echo json_encode($response);
            break;
    }
}
 public function sendEmailToAdmin()
 {
     $emailSender = new Mail();
     $emailSender->setTo("*****@*****.**");
     $emailSender->setFrom($this->email);
     $emailSender->setMessage($this->createEmailMessageBodyForContact());
     $emailSender->setSubject("An Email from " . $this->name . ".");
     return $emailSender->sendEmail($emailSender);
 }
Beispiel #3
0
    $oldpass = $_POST['oldpass'];
    $newpass = $_POST['newpass'];
    $reppass = $_POST['reppass'];
    if (rtrim($curpass) == $oldpass) {
        if ($newpass != $reppass) {
            $error = "The password's you have entered do not match. Please try again.";
        } else {
            if (strlen($newpass) < 3 || strlen($newpass) > 15) {
                $error = "Password must be between 3 and 15 characters!";
            } else {
                $new = $db->encrypt($_POST['newpass'], enc_key);
                $db->setPassword($_SESSION['user']['username'], $new);
                $_SESSION['user']['password'] = $new;
                $mailer->setReceiver($_SESSION['user']['email']);
                $mailer->setSubject("Password Change");
                $mailer->setMessage("You've requested a password change. Your new password is as follows:<br><br>Your password: <b>" . $newpass . "</b>");
                if ($mailer->sendMail()) {
                    $success = 'Your password has been set and emailed to you!';
                } else {
                    $success = 'Your password has been set, but we were unable to send an email. Your new password: <b>' . $newpass . '</b>!';
                }
            }
        }
    } else {
        $error = "Please check your current password and try again. '" . $curpass . "'";
    }
}
if (isset($_POST['avatar'])) {
    $url = filter_var($_POST['avatar'], FILTER_SANITIZE_URL);
    if (empty($_POST['avatar'])) {
        $db->setAvatarUrl($_SESSION['user']['username'], null);
<?php

$pack = 'contact-user';
$data['liensCSS']->add($pack, 'style03.css');
$page['path'] = $path['ressources'] . $pack . '/';
$data['namepage'] = 'Contact';
// Fil d'Ariane --
$data['navi']->add('?user=contact', 'Contacts');
if (isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['email']) && isset($_POST['message'])) {
    require $path['class'] . 'Mail.php';
    $mail = new Mail();
    $mail->setTo('*****@*****.**', 'Admin');
    $mail->setTo($_POST['email'], $_POST['prenom'] . ' ' . $_POST['nom']);
    $mail->setMessage($_POST['message']);
    $mail->envoyer();
}
Beispiel #5
0
    $email = $_POST['email'];
    if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        $error = "Invalid email address";
    } else {
        $valid = $db->checkEmail($email);
        if ($valid == null) {
            $error = "That email does not exist";
        } else {
            $success = "Your password has been emailed to you.";
            $pass = $db->decrypt($valid['password'], enc_key);
            $mailer->setReceiver($valid['email']);
            $mailer->setSubject("Password Recovery");
            $message = "You have requested your password, it is below:<br><br>";
            $message .= "Username: <b>" . $valid['username'] . "</b><br>";
            $message .= "Password: <b>" . $pass . "</b><br>";
            $mailer->setMessage($message);
            $mailer->sendMail();
        }
    }
}
?>
<!DOCTYPE html>
<html>
	<?php 
include 'assets/templates/global/head.php';
?>
<body>
	
	<div class="container text-center" style="width:300px;">
		<div class="col-md-12 col-md-12">
			<h1 class="text-primary text-center">Recover</h1>