public function pages_bar($options = array())
 {
     $output = '';
     $url_string = preg_match('/\\?/', get_requested_url()) ? get_requested_url() . '&p=' : get_requested_url() . '?p=';
     $bar_text = isset($options['bar_text']) && !empty($options['bar_text']) ? $options['bar_text'] : 'Pages';
     $ul_class = 'paginator';
     if ($this->items_count > $this->items_page) {
         $output .= sprintf('<ul class="%1$s"><li class="bar-text">%2$s</li>', $ul_class, $bar_text);
         if ($this->actual_page > 0) {
             $prev_url = 'href="' . $url_string . ($this->actual_page - 1) . '"';
             $output .= sprintf('<li class="prev-page page-button"><a %s>&lt;</a></li>', $prev_url);
         }
         foreach ($this->get_pages() as $page) {
             $url;
             if ($page == $this->actual_page) {
                 $url = '';
                 $li_class = 'page-button current-page';
             } else {
                 $url = 'href="' . $url_string . $page . '"';
                 $li_class = 'page-button';
             }
             $output .= sprintf('<li class="%1$s"><a %3$s>%2$d</a></li>', $li_class, $page + 1, $url);
         }
         if ($this->actual_page < count($this->get_pages()) - 1) {
             $next_url = 'href="' . $url_string . ($this->actual_page + 1) . '"';
             $output .= sprintf('<li class="next-page page-button"><a %s>&gt;</a></li>', $next_url);
         }
         $output .= '</ul>';
     }
     echo $output;
 }
Exemple #2
0
<?php

