//MySQL database
define( "dbuser", "store" );
define( "dbpassword", "W3bmaster233" );
define( "dbname", "1dollar_store" );
define( "dbhost", "localhost" );
//Site HTTP URL
define( "surl", "http://1dollarclips.com" );
//Site HTTPS URL
define( "ssurl", "http://1dollarclips.com" );
//Site root. It is an empty if the script is in root directory or "/store" if the script in "/store" directory.
define( "site_root", "" );
include("functions.php");
?>
if(!defined("site_root")){exit();}
//id_parent determination
if(isset($_GET["id_parent"]))
{
$id_parent=(int)$_GET["id_parent"];
}
elseif(isset($_GET["category"]))
{
if(!preg_match("/^[0-9]+$/",$_GET["category"]))
{
$sql="select id_parent,title from category where title='".str_replace("-"," ",result3($_GET["category"]))."'";
$dr->open($sql);
if(!$dr->eof){$id_parent=$dr->row["id_parent"];}
else{$id_parent=5;}
}
else
{
$sql="select id_parent from category where id_parent=".(int)$_GET["category"];
$dr->open($sql);
if(!$dr->eof){$id_parent=$dr->row["id_parent"];}
else{$id_parent=5;}
}
}
elseif(isset($_GET["acategory"]))
{
$id_parent=(int)$_GET["acategory"];
}
elseif(isset($_POST["acategory"]))
{
$id_parent=(int)$_POST["acategory"];
}
elseif(isset($_GET["catalog"]))
{
$id_parent=item_id($_GET["catalog"],$_GET["ctypes"]);
}
else
{
$id_parent=5;
}
//Module table
$module_table=0;
if($id_parent!=5)
{
$sql="select module_table from structure where id=".(int)$id_parent;
$rs->open($sql);
if(!$rs->eof)
{
$module_table=$rs->row["module_table"];
}
/*
if(($module_table==30 or $module_table==31 or $module_table==52 or $module_table==53) and !isset($_SESSION["people_id"]))
{
header("location:".site_root."/members/login.php");
exit();
}
*/
}
//Affiliate
if(isset($_GET["aff"]))
{
$sql="update users set aff_visits=aff_visits+1 where id_parent=".(int)$_GET["aff"];
$db->execute($sql);
setcookie("aff",(int)$_GET["aff"],time()+60*60*24*30,"/",str_replace("http://","",surl));
}
//user determination
$name_user="";
if(isset($_GET["user"]))
{
$sql="select id_parent,login from users where id_parent=".(int)$_GET["user"];
$dr->open($sql);
if(!$dr->eof){$user_id=$dr->row["id_parent"];$name_user=$dr->row["login"];}
else{$user_id=0;}
}
//Variables
$file_template="";
$template_home="";
$template_header="";
//Header template
$template_header=file_get_contents($DOCUMENT_ROOT."/".$site_template_url."header.tpl");
//Home_template
$template_home=file_get_contents($DOCUMENT_ROOT."/".$site_template_url."home.tpl");
if(count($_POST)==0 and (count($_GET)==0 or isset($_GET["template"]) or isset($_GET["aff"])) and $site=="main" and $site_home_separated)
{
$file_template=$template_home;
$homepage=$file_template;
include("$DOCUMENT_ROOT/members/homepage.php");
$file_template=$homepage;
}
else
{
$file_template=$template_header;
}
//Meta keywords description
$meta_keywords=$global_settings["meta_keywords"]." ";
$meta_description=$global_settings["meta_description"].". ";
if($module_table==30)
{
$sql="select keywords,description from photos where id_parent=".(int)$id_parent;
$rs->open($sql);
if(!$rs->eof)
{
$meta_keywords.=$rs->row["keywords"];
$meta_description.=$rs->row["description"];
}
}
if($module_table==31)
{
$sql="select keywords,description from videos where id_parent=".(int)$id_parent;
$rs->open($sql);
if(!$rs->eof)
{
$meta_keywords.=$rs->row["keywords"];
$meta_description.=$rs->row["description"];
}
}
if($module_table==52)
{
$sql="select keywords,description from audio where id_parent=".(int)$id_parent;
$rs->open($sql);
if(!$rs->eof)
{
$meta_keywords.=$rs->row["keywords"];
$meta_description.=$rs->row["description"];
}
}
if($module_table==53)
{
$sql="select keywords,description from vector where id_parent=".(int)$id_parent;
$rs->open($sql);
if(!$rs->eof)
{
$meta_keywords.=$rs->row["keywords"];
$meta_description.=$rs->row["description"];
}
}
$file_template=str_replace("{KEYWORDS}",$meta_keywords,$file_template);
$file_template=str_replace("{DESCRIPTION}",$meta_description,$file_template);
//boxes
$boxes_left="";
$boxes_right="";
$box=file_get_contents($DOCUMENT_ROOT."/".$site_template_url."box.tpl");
$box_first=file_get_contents($DOCUMENT_ROOT."/".$site_template_url."box_first.tpl");
$sql="select title,side,template from sideboxes where activ=1 order by priority";
$rs->open($sql);
while(!$rs->eof)
{
$box_content=str_replace("{BOX_CONTENT}",stripslashes($rs->row["template"]),str_replace("{BOX_TITLE}",word_lang($rs->row["title"]),$box));
$box_content_first=str_replace("{BOX_CONTENT}",stripslashes($rs->row["template"]),str_replace("{BOX_TITLE}",word_lang($rs->row["title"]),$box_first));
if($rs->row["title"]=="Categories")
{
if($rs->row["side"]=="Left")
{
$boxes_left.=$box_content_first;
}
else
{
$boxes_right.=$box_content_first;
}
}
else
{
if($rs->row["side"]=="Left")
{
$boxes_left.=$box_content;
}
else
{
$boxes_right.=$box_content;
}
}
$rs->movenext();
}
//Box categories
include("box_categories.php");
//Box shopping cart
include("box_shopping_cart.php");
//Box members template
include("box_members.php");
//Box search
include("box_search.php");
//Box site info
include("box_site_info.php");
//Box news
include("box_news.php");
//Box photographers
include("box_photographers.php");
//Box stat
include("box_stat.php");
//Box languages
include("box_languages.php");
//Box tag clouds
include("box_tag_clouds.php");
//Top menu
include("top_menu.php");
//Maps
$google_code="";
if($site_google)
{
if (!$smarty->is_cached('google.tpl',"google"))
{
$sql="(select a.id,a.id_parent as idp,a.module_table,b.id_parent,b.title,b.published,b.folder,b.server1,b.google_x,b.google_y,b.description from structure a,photos b where b.published=1 and a.id=b.id_parent and b.google_x<>0 and b.google_y<>0) union (select a.id,a.id_parent as idp,a.module_table,b.id_parent,b.title,b.published,b.folder,b.server1,b.google_x,b.google_y,b.description from structure a,videos b where b.published=1 and a.id=b.id_parent and b.google_x<>0 and b.google_y<>0) union (select a.id,a.id_parent as idp,a.module_table,b.id_parent,b.title,b.published,b.folder,b.server1,b.google_x,b.google_y,b.description from structure a,audio b where b.published=1 and a.id=b.id_parent and b.google_x<>0 and b.google_y<>0) union (select a.id,a.id_parent as idp,a.module_table,b.id_parent,b.title,b.published,b.folder,b.server1,b.google_x,b.google_y,b.description from structure a,vector b where b.published=1 and a.id=b.id_parent and b.google_x<>0 and b.google_y<>0) order by rand() limit 0,20";
$rs->open($sql);
$n=0;
while(!$rs->eof)
{
if($n!=0)
{
$google_code.=",";
}
$img_url="";
if($rs->row["module_table"]==30)
{
$img_url=show_preview($rs->row["id"],"photo",1,1,$rs->row["server1"],$rs->row["folder"]);
}
if($rs->row["module_table"]==31)
{
$img_url=show_preview($rs->row["id"],"video",1,1,$rs->row["server1"],$rs->row["folder"]);
}
if($rs->row["module_table"]==52)
{
$img_url=show_preview($rs->row["id"],"audio",1,1,$rs->row["server1"],$rs->row["folder"]);
}
if($rs->row["module_table"]==53)
{
$img_url=show_preview($rs->row["id"],"vector",1,1,$rs->row["server1"],$rs->row["folder"]);
}
$size = @getimagesize ($_SERVER["DOCUMENT_ROOT"].$img_url);
$img_width=round($size[0]/2);
$img_height=round($size[1]/2);
$google_code.="{
latitude: \"".$rs->row["google_x"]."\",
longitude: \"".$rs->row["google_y"]."\",
icon: { image: \"".$img_url."\",
iconsize: [".$img_width.",".$img_height."],
iconanchor: [12,46],
infowindowanchor: [12, 0] },
html:\"".$rs->row["title"]."
".$rs->row["description"]."\"
}";
$n++;
$rs->movenext();
}
}
$smarty->cache_lifetime = 3600;
$smarty->assign("google",$google_code);
$google_code=$smarty->fetch('google.tpl',"google");
}
$file_template=str_replace("{GOOGLE_MAP}",$google_code,$file_template);
$file_template=str_replace("{GOOGLE_API}",$site_google_api,$file_template);
if($site=="main" or $site=="profile_about" or $site=="profile" or $site=="orders" or $site=="credits" or $site=="subscription" or $site=="upload" or $site=="filemanager" or $site=="publications" or $site=="models" or $site=="commission" or $site=="friends" or $site=="messages" or $site=="blog" or $site=="reviews" or $site=="testimonials" or $site=="affiliate" or $site=="profile_downloads" or $site=="coupons" or $site=="billing" or $site=="paypalpro" or $site=="moneyorder" or $site=="myvirtualmerchant" or $site=="user")
{
$file_template=str_replace("{BOX_LEFT}","",$file_template);
$file_template=str_replace("{LEFT_WIDTH}","1",$file_template);
}
else
{
//Left box
$file_template=str_replace("{BOX_LEFT}",$boxes_left,$file_template);
//Left width
$file_template=str_replace("{LEFT_WIDTH}",left_width,$file_template);
}
//Site name
$sname=$site_name;
if($site=="news"){$sname.=" - ".word_lang("news");}
if($site=="about"){$sname.=" - ".word_lang("about");}
if($site=="contacts"){$sname.=" - ".word_lang("contacts");}
if($site=="support"){$sname.=" - ".word_lang("support");}
if($site=="tell_a_friend"){$sname.=" - ".word_lang("tell a friend");}
if($site=="shopping_cart"){$sname.=" - ".word_lang("shopping cart");}
if($site=="checkout"){$sname.=" - ".word_lang("checkout");}
if($site=="main"){$sname=avtodor3(5,$id_parent,"structure","name","","").$sname;}
if($site=="forgot"){$sname.=" - ".word_lang("forgot password");}
if($site=="orders"){$sname.=" - ".word_lang("orders");}
if($site=="profile"){$sname.=" - ".word_lang("my profile");}
if($site=="favorite"){$sname.=" - ".word_lang("my favorite list");}
if($site=="signup"){$sname.=" - ".word_lang("sign up");}
if($site=="upload"){$sname.=" - ".word_lang("my upload");}
if($site=="commission"){$sname.=" - ".word_lang("my commission");}
if($site=="license"){$sname.=" - ".word_lang("license");}
if($site=="models"){$sname.=" - ".word_lang("models");}
if($site=="map"){$sname.=" - Google map";}
if($site=="user"){$sname.=" - ".word_lang("user")." - ".$name_user;}
if($site=="user_portfolio"){$sname.=" - ".word_lang("portfolio")." - ".$name_user;}
if($site=="user_blog"){$sname.=" - ".word_lang("blog")." - ".$name_user;}
if($site=="user_testimonials"){$sname.=" - ".word_lang("testimonials")." - ".$name_user;}
if($site=="user_friends"){$sname.=" - ".word_lang("friends")." - ".$name_user;}
if($site=="user_lightbox"){$sname.=" - ".word_lang("my favorite list")." - ".$name_user;}
$file_template=str_replace("{SITE_NAME}",$sname,$file_template);
//Bottom menu
include("bottom_menu.php");
//Words
$file_template=str_replace("{WORD_CATEGORIES}",word_lang("categories"),$file_template);
$file_template=str_replace("{WORD_SHOPPING_CART}",word_lang("shopping cart"),$file_template);
$file_template=str_replace("{WORD_MEMBER_AREA}",word_lang("member area"),$file_template);
$file_template=str_replace("{WORD_TOP_RATED}",word_lang("top rated"),$file_template);
$file_template=str_replace("{WORD_NEWS}",word_lang("news"),$file_template);
$file_template=str_replace("{WORD_HOME}",word_lang("home"),$file_template);
$file_template=str_replace("{WORD_ABOUT}",word_lang("about"),$file_template);
$file_template=str_replace("{WORD_SUPPORT}",word_lang("support"),$file_template);
$file_template=str_replace("{WORD_CONTACTS}",word_lang("contacts"),$file_template);
$file_template=str_replace("{WORD_SEARCH}",word_lang("search"),$file_template);
$file_template=str_replace("{WORD_ADVANCED_SEARCH}",word_lang("advanced search"),$file_template);
$file_template=str_replace("{WORD_NEW}",word_lang("new"),$file_template);
$file_template=str_replace("{WORD_FEATURED}",word_lang("featured"),$file_template);
$file_template=str_replace("{WORD_DOWNLOADED}",word_lang("most downloaded"),$file_template);
$file_template=str_replace("{WORD_POPULAR}",word_lang("most popular"),$file_template);
$file_template=str_replace("{WORD_FREE}",word_lang("free"),$file_template);
$file_template=str_replace("{WORD_PHOTOGRAPHER}",word_lang("photographers"),$file_template);
$file_template=str_replace("{WORD_STAT}",word_lang("stats"),$file_template);
$file_template=str_replace("{WORD_COLORS}",word_lang("color"),$file_template);
$file_template=str_replace("{WORD_RANDOM}",word_lang("random"),$file_template);
//Language
$file_template=str_replace("{LNG}",strtolower($lng),$file_template);
//Meta tag
$file_template=str_replace("{MTG}",$mtg,$file_template);
$file_template=str_replace("{WORD_RESERVED}",word_lang("all rights reserved"),$file_template);
//Site root
$file_template=str_replace("{SITE_ROOT}",site_root."/",$file_template);
//Template root
$file_template=str_replace("{TEMPLATE_ROOT}",site_root."/".$site_template_url,$file_template);
$file_template=format_layout($file_template,"sitephoto",$global_settings["allow_photo"]);
$file_template=format_layout($file_template,"sitevideo",$global_settings["allow_video"]);
$file_template=format_layout($file_template,"siteaudio",$global_settings["allow_audio"]);
$file_template=format_layout($file_template,"sitevector",$global_settings["allow_vector"]);
$file_template=format_layout($file_template,"sitecredits",$global_settings["credits"]);
$file_template=format_layout($file_template,"sitesubscription",$global_settings["subscription"]);
echo(translate_text($file_template));
if($id_parent==5 and count($_POST)==0 and (count($_GET)==0 or isset($_GET["template"]) or isset($_GET["aff"])) and $site=="main" and $site_home_separated)
{
exit();
}
?>
if(!defined("site_root")){exit();}
//Footer template
if (!$smarty->is_cached('footer.tpl',cache_id('footer')) or $site_cache_footer<0)
{
$file_template=file_get_contents($DOCUMENT_ROOT."/".$site_template_url."footer.tpl");
if($site=="profile_about" or $site=="profile" or $site=="orders" or $site=="credits" or $site=="subscription" or $site=="upload" or $site=="filemanager" or $site=="publications" or $site=="models" or $site=="commission" or $site=="friends" or $site=="messages" or $site=="blog" or $site=="reviews" or $site=="testimonials" or $site=="affiliate")
{
$file_template=str_replace("{BOX_RIGHT}","",$file_template);
$file_template=str_replace("{RIGHT_WIDTH}","1",$file_template);
}
else
{
//Right box
$file_template=str_replace("{BOX_RIGHT}",$boxes_right,$file_template);
//Right width
$file_template=str_replace("{RIGHT_WIDTH}",right_width,$file_template);
}
//Bottom menu
include("bottom_menu.php");
//Box stat
include("box_stat.php");
//Words
$file_template=str_replace("{WORD_CATEGORIES}",word_lang("categories"),$file_template);
$file_template=str_replace("{WORD_SHOPPING_CART}",word_lang("shopping cart"),$file_template);
$file_template=str_replace("{WORD_MEMBER_AREA}",word_lang("member area"),$file_template);
$file_template=str_replace("{WORD_TOP_RATED}",word_lang("top rated"),$file_template);
$file_template=str_replace("{WORD_NEWS}",word_lang("news"),$file_template);
$file_template=str_replace("{WORD_HOME}",word_lang("home"),$file_template);
$file_template=str_replace("{WORD_ABOUT}",word_lang("about"),$file_template);
$file_template=str_replace("{WORD_SUPPORT}",word_lang("support"),$file_template);
$file_template=str_replace("{WORD_CONTACTS}",word_lang("contacts"),$file_template);
$file_template=str_replace("{WORD_SEARCH}",word_lang("search"),$file_template);
//Site name
$file_template=str_replace("{SITE_NAME}",$site_name,$file_template);
//Site root
$file_template=str_replace("{SITE_ROOT}",site_root."/",$file_template);
$file_template=str_replace("{WORD_RESERVED}",word_lang("all rights reserved"),$file_template);
//Template root
$file_template=str_replace("{TEMPLATE_ROOT}",site_root."/".$site_template_url,$file_template);
$file_template=format_layout($file_template,"sitephoto",$site_photo);
$file_template=format_layout($file_template,"sitevideo",$site_video);
$file_template=format_layout($file_template,"siteaudio",$site_audio);
$file_template=format_layout($file_template,"sitevector",$site_vector);
$file_template=format_layout($file_template,"sitecredits",$site_credits);
$file_template=format_layout($file_template,"sitesubscription",$site_subscription);
$file_template=translate_text($file_template);
//End Footer template
}
if($site_cache_footer>=0)
{
if($site_cache_footer>0)
{
$smarty->cache_lifetime = $site_cache_footer*3600;
}
$smarty->assign('footer', $file_template);
$file_template=$smarty->fetch('footer.tpl',cache_id('footer'));
}
echo($file_template);
?>