Exemple #1
0
function isAllowed()
{
    if (!isLogged()) {
        setFlash("Veuillez vous connecter pour pouvoir effectuer cette action.", "danger");
        redirect('index.php');
    }
}
function initialize_page()
{
    $category_id = requestIdParam();
    $category = Categories::FindById($category_id);
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if (isset($_POST['delete'])) {
        $category->delete(true);
        setFlash("<h3>Category Deleted</h3>");
        redirect("/admin/list_categories/");
    } else {
        if ($post_action == "Edit Category" || $post_action == "Edit and Return to List") {
            $category->display_name = getPostValue('display_name');
            $category->name = slug(getPostValue('display_name'));
            $category->content = getPostValue('category_content');
            $category->save();
            setFlash("<h3>Category Edited</h3>");
            if ($post_action == "Edit and Return to List") {
                redirect("admin/list_categories/");
            }
        }
    }
}
Exemple #3
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add Document" || $post_action == "Add and Return to List") {
        $name = $_POST['name'];
        $file_type = getFileExtension($_FILES['file']['name']);
        $filename = slug(getFileName($_FILES['file']['name']));
        $filename_string = $filename . "." . $file_type;
        // Check to make sure there isn't already a file with that name
        $possibledoc = Documents::FindByFilename($filename_string);
        if (is_object($possibledoc)) {
            setFlash("<h3>Failure: Document filename already exists!</h3>");
            redirect("admin/add_document");
        }
        $target_path = SERVER_DOCUMENTS_ROOT . $filename_string;
        if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
            $new_doc = MyActiveRecord::Create('Documents', array('name' => $name, 'filename' => $filename_string, 'file_type' => $file_type));
            $new_doc->save();
            if (!chmod($target_path, 0644)) {
                setFlash("<h3>Warning: Document Permissions not set; this file may not display properly</h3>");
            }
            setFlash("<h3>Document uploaded</h3>");
        } else {
            setFlash("<h3>Failure: Document could not be uploaded</h3>");
        }
        if ($post_action == "Add and Return to List") {
            redirect("admin/list_documents");
        }
    }
}
Exemple #4
0
function uploadImage($name, $alt, $bdd, $sizeMax)
{
    $fileSize = '';
    if ($_FILES['img']['error'] == 2) {
        $fileSize = "<br/>Taille maximale: " . $sizeMax . " octets; Taille du fichier (probablement plus)";
        setFlash("Problème dans l'upload " . $fileSize, "error");
    }
    $type = ['image/png', 'image/gif', 'image/jpg', 'image/jpeg'];
    if (in_array($_FILES['img']['type'], $type)) {
        $src = 'http://cd84-tennis-de-table.fr/images/gallerie/' . $name;
        $src_min = $src;
        $alt = $_POST['alt'];
        $insert_q = $bdd->prepare("INSERT INTO image(id, src, src_min, alt, valid) VALUES ('', :src, :src_min, :alt, '1')");
        $insert_q->execute(array('src' => $src, 'src_min' => $src_min, 'alt' => $alt));
        $uploaddir = 'images/gallerie/';
        $uploadfile = $uploaddir . basename($name);
        if (move_uploaded_file($_FILES['img']['tmp_name'], $uploadfile)) {
            setFlash("Le fichier est valide, et a été upload avec succès.");
        } else {
            setFlash("Problème dans l'upload " . $fileSize, "error");
        }
    } else {
        if ($_FILES['img']['error'] == 0) {
            setFlash('Le fichier n\'est pas une image: ' . $_FILES['img']['type'], 'error');
        }
    }
}
 public function view($user)
 {
     if (empty($user)) {
         $this->Session - setFlash('Invalid user.');
         $this->redirect('/');
     }
 }
