<?php
if (!file_exists("po-library/po-config.php")){
	$now = gmdate('D, d M Y H:i:s') . ' GMT';
	header("Expires: $now");
	header("Last-Modified: $now");
	header("Cache-Control: no-cache, must-revalidate");
	header("Pragma: no-cache");
	echo "Maaf, PopojiCMS anda <b>belum terinstall</b>\n";
	if (file_exists("po-install/index.php")){
		echo "Mohon tunggu kami akan mendirect ke halaman installasi<br />\n";
		echo "<script language=\"Javascript\">location.href = 'po-install/index.php';</script>\n";
	}
	exit;
}else{
	ob_start();
	session_start();
	include_once 'po-library/po-database.php';
	include_once 'po-library/po-function.php';

	$val = new Povalidasi;

	$table = new PoTable('theme');
	$current = $table->findBy(active, 'Y');
	$current = $current->current();
	$folder = $current->folder;
	
	$tableset = new PoTable('setting');
	$currentSet = $tableset->findBy(id_setting, '1');
	$currentSet = $currentSet->current();
	$website_name = $currentSet->website_name;
	$website_url = $currentSet->website_url;
	$meta_description = $currentSet->meta_description;
	$meta_keyword = $currentSet->meta_keyword;
	$favicon = $currentSet->favicon;

	/*--- hapus baris ini dan ubah urlnya jika web Anda sudah di hosting
	$url = 'http://popoji.site.my.id/';
	$finfo = json_decode(file_get_contents('http://api.ak.facebook.com/restserver.php?v=1.0&method=links.getStats&urls='.$url.'&format=json'));
	$tinfo = json_decode(file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url='.$url));
	$dinfo = json_decode(file_get_contents('http://feeds.delicious.com/v2/json/urlinfo/data?url='.$url));
	$pinfo = json_decode(preg_replace('/^receiveCount\((.*)\)$/', "\\1",file_get_contents('http://api.pinterest.com/v1/urls/count.json?callback=receiveCount&url='.$url)));
	$gplus = gplus_shares($url);

	function gplus_shares($url){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, "https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ");
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
		$result = curl_exec ($ch);
		curl_close ($ch);
		return json_decode($result, true);
	}
 
	$output = array(
		'facebook'=> isset($finfo[0]) ? $finfo[0]->total_count : NULL,
		'twitter'=> isset($tinfo->count) ? $tinfo->count : NULL,
		'delicious'=> isset($dinfo[0]) ? $dinfo[0]->total_posts : NULL,
		'pinterest'=> isset($pinfo->count) ? $pinfo->count : NULL,
		'googlePlus'=> isset($gplus[0]['result']) ? $gplus[0]['result']['metadata']['globalCounts']['count'] : NULL
	);
	hapus baris ini dan ubah urlnya jika web Anda sudah di hosting ---*/

	$langset = $_GET['lang'];
	$langset = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($langset,ENT_QUOTES))));
	if ($langset==""){
		$lang = "id";
	}else{
		$lang = $langset;
	}

	if (!isset($_SESSION['submit'])) {
		$_SESSION['submit'] = true;
	}

	include "po-content/$folder/theme.php";
}
?>