private function open_link() { try { $this->link = new mysqli(PERCH_DB_SERVER, PERCH_DB_USERNAME, PERCH_DB_PASSWORD, PERCH_DB_DATABASE, PERCH_DB_PORT, PERCH_DB_SOCKET); } catch (Exception $e) { } if ($this->link->connect_errno) { switch (PERCH_ERROR_MODE) { case 'SILENT': break; case 'ECHO': if (!$this->errored) { echo 'Could not connect to the database. Please check that the username and password are correct.'; $this->errored = true; } break; default: PerchUtil::redirect(PERCH_LOGINPATH . '/core/error/db.php'); break; } PerchUtil::debug("Could not create DB link!", 'error'); return false; } if (PERCH_DB_CHARSET && !$this->link->set_charset(PERCH_DB_CHARSET)) { PerchUtil::debug("Error loading character set utf8: " . $this->link->error, 'error'); } }
private function open_link() { $dsn_opts = array(); $dsn_opts['host'] = PERCH_DB_SERVER; $dsn_opts['dbname'] = PERCH_DB_DATABASE; if (PERCH_DB_SOCKET) { $dsn_opts['unix_socket'] = PERCH_DB_SOCKET; } if (PERCH_DB_PORT) { $dsn_opts['port'] = (int) PERCH_DB_PORT; } $dsn = 'mysql:'; foreach ($dsn_opts as $key => $val) { $dsn .= "{$key}={$val};"; } $this->dsn = $dsn; $opts = NULL; if (PERCH_DB_CHARSET) { // $opts = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES '".PERCH_DB_CHARSET."'"); // PHP bug means that this const isn't always defined. Useful. $opts = array(1002 => "SET NAMES '" . PERCH_DB_CHARSET . "'"); } try { $this->link = new PDO($dsn, PERCH_DB_USERNAME, PERCH_DB_PASSWORD, $opts); if ($this->link) { $this->link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } } catch (PDOException $e) { switch (PERCH_ERROR_MODE) { case 'SILENT': break; case 'ECHO': if (!$this->errored) { echo 'Could not connect to the database. Please check that the username and password are correct.'; $this->errored = true; } break; default: PerchUtil::redirect(PERCH_LOGINPATH . '/core/error/db.php'); break; } PerchUtil::debug("Could not create DB link!", 'error'); PerchUtil::debug($e->getMessage(), 'error'); return false; } }
/** * Process the login form, calling the appropriate authenticator as required. * @param [type] $SubmittedForm [description] * @return [type] [description] */ public function handle_login($SubmittedForm) { $Session = PerchMembers_Session::fetch(); if ($Session->logged_in) { return true; } $authenticator = 'native'; if (isset($SubmittedForm->data['authenticator'])) { $authenticator = $SubmittedForm->data['authenticator']; } $class = 'PerchMembers_Authenticator_' . $authenticator; $user_path = realpath(PerchUtil::file_path($this->authenticator_path . $authenticator)); if (PerchUtil::file_path(substr($user_path, 0, strlen($this->authenticator_path))) == PerchUtil::file_path($this->authenticator_path)) { $path = PerchUtil::file_path($this->authenticator_path . $authenticator . '/' . $class . '.class.php'); if (file_exists($path)) { include $path; $Authenticator = new $class($this->api); if (is_object($Authenticator)) { $user_row = $Authenticator->form_login($SubmittedForm); if ($user_row) { PerchUtil::debug('log them in'); if (isset($user_row['memberPassword'])) { unset($user_row['memberPassword']); } $this->_generate_session($user_row); $this->recover_session(); if (isset($SubmittedForm->data['r']) && $SubmittedForm->data['r'] != '') { PerchUtil::redirect($SubmittedForm->data['r']); } } else { PerchUtil::debug($Authenticator->get_messages()); } } } else { PerchUtil::debug('Authenticator ' . $class . ' not found.', 'error'); } } else { PerchUtil::debug('Invalid authenticator path: ' . PerchUtil::file_path($this->authenticator_path . $authenticator), 'error'); } }
<?php $HTML = $API->get('HTML'); if (!$CurrentUser->has_priv('perch_blog.import')) { PerchUtil::redirect($API->app_path()); } $BlogUtil = new PerchBlog_Util($API); $files = $BlogUtil->find_importable_files(); $Form = $API->get('Form'); $Form->require_field('file', 'Required'); if ($Form->submitted()) { $postvars = array('file', 'format', 'type', 'section'); $data = $Form->receive($postvars); switch ($data['type']) { case 'wordpress': PerchUtil::redirect($API->app_path() . '/import/wordpress?' . http_build_query($data)); break; case 'posterous': PerchUtil::redirect($API->app_path() . '/import/posterous?' . http_build_query($data)); break; } }
<?php $HTML = $API->get('HTML'); // Try to update $Settings = $API->get('Settings'); if ($Settings->get('perch_blog_update')->val() != '5.0') { PerchUtil::redirect($API->app_path() . '/update/'); } $Blog = new PerchBlog_Posts($API); $Paging = $API->get('Paging'); $Paging->set_per_page(15); $Categories = new PerchCategories_Categories(); $categories = $Categories->get_for_set('blog'); $Sections = new PerchBlog_Sections($API); $sections = $Sections->all(); $Lang = $API->get('Lang'); $posts = array(); $filter = 'all'; if (isset($_GET['category']) && $_GET['category'] != '') { $filter = 'category'; $category = $_GET['category']; } if (isset($_GET['section']) && $_GET['section'] != '') { $filter = 'section'; $section = $_GET['section']; } if (isset($_GET['status']) && $_GET['status'] != '') { $filter = 'status'; $status = $_GET['status']; } switch ($filter) {
<?php if (isset($_GET['id']) && is_numeric($_GET['id'])) { $region_id = (int) $_GET['id']; $item_id = (int) $_GET['itm']; $Regions = new PerchContent_Regions(); $Region = $Regions->find($region_id); $Pages = new PerchContent_Pages(); $Page = $Pages->find($Region->pageID()); } if (!$Region || !is_object($Region)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content'); } // set the current user $Region->set_current_user($CurrentUser->id()); /* --------- Delete Form ----------- */ $Form = new PerchForm('delete'); if ($Form->posted() && $Form->validate() && isset($item_id)) { $Region->delete_item($item_id); $Region->index(); if ($Form->submitted_via_ajax) { echo PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . $Region->id(); exit; } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . $Region->id()); } }
$FieldTag->set('input_id', 'image'); $Assets = new PerchAssets_Assets(); $Tags = new PerchAssets_Tags(); $Form = new PerchForm('edit'); $message = false; if (isset($_GET['id']) && is_numeric($_GET['id'])) { $assetID = (int) $_GET['id']; $Asset = $Assets->find($assetID); if ($Asset) { if (!$Asset->is_image()) { $FieldTag->set('type', 'file'); } } } else { if (!$CurrentUser->has_priv('assets.create')) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/assets/'); } $assetID = false; $Asset = false; } $Form = new PerchForm('edit'); $req = array(); $req['resourceTitle'] = "Required"; $Form->set_required($req); if ($Form->posted() && $Form->validate()) { /* if (isset($_POST['image_remove']) && $_POST['image_remove']=='1') { $Asset->delete(); PerchUtil::redirect() } */
$groupID = false; $NavGroup = false; } $Form = new PerchForm('editpage'); $req = array(); $req['groupTitle'] = "Required"; $Form->set_required($req); if ($Form->posted() && $Form->validate()) { $postvars = array('groupTitle'); $data = $Form->receive($postvars); if (is_object($NavGroup)) { $NavGroup->update($data); $Alert->set('success', PerchLang::get('Your navigation group has been successfully updated.')); } else { $data['groupSlug'] = PerchUtil::urlify($data['groupTitle']); $NavGroup = $NavGroups->create($data); if (is_object($NavGroup)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/navigation/edit/?id=' . $NavGroup->id() . '&created=1'); } else { $Alert->set('failure', PerchLang::get('There was a problem creating the navigation group.')); } } } if (isset($_GET['created'])) { $Alert->set('success', PerchLang::get('Your navigation group has been successfully created.')); } if (is_object($NavGroup)) { $details = $NavGroup->to_array(); } else { $details = array(); }
$data = $Form->receive($postvars); $data['eventDateTime'] = $Form->get_date('eventDateTime'); $prev = false; if (isset($details['eventDynamicFields'])) { $prev = PerchUtil::json_safe_decode($details['eventDynamicFields'], true); } $dynamic_fields = $Form->receive_from_template_fields($Template, $prev); $data['eventDynamicFields'] = PerchUtil::json_safe_encode($dynamic_fields); $result = false; if (is_object($Event)) { $result = $Event->update($data); } else { $new_event = $Events->create($data); if ($new_event) { $result = true; PerchUtil::redirect($API->app_path() . '/edit/?id=' . $new_event->id() . '&created=1'); } else { $message = $HTML->failure_message('Sorry, that event could not be updated.'); } } if ($result) { $message = $HTML->success_message('Your event has been successfully updated. Return to %sevent listing%s', '<a href="' . $API->app_path() . '">', '</a>'); } else { $message = $HTML->failure_message('Sorry, that event could not be updated.'); } if (is_object($Event)) { $details = $Event->to_array(); } else { $details = array(); } }
$user = $Form->receive($postvars); PerchSession::set('user', $user); $postvars = array('loginpath', 'db_server', 'db_database', 'db_username', 'db_password', 'licenseKey', 'tz'); $conf = $Form->receive($postvars); if (!isset($conf['db_password'])) { $conf['db_password'] = ''; } $conf['loginpath'] = rtrim($conf['loginpath'], '/'); $config_file = file_get_contents('config.sample.php'); $config_file = preg_replace_callback('/\\$(\\w+)/', "substitute_vars", $config_file); $config_file_path = PerchUtil::file_path(realpath('../config') . '/config.php'); if (is_writable($config_file_path)) { file_put_contents($config_file_path, $config_file); $test_contents = file_get_contents($config_file_path); if ($test_contents == $config_file) { PerchUtil::redirect('index.php?install=1&auto=1'); } } $mode = 'configfile'; } function substitute_vars($matches) { global $user, $conf; if (isset($user[$matches[1]])) { return addslashes($user[$matches[1]]); } if (isset($conf[$matches[1]])) { return $conf[$matches[1]]; } else { return '$' . $matches[1]; }
<?php # include the API include '../../../../core/inc/api.php'; $API = new PerchAPI(1.0, 'perch_events'); $Lang = $API->get('Lang'); if (!$CurrentUser->has_priv('perch_events.categories.manage')) { PerchUtil::redirect($API->app_path()); } # include your class files include '../PerchEvents_Categories.class.php'; include '../PerchEvents_Category.class.php'; # Set the page title $Perch->page_title = $Lang->get('Manage Event Categories'); # Do anything you want to do before output is started include '../modes/cat.list.pre.php'; # Top layout include PERCH_CORE . '/inc/top.php'; # Display your page include '../modes/cat.list.post.php'; # Bottom layout include PERCH_CORE . '/inc/btm.php';
<?php $GalleryImages = new PerchGallery_Images($API); $Albums = new PerchGallery_Albums($API); $HTML = $API->get('HTML'); $Form = $API->get('Form'); $message = false; if (isset($_GET['id']) && $_GET['id'] != '') { $Image = $GalleryImages->find($_GET['id']); } else { PerchUtil::redirect($API->app_path() . '/'); } if ($Form->submitted()) { if (is_object($Image)) { $albumID = $Image->albumID(); $Image->delete(); $Album = $Albums->find($albumID); if (is_object($Album)) { $Album->update_image_count(); } PerchUtil::redirect($API->app_path() . '/images/?id=' . $albumID); } else { $message = $HTML->failure_message('Sorry, the image could not be deleted.'); } } $details = $Image->to_array();
} } // Template $Template = $API->get('Template'); $Template->set('mailchimp/lists/list.html', 'mailchimp'); $tags = $Template->find_all_tags_and_repeaters(); $Form = $API->get('Form'); $Form->handle_empty_block_generation($Template); $Form->set_required_fields_from_template($Template, $details); if ($Form->submitted()) { $data = $Form->get_posted_content($Template, $Lists, $List); if ($List) { $List->update($data); } else { $List = $Lists->create($data); if ($List) { PerchUtil::redirect($Perch->get_page() . '?id=' . $List->id() . '&created=1'); } } if (is_object($List)) { $message = $HTML->success_message('Your list has been successfully edited. Return to %slisting%s', '<a href="' . $API->app_path('perch_mailchimp') . '/">', '</a>'); } else { $message = $HTML->failure_message('Sorry, that update was not successful.'); } } if (PerchUtil::get('created') && !$message) { $message = $HTML->success_message('Your list has been successfully created. Return to %s listing%s', '<a href="' . $API->app_path('perch_mailchimp') . '/">', '</a>'); } if (is_object($List)) { $details = $List->to_array(); }
<?php $Settings->get('headerColour')->settingValue(); PerchUtil::set_security_headers(); // Check for updates $update_setting_key = 'update_' . $Perch->version; if (PERCH_RUNWAY) { $update_setting_key = 'update_runway_' . $Perch->version; } if (!$auth_page && !$Settings->get($update_setting_key)->val()) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/update/'); } // Help markup as used by apps etc $Perch->help_html = ''; $help_html = ''; header('Content-Type: text/html; charset=utf-8'); ?> <!DOCTYPE html> <html lang="<?php echo $Settings->get('lang')->settingValue(); ?> "> <head> <meta charset="utf-8" /> <title><?php echo PerchUtil::html($Perch->page_title); if (!$Settings->get('hideBranding')->settingValue()) { if (PERCH_RUNWAY) { echo PerchUtil::html(' - ' . PerchLang::get('Perch Runway')); } else { echo PerchUtil::html(' - ' . PerchLang::get('Perch'));
public static function force_non_ssl() { Perch::fetch(); // to define PERCH_SSL if (PERCH_SSL) { if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { header('Strict-Transport-Security: max-age=0'); PerchUtil::redirect(PerchUtil::url_to_non_ssl($_SERVER['REQUEST_URI'])); } } }
<?php perch_member_log_out(); PerchUtil::redirect('/user/');
$new_user_mode = false; if (isset($_GET['new'])) { $new_user_mode = true; } include '../inc/pre_config.php'; include '../../config/config.php'; include PERCH_CORE . '/inc/loader.php'; $Perch = new Perch(); include PERCH_CORE . '/inc/auth.php'; // Check for logout if ($CurrentUser->logged_in() && isset($_GET['logout']) && is_numeric($_GET['logout'])) { $CurrentUser->logout(); } // If the user's logged in, send them to edit content if ($CurrentUser->logged_in()) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/'); } $Perch->page_title = $new_user_mode ? PerchLang::get('Create your password') : PerchLang::get('Reset your password'); if (PerchUtil::get('token')) { $mode = 'enter_token'; $Users = new PerchUsers(); $User = $Users->get_by_password_recovery_token(PerchUtil::get('token')); if (!$User) { $mode = 'token_expired'; } else { if (PerchUtil::post('username') && PerchUtil::post('new_password')) { if (PerchUtil::post('username') == $User->userUsername()) { PerchUtil::debug('Username matches'); if (PerchUtil::post('new_password') == PerchUtil::post('new_password2')) { if ($User->password_meets_requirements(PerchUtil::post('new_password'))) { $User->set_new_password(PerchUtil::post('new_password'));
$Regions = new PerchContent_Regions(); $Region = $Regions->find($id); $Pages = new PerchContent_Pages(); if (is_object($Region)) { if ($Region->regionPage() == '*') { $Page = $Pages->get_mock_shared_page(); } else { $Page = $Pages->find($Region->pageID()); } } } if (!$Region || !is_object($Region)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content'); } // Check permission to delete if ($CurrentUser->has_priv('content.regions.delete') || $CurrentUser->has_priv('content.pages.delete.own') && $Page->pageCreatorID() == $CurrentUser->id()) { // we're ok. } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content'); } /* --------- Delete Form ----------- */ $Form = new PerchForm('delete'); if ($Form->posted() && $Form->validate()) { $Region->delete(); if ($Form->submitted_via_ajax) { echo PERCH_LOGINPATH . '/core/apps/content/page/?id=' . $Page->id(); exit; } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/page/?id=' . $Page->id()); } }
<?php if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $User = $Users->find($id); } if (!$User || !is_object($User)) { PerchUtil::redirect(PERCH_LOGINPATH . '/users'); } $Roles = new PerchUserRoles(); $roles = $Roles->all(); /* --------- Edit User Form ----------- */ $Form = new PerchForm('user', false); $req = array(); $req['userUsername'] = "******"; $req['userGivenName'] = "Required"; $req['userFamilyName'] = "Required"; $req['userEmail'] = "Required"; if ($User->id() != $CurrentUser->id()) { $req['roleID'] = "Required"; } $Form->set_required($req); $validation = array(); $validation['userUsername'] = array("username", PerchLang::get("Username not available, try another."), array('userID' => $User->id())); $validation['userEmail'] = array("email", PerchLang::get("Email incomplete or already in use."), array('userID' => $User->id())); $Form->set_validation($validation); if ($Form->posted() && $Form->validate()) { $data = array(); $postvars = array('userUsername', 'userGivenName', 'userFamilyName', 'userEmail', 'roleID'); $data = $Form->receive($postvars); $User->update($data);
<?php if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $ContentItem = $PerchPage->find($id); } if (!$ContentItem || !is_object($ContentItem)) { PerchUtil::redirect(PERCH_LOGINPATH . '/apps/perchpages'); } // Check permission to delete if ($CurrentUser->userRole() == 'Editor' && !$Settings->get('editorMayDeleteRegions')->settingValue()) { PerchUtil::redirect(PERCH_LOGINPATH . '/apps/perchpages'); } /* --------- Delete Form ----------- */ $Form = new PerchForm('delete'); if ($Form->posted() && $Form->validate()) { $path = $PerchPage->root; $file = $path . $ContentItem->Location(); if (file_exists($file)) { if (!unlink($file)) { PerchUtil::redirect(PERCH_LOGINPATH . '/apps/perchpages/?failure=delete'); return false; } } $ContentItem->delete(); PerchUtil::redirect(PERCH_LOGINPATH . '/apps/perchpages/?success=delete'); }
$Hasher = new PasswordHash(8, $portable_hashes); $data['memberPassword'] = $Hasher->HashPassword($clear_pwd); } if (!$Members->check_email($data['memberEmail'])) { $message = $HTML->failure_message('A member with that email address already exists.'); } else { //$data['memberProperties'] = ''; $Member = $Members->create($data); if ($Member) { $member = array('memberAuthID' => $Member->id()); $Member->update($member); if (isset($post['send_email']) && $post['send_email'] == '1') { $Member->send_welcome_email(); } $result = true; PerchUtil::redirect($API->app_path() . '/edit/?id=' . $Member->id() . '&created=1'); } else { $message = $HTML->failure_message('Sorry, that member could not be updated.'); } } } // Tags if ($result) { // existing tags $Tags->remove_from_member($Member->id(), $existing_tagIDs); // new tag if (isset($post['new-tag']) && $post['new-tag'] != '') { $tagset = $Tags->parse_string($post['new-tag']); if (PerchUtil::count($tagset)) { if (isset($post['new-expire']) && $post['new-expire'] != '') { $tag_expiry = $Form->get_date('new-expires', $post);
<?php $Roles = new PerchUserRoles(); if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $Role = $Roles->find($id); } else { $id = false; $Role = false; } if (!$Role || !is_object($Role)) { PerchUtil::redirect(PERCH_LOGINPATH . '/users'); } /* --------- Delete User Form ----------- */ $Form = new PerchForm('delete', false); if ($Form->posted() && $Form->validate()) { $postvars = array('roleID'); $data = $Form->receive($postvars); $Role->migrate_users($data['roleID']); $Role->delete(); if ($Form->submitted_via_ajax) { echo PERCH_LOGINPATH . '/core/users/roles/'; exit; } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/users/roles/'); } } $details = $Role->to_array(); $all_roles = $Roles->all();
$fileName_b = substr($filename, $ext); $count = 1; while (file_exists(PERCH_RESFILEPATH . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b)) { $count++; } $filename = $fileName_a . '_' . $count . $fileName_b; $target = PERCH_RESFILEPATH . DIRECTORY_SEPARATOR . $filename; } } PerchUtil::move_uploaded_file($_FILES['upload']['tmp_name'], $target); if (is_object($Image)) { $Image->process_versions($filename, $Template); } } if ($new_image) { PerchUtil::redirect($API->app_path() . '/images/edit/?album_id=' . $albumID . '&id=' . $result->id() . '&created=1'); } else { $message = $HTML->success_message('Your image has been successfully updated. Return to %simage listing%s', '<a href="' . $API->app_path() . '/images/?id=' . $albumID . '">', '</a>'); } } else { $message = $HTML->failure_message('Sorry, that image could not be updated.'); } if (is_object($Image)) { $details = $Image->to_array(); } else { $details = array(); } } if (isset($_GET['created']) && !$message) { $message = $HTML->success_message('Your image has been successfully created. Return to %simage listing%s', '<a href="' . $API->app_path() . '/images/?id=' . $albumID . '">', '</a>'); }
<?php $API = new PerchAPI('categories', 1.0); $HTML = $API->get('HTML'); $Sets = new PerchCategories_Sets(); $Categories = new PerchCategories_Categories(); $setID = false; $Set = false; if (isset($_GET['id']) && $_GET['id'] != '') { $setID = (int) $_GET['id']; $Set = $Sets->find($setID); } if ($setID == false) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/'); } $cats = $Categories->get_tree($setID);
<?php if (!$CurrentUser->has_priv('categories.delete')) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/'); } $Categories = new PerchCategories_Categories(); if (isset($_GET['id']) && is_numeric($_GET['id'])) { $catID = (int) $_GET['id']; $Category = $Categories->find($catID); } if (!$Category || !is_object($Category)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/'); } /* --------- Delete Form ----------- */ $Form = new PerchForm('delete'); if ($Form->posted() && $Form->validate()) { $Category->delete(); if ($Form->submitted_via_ajax) { echo PERCH_LOGINPATH . '/core/apps/categories/sets/?id=' . $Category->setID(); exit; } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/sets/?id=' . $Category->setID()); } }
$Users = new PerchUsers(); $CurrentUser = $Users->get_current_user(); /* Check for incoming login form and attempt login */ $username = false; $password = false; if (isset($_POST['username']) && isset($_POST['password']) && $_POST['username'] != '' && $_POST['password'] != '') { $username = $_POST['username']; $password = $_POST['password']; } if ($username != false && $password != false) { $auth_succeeded = $CurrentUser->authenticate($username, $password); if (!$auth_succeeded) { header("HTTP/1.0 403 Forbidden", true, 403); } } if (!isset($auth_page)) { $auth_page = false; } if (!$CurrentUser->logged_in() && !$auth_page) { PerchUtil::debug('Not logged in'); $current_page = urlencode($Perch->get_page(true)); PerchUtil::redirect(PERCH_LOGINPATH . '?r=' . $current_page); } else { $Settings = PerchSettings::fetch(); $Settings->set_user($CurrentUser); $Perch->find_installed_apps($CurrentUser); } if (!$CurrentUser->logged_in() && $auth_page) { header("HTTP/1.0 403 Forbidden", true, 403); } $Alert = new PerchAlert();
<?php $Item = false; $details = false; if (PerchUtil::get('id')) { if (!$CurrentUser->has_priv($delete_priv)) { PerchUtil::redirect($API->app_path()); } $Item = $Factory->find(PerchUtil::get('id')); } else { PerchUtil::redirect($API->app_path('perch_mailchimp') . $return_path); } $Form = $API->get('Form'); $Form->set_name('delete'); if ($Form->submitted()) { if ($Item) { $Item->delete(); } if ($Form->submitted_via_ajax) { echo $API->app_path('perch_mailchimp') . $return_path; exit; } else { PerchUtil::redirect($API->app_path('perch_mailchimp') . $return_path); } } if (!$Item) { PerchUtil::redirect($API->app_path('perch_mailchimp') . $return_path); }
<?php include __DIR__ . '/../../inc/pre_config.php'; include __DIR__ . '/../../../config/config.php'; include PERCH_CORE . '/inc/loader.php'; $Perch = PerchAdmin::fetch(); include PERCH_CORE . '/inc/auth.php'; if (!$CurrentUser->has_priv('perch.settings')) { PerchUtil::redirect(PERCH_LOGINPATH); } $Perch->page_title = PerchLang::get('Settings'); $Alert = new PerchAlert(); if (isset($_GET['extended'])) { include __DIR__ . '/../modes/diagnostics.extended.pre.php'; } else { include __DIR__ . '/../modes/diagnostics.pre.php'; } include __DIR__ . '/../modes/diagnostics.pre.php'; include PERCH_CORE . '/inc/top.php'; if (isset($_GET['extended'])) { include __DIR__ . '/../modes/diagnostics.extended.post.php'; } else { include __DIR__ . '/../modes/diagnostics.post.php'; } include PERCH_CORE . '/inc/btm.php';
$Form->handle_empty_block_generation($Template); $tags = $Template->find_all_tags_and_repeaters(); $Form->require_field('blogTitle', 'Required'); $Form->set_required_fields_from_template($Template, $details); if ($Form->submitted()) { $postvars = array('blogTitle', 'setSlug', 'postTemplate'); $data = $Form->receive($postvars); $prev = false; if (isset($details['blogDynamicFields'])) { $prev = PerchUtil::json_safe_decode($details['blogDynamicFields'], true); } $dynamic_fields = $Form->receive_from_template_fields($Template, $prev, $Blogs, $Blog); $data['blogDynamicFields'] = PerchUtil::json_safe_encode($dynamic_fields); if (!is_object($Blog)) { $data['blogSlug'] = PerchUtil::urlify($data['blogTitle']); $Blog = $Blogs->create($data); PerchUtil::redirect($API->app_path() . '/blogs/edit/?id=' . $Blog->id() . '&created=1'); } $Blog->update($data); if (is_object($Blog)) { $message = $HTML->success_message('Your blog has been successfully edited. Return to %sblog listing%s', '<a href="' . $API->app_path() . '/blogs">', '</a>'); } else { $message = $HTML->failure_message('Sorry, that blog could not be edited.'); } // clear the caches PerchBlog_Cache::expire_all(); $details = $Blog->to_array(); } if (isset($_GET['created']) && !$message) { $message = $HTML->success_message('Your blog has been successfully created. Return to %sblog listing%s', '<a href="' . $API->app_path() . '/blogs">', '</a>'); }
<?php $Templates = new PerchContent_PageTemplates(); $Pages = new PerchContent_Pages(); $Form = new PerchForm('edit'); $message = false; // Check permissions if (!$CurrentUser->has_priv('content.templates.delete')) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/pages/templates/'); } if (isset($_GET['id']) && is_numeric($_GET['id'])) { $templateID = (int) $_GET['id']; $Template = $Templates->find($templateID); } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/page/templates/'); } $Form = new PerchForm('rm'); if ($Form->posted() && $Form->validate()) { $Template->delete(); PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/page/templates/'); } $details = $Template->to_array();