Exemple #6
0
function initialize_page()
{
    $type_id = requestIdParam();
    $type = EventTypes::FindById($type_id);
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Save Type" || $post_action == "Edit and Return to List") {
        if (isset($_POST['delete'])) {
            $type->updateEventTypes();
            $type->delete(true);
            setFlash("<h3>Event type deleted</h3>");
            redirect("/admin/list_event_types");
        } else {
            $type->name = $_POST['name'];
            $type->color = $_POST['color'];
            $type->text_color = EventTypes::$color_array[$type->color];
            $type->save();
            setFlash("<h3>Event type changes saved</h3>");
            if ($post_action == "Edit and Return to List") {
                redirect("admin/list_event_types");
            }
        }
    }
}
Exemple #7
0
function checkGetCsrf()
{
    if (!isset($_SESSION['OLD_CSRF']) || !isset($_GET['CSRF']) || $_SESSION['OLD_CSRF'] != $_GET['CSRF']) {
        setFlash('error', "Vous n'etes pas autorisé  à effectuer cette action.");
        redirect(401, url('home'));
        exit(1);
    }
}
Exemple #8
0
function initialize_page()
{
    $page_id = requestIdParam();
    $page = Pages::FindById($page_id);
    // get all the areas
    $areas = Areas::FindPublicAreas();
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Save Page" || $post_action == "Save and Return to List") {
        if (isset($_POST['delete'])) {
            $page->delete(true);
            setFlash("<h3>Page deleted</h3>");
            redirect("/admin/list_pages");
        } else {
            $page->display_name = $_POST['display_name'];
            $oldname = $page->name;
            if (ALLOW_SHORT_PAGE_NAMES) {
                if ($_POST['name'] == "") {
                    $page->name = slug($_POST['display_name']);
                } else {
                    $page->name = slug($_POST['name']);
                }
            } else {
                $page->name = slug($_POST['display_name']);
            }
            $page->content = $_POST['page_content'];
            $page->template = $_POST['template'];
            $page->public = checkboxValue($_POST, 'public');
            // Pages can either be directly assigned to areas, or assigned as a sub-page.
            // It's an either-or thing. For now, default to areas if they're selected (ie, if both selected, ignore the sub-page)
            // synchronize the users area selections
            $selected_areas = array();
            if (isset($_POST['selected_areas'])) {
                $selected_areas = $_POST['selected_areas'];
            }
            if (count($selected_areas) > 0) {
                $page->parent_page_id = null;
                $page->updateSelectedAreas($selected_areas);
            } else {
                if ($_POST['parent_page'] != "") {
                    $page->parent_page_id = $_POST['parent_page'];
                } else {
                    $page->parent_page_id = null;
                }
            }
            $page->save();
            $page->checkAlias($selected_areas, $oldname);
            setFlash("<h3>Success. Database Updated</h3>");
            if ($post_action == "Save and Return to List") {
                redirect("admin/list_pages");
            }
        }
    }
}
 private function UpdateUserInfo($id)
 {
     $user = new model\User($_POST['username'], '', $id);
     if (isset($_POST['permission']) && is_array($_POST['permission'])) {
         foreach ($_POST['permission'] as $permission) {
             $user->AddPermission($permission);
         }
     }
     $this->model->Update($user);
     setFlash("You've edited " . htmlspecialchars($user->GetUsername()), 'success');
     $this->Redirect('/admin/user');
 }
 public function view($id = null)
 {
     if (!$id) {
         $this->Session - setFlash('Tarea inv&aacute;lida');
         $this->redirect(array('action' => 'index', 'pendiente'), null, true);
     }
     $this->Tarea->id = $id;
     if (!$this->Tarea->exists()) {
         throw new NotFoundException('Tarea inv&aacute;lido');
     }
     $this->set('tarea', $this->Tarea->findAllById($id));
 }
