<?php
if(!defined('AUTHACCESS')){echo "Not Allowed";exit();}
if ($parsemode == "searchcams") {
	global $xmlparse;
	global $p_start, $p_end,$model_thbcells,$total_item_count,$clean_req;
	global $allmodel_array,$doingsearch,$xmlparse;
	
	$xmlmodels = array();
	$allmodel_array = array();
	$results = unserialize($xmlparse[$sponsorx]);
	if(!empty($clean_req['page'])) {
		if($p_start>=count($results)){
			return;
		}
	}
	if($p_end>count($results)) {
		$p_end = count($results);
	}
	$t_ndx = 0;
	$npt = count($results);
	$npt--;
	$ordinator = get_ordinator($npt);
	$temp_end = count($results);
	for($x=0;$x<$temp_end;$x++) {
		$rsindx = (int)$ordinator[$x];
		$xmlmodels[] = $results[$rsindx];
		$t_ndx++;
		if($t_ndx>10000){echo "overflow!";exit();}
	}
	$trk = 0;
	foreach($xmlmodels as $value=>$content) {
		if ($doingsearch) {
			$s_matched = false;
			$s_matched = search_active_feed($content);
			if ($s_matched) {
				$allmodel_array[] = $content;
			}
		} else {
			$allmodel_array[] = $content;
			$model_thbcells .= thbcell_html($content);
		}
		$trk++;
		if($trk>10000){echo "overflow!";exit();}
	}
	$total_item_count = count($allmodel_array);
}

if (($parsemode == "modelindex") || ($parsemode == "update")) {

	$xmlmodels_names = array();
	global $used_modelnames;
	
	if($sponsorx == "chaturbate"){
		include(__DIR__ . "/chaturbate_update.php");
	}//chaturbate
	    
	elseif($sponsorx == "camsoda"){
		include(__DIR__ . "/camsoda_update.php");
	}//camsoda
	
	elseif($sponsorx == "bongacams"){
		include(__DIR__ . "/bongacams_update.php");
	}//bongacams
	
	elseif($sponsorx == "imlive"){
		include(__DIR__ . "/imlive_update.php");
	}//imlive
	
	elseif($sponsorx == "stripchat"){
		include(__DIR__ . "/stripchat_update.php");
	}//stripchat	

	elseif($sponsorx == "awempire"){
		include(__DIR__ . "/awempire_update.php");
	}//awempire
	
	elseif($sponsorx == "xlovecam"){
		include(__DIR__ . "/xlovecam_update.php");
	}//xlovecam	
	
	elseif($sponsorx == "camspower"){
		include(__DIR__ . "/camspower_update.php");
	}//camspower	
	
	elseif($sponsorx == "itslive"){
		include(__DIR__ . "/itslive_update.php");
	}//camspower	
	
	
	
}

if ($parsemode == "modelpage") {
	$xlink = __DIR__ . "/../feeds/feed_" . $sponsorx . ".txt";
	$xml= @file_get_contents($xlink);
	$results=unserialize($xml);	
	
	if(empty($mndx[$musername])){
		$mdinfondx = 0;
	}else{
		$mdinfondx = $mndx[$musername];
	}
	
	
	$sizx = count($results);
	$items = $mdinfondx + $num_related_models;
	$items++;
	if ($items > $sizx ){$items = $sizx;}
	$ndx = 0;		
	for($x=$mdinfondx;$x<$items;$x++){
		if($ndx == 0){
			$this_iframe  = !empty($results[$x]['iframe_src']) ? $results[$x]['iframe_src'] : "";
		}
		$model_info['sponsor'] = $sponsorx;
		if(!empty($results[$x]['iframe_src'])){
			$model_info['iframe_src'] = $results[$x]['iframe_src'];
		}else {
			$model_info['iframe_src'] = "";
		}
		$model_info['display_name'] = !empty($results[$x]['display_name']) ? $results[$x]['display_name'] : "";
		if(!empty($results[$x]['tags'])){$model_info['tags'] = $results[$x]['tags'];}
		$model_info['username'] = strtolower($results[$x]['username']);
		$model_info['thumb'] = $results[$x]['thumb'];
		$model_info['topic'] = $results[$x]['topic'];
		
		
		if(!empty($results[$x]['turns_on'])){$model_info['turns_on'] = $results[$x]['turns_on'];}
		if(!empty($results[$x]['turns_of'])){$model_info['turns_of'] = $results[$x]['turns_of'];}
		
		if($ndx == 0){
			$page_model = $results[$x];
		}else{
			$related_model[] = $results[$x];
		}
		$ndx++;
	}
}
?>
