<?php
// 2 bitcon, 3 health , 4 ru, 5 cars
//$bitcoin = array(‘1’ => 1, ‘9’ => 2, ’24’ => 4, ’26’ => 2, ’27’ => 2, ’33’ => 2, ’34’ => 4, ’41’ => 2, ’42’ => 4, ’65’ => 4, ’70’ => 3, ’71’ => 4, ’73’ => 4);
switch ($bitcoin[$_GET[“blog_id”]]) {
// Home page
case '2':
// echo 'bitcoin';
$files = glob('bitcoin/*');
break;
case '3':
// echo 'bitcoin';
$files = glob('health/*');
break;
case '4':
// echo 'bitcoin';
$files = glob('ru/*');
break;
// Everything else
default:
//echo 'main';
$files = glob('casino/*');
break;
}
$file = $files[rand(0, count($files) – 1)];
$text = file_get_contents($file);
class Spintax
{
public function process($text)
{
return preg_replace_callback(
‘/{(((?>[^{}]+)|(?R))*)}/x’,
array($this, ‘replace’),
$text
);
}
public function replace($text)
{
$text = $this->process($text[1]);
$parts = explode('|', $text);
return $parts[array_rand($parts)];
}
}
/ EXAMPLE USAGE /
$spintax = new Spintax();
$text = str_replace(‘http://link.com‘, $_GET[“link1″], $text);
$text = str_replace(”, $_GET[“link2″], $text);
$text = str_replace(”, $_GET[“link1″], $text);
$text = str_replace(”, $_GET[“link2”], $text);
$string = $text;
//echo $spintax->process($string);
preg_match_all(‘$$i’,$string, $subresult);
$post_title = $spintax->process($subresult[1][0]);
if ($post_title == NULL) {
$post_title = strtok($string, “n”);
$post_title = $spintax->process($post_title);
}
$string = preg_replace(“!!”,””,$string);
//print_r($subresult);
//exit;
require( ‘../wp-load.php’ );
switch_to_blog($_GET[“blog_id”]);
$content = $spintax->process($string);
// Create post object
$my_post = array();
$my_post[‘post_title’] = $post_title;
$my_post[‘post_content’] = $content;
$my_post[‘post_status’] = ‘publish’;
$my_post[‘post_author’] = 1;
$my_post[‘post_category’] = array(0);
// Insert the post into the database
$link = wp_insert_post( $my_post );
$link_url = get_permalink($link );
?><?php echo $_GET[“callback”]; ?>({“author”:”Ovidiu Platon”,”id”:11,”quote”:”<?php echo $link_url;?>”,”links”:””})