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


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


	$rsindx = (int)$ordinator[$x];


				$model_info = array();
				$model_info['sponsor'] = 'itslive';

				$iframe_src = (string)$xml->channel->item[$rsindx]->link;


				$model_info['iframe_src'] = $iframe_src;

				$model_info['display_name'] = clean_basic((string)$xml->channel->item[$rsindx]->title);
				if (ctype_space($model_info['display_name'])) {
					unset($model_info['display_name']);
				}


				$model_info['username'] = cleanname((string)$xml->channel->item[$rsindx]->title);
				$model_info['username'] = strtolower($model_info['username']);

				$href0 = explode("href", (string)$xml->channel->item[$rsindx]->description);
				$href0[1] = preg_replace("/ =/", "=", $href0[1]);
				$href0[1] = preg_replace("/= /", "=", $href0[1]);

				$href1 = explode("=", $href0[1]);
				$href1 = explode(" ", $href0[1]);

				$href1 = explode(">", $href1[0]);

				$href = preg_replace("/'/", "", $href1[0]);
				$href = preg_replace("/=/", "", $href);
				$href = preg_replace("/>/", "", $href);
				$href = preg_replace("/ /", "", $href);
				$href = preg_replace("/\"/", "", $href);

			
				$src0 = explode("src", (string)$xml->channel->item[$rsindx]->description);
				$src0[1] = preg_replace("/ =/", "=", $src0[1]);
				$src0[1] = preg_replace("/= /", "=", $src0[1]);

				$src1 = explode("=", $src0[1]);
				$src1 = explode(" ", $src0[1]);

				$src1 = explode(">", $src1[0]);

				$src = preg_replace("/'/", "", $src1[0]);
				$src = preg_replace("/=/", "", $src);
				$src = preg_replace("/>/", "", $src);
				$src = preg_replace("/ /", "", $src);
				$src = preg_replace("/\"/", "", $src);


				$excerpt0 = explode(">", (string)$xml->channel->item[$rsindx]->description);
			
	
				$txt="";
				foreach($excerpt0 as $v) {
					if (strpos($v, "/") !== false) {

					} else {
						$txt .= preg_replace("/</", "", $v);
					}
				}


				$model_info['thumb'] = $src;

				$model_info['thumb'] = cleanthumb($model_info['thumb']);
				$thm = $model_info['thumb'];
				$model_info['thumb'] = $thm;
				$model_info['topic'] = cleansub($txt);
	
				if(in_array($model_info['username'], $used_modelnames)) {
					$model_info['username'] = $model_info['username'] . "_itl";
				}
				$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();}

			 


		}//itslive
		$total_item_count += count($xmlmodels);
$out_file = __DIR__ . "/../feeds/feed_itslive.txt";
$filedata = serialize($xmlmodels);
writetxtfile($out_file, $filedata);
$out_file = __DIR__ . "/../feeds/modelndx_itslive.txt";
$filedata = serialize($xmlmodels_names);
writetxtfile($out_file, $filedata);	
?>
