/**
  * Set defaults
  */
 public function __construct()
 {
     parent::__construct();
     $this->form_id = 'modal';
     $this->modal_id = 'panel_modal';
     $this->modal_css = 'reveal-modal';
     $this->cancel_button = '<a id="cancel" class="close-reveal-modal btn tertiary">Cancel</a>';
     $this->modal_save_name = 'modal-submit';
     $this->row_class = 'row modal';
 }
<?php

/* Artists use this script to add connections to social media services.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
$view = new GrlxView();
$form = new GrlxForm();
$modal = new GrlxForm_Modal();
$message = new GrlxAlert();
$view->yah = 8;
/*****
 * Updates
 */
// Reset comment service
if (is_numeric($_GET['reset_comments'])) {
    $service_id = $_GET['reset_comments'];
    $data = array('user_info' => null);
    $db->where('id', $service_id);
    $db->update('third_service', $data);
    $data = array('active' => 0);
    $db->where('service_id', $service_id);
    $db->update('third_match', $data);
}
// Save edits from the info modal
if ($_POST['edit']) {
    foreach ($_POST['edit'] as $key => $val) {
        if (is_numeric($key)) {
            $data = array('user_info' => $val);
<?php

/* Artists use this script to create a link list.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
$view = new GrlxView();
$modal = new GrlxForm_Modal();
$message = new GrlxAlert();
$list = new GrlxList();
$form = new GrlxForm();
$fileops = new GrlxFileOps();
$image_path = $milieu_list['directory']['value'] . '/assets/images/icons';
$view->yah = 11;
/*****
 * Updates
 */
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $input = $_POST['input'];
    foreach ($input as $val) {
        $val = trim($val);
        $val = htmlspecialchars($val, ENT_COMPAT);
    }
    $input['url'] = mb_strtolower($input['url'], "UTF-8");
    if (count($_FILES) > 0) {
        $file_name = basename($_FILES['input']['name']['img_path']);
        $uploadfile = '..' . $image_path . '/' . $file_name;
        $web_file_path = $image_path . '/' . $file_name;
        if (move_uploaded_file($_FILES['input']['tmp_name']['img_path'], $uploadfile)) {
<?php

/*****
 * Setup
 */
require_once 'panl.init.php';
$view = new GrlxView();
//$modal = new GrlxForm_Modal;
$message = new GrlxAlert();
$link = new GrlxLinkStyle();
$list = new GrlxList();
$sl = new GrlxSelectList();
$form = new GrlxForm();
$marker = new GrlxMarker();
$view->yah = 3;
$var_list = array('book_id', 'delete_page_id', 'start_sort_order', 'keyword', 'delete_marker_id', 'sel', 'add_marker_type');
if ($var_list) {
    foreach ($var_list as $key => $val) {
        ${$val} = register_variable($val);
    }
}
if ($start_sort_order) {
    $_SESSION['start_sort_order'] = $start_sort_order;
} else {
    $start_sort_order = $_SESSION['start_sort_order'];
}
$start_sort_order ? $start_sort_order : ($start_sort_order = 1);
/*****
 * Updates
 */
if ($book_id) {
<?php

/* Artists use this script to manage their site themes.
 */
/* ! Setup * * * * * * * */
require_once 'panl.init.php';
$args['yah'] = 9;
$view = new GrlxView($args);
$form = new GrlxForm();
$button = new GrlxLinkStyle();
$sl = new GrlxSelectList();
/* ! Actions * * * * * * * */
// Change one or more tone_id records
if (is_numeric($_POST['new_tone_id']) && $_POST['sel'] && $_POST['submit']) {
    unset($_GET);
    $new_id = $_POST['new_tone_id'];
    if (is_array($_POST['sel'])) {
        $sel = array_keys($_POST['sel']);
        foreach ($sel as $item) {
            $db_vars[] = strfunc_split_tablerow($item);
        }
    } else {
        $db_vars[] = strfunc_split_tablerow($_POST['sel']);
    }
    if ($db_vars) {
        foreach ($db_vars as $i => $row) {
            $row['table'] == 'milieu' ? $col = 'value' : ($col = 'tone_id');
            $data = array($col => $new_id);
            if ($row['table'] == 'book_page') {
                $marker = new GrlxMarker($row['id']);
                $page_ids = array_keys($marker->pageList);
<?php

/* ! Setup * * * * * * * */
require_once 'panl.init.php';
$view = new GrlxView();
$view->yah = 4;
$form = new GrlxForm();
$form->send_to($_SERVER['SCRIPT_NAME']);
$form->row_class = 'row arcv';
// Load up the settings/info for building the archive
$args['infoXML'] = 1;
$infoXML = new GrlxXML_Book($args);
unset($args);
$book_id = $_POST['book_id'];
$book_id ? $book_id : ($book_id = $_GET['book_id']);
if (!$book_id) {
    $book = new GrlxComicBook();
    $book_id = $book->bookID;
}
if ($_POST['submit']) {
    $args['archiveNew'] = array('behavior' => $_POST['behavior'], 'chapter' => $_POST['chapter'], 'page' => $_POST['page']);
    // These can’t be empty
    if (!array_key_exists('option', $args['archiveNew']['chapter'])) {
        $args['archiveNew']['chapter']['option'] = 'number';
    }
    if (!array_key_exists('option', $args['archiveNew']['page'])) {
        $args['archiveNew']['page']['option'] = 'number';
    }
}
$args['bookID'] = $book_id;
$xml = new GrlxXML_Book($args);
<?php

/* Artists use this script to configure a theme tone.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
$view = new GrlxView();
$modal = new GrlxForm_Modal();
$link = new GrlxLinkStyle();
$message = new GrlxAlert();
$form = new GrlxForm();
$theme = new GrlxXML_Theme();
$img = new GrlxImage();
$img->db_new = $db;
$theme_id = numfunc_register_var('theme_id');
$tone_id = numfunc_register_var('tone_id');
$theme->set_theme_id($theme_id);
$theme->set_tone_id($tone_id);
/*****
 * Updates
 */
// Delete a tone
if (is_numeric($_GET['delete_id'])) {
    $delete_id = $_GET['delete_id'];
    $result = $db->where('id', $delete_id)->delete('theme_tone');
    if ($result) {
        $match_list = $db->where('tone_id', $delete_id)->delete('image_tone_match');
    } else {
        $alert_output .= $message->alert_dialog('Unable to delete tone from database.');
<?php

/* Artists use this script to control general site settings.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
require_once 'lib/htmLawed.php';
$view = new GrlxView();
$link = new GrlxLinkStyle();
$form = new GrlxForm();
$form->send_to($_SERVER['SCRIPT_NAME']);
$form->row_class('config');
$sl = new GrlxSelectList();
$view->yah = 12;
$date_list[] = array('id' => 'm/d/y', 'title' => '10/31/15');
$date_list[] = array('id' => 'm-d-Y', 'title' => '10-31-2015');
$date_list[] = array('id' => 'd-M-Y', 'title' => '31-Oct-2015');
$date_list[] = array('id' => 'F j, Y', 'title' => 'October 31, 2015');
$date_list[] = array('id' => 'j F Y', 'title' => '31 October 2015');
$timezone_master_list['America/Los_Angeles'] = array('id' => 'America/Los_Angeles', 'title' => 'UTC−08:00: San Francisco, Vancouver, Tijuana');
$timezone_master_list['America/Denver'] = array('id' => 'America/Denver', 'title' => 'UTC−07:00: Denver, Phoenix, Calgary, Ciudad Juárez');
$timezone_master_list['America/Chicago'] = array('id' => 'America/Chicago', 'title' => 'UTC−06:00: Chicago, Guatemala City, Mexico City, San José, San Salvador, Tegucigalpa, Winnipeg');
$timezone_master_list['America/New_York'] = array('id' => 'America/New_York', 'title' => 'UTC−05:00: New York, Lima, Toronto, Bogotá, Havana, Kingston');
$timezone_master_list['America/Caracas'] = array('id' => 'America/Caracas', 'title' => 'UTC−04:30: Caracas');
$timezone_master_list['America/Santiago'] = array('id' => 'America/Santiago', 'title' => 'UTC−04:00: Santiago, La Paz, San Juan de Puerto Rico, Manaus, Halifax');
$timezone_master_list['America/Argentina/Buenos_Aires'] = array('id' => 'America/Argentina/Buenos_Aires', 'title' => 'UTC−03:00: Buenos Aires, Montevideo, São Paulo');
$timezone_master_list['America/Canada/Newfoundland'] = array('id' => 'America/Canada/Newfoundland', 'title' => 'UTC−03:30: St. John’s');
$timezone_master_list['Europe/Lisbon'] = array('id' => 'Europe/Lisbon', 'title' => 'UTC±00:00: Accra, Abidjan, Casablanca, Dakar, Dublin, Lisbon, London');
$timezone_master_list['Europe/Berlin'] = array('id' => 'Europe/Berlin', 'title' => 'UTC+01:00: Belgrade, Berlin, Brussels, Lagos, Madrid, Paris, Rome, Tunis, Vienna, Warsaw');
 * Setup
 */
$except = true;
require_once 'panl.init.php';
require_once '../_system/password.php';
$var_list = array('email', 'new_password', 's');
if ($var_list) {
    foreach ($var_list as $key => $val) {
        ${$val} = register_variable($val);
    }
}
$view = new GrlxView_Login();
$view->page_title('Reset password: step two');
$view->headline('Reset password: step two');
$view->main_id('reset');
$form = new GrlxForm();
$form->send_to($_SERVER['SCRIPT_NAME']);
/*****
 * Updates
 */
// When the user submits a form
if ($new_password && $s) {
    // Give the user a new serial number.
    for ($i = 0; $i < 16; $i++) {
        $new_serial .= rand(0, 9);
    }
    $new_hash = password_hash($new_password, PASSWORD_BCRYPT);
    if (password_verify($new_password, $new_hash)) {
        $data = array('serial' => $new_serial, 'password' => $new_hash, 'date_modified' => $db->now());
        $db->where('serial', $s);
        $db->update('user', $data);
            // software update check
            $_SESSION['install_cleanup'] = 'run_check';
            // check if firstrun is still present
            grlx_cookie();
            header('location:' . $ref);
            die;
        } else {
            $view->alert_msg('Login failed.');
        }
    }
    if ($username && $extra && !$result || $count == 0) {
        $view->alert_msg('Login failed.');
    }
}
/* ! Build * * * * * * * */
$form = new GrlxForm();
$form->error_check(false);
$form->no_div_wrap();
$form->hide_error();
$form->send_to($_SERVER['SCRIPT_NAME']);
$form_output = $form->open_form();
$form->input_hidden('ref');
$form->value($ref);
$form_output .= $form->paint();
$form->input_text('username');
$form->placeholder('username');
$form->autofocus(true);
$form_output .= $form->paint();
$form->input_password('extra');
$form->placeholder('password');
$form_output .= $form->paint();
<?php

/*****
 * Setup
 */
include 'panl.init.php';
$link = new GrlxLinkStyle();
$view = new GrlxView();
$message = new GrlxAlert();
$form = new GrlxForm();
$fileops = new GrlxFileOps();
$fileops->db = $db;
$book = new GrlxComicBook();
$marker = new GrlxMarker();
$comic_image = new GrlxComicImage();
$message = new GrlxAlert();
$sl = new GrlxSelectList();
$view->yah = 2;
$book_id = $book->bookID;
/*****
 * Updates
 */
if ($_FILES && $book_id) {
    if (is_writable('../' . DIR_COMICS_IMG)) {
        $which = 'file';
        $fileops->up_set_destination_folder('../' . DIR_COMICS_IMG);
        $files_uploaded = $fileops->up_process($which);
        $new_order = $_POST['new_order'];
        $new_order ? $new_order : ($new_order = 1);
        if ($files_uploaded) {
            $i = -1;
<?php

/* Artists use this script to control the main site navigation.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
$view = new GrlxView();
$link = new GrlxLinkStyle();
$form = new GrlxForm();
$modal = new GrlxForm_Modal();
$message = new GrlxAlert();
$list = new GrlxList();
$view->yah = 7;
/*****
 * Updates
 */
// Act on an edit from the reveal modal
if ($_POST['modal-submit']) {
    $input = $_POST['input'];
    foreach ($input as $val) {
        $val = trim($val);
        $val = htmlspecialchars($val, ENT_COMPAT);
    }
    $input['url'] = mb_strtolower($input['url'], "UTF-8");
    // Add an external URL to nav
    if ($_POST['modal-submit'] == 'add') {
        $data = array('title' => $input['title'], 'url' => $input['url'], 'rel_type' => 'external', 'sort_order' => 0, 'in_menu' => 1);
        $new_id = $db->insert('path', $data);
        if ($new_id == 0) {
<?php

/*****
 * Setup
 */
require_once 'panl.init.php';
$view = new GrlxView();
//$modal = new GrlxForm_Modal;
$message = new GrlxAlert();
$link = new GrlxLinkStyle();
$list = new GrlxList();
$form = new GrlxForm();
$fileops = new GrlxFileOps();
$fileops->db = $db;
$comic_image = new GrlxComicImage();
$sl = new GrlxSelectList();
$form->send_to($_SERVER['SCRIPT_NAME']);
$var_list = array('marker_id', 'book_id', 'new_order');
if ($var_list) {
    foreach ($var_list as $key => $val) {
        ${$val} = register_variable($val);
    }
}
if (!$marker_id) {
    header('location:book.view.php');
    die;
}
$marker = new GrlxMarker($marker_id);
$new_order ? $new_order : ($new_order = 1);
/*****
 * Updates
function fetch_all_users($db)
{
    $cols = array('username', 'email', 'id');
    $users = $db->get('user', null, $cols);
    foreach ($users as $user) {
        $user_list[$user['id']] = $user;
    }
    return $user_list;
}
/*****
 * Setup
 */
require_once 'panl.init.php';
require_once '../_system/password.php';
$view = new GrlxView();
$form = new GrlxForm();
$var_list = array('username', 'password', 'email', 'submit');
if ($var_list) {
    foreach ($var_list as $key => $val) {
        ${$val} = register_variable($val);
    }
}
$view->yah = 13;
/*****
 * Updates
 */
if ($_POST['submit']) {
    foreach ($_POST['username'] as $key => $val) {
        $username_change = $val;
        $email_change = $email[$key];
        if ($username_change != '') {
$allowed_file_types = array('gif', 'png', 'jpg', 'jpeg', 'svg');
$variable_list = array('page_id', 'new_title', 'new_description', 'old_title', 'xml_format', 'function', 'raw_content', 'msg', 'pattern_id', 'url', 'layout_id');
if ($variable_list) {
    foreach ($variable_list as $val) {
        ${$val} = register_variable($val);
    }
}
// Hold it — no ID, no entrance.
if (!$page_id) {
    header('location:sttc.page-list.php');
    die;
}
$view = new GrlxView();
$link = new GrlxLinkStyle();
$message = new GrlxAlert();
$form = new GrlxForm();
$fileops = new GrlxFileOps();
$sl = new GrlxSelectList();
// Make sure the image folder exists and is accessible.
$alert_output .= $fileops->check_or_make_dir('../' . DIR_STATIC_IMG);
/*****
 * ! Updates
 */
// This comes from sttc.xml-new.php.
if ($msg == 'created') {
    $link1 = new GrlxLinkStyle();
    $link1->url('sttc.xml-new.php');
    $link1->tap('Create another new page');
    $link->url('site.nav.php');
    $link->tap('Add this page to the site’s menu');
    $alert_output .= $message->success_dialog('Page created. <ul><li>Make changes below</li><li>' . $link->paint() . '</li><li>' . $link1->paint() . '</li>');
/*****
 * Setup
 */
$except = true;
require_once 'panl.init.php';
$var_list = array('email', 'new_password', 's');
if ($var_list) {
    foreach ($var_list as $key => $val) {
        ${$val} = register_variable($val);
    }
}
$view = new GrlxView_Login();
$view->page_title('Reset password: step one');
$view->headline('Reset password: step one');
$view->main_id('forgot');
$form = new GrlxForm();
$form->send_to($_SERVER['SCRIPT_NAME']);
/*****
 * Updates
 */
// When the user submits a form
if ($email && !$s) {
    // Check if valid user
    $user = $db->where('email', $email)->getOne('user', 'count(*) AS count');
    if ($user['count'] == 1) {
        // Give the user a new serial number.
        for ($i = 0; $i < 16; $i++) {
            $new_serial .= rand(0, 9);
        }
        $data = array('serial' => $new_serial, 'date_modified' => $db->now());
        $db->where('email', $email);