Esempio n. 1
0
    }
}
// The number of items per page on a table
global $page_size;
$page_size = 10;
global $prli_blogurl;
global $prli_siteurl;
global $prli_blogname;
global $prli_blogdescription;
$prli_blogurl = get_option('home') ? get_option('home') : get_option('siteurl');
$prli_siteurl = get_option('siteurl');
$prli_blogname = get_option('blogname');
$prli_blogdescription = get_option('blogdescription');
/***** SETUP OPTIONS OBJECT *****/
global $prli_options;
$prli_options = PrliOptions::get_options();
/***** TODO: Uh... these functions should find a better home somewhere *****/
function setup_new_vars($groups)
{
    global $prli_link, $prli_options;
    $values = array();
    $values['url'] = isset($_REQUEST['url']) ? $_REQUEST['url'] : '';
    $values['slug'] = isset($_REQUEST['slug']) ? $_REQUEST['slug'] : $prli_link->generateValidSlug();
    $values['name'] = htmlspecialchars(isset($_REQUEST['name']) ? stripslashes($_REQUEST['name']) : '');
    $values['description'] = htmlspecialchars(isset($_REQUEST['description']) ? stripslashes($_REQUEST['description']) : '');
    $values['track_me'] = (isset($_REQUEST['track_me']) and $_REQUEST['track_me'] == 'on' or !isset($_REQUEST['track_me']) and $prli_options->link_track_me == '1') ? 'checked="true"' : '';
    $values['nofollow'] = (isset($_REQUEST['nofollow']) and $_REQUEST['nofollow'] == 'on' or !isset($_REQUEST['nofollow']) and $prli_options->link_nofollow == '1') ? 'checked="true"' : '';
    $values['redirect_type'] = array();
    $values['redirect_type']['307'] = (isset($_REQUEST['redirect_type']) and $_REQUEST['redirect_type'] == '307' or !isset($_REQUEST['redirect_type']) and $prli_options->link_redirect_type == '307') ? 'selected="selected"' : '';
    $values['redirect_type']['301'] = (isset($_REQUEST['redirect_type']) and $_REQUEST['redirect_type'] == '301' or !isset($_REQUEST['redirect_type']) and $prli_options->link_redirect_type == '301') ? 'selected="selected"' : '';
    $values['redirect_type']['prettybar'] = (isset($_REQUEST['redirect_type']) and $_REQUEST['redirect_type'] == 'prettybar' or !isset($_REQUEST['redirect_type']) and $prli_options->link_redirect_type == 'prettybar') ? 'selected="selected"' : '';
Esempio n. 2
0
function prli_install()
{
    global $wpdb, $prli_utils, $prli_update, $prli_db_version;
    $old_db_version = get_option('prli_db_version');
    $groups_table = $wpdb->prefix . "prli_groups";
    $clicks_table = $wpdb->prefix . "prli_clicks";
    $pretty_links_table = $wpdb->prefix . "prli_links";
    $link_metas_table = $wpdb->prefix . "prli_link_metas";
    $charset_collate = '';
    if ($wpdb->has_cap('collation')) {
        if (!empty($wpdb->charset)) {
            $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $charset_collate .= " COLLATE {$wpdb->collate}";
        }
    }
    if ($prli_db_version != $old_db_version) {
        $prli_utils->migrate_before_db_upgrade();
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        /* Create/Upgrade Clicks (Hits) Table */
        $sql = "CREATE TABLE {$clicks_table} (\n              id int(11) NOT NULL auto_increment,\n              ip varchar(255) default NULL,\n              browser varchar(255) default NULL,\n              btype varchar(255) default NULL,\n              bversion varchar(255) default NULL,\n              os varchar(255) default NULL,\n              referer varchar(255) default NULL,\n              host varchar(255) default NULL,\n              uri varchar(255) default NULL,\n              robot tinyint default 0,\n              first_click tinyint default 0,\n              created_at datetime NOT NULL,\n              link_id int(11) default NULL,\n              vuid varchar(25) default NULL,\n              PRIMARY KEY  (id),\n              KEY link_id (link_id),\n              KEY ip (ip),\n              KEY browser (browser),\n              KEY btype (btype),\n              KEY bversion (bversion),\n              KEY os (os),\n              KEY referer (referer),\n              KEY host (host),\n              KEY uri (uri),\n              KEY robot (robot),\n              KEY first_click (first_click),\n              KEY vuid (vuid)" . ") {$charset_collate};";
        dbDelta($sql);
        /* Create/Upgrade Pretty Links Table */
        $sql = "CREATE TABLE {$pretty_links_table} (\n              id int(11) NOT NULL auto_increment,\n              name varchar(255) default NULL,\n              description text default NULL,\n              url text default NULL,\n              slug varchar(255) default NULL,\n              nofollow tinyint(1) default 0,\n              track_me tinyint(1) default 1,\n              param_forwarding varchar(255) default NULL,\n              param_struct varchar(255) default NULL,\n              redirect_type varchar(255) default '307',\n              created_at datetime NOT NULL,\n              group_id int(11) default NULL,\n              PRIMARY KEY  (id),\n              KEY group_id (group_id),\n              KEY name (name),\n              KEY nofollow (nofollow),\n              KEY track_me (track_me),\n              KEY param_forwarding (param_forwarding),\n              KEY param_struct (param_struct),\n              KEY redirect_type (redirect_type),\n              KEY slug (slug)\n            ) {$charset_collate};";
        dbDelta($sql);
        /* Create/Upgrade Groups Table */
        $sql = "CREATE TABLE {$groups_table} (\n              id int(11) NOT NULL auto_increment,\n              name varchar(255) default NULL,\n              description text default NULL,\n              created_at datetime NOT NULL,\n              PRIMARY KEY  (id),\n              KEY name (name)\n            ) {$charset_collate};";
        dbDelta($sql);
        /* Create/Upgrade Groups Table */
        $sql = "CREATE TABLE {$link_metas_table} (\n              id int(11) NOT NULL auto_increment,\n              meta_key varchar(255) default NULL,\n              meta_value longtext default NULL,\n              link_id int(11) NOT NULL,\n              created_at datetime NOT NULL,\n              PRIMARY KEY  (id),\n              KEY meta_key (meta_key),\n              KEY link_id (link_id)\n            ) {$charset_collate};";
        dbDelta($sql);
        $prli_utils->migrate_after_db_upgrade();
    }
    // Install Pro DB if this user is authorized
    if ($prli_update->pro_is_authorized()) {
        $prli_utils->install_pro_db();
    }
    // If there are any post metas with a post_id of 0 get rid of them...
    $prli_utils->clear_unknown_post_metas();
    /***** SAVE OPTIONS *****/
    $prli_options = PrliOptions::get_options();
    $prli_options->store();
    /***** SAVE DB VERSION *****/
    update_option('prli_db_version', $prli_db_version);
}