function initialize_page()
{
    $section_id = requestIdParam();
    $section = Sections::FindById($section_id);
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Edit Section" || $post_action == "Edit and Return to List") {
        if (isset($_POST['delete'])) {
            $items = $section->findItems();
            $selected_sections = array('1');
            foreach ($items as $item) {
                $item->updateSelectedSections($selected_sections);
            }
            $section->delete(true);
            setFlash("<h3>Section deleted</h3>");
            //$main_portlink = ( DISPLAY_ITEMS_AS_LIST ) ? "admin/portfolio_list/alphabetical" : "admin/portfolio_list";
            //redirect( $main_portlink );
            redirect("admin/portfolio_list");
        } else {
            if (ALLOW_SHORT_PAGE_NAMES) {
                if ($_POST['name'] == "") {
                    $section->name = slug($_POST['display_name']);
                } else {
                    $section->name = slug($_POST['name']);
                }
            } else {
                $section->name = slug($_POST['display_name']);
            }
            $section->display_name = $_POST['display_name'];
            $section->template = $_POST['template'];
            $section->content = $_POST['section_content'];
            $section->public = isset($_POST['public']) ? 1 : 0;
            $selected_areas = array();
            if (isset($_POST['selected_areas'])) {
                $selected_areas = $_POST['selected_areas'];
            } else {
                $selected_areas = array('2');
            }
            $section->updateSelectedAreas($selected_areas);
            $section->save();
            setFlash("<h3>Section changes saved</h3>");
            if ($post_action == "Edit and Return to List") {
                //$main_portlink = ( DISPLAY_ITEMS_AS_LIST ) ? "admin/portfolio_list/alphabetical" : "admin/portfolio_list";
                //redirect( $main_portlink );
                redirect("admin/portfolio_list");
            }
        }
    }
}
Exemple #12
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Delete Selected") {
        foreach ($_POST['delete'] as $blast_id) {
            $blast = MailBlast::FindById($blast_id);
            $blast->delete();
        }
        setFlash("<h3>Mail Blasts Updated</h3>");
    }
}
Exemple #13
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
        if ($post_action == "Submit All Options and Preview") {
            $blast_config = $_SESSION['blaster'];
            if (!is_array($blast_config['lists'])) {
                setFlash('<h3>You must Select a list to send to.</h3>');
                redirect(BASEHREF . "admin/mail_blast");
            }
        }
    }
}
 private static function showForm($action)
 {
     // Postando?
     if (count($_POST) > 0) {
         /* @var $inscricao Inscricao */
         $inscricao = Inscricoes::getInstance()->getById(get_query_var('avaliacao') / 13);
         /* @var $evento Evento */
         $questionario = $inscricao->evento()->getQuestionarioAvaliacao();
         $perguntas = $questionario->getPerguntas();
         $jaRespondeu = $inscricao->hasAvaliacaoResposta(1);
         $mensagem = null;
         foreach ($perguntas as $pergunta) {
             $resp = trim($_POST['input_' . $pergunta->id]);
             //                var_dump($resp);
             if ($pergunta->obrigatoria && $resp == '') {
                 setFlashError("Por favor, responda as perguntas obrigatórias (marcadas com *)");
                 break;
             }
             if ($resp != '') {
                 $resposta = Respostas::getInstance()->createResposta($pergunta, $inscricao, $resp);
                 $mensagem .= $pergunta->titulo . ': ' . $resp . '<br>';
             }
         }
         if (!hasFlashError()) {
             setFlash("sucesso");
             // Enviar email com respostas
             //                $mensagem="Respostas:<br><br>".$mensagem;
             //                $inscricao->evento()->organizador()->enviarEmail(
             //                    $inscricao->evento()->organizador()->email,
             //                    "Resposta - ".$questionario->titulo." - ".$inscricao->evento()->titulo." - ". $inscricao->pessoa()->nome,
             //                    $mensagem
             //                );
             // Creditar o gamification
             if (TGO_EVENTO_GAMIFICATION === true && !$jaRespondeu) {
                 Gamification::getInstance()->broadcast('event_feedback', $inscricao->id_pessoa, $inscricao);
             }
         }
     } else {
         // Obter inscrição
         $inscricao = Inscricoes::getInstance()->getById(get_query_var('avaliacao') / 13);
         if ($inscricao == null) {
             die("Inscrição não localizada");
         }
         // Validar inscrição
         if ($inscricao->confirmado != '1') {
             die("Inscrição não confirmada");
         }
     }
     return 'avaliacao.php';
 }
