<?php
if(!defined('AUTHACCESS')){echo "Not Allowed";exit();}
//xlovecam_update
$xmlmodels = array();
//$xml=simplexml_load_string($xmlfile);
$xml = simplexml_load_string($xmlfile, 'SimpleXMLElement', LIBXML_PARSEHUGE);
$p_end = count($xml->performer);
$t_ndx = 0;
$mnndx = 0;
$npt = $p_end;
$npt--;
$ordinator = get_ordinator($npt);


for($x=0;$x<$p_end;$x++) {


	$rsindx = (int)$ordinator[$x];
	if (in_array($xml->performer[$rsindx]->sex, $allowed_genders) ) {

				$model_info = array();
				$model_info['sponsor'] = "xlovecam";
				$model_info['iframe_src'] = (string)$xml->performer[$rsindx]->freechatlink;
				$thm = $model_info['iframe_src'];
				$model_info['iframe_src'] = $thm;
				$model_info['display_name'] = cleandisplayname($xml->performer[$rsindx]->screenname);
				
		
				if (ctype_space($model_info['display_name'])) {unset($model_info['display_name']);}
				//$tags = $xml->performer[$rsindx]->tags;
				//$numtags = sizeof($tags->tag);
				//if ($numtags > 10) {$numtags = 10;}
				//unset($tagsarray);
				$tagsarray=array();
				//for ($ctr=0;$ctr<$numtags;$ctr++) {
				//	$tag = $tags->tag[$ctr];
				//	$tagsarray[] = clean_tags($tag);	
				//}
				$model_info['tags'] = $tagsarray;
				$tags = $tagsarray;
				$model_info['ethnicity'] = preg_replace("/\//", " ", $xml->performer[$rsindx]->ethnicity);
				$model_info['ethnicity'] = clean_basic($model_info['ethnicity']);
				$model_info['hair_color'] = clean_basic($xml->performer[$rsindx]->haircolor);
				$model_info['eye_color'] = clean_basic($xml->performer[$rsindx]->eyecolor);
				$model_info['primary_language'] = clean_basic($xml->performer[$rsindx]->languages[0]);
				$model_info['username'] = cleanname($xml->performer[$rsindx]->screenname);
				$model_info['username'] = strtolower($model_info['username']);
				$model_info['thumb'] = (string)$xml->performer[$rsindx]->liveimage;
				$thm = $model_info['thumb'];
				$model_info['thumb'] = $thm;
				$model_info['turns_on'] = clean_basic($xml->performer[$rsindx]->turnons);
				$model_info['turns_off'] = clean_basic($xml->performer[$rsindx]->turnoffs);
				$model_info['gender'] = clean_basic($xml->performer[$rsindx]->sex);
				$model_info['topic'] = cleansub($xml->performer[$rsindx]->personnalmessage);

				if(in_array($model_info['username'], $used_modelnames)) {
					$model_info['username'] = $model_info['username'] . "_xlc";
				}
				$used_modelnames[] = $model_info['username'];
				$xmlmodels[] = $model_info;
				$allmodel_array[] = $model_info;
				$xmlmodels_allcams[] = $model_info;
			
			$t_ndx++;
			if($t_ndx>9000){echo "overflow! 9000 ";exit();}
	}//gender
			
	}//xlovecam


$total_item_count += count($xmlmodels);
$out_file = __DIR__ . "/../feeds/feed_xlovecam.txt";
$filedata = serialize($xmlmodels);
writetxtfile($out_file, $filedata);
$out_file = __DIR__ . "/../feeds/modelndx_xlovecam.txt";
$filedata = serialize($xmlmodels_names);
writetxtfile($out_file, $filedata);	


?>

