/home/devfahim/public_html/wp-content/plugins/XSystem/SXINDEX/SXIRender.php
<?php
//00008
class CIRender {
private $class;
private $iid;
private $m_tt = false;
private $m_ex = false;
private $m_im = false;
private $m_cn = false;
private $m_vd = false;
public static function __find_L_IID($title) {
$dir = plugin_dir_path(__FILE__) . 'Render';
$base = file_get_contents($dir . "/c-softw/soft_L.dat");
$base = explode("\r\n~\r\n", $base);
$title = html_entity_decode($title);
foreach($base as $soft) {
$mdat = explode("\r\n", $soft);
if(stripos($title, $mdat[0]) !== false) {
return substr(md5($mdat[0]) , -8);
}
}
return false;
}
public function __construct($iid = false) {
$dir = plugin_dir_path(__FILE__) . 'Render';
if($iid === false) {
$this->_setTimeAddiction();
$this->class = mt_rand(0, 1) ? "T" : "L";
if($this->class == "T") {
$base = file_get_contents($dir . "/c-softw/soft_T.dat");
$base = explode("\r\n~\r\n", $base);
$mdat = $base[array_rand($base)];
$mdat = explode("\r\n", $mdat);
$this->iid = $mdat[1];
$this->m_tt = $mdat[0];
$this->m_ex = $mdat[2];
$this->m_cn = $mdat[3];
$this->m_vd = $mdat[4];
} else {
$base = file_get_contents($dir . "/c-softw/soft_L.dat");
$base = explode("\r\n~\r\n", $base);
$mdat = $base[array_rand($base)];
$mdat = explode("\r\n", $mdat);
$this->iid = substr(md5($mdat[0]), -8);
$this->XWPDownImage($mdat[2]);
$this->m_tt = $mdat[0];
$this->m_ex = false;
$this->m_cn = $mdat[1];
$this->m_vd = false;
}
}
else {
$this->iid = $iid;
}
}
private function _setSiteAddiction($seed = "") {
srand(hexdec(substr(md5(site_url().$seed), -5)));
}
private function _setTimeAddiction() {
srand(round(microtime(true) * 1000) + mt_rand(0,10**6));
}
private function XWPRenderPSlug($title) {
$this->_setTimeAddiction();
$words = preg_split('/\s+/', strtolower(preg_replace('/[^a-zA-Z\s]/', '', $title)));
$words = array_filter($words);
$limitedWords = array_slice($words, 0, 4);
if (count($limitedWords) <= 2) {
return implode('_', $limitedWords);
}
$randKeys = array_rand($limitedWords, 2);
if (!is_array($randKeys)) {
$randKeys = [$randKeys];
}
return implode('_', [ $limitedWords[$randKeys[0]], $limitedWords[$randKeys[1]] ]);
}
private function XWPDownImage($url) {
$dir = plugin_dir_path(__FILE__) . 'Render';
$image = $dir . "/image/{$this->iid}.png";
if(file_exists($image)) {
return true;
}
$image_e = $dir . "/image/soft.png";
$ch = curl_init($url);
$fp = fopen($image, 'wb');
if (!$fp) return false;
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$success = curl_exec($ch);
curl_close($ch);
fclose($fp);
if (!$success || filesize($image) === 0 || filesize($image) > 1024**2) {
if (file_exists($image)) {
unlink($image);
}
copy($image_e, $image);
}
return true;
}
private function XWPRenderImage() {
$dir = plugin_dir_path(__FILE__) . 'Render';
$image = @imagecreatefrompng($dir . "/image/{$this->iid}.png");
if(!$image) {
$image = @imagecreatefromjpeg($dir . "/image/{$this->iid}.png");
}
$width = imagesx($image);
$height = imagesy($image);
$scFactor = 1 + (mt_rand(-5, 5) / 100);
$scWidth = (int)($width * $scFactor);
$scHeight = (int)($height * $scFactor);
if ($scWidth > 512) {
$scHeight = (int)($scHeight * (512 / $scWidth));
$scWidth = 512;
}
$resized = imagecreatetruecolor($scWidth, $scHeight);
imagealphablending($resized, false);
imagesavealpha($resized, true);
imagecopyresampled(
$resized, $image,
0, 0, 0, 0,
$scWidth, $scHeight,
$width, $height
);
$crLeft = mt_rand(0, 10);
$crTop = mt_rand(0, 10);
$cropRight = mt_rand(0, 10);
$cropBottom = mt_rand(0, 10);
$crWidth = $scWidth - $crLeft - $cropRight;
$crHeight = $scHeight - $crTop - $cropBottom;
$cropped = imagecreatetruecolor($crWidth, $crHeight);
imagealphablending($cropped, false);
imagesavealpha($cropped, true);
imagecopy(
$cropped, $resized,
0, 0, $crLeft, $crTop,
$crWidth, $crHeight
);
ob_start();
imagepng($cropped);
$imgData = ob_get_clean();
imagedestroy($image);
imagedestroy($resized);
imagedestroy($cropped);
return 'data:image/png;base64,' . base64_encode($imgData);
}
private function XWPRenderObject($object, $wrap = false) {
$dir = plugin_dir_path(__FILE__) . 'Render';
$base = file_get_contents($dir . "/$object.dat");
$base = explode("\r\n~\r\n", $base);
$text = "";
foreach($base as $block) {
$a_blk = explode("\r\n", $block);
$r_pre = "";
while($r_pre == "") {
$r_pre = trim($a_blk[array_rand($a_blk)]);
}
$text .= $r_pre . " ";
}
if($wrap) {
$text = str_replace("%WRAP%", $wrap, $text);
}
return trim($text);
}
private function XWPRenderSubObject($object, $wrap = false) {
$base = explode("|", $object);
$text = "";
foreach($base as $block) {
$a_blk = explode(".", $block);
$r_pre = "";
while($r_pre == "") {
$r_pre = trim($a_blk[array_rand($a_blk)]);
}
$text .= $r_pre . ". ";
}
if($wrap) {
$text = str_replace("%WRAP%", $wrap, $text);
}
return trim($text);
}
public function XWPRenderCategory($cposts) {
$this->_setSiteAddiction(intval($cposts / XWP_POSTING_CAT));
return $this->XWPRenderObject("sh_categ_softw");
}
public function XWPRenderPTitle() {
$this->_setTimeAddiction();
$dir = plugin_dir_path(__FILE__) . 'Render';
$base = file_get_contents($dir . "/sh_ptitle_softw.dat");
$base = explode("\r\n", $base);
array_unshift($base, $this->m_ex);
$title = $this->m_tt . " ";
foreach($base as $block) {
$t_a = explode(",", $block);
$title .= trim($t_a[array_rand($t_a)]) . " ";
}
$title = str_replace("{}", "", $title);
for($n = 0; $n < 5; $n++) {
$title = str_replace(" ", " ", $title);
}
return trim($title);
}
public function XWPRenderPContent() {
$this->_setTimeAddiction();
$title = $this->m_tt;
if($this->class == "T") {
$content = $this->XWPRenderSubObject($this->m_cn);
} else {
$content = $this->m_cn;
}
$video = $this->m_vd;
$opt_n = mt_rand(3, 6);
$optimiz = "";
for($n = 0; $n < $opt_n; $n++) {
$free = mt_rand(0, 1) ? "" : " FREE";
$li_tag = $this->XWPRenderObject("sh_optim_softw");
$li_tag = str_replace("%ITEM%", $title, $li_tag);
$optimiz .= $li_tag;
$li_tag = "<li>" . $this->XWPRenderPTitle() . $free . "</li>";
$optimiz .= $li_tag;
}
$optimiz = $this->XWPRenderObject("wr_ulol", $optimiz);
$content .= $optimiz;
if($video && mt_rand(0, 1)) {
$videofr = $this->XWPRenderObject("wr_video", $video);
$content .= $videofr;
}
return $content;
}
public function XWPRenderLnkBlock() {
$this->_setTimeAddiction();
$dlang = $this->XWPRenderObject("sh_downlang");
$this->_setSiteAddiction();
$dir = plugin_dir_path(__FILE__) . 'Render';
$dtable = $this->XWPRenderObject("sh_dtable");
$dbutts = $this->XWPRenderObject("sh_button");
$dbutts = str_replace("%DOWNLANG%", $dlang, $dbutts);
$this->_setTimeAddiction();
$sizegb = $this->XWPRenderObject("sh_hashes");
$drequm = $this->XWPRenderObject("sh_dreqm_softw");
$drequm = $this->XWPRenderObject("wr_dreqm_ul", $drequm);
$block = $sizegb . $dbutts . $drequm;
$block = $this->XWPRenderObject("wr_dreqm_dv", $block);
$image = $this->XWPRenderImage();
$dtable = str_replace("%IMAGE%", $image, $dtable);
$dtable = str_replace("%BUTTS%", $block, $dtable);
return $dtable;
}
public function XWPRenderDownPage($title) {
$this->_setSiteAddiction();
$dir = plugin_dir_path(__FILE__) . 'Render';
if (!is_dir($dir . "/dpage")) {
return false;
}
$files = glob($dir . '/dpage/*.*');
if (empty($files)) {
return false;
}
$dpage = $files[array_rand($files)];
$dhtml = file_get_contents($dpage);
$dcont = $this->XWPRenderObject("sh_dpage");
$dcont = $this->XWPRenderObject("wr_dpage", $dcont);
$b_file = $dir . "/[softw].html";
$b_html = file_get_contents($b_file);
$image = $this->XWPRenderImage();
$b_html = str_replace("%IMAGE%", $image, $b_html);
$dhtml = str_replace("%DTITLE%", $title, $dhtml);
$dhtml = str_replace("%DBLOCK%", $b_html, $dhtml);
$dhtml = str_replace("%DCONTS%", $dcont, $dhtml);
$dhtml = str_replace("%DSLUG%", $this->XWPRenderPSlug($title), $dhtml);
return $dhtml;
}
}
?>