Exemple #15
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add Gallery") {
        $gallery = MyActiveRecord::Create('Galleries');
        $gallery->name = $_POST['name'];
        $gallery->slug = slug($_POST['name']);
        $gallery->save();
        setFlash("<h3>Gallery Added</h3>");
        redirect("/admin/edit_gallery/" . $gallery->id);
    }
}
Exemple #16
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add") {
        $blog = MyActiveRecord::Create('Blogs');
        $blog->name = $_POST['name'];
        $blog->slug = slug($_POST['name']);
        $blog->user_id = $_POST['user_id'];
        $blog->save();
        setFlash("<h3>Blog Added</h3>");
    }
}
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Manage This Email") {
        redirect("users/manage/" . $_POST["email"]);
    }
    if ($post_action == "Save Subscription Settings") {
        $currentemail = $_POST["email"];
        $oldemail = $_POST["oldemail"];
        if ($currentemail != $oldemail) {
            $thisemail = NLEmails::FindByEmail($oldemail);
        } else {
            $thisemail = NLEmails::FindByEmail($currentemail);
        }
        $lists = NLLists::FindAll();
        // Remove all links first...
        $query = "DELETE FROM nlemails_nllists WHERE nlemails_id = {$thisemail->id}";
        mysql_query($query, MyActiveRecord::Connection());
        if (isset($_POST['delete'])) {
            $thisemail->delete(true);
            redirect("/mail/subscribe/deleted");
        }
        // Then add the ones selected back in...
        foreach ($lists as $list) {
            if (array_key_exists($list->name, $_POST)) {
                $list->attach($thisemail);
            }
        }
        // Set the optional info fields and allow them to change the email they subscribed with...
        $thisemail->email = $_POST["email"];
        $thisemail->first_name = $_POST["first_name"];
        $thisemail->last_name = $_POST["last_name"];
        $thisemail->address1 = $_POST["address1"];
        $thisemail->address2 = $_POST["address2"];
        $thisemail->city = $_POST["city"];
        $thisemail->state = $_POST["state"];
        $thisemail->zip = $_POST["zip"];
        $thisemail->phone = $_POST["phone"];
        $thisemail->save();
        setFlash("<h3>Subscription Settings Saved</h3>");
        // If they changed their email, redirect them to that page
        redirect("users/manage/" . $thisemail->email);
    }
}
Exemple #18
0
function initialize_page()
{
    LoginRequired("/admin/login/", array("admin"));
    $accnt_id = requestIdParam();
    $account = Paypal_Config::FindById($accnt_id);
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Save") {
        $account->email = $_POST['email'];
        $account->success_url = $_POST['success_url'];
        $account->cancel_url = $_POST['cancel_url'];
        $account->save();
        setFlash("<h3>Paypal account changes saved</h3>");
    }
}
Exemple #19
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add Alias" || $post_action == "Add and Return to List") {
        $alias = MyActiveRecord::Create('Alias');
        $alias->alias = $_POST['alias'];
        $alias->path = $_POST['path'];
        $alias->save();
        setFlash("<h3>Alias created</h3>");
        if ($post_action == "Add and Return to List") {
            redirect("/admin/alias_list");
        }
    }
}
Exemple #20
0
 public function put_Edit($id)
 {
     $this->AuthorizeOrGoToAdmin("manage-slider");
     $slide = $this->repository->find($id) ?? $this->Reload();
     /* @var $slide Slide */
     if ($this->hasFile()) {
         $slide->uploadFile();
     }
     $slide->setName($_POST["name"]);
     $slide->setAlignment($_POST["alignment"]);
     if ($this->repository->save($slide)) {
         setFlash('Slider saved!', 'success');
         $this->Redirect('/admin/slider');
     }
     setFlash('There was an error!', 'error');
     return $this->View("admin.slider_edit", compact('slide'));
 }
