localCache = true; $this->base_name = plugin_basename(__FILE__); if(!is_admin()) { add_action('wp_head', array($this,'init_css_js')); add_shortcode('affiliandovergleich',array($this,'shortcode_affiliandovergleich')); } else { add_action('admin_menu',array($this,'init_admin_menu')); if ($this->is_current_page('plugins')) { add_action('admin_notices',array($this,'show_version_notice')); } } } /* Funktionsaufrufe aus der Hauptfunktion heraus */ function init_css_js() { global $post; $this->post = $post; $this->shortcode_found = false; if (isset($this->post->ID)) { $pos = preg_match('/\[affiliandovergleich(.)*\]/', $this->post->post_content, $matches); if(!$pos) { return; } $matches[0] = trim(substr($matches[0],20,strlen($matches[0]))); $split1 = preg_split('/ /', trim($matches[0])); for($x = 0; $x < count($split1); $x++) { $split2 = preg_split('/=/',trim($split1[$x])); switch(trim($split2[0])) { case "pid": $this->pid = substr(trim($split2[1]), 1, -1); break; case "campaign": $this->campaign = substr(trim($split2[1]), 1, -1); break; case "rtype": $this->rtype = substr(trim($split2[1]), 1, -1); break; default: break; } } require_once("affiliandorechner.class.php"); $this->r = new Rechner($this->pid, $this->campaign, $this->rtype); // anlegen $this->csstype = $this->rtype; if($this->csstype == "kredit") { $this->csstype = "kreditrechner"; } $this->css1 = $this->r->domain.'/extension/site_konsumentenkredite/design/konsumentenkredite_user/stylesheets/vergleich_base.css'; $this->cssie = $this->r->domain.'/extension/site_konsumentenkredite/design/konsumentenkredite_user/stylesheets/vergleich_base_ie6.css'; $this->css2 = $this->r->domain.'/extension/zt_kreditrechner/design/konfigurator/stylesheets/additional/'.$this->csstype.'_'.$this->pid.'_'.$this->campaign.'.css'; if($this->localCache == true) { $jetzt = time(); @$nextupdate = filemtime($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($this->css1).'.css')+(3600*24); if($jetzt > $nextupdate) { $css = file_get_contents($this->css1); preg_match_all("|url\(([^\)]*)|i",$css, $urls); foreach($urls[0] as $url) { $dl = $this->r->domain.'/extension/site_konsumentenkredite/design/konsumentenkredite_user'.substr($url,6,strlen($url)); file_put_contents($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner'.substr($url,6,strlen($url)), file_get_contents($dl)); } file_put_contents($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($this->css1).'.css', $css); } @$nextupdate = filemtime($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($this->cssie).'.css')+(3600*24); if($jetzt > $nextupdate) { $css = file_get_contents($this->cssie); preg_match_all("|url\(([^\)]*)|i",$css, $urls); foreach($urls[0] as $url) { $dl = $this->r->domain.'/extension/site_konsumentenkredite/design/konsumentenkredite_user'.substr($url,6,strlen($url)); file_put_contents($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner'.substr($url,6,strlen($url)), file_get_contents($dl)); } file_put_contents($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($this->cssie).'.css', $css); } @$nextupdate = filemtime($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($this->css2).'.css')+(3600*24); if($jetzt > $nextupdate) { $css = file_get_contents($this->css2); file_put_contents($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($this->css2).'.css', $css); } $this->css1 = get_bloginfo('wpurl').'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($this->css1).'.css'; $this->cssie = get_bloginfo('wpurl').'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($this->cssie).'.css'; $this->css2 = get_bloginfo('wpurl').'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($this->css2).'.css'; } echo ' '; } } function shortcode_affiliandovergleich($atts) { extract(shortcode_atts(array( 'pid' => 0, 'campaign' => 0, 'rtype' => 'kredit', 'anzahl' => 10, 'small' => false, 'expand' => false, ), $atts)); if($small == 1 or $small == 'true') { $small = true; } if($expand == 1 or $expand == 'true') { $expand = true; } require_once("affiliandorechner.class.php"); $this->r->to_encoding(get_bloginfo('charset')); // Zielkodierung (falls nicht UTF-8) $this->r->htmlWrap(false); // ... $this->r->expand($expand); // ausgeklappt? $this->r->smallLayout($small); // schmales Layout? $this->r->visibleResults($anzahl); // Anzahl sichtbarer Ergebnisse // $r->hideProducts(array("produkt_1", "produkt_2")); // nicht sichtbare Fremdprodukte $content = $this->r->render(); // Ausgabe if($this->localCache == true) { $jetzt = time(); preg_match_all("|".$this->r->domain."([^\"]*)|i",$content, $urls); $newurl = array(); foreach ($urls[0] as $url) { $newurl[] = get_bloginfo('wpurl').'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($url).strrchr($url, "."); @$next = filemtime($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($url).strrchr($url, "."))+(3600*24); if($jetzt > $next) { file_put_contents($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/affiliandovergleichsrechner/files/'.md5($url).strrchr($url, "."), file_get_contents($url)); } } $content = str_replace($urls[0],$newurl,$content); } return $content; } function is_current_page($page) { switch($page) { case 'home': return (!empty($_REQUEST['page']) && $_REQUEST['page'] == $this->base_name); case 'index': case 'plugins': return (!empty($GLOBALS['pagenow']) && $GLOBALS['pagenow'] == sprintf('%s.php', $page)); default: return false; } } function show_version_notice() { if ($this->is_min_wp('2.7')) { return; } echo sprintf( '
%s %s
Einstellungen gespeichert