__construct(); } function __construct() { global $wpdb; $this->adCount=0; $this->wpdb=$wpdb; $this->verticalPrefix = "AdFever - Vertical"; $this->horyzontalName = "adfever"; $this->vb_title = ""; $this->optionName = $this->horyzontalName; $this->file=basename(__FILE__); $this->max_no_vertads=5; $this->formError=array(); $this->default_jscode=""; $this->jm_db_version = "1.0"; $this->table_name = $wpdb->prefix . "adfever"; } function setAdFeverJS() { $this->optionName=$this->horyzontalName; if(! $this->setOption() ) { $this->save2DB(); $this->setOption(); } return $this->getOption(); } function initAdFever() { $this->setAdFeverJS(); add_action('activate_'.$this->file, array(&$this, 'activationWP')); $this->addHook(); add_action('plugins_loaded',array(&$this, 'widgetSideBar')); add_filter('the_content', array(&$this,'placeAdInContent')); // may not work on windows register_deactivation_hook(__FILE__,array(&$this,'deactivationWP')); } ////////////////////////////////////////////// widget sidebar code ///////////////////////////////////////// function widgetSideBar() { $number=3; if (!function_exists('register_sidebar_widget')) { return; } for ($i = 1; $i <= $this->max_no_vertads; $i++) { $name = array($this->verticalPrefix.' %s', 'widgets', $i); register_sidebar_widget($name, $i <= $number ? array(&$this, 'vertAdFever') : /* unregister */ '', $i); register_widget_control($name, $i <= $number ? array(&$this, 'vertAdFeverEdit') : /* unregister */ '', 400, 400, $i); } } function vertAdFeverEdit($number=1) { $this->processWidgetForm($number); $this->optionName = $this->verticalPrefix." ".$number; $this->displaySettingV($this->optionName, $number); } function vertAdFever($args,$number=1) { $this->optionName = $this->verticalPrefix." ".$number; $this->setOption(); echo $args['before_widget'].'
'; echo $args['before_title'] . $this->vb_title . $args['after_title']; echo $this->getOption(); echo "
".$args['after_widget']; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function makeNewTable () { if($this->wpdb->get_var("show tables like '{$this->table_name}'") != $this->table_name) { $sql = "CREATE TABLE " . $this->table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, dtime timestamp NOT NULL, name tinytext NOT NULL, text text NOT NULL, url VARCHAR(55) NOT NULL, PRIMARY KEY id (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); $welcome_name = "Plugin"; $welcome_text = "Installation complete"; $insert = "INSERT INTO " . $this->table_name . " ( name, text) " . "VALUES ('" . $this->wpdb->escape($welcome_name) . "','" . $this->wpdb->escape($welcome_text) . "')"; $results = $this->wpdb->query( $insert ); add_option("jm_db_version", $this->jm_db_version); } else { //print "Table already exists"; } } function save2DB() { $results = $this->wpdb->query("DELETE FROM $this->table_name WHERE name='" . $this->wpdb->escape($this->optionName) . "'"); $results = $this->wpdb->query("INSERT INTO $this->table_name ( vb_title, name, text) "."VALUES ('" . $this->wpdb->escape($this->vb_title) . "','" . $this->wpdb->escape($this->optionName) . "','" . $this->wpdb->escape( $this->default_jscode) . "')"); } function setOption() { $this->default_jscode = $this->wpdb->get_var("SELECT text FROM $this->table_name WHERE name='" . $this->wpdb->escape($this->optionName) . "'"); $this->vb_title = $this->wpdb->get_var("SELECT vb_title FROM $this->table_name WHERE name='" . $this->wpdb->escape($this->optionName) . "'"); return $this->default_jscode; } function getOption() { return $this->default_jscode; } function deleteOption() { $results = $this->wpdb->query("DELETE FROM $this->table_name WHERE name='" . $this->wpdb->escape($this->optionName) . "'"); } // ACTIVATION & DEACTIVATION: due to register_activation_hook failing on windows, work around performed // activation via add_action('activate_'.$this->file, array(&$this, 'activationWP')); function activationWP() { $this->makeNewTable(1); $this->save2DB(); } function deactivationWP() { $this->name_ar = $this->wpdb->get_col("SELECT name FROM $this->table_name"); foreach ($this->name_ar as $name) { $this->optionName = $name; register_sidebar_widget ($name,""); // same as unregister with empty string callback value register_widget_control ($name,""); $this->deleteOption(); // empty DB table } add_action('widgets_init',array(&$this, 'unregisterWidgets')); } function unregisterWidgets() { // doesnt do anything on windows foreach ($this->name_ar as $name) { unregister_sidebar_widget($name); unregister_sidebar_widget($name); } } function admin_adview() { print $this->getOption(). $this->getOption(); } //////////////////////////////////////////////////////// AdFever Admin ///////////////////////////////////////////// function addHook() { add_action('admin_menu',array(&$this, 'addSubMenu')); } function addSubMenu() { add_options_page('AdFever settings', 'AdFever', 9, $this->file, array(&$this, 'displaySetting')); } function displaySetting($name="") { $radios=array( "left" => "Left", "center" => "Center", "right" => "Right" ); $textarea= $this->fr_TextArea("adfever_jscode", 35, 10); $inputtext= $this->fr_TextInput("maxads", 2) ; $radio= $this->fr_Radio("pos", $radios); $this->processPluginForm(); $this->optionName = ($name == "")?$this->horyzontalName:$name; print <<

AdFever admin

{$this->formHeadMessage}
AdFever banner ad setting
Paste AdFever JavaScript code below
{$this->formError["adfever_jscode"]} $textarea
{$this->formError["maxads"]} $inputtext Max number of ads to display in main content page
{$this->formError["pos"]} Ad position: $radio
CNT; } function displaySettingV($name="",$no=1) { $textarea= $this->fr_TextArea("adfever_jscode".$no, 35, 10); $this->optionName = ($name == "")?$this->horyzontalName:$name; // useless must be set to vertical banner name $inputtext= $this->fr_TextInput("vb_title{$no}", 25); print <<

AdFever admin

Add title (optional)
$inputtext
Paste AdFever JavaScript code below
{$this->formError["adfever_jscode".$no]} $textarea
CNT; } ///////////////////////////////////////////// FORM PROCESSING ////////////////////////////////////////// function processWidgetForm($no) { // if ( isset($_POST["do".$no]) && ($_POST["do".$no]=="adfever_id_v")) { $this->optionName = $_POST["widget_name".$no]; $this->default_jscode =$this->stripS($_POST["adfever_jscode".$no]); $this->vb_title =$this->stripS($_POST["vb_title".$no]); $this->check_form("string","adfever_jscode".$no); if (preg_match("/(?:javascript|iframe)/i", $this->default_jscode )) { $this->save2DB(); } } } function processPluginForm() { // $this->formHeadMessage=""; if ( isset($_POST["do"]) && ($_POST["do"]=="adfever_id_h")) { $this->optionName = $_POST["widget_name"]; // always same value: could be set manually $this->default_jscode =$this->stripS($_POST["adfever_jscode"]); $this->check_form("number", "maxads"); $this->check_form("string","adfever_jscode"); $this->check_form("radio","pos", array("left","center","right")); if ($this->insertOk()) { $this->save2DB(); update_option('adfever_maxads', $_POST['maxads']); update_option('adfever_pos', $_POST['pos'][0]); $this->formHeadMessage="
Banner ad saved!!
"; } else { $this->formHeadMessage="
Check for input errors and try again
"; } } } function insertOk() { return ((count($this->formError) >= 1)?false:true); } function check_form($type, $name, $options=null) { switch($type) { case "number": if (preg_match("/^\d+$/",$_POST[$name])) { return true; } else { $this->formError[$name]="
Valid number required
"; } break; case "string": if (preg_match("/(?:javascript|iframe)/i",$_POST[$name] )) { return true; } else { $this->formError[$name]="
Invalid data supplied
"; } break; case "number": if (preg_match("/^\d+$/",$_POST[$name])) { return true; } else { $this->formError[$name]="
Valid number required
"; } break; case "radio": $reg=implode("|",$options); if (preg_match("/^(?:$reg)$/",$_POST[$name][0])) { return true; } else { $this->formError[$name]="
Selection required
"; } break; } } ////////////////////////////// Sticky forms: textarea, text input, radio button ////////////////////////// function fr_TextArea($name, $cols, $rows) { return ""; } function fr_TextInput($name, $size=25) { return "stripS($_POST[$name]))."\">"; } function fr_Radio($name, $values) { $ct=""; foreach ($values as $v => $t) { $checked=($_POST[$name][0]==$v)?"checked":""; $ct .= ""; $ct .= $t." "; } return $ct; } function stripS($v) { return stripslashes($v); // remove compulsory wordpress slashes } ///////////////////////////////////////////// CONTENT FILTER ////////////////////////////////////////// function placeAdInContent($content) { $this->adCount++; if ($this->adCount > (int) get_option("adfever_maxads") ) { return ""; } $this->optionName=$this->horyzontalName; $this->setOption(); $pos=get_option("adfever_pos"); $ad=""; switch ($pos) { case "left": $css="text-align: left;"; $ad.="
".$this->getOption()."
"; break; case "center": $css="text-align:center;"; $ad.="
".$this->getOption()."
"; break; case "right": $css="text-align: right;"; $ad.="
".$this->getOption()."
"; break; default: $ad.="
".$this->getOption()."
"; } return $ad.$content; } } $myAdFever = new AdFever(); $myAdFever->initAdFever(); ?>
.. . ..... .. ... .. . . .
.. . ..... .. ... .. . . .
.. . ..... .. ... .. . . .
© VOYANCE OMEGA gagner de l'argent
connaissez-vous votre avenir ? | Bloguez.com
Creer un blog
Votez pour ce site au Weborama

lion

  : Ajouté le 11/7/2008 à 10:01

Tags :

» Catégorie Non spécifié
Commentaires (0) :: Poster un commentaire :: Lien permanent :: Envoyer à un ami

verseau

  : Ajouté le 11/7/2008 à 10:00

Tags :

» Catégorie Non spécifié
Commentaires (0) :: Poster un commentaire :: Lien permanent :: Envoyer à un ami

poisson

  : Ajouté le 11/7/2008 à 09:59

Tags :

» Catégorie Non spécifié
Commentaires (0) :: Poster un commentaire :: Lien permanent :: Envoyer à un ami

<- Précedent :: Suivant | | ->

A propos du blogueur

voyance à domicile

Liens

Accueil
Voir mon profile
Archives
Email
Blog RSS

Catégories

Amis

0

Liens

connaissez vous votre signe astro

Services


Sondage

Créer un blog | Contacter l'auteur |
Recherche personnalisée