Exemple #21
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add New List") {
        $success = '';
        $list = MyActiveRecord::Create('NLLists');
        $list->display_name = $_POST['name'];
        $list->name = slug($_POST['name']);
        $list->template = $_POST['template'];
        $list->description = $_POST['description'];
        $list->public = $_POST['public'];
        $list->save();
        $success .= "Mailing List Created";
        $emails = explode(",", str_replace(" ", "", $_POST['emails']));
        if (is_array($emails)) {
            $count = 0;
            foreach ($emails as $email) {
                if (!$list->emailLinked($email) && is_validemail($email)) {
                    // Check for an existing match in the system
                    $newAddy = NLEmails::FindByEmail($email);
                    if (!isset($newAddy) and !is_object($newAddy)) {
                        $newAddy = MyActiveRecord::Create('NLEmails');
                        $newAddy->email = $email;
                        $newAddy->save();
                        $count++;
                    }
                    // Existing or not, attach that email to this List
                    $query = "INSERT INTO nlemails_nllists VALUES ({$newAddy->id}, {$list->id});";
                    if (!mysql_query($query, MyActiveRecord::Connection())) {
                        die($query);
                    }
                }
            }
            if ($count > 0) {
                $success .= " / Emails Added to {$list->display_name}";
            } else {
                $success .= " / All Emails Added or Invalid";
            }
        }
        setFlash("<h3>" . $success . "</h3>");
    }
}
Exemple #22
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add Category" || $post_action == "Add and Return to List") {
        $category = MyActiveRecord::Create('Categories');
        $category->display_name = getPostValue('display_name');
        $category->name = slug(getPostValue('display_name'));
        $category->content = getPostValue('category_content');
        $category->save();
        setFlash("<h3>Category Added</h3>");
        if ($post_action == "Add and Return to List") {
            redirect("admin/list_categories/");
        }
    }
}
Exemple #23
0
 public function post_Index(...$params)
 {
     $this->model->Save($this->getPluginPostArray());
     foreach ($this->getPluginPostArray() as $plugin => $action) {
         try {
             if ($action == 'delete-data') {
                 $this->application->GetPlugin($plugin)->Uninstall();
                 $this->application->Remove($plugin);
             } elseif ($action == 'Install') {
                 $this->application->InstallPlugin($plugin);
             }
         } catch (\Exception $e) {
         }
     }
     $this->application->InvokeEvent('GenerateNewSitemap');
     setFlash('Plugins updated', 'success');
     $this->Reload();
 }
