-
Üyelik
23.11.2017
-
Yaş/Cinsiyet
54 / E
-
Meslek
Grafik Tasarımcı / Coder
-
Konum
İstanbul Anadolu
-
Ad Soyad
S** B**
-
Mesajlar
101
-
Beğeniler
7 / 6
-
Ticaret
0, (%0)
require_once("Security/Connect.php");
header('Content-Type: application/json');
function _j($status,$data)
{
@ob_end_clean();
die(json_encode(array('Status' => $status, 'Data' => $data)));
}
if (isset($_POST))
{
if (isset($_POST["p"]))
{
$process = $_POST["p"];
$key = $_POST["data"];
$activepage = $_POST["page"];
if ($process == "search")
{
$l = ($activepage - 1) * 15;
$e = $l + 15;
$data = array();
$key = str_replace("%","",$key);
$key_check = str_replace(" ","",$key);
if (!empty($key_check) && strlen($key_check) >=2)
{
$repKey = "";
$searchkey = "(";
$searchkeyOrder = "";
$searchkey_special = "(";
$word_list = explode(' ',$key);
foreach($word_list as $word)
{
if (str_replace(" ","",$word) != "")
{
$searchkey .= " (SiteAnahtarlar like '%".$word."%' or SiteLink like '%".$word."%' or SiteBaslik like '%".$word."%' or SiteAciklama like '%".$word."%' or SiteOzellikleri like '%".$word."%') and";
$searchkey_special .= " WordKey like '%".$word."%' or";
}
}
$searchkeyOrder = "CASE WHEN SiteBaslik like '%".$key."%' THEN 1
WHEN SiteAnahtarlar like '%".$key."%' THEN 2
WHEN SiteAciklama like '%".$key."%' THEN 3
WHEN SiteLink like '%".$key."%' THEN 4
WHEN SiteOzellikleri like '%".$key."%' THEN 5 ELSE 6 END";
$searchkey = substr($searchkey,0,strlen($searchkey)-3);
$searchkey .= ")";
$searchkey_special = substr($searchkey_special,0,strlen($searchkey_special)-3);
$searchkey_special .= ")";
$site_ids = array();
$sSpecRes = Query("select * from words where ".$searchkey_special."");
$sSpecRow = mysql_fetch_array($sSpecRes);
$_w_id = $sSpecRow["WordId"];
if ($_w_id > 0)
{
for($i=1;$i<=15;$i++){
$_siteid = $sSpecRow["Word_Site".$i];
$_endtime = $sSpecRow["Word_Site_D".$i];
$_timenow = date("Y-m-d H:i:s");
if (!empty($_siteid) && $_endtime > $_timenow){
$site_ids[] = $_siteid;
}
}
if ($activepage == 1)
$e -= count($site_ids);
else
{
$l -= count($site_ids);
$e -= count($site_ids);
$site_ids = array();
}
}
$sRes2 = Query("select * from siteler where SiteAktif = 1 and ".$searchkey);
$totalpage = mysql_num_rows($sRes2);
$sRes = Query("select * from siteler where SiteAktif = 1 and ".$searchkey." order by ".$searchkeyOrder.",SiteTik DESC limit ".$l.",".$e);
while($sRow = mysql_fetch_array($sRes))
{
$_s_id = $sRow[0];
if (!in_array($_s_id,$site_ids))
$site_ids[] = $sRow[0];
}
foreach($site_ids as $keys=>$val){
$sRes = Query("select * from siteler where Id = %u",$val);
while($sRow = mysql_fetch_array($sRes))
{
$item = new stdclass;
$item->SiteID = $sRow["Id"];
$item->SiteAdi = $sRow["SiteBaslik"];
$item->SiteAciklama = $sRow["SiteAciklama"];
$item->SiteLink = $sRow["SiteLink"];
$item->SiteShort = (strlen($sRow["SiteLink"]) > 50 ? substr($sRow["SiteLink"],0,50) . "..." : $sRow["SiteLink"]);
$item->SiteLogo =$sRow["SiteLogo"];
$item->SitePlus = ($sRow["SitePlus"] ? 1 : 0);
$attr = $sRow["SiteOzellikleri"];
if (!empty($attr)){
$item->Attr = json_decode($attr,false);
}
if (count($item->Attr->Header) > 0){
if (!empty($item->Attr->Header[0]))
$item->Subject = true;
else $item->Subject = false;
}
else $item->Subject = false;
$item->PropText = '';
for($i=0;$iAttr->Header);$i++)
$item->PropText .= ''.$item->Attr->Header[$i].' : '.$item->Attr->Content[$i].'
';
$data[] = $item;
}
}
$pages_list = array();
if (count($data) > 0){
$totalpage = ceil($totalpage / 15);
for($i=1;$i<=$totalpage;$i++){
$page = new stdclass;
$page->PageNum = $i;
$pages_list[] = $page;
}
}
}
ob_start();
include('models/content/right_adv.php');
$rightadvers = ob_get_clean();
include('models/content/bottom_adv.php');
$bottomadvers = ob_get_clean();
$title = $key . ' - Arama Sonuçları';
$url = str_replace(" ","-",$key);
_j("Success",array('SearchKey' => $key, 'Datas' => $data, 'Count' => count($data),'Pages' => $pages_list, 'ActivePage' => (int)$activepage, 'RightAdvers' => $rightadvers, 'BottomAdvers' => $bottomadvers,
'Title'=>$title,'Url'=>$url));
}
else if ($process == "addsite")
{
$site_name = strip_tags(urldecode($_POST["site_name"]));
$site_desc = strip_tags(urldecode($_POST["site_desc"]));
$site_keywords = strip_tags(urldecode($_POST["site_keywords"]));
$site_link = strip_tags(urldecode($_POST["site_link"]));
$site_props = strip_tags(urldecode($_POST["site_props"]));
$site_propsval = strip_tags(urldecode($_POST["site_propsval"]));
$site_logourl = strip_tags(urldecode($_POST["site_logo"]));
$site_logofile = urldecode($_POST["site_logo_file"]);
$logo = "";
if ($site_link == "URL")
_j("Error",_L("%errorurl%"));
if (empty($site_name) ||empty($site_desc) ||empty($site_link))
_j("Error",_L("%errorempty%"));
if (strlen($site_name) > 70)
_j("Error",_L("%error_name_max%"));
if (strlen($site_desc) > 250)
_j("Error",_L("%error_desc_max%"));
if (strlen($site_keywords) > 280)
_j("Error",_L("%error_key_max%"));
if (!empty($site_logofile))
{
$data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $site_logofile));
$fname = "wys/uploads/images/sites/".sef_link($site_link).".png";
file_put_contents($fname,$data);
$logo = $fname;
}
else{
if (!empty($site_logourl))
{
if ($site_logourl != "Logo URL") {
$fname = "wys/uploads/images/sites/".sef_link($site_link).".png";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $site_logourl);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$image = curl_exec($ch);
curl_close($ch);
file_put_contents($fname,$image);
$logo = $fname;
}
}
}
$allow_sites = array("tr-tr.facebook.com",
"facebook.com",
"facebook.com.tr",
"twitter.com",
"instagram.com",
"tumblr.com",
"snapchat.com",
"youtube.com",
"vine.co",
"badoo.com",
"periscope.tv",
"myspace.com",
"dailymotion.com",
"vimeo.com",
"scorpapp.com",
"wechat.com",
"linkedin.com",
"about.me",
"ask.fm",
"formspring.me",
"swarmapp.com",
"foursquare.com",
"plus.google.com",
"flickr.com",
"aim.com",
"yelp.com.tr");
$site_www = j_parseUrl($site_link);
if (in_array($site_www["host"],$allow_sites))
$is_social = true;
else $is_social = false;
$qRes = Query("select * from siteler where SiteLink like '%".$site_www["host"]."%' and SiteAktif = 1");
$count = mysql_num_rows($qRes);
if ($count <= 0 || $is_social)
{
$p_sub = explode(',',$site_props);
$p_subv = explode(',',$site_propsval);
foreach($site_props as $p => $v)
{
$p_sub[] = $v;
if (strlen($v) > 15)
_j("Error",_L("%error_property_max%"));
}
foreach($site_propsval as $p => $v)
{
$p_subv[] = $v;
if (strlen($v) > 50)
_j("Error",_L("%error_property_max%"));
}
$site_propsA = new stdclass;
$site_propsA->Header = $p_sub;
$site_propsA->Content = $p_subv;
$saveRes = Query("insert into siteler (SiteBaslik,SiteAciklama,SiteAnahtarlar,SiteLogo,SiteLink,SiteOzellikleri,SiteEkleyenIP) values ('%s','%s','%s','%s','%s','%s','%s')",$site_name,$site_desc,$site_keywords,$logo,$site_link,json_encode($site_propsA,JSON_UNESCAPED_UNICODE),$_SERVER["REMOTE_ADDR"]);
if ($saveRes)
{
_j("Success",$site_link);
}
else
_j("Error",_L("%systemerror%"));
}
else
_j("Error",_L("%alreadyregistered%"));
}
}
}
_j("Error",_L("%paramserror%"));
?>