// Setup Configuration file
//Get Site Url, the url reflects the location ot the admin folder.
$setup_site_url = preg_replace('/([\\/]admin[\\/])$/', '', get_requested_url());
//Get Language from browser
$setup_site_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
//Variables
$site_data = array('name' => '', 'description' => '');
$user_data = array('username' => '', 'secretphrase' => '');
$success_msg = '';
if (isset($_POST['confignow'])) {
    unset($_POST['confignow']);
    //Separate the data
    //User Data
    $user_data['id'] = '1';
    $user_data['username'] = $_POST['username'];
    $user_data['secretphrase'] = create_hash($_POST['secretphrase']);
    //Unset user data from $_POST;
    foreach ($user_data as $key => $value) {
        unset($_POST[$key]);
    }
    //Create all the needed files and server configurations
    if (config_init($_POST) && rss_init($_POST) && admin_init($user_data)) {
        unset($user_data['secretphrase']);
        foreach ($_POST as $key => $value) {
            $site_data[$key] = $value;
        }
        $success_msg = '<div class="over-top-msg"><p>Please wait, Your blog is being configured.</p></div>';
        header('refresh:3;url=' . dirname($_SERVER['PHP_SELF']));
    }
/**
 * Adds a custom or predefined contact form.
 * This form does not support drop down input tags such as option yet
 * @param array $args Set of options to set the contact form
 *                    email : Recipient email is mandatory
 *                    class : Class of the contact form
 *                    textarea_placeholder : Placeholder text of textarea
 *                    						 defaults to "Type your message"
 *                    g_captcha : activate google captcha, defaults to true
 *                    captcha_options : is an array to set up options as per
 *                    					google reCaptcha docs:
 *                    					- data_sitekey
 *                    					- data_type
 *                    					- data_theme
 *                    					- data_callback
 *                    fields : an array to set up the custom input fields
 *                    		   if assoc array used, the keys will be used to
 *                    		   set <label> tags, otherwise no <label> tags
 *                    		   will be used
 *                    textarea : activate textarea field, defaults to true
 *                    submit_text : text shown submit button, defaults to "submit"
 *                    
 *                    		   			
 */
function add_contact_form($args = array())
{
    global $root;
    //Set default variables
    $output = '';
    $str_p = '';
    $end_p = '';
    $has_label = false;
    // Set <label> tags off by default
    $form_class = isset($args['class']) && !empty($args['class']) ? $args['class'] : '';
    $txtarea_plcholder = isset($args['textarea_placeholder']) && !empty($args['textarea_placeholder']) ? $args['textarea_placeholder'] : 'Type your message';
    // Enable Google reCaptcha by default
    $g_captcha = isset($args['g_captcha']) ? $args['g_captcha'] : true;
    // Google reCaptcha options
    $captcha_sitekey = !empty($args['captcha_options']['data_sitekey']) ? $args['captcha_options']['data_sitekey'] : 'YOUR SITE KEY';
    $captcha_type = !empty($args['captcha_options']['data_type']) ? 'data-type="' . $args['captcha_options']['data_type'] . '"' : '';
    $captcha_theme = !empty($args['captcha_options']['data_theme']) ? 'data-theme="' . $args['captcha_options']['data_theme'] . '"' : '';
    $captcha_callback = !empty($args['captcha_options']['data_callback']) ? 'data-callback="' . $args['captcha_options']['data_callback'] . '"' : '';
    // Get data for hidden fields used to check google recaptcha response
    $hidden_fields = array('visitor_ip' => $_SERVER['REMOTE_ADDR'], 'visitor_useragent' => $_SERVER['HTTP_USER_AGENT']);
    // Default fields
    $fields = isset($args['fields']) && is_array($args['fields']) ? $args['fields'] : array(array('name' => 'name', 'type' => 'text', 'placeholder' => 'Name', 'required' => 'required'), array('name' => 'email', 'type' => 'email', 'placeholder' => 'e-mail', 'required' => 'required'), array('name' => 'subject', 'type' => 'text', 'placeholder' => 'Subject', 'required' => 'required'));
    // If form has been submitted include the message-script
    if (isset($_POST['submit'])) {
        include $root . '/message-script.php';
    }
    // Check if email address has been passed, if not advice the admin
    if (!isset($args['email']) || empty($args['email'])) {
        $output = '<p>You have not declare an email, messages won&#39;t be sent</p>';
    }
    // if form has been submitted, store the message that was sent by the form
    if (!empty($message)) {
        $output .= sprintf($message, $_POST['name']);
    }
    $output .= sprintf('<form class="mail-form %1$s" method="POST" action="%2$s" >', $form_class, get_requested_url());
    // Add all the input fields into the form
    foreach ($fields as $type => $field) {
        $str_p = $field['type'] == 'hidden' ? '' : '<p>';
        $end_p = $field['type'] == 'hidden' ? '' : '</p>';
        if (is_int($type)) {
            $output .= $str_p;
            $output .= '<input';
            foreach ($field as $attr => $val) {
                $output .= sprintf(' %1$s="%2$s"', $attr, $val);
            }
            $output .= '/>';
            $output .= $end_p;
        } else {
            $has_label = true;
            $output .= $str_p;
            $output .= sprintf('<label class="form-label">%s</label><input', $type);
            foreach ($field as $attr => $val) {
                $output .= sprintf(' %1$s="%2$s"', $attr, $val);
            }
            $output .= '/>';
            $output .= $end_p;
        }
    }
    // Include textarea if enabled
    if (!isset($args['textarea']) || $args['textarea'] == true) {
        if ($has_label) {
            $output .= sprintf('<p><label>%s</label>', $txtarea_plcholder);
            $txtarea_plcholder = '';
        }
        $output .= sprintf('<textarea name="message" placeholder="%s"></textarea>', $txtarea_plcholder);
        if ($has_label) {
            $output .= '</p>';
        }
    }
    // Add hidden fields
    foreach ($hidden_fields as $key => $value) {
        $output .= sprintf('<input name="%1$s" type="hidden" value="%2$s"/>', $key, $value);
    }
    // Enable Google no Captcha ReCaptcha
    if ($g_captcha) {
        $output .= sprintf('<div class="g-recaptcha" data-sitekey="%1$s" %2$s %3$s %4$s></div>', $captcha_sitekey, $captcha_type, $captcha_theme, $captcha_callback);
    }
    $submit_txt = empty($args['submit_text']) ? 'Send Message' : $args['submit_text'];
    $output .= sprintf('<input id="submit-form" name="submit" type="submit" value="%s"/>', $submit_txt);
    $output .= '</form>';
    echo $output;
}