Exemple #24
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add Page" || $post_action == "Add and Return to List") {
        $page = MyActiveRecord::Create('Pages');
        $page->display_name = $_POST['display_name'];
        if (ALLOW_SHORT_PAGE_NAMES) {
            if ($_POST['name'] == "") {
                $page->name = slug($_POST['display_name']);
            } else {
                $page->name = slug($_POST['name']);
            }
        } else {
            $page->name = slug($_POST['display_name']);
        }
        $page->content = $_POST['page_content'];
        $page->content_file = '';
        $page->template = $_POST['template'];
        $page->public = checkboxValue($_POST, 'public');
        // synchronize the users area selections
        $selected_areas = array();
        if (isset($_POST['selected_areas'])) {
            $selected_areas = $_POST['selected_areas'];
        }
        if (count($selected_areas) > 0) {
            $page->parent_page_id = null;
        } else {
            if ($_POST['parent_page'] != "") {
                $page->parent_page_id = $_POST['parent_page'];
            } else {
                $page->parent_page_id = null;
            }
        }
        if ($page->save() && $page->updateSelectedAreas($selected_areas) && $page->setDisplayOrderInArea()) {
            setFlash("<h3>Page Added</h3>");
        }
        if ($post_action == "Add and Return to List") {
            redirect("admin/list_pages");
        }
    }
}
Exemple #25
0
function initialize_page()
{
    $document_id = requestIdParam();
    $document = Documents::FindById($document_id);
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Save Document" || $post_action == "Save and Return to List") {
        if (isset($_POST['delete'])) {
            $document->delete(true);
            //Pages::DeleteDocumentReferences($old_filename, $document->filename);
            setFlash("<h3>Document deleted</h3>");
            redirect("/admin/list_documents");
        } else {
            // did the user upload a new document?
            if ($_FILES['file']['name']) {
                $extension = substr($_FILES['file']['name'], strrpos($_FILES['file']['name'], "."));
                $filename = slug($_FILES['file']['name']) . $extension;
                $target_path = SERVER_DOCUMENTS_ROOT . $filename;
                if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
                    if (!chmod($target_path, 0644)) {
                        setFlash("<h3>Document Permissions not set</h3>");
                    }
                } else {
                    setFlash("<h3>Updated document could not be uploaded</h3>");
                }
                // Grab old name
                $old_filename = $document->filename;
                // Set the new name
                $document->filename = $filename;
                $document->file_type = substr($extension, 1);
                // Chop the dot off
                Pages::UpdateDocumentReferences($old_filename, $document->filename);
            }
            $document->name = $_POST['name'];
            $document->save();
            setFlash("<h3>Document changes saved</h3>");
            if ($post_action == "Save and Return to List") {
                redirect("admin/list_documents");
            }
        }
    }
}
Exemple #26
0
function initialize_page()
{
    $user_id = requestIdParam();
    $user = Users::FindById($user_id);
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Edit User" || $post_action == "Edit and Return to List") {
        if (isset($_POST['delete'])) {
            $user->delete(true);
            setFlash("<h3>User deleted</h3>");
            redirect("/admin/list_users");
        } else {
            $user->email = $_POST['email'];
            $user->display_name = $_POST['display_name'];
            $user->is_admin = isset($_POST['is_admin']) ? 1 : 0;
            $user->is_staff = $user->is_admin ? 0 : 1;
            $badpass = false;
            if (isset($_POST['password']) && !empty($_POST['password'])) {
                $possible_space = strrpos($_POST['password'], " ");
                if ($possible_space == true) {
                    setFlash("<h3>No spaces are allowed in a password. Changes not saved</h3>");
                    $badpass = true;
                } else {
                    if (strlen(utf8_decode($_POST['password'])) < 6) {
                        setFlash("<h3>A password should contain at least 6 characters and no spaces. Changes not saved</h3>");
                        $badpass = true;
                    } else {
                        $user->password = $_POST['password'];
                        $user->hash_password();
                    }
                }
            }
            if (!$badpass) {
                $user->save();
                setFlash("<h3>User changes saved</h3>");
                if ($post_action == "Edit and Return to List") {
                    redirect("admin/list_users");
                }
            }
        }
    }
}
Exemple #27
0
function initialize_page()
{
    LoginRequired("/admin/login/", array("admin"));
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add User" || $post_action == "Add and Send New User Email") {
        $email = $_POST['email'];
        $password = $_POST['password'];
        $possible_space = strrpos($password, " ");
        if (empty($email) || empty($password)) {
            setFlash("<h3>Please enter a username and/or password of at least 6 characters and no spaces</h3>");
        } else {
            if ($possible_space == true) {
                setFlash("<h3>No spaces are allowed in a password</h3>");
            } else {
                if (strlen(utf8_decode($password)) < 6) {
                    setFlash("<h3>A password should contain at least 6 characters and no spaces</h3>");
                } else {
                    $count = MyActiveRecord::Count('Users', "email = '{$email}'");
                    if ($count > 0) {
                        $duplicate = Users::FindByEmail($email);
                        setFlash("<h3>User already exists (see below)</h3>");
                        redirect("/admin/edit_user" . $duplicate->id);
                    } else {
                        $new_user = MyActiveRecord::Create('Users', $_POST);
                        $new_user->hash_password();
                        $new_user->is_admin = checkboxValue($_POST, 'is_admin');
                        $new_user->is_staff = $new_user->is_admin ? 0 : 1;
                        $new_user->save();
                        $success = "User added";
                        if ($post_action == "Add User and Send New User Email") {
                            $new_user->send_newuser_email($_POST['password']);
                            $success .= " / Email Notification Sent";
                        }
                        setFlash("<h3>" . $success . "</h3>");
                        redirect("/admin/list_users");
                    }
                }
            }
        }
    }
}
Exemple #28
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add Type" || $post_action == "Add and Return to List") {
        $type = MyActiveRecord::Create('EventTypes');
        $type->name = $_POST['name'];
        $type->color = $_POST['color'];
        $type->text_color = EventTypes::$color_array[$type->color];
        $type->calendar_id = 1;
        $type->save();
        setFlash("<h3>Event type created</h3>");
        if ($post_action == "Add and Return to List") {
            redirect("admin/list_event_types");
        }
    }
}
Exemple #29
0
 public static function registration($formAttribues)
 {
     unset($_SESSION['errors']);
     $email = $formAttribues['email'];
     $password = $formAttribues['password'];
     $name = $formAttribues['name'];
     $password_compare = $formAttribues['password_compare'];
     $username = $formAttribues['username'];
     $attributes = ['name' => $name, 'email' => $email, 'password' => $password, 'password_compare' => $password_compare, 'username' => $username];
     $rules = [[['email', 'password', 'name', 'password_compare', 'username'], 'required'], [['name'], 'type', 'type' => 'string', 'min' => 6, 'max' => 32], [['email'], 'email'], [['password'], 'type', 'type' => 'string', 'min' => 4, 'max' => 32], [['password_compare'], 'compare', 'attribute' => 'password', 'message' => 'Повтор пароля повинен співпадати з паролем'], [['email', 'username'], 'unique', 'tableName' => 'users']];
     $validation = new Validation();
     $validation->check($attributes, $rules);
     if (empty($validation->errors)) {
         $row = Db::insert('users', ['email' => $email, 'password' => md5($password), 'name' => $name, 'username' => $username]);
         setFlash('sucess', 'Бла бла бла ...');
         return true;
     }
     $_SESSION['errors'] = $validation->errors;
     return false;
 }
Exemple #30
0
function initialize_page()
{
    // This file does both, so check the parameters first
    if (requestIdParam() == "add") {
        $chunk = MyActiveRecord::Create('Chunks');
    } else {
        $chunk_id = requestIdParam();
        $chunk = Chunks::FindById($chunk_id);
    }
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Save Chunk" || $post_action == "Save and Return to List") {
        if (isset($_POST['delete'])) {
            $chunk->delete(true);
            setFlash("<h3>Chunk deleted</h3>");
            redirect("/admin/list_pages");
        } else {
            /*
             * Columns: id, slug, full_html(boolean), content
             */
            if (!empty($_POST['slug'])) {
                $chunk->slug = slug($_POST['slug']);
            }
            if (!empty($_POST['description'])) {
                $chunk->description = $_POST['description'];
            }
            if (!empty($_POST['description'])) {
                $chunk->full_html = checkboxValue($_POST, 'full_html');
            }
            $chunk->content = $_POST['chunk_content'];
            $chunk->save();
            setFlash("<h3>Chunk changes saved</h3>");
            if ($post_action == "Save and Return to List") {
                redirect("admin/list_pages");
            }
        }
    }
}