_white = 1; if (trim($xml_url) != "") $this->set_xml_url ($xml_url); } function set_xml_url ($url) { $this->_xml_url = $url; } function read () { if (!$this->_xml_url) $this->error ("XML File is not assigned."); $filepointer = fopen("temp2.xml", "w"); fputs ($filepointer,""); fclose ($filepointer); $ch = curl_init ($this->_xml_url); $fp = fopen ("temp2.xml", "w"); curl_setopt ($ch, CURLOPT_FILE, $fp); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_exec ($ch); curl_close ($ch); fclose ($fp); $fp = fopen ("temp2.xml", "r"); // $fp = fopen ($this->_xml_url, "r"); while (!feof ($fp)) $this->_data .= fgets($fp, 4096); fclose ($fp); $this->_data = trim ($this->_data); } function parse () { $this->read(); if (trim ($this->_data) == "") $this->error ("Data not ready."); $vals = $index = $array = array(); $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $this->_white); xml_parse_into_struct($parser, $this->_data, $vals, $index); xml_parser_free($parser); $i = 0; $tagname = $vals[$i]['tag']; if ( isset ($vals[$i]['attributes'] ) ) { $array[$tagname]['@'] = $vals[$i]['attributes']; } else { $array[$tagname]['@'] = array(); } $array[$tagname]["#"] = $this->xml_depth($vals, $i); return $array; } function xml_depth($vals, &$i) { $children = array(); if ( isset($vals[$i]['value']) ) { array_push($children, $vals[$i]['value']); } while (++$i < count($vals)) { switch ($vals[$i]['type']) { case 'open': if ( isset ( $vals[$i]['tag'] ) ) { $tagname = $vals[$i]['tag']; } else { $tagname = ''; } if ( isset ( $children[$tagname] ) ) { $size = sizeof($children[$tagname]); } else { $size = 0; } if ( isset ( $vals[$i]['attributes'] ) ) { $children[$tagname][$size]['@'] = $vals[$i]["attributes"]; } $children[$tagname][$size]['#'] = $this->xml_depth($vals, $i); break; case 'cdata': array_push($children, $vals[$i]['value']); break; case 'complete': $tagname = $vals[$i]['tag']; if( isset ($children[$tagname]) ) { $size = sizeof($children[$tagname]); } else { $size = 0; } if( isset ( $vals[$i]['value'] ) ) { $children[$tagname][$size]["#"] = $vals[$i]['value']; } else { $children[$tagname][$size]["#"] = ''; } if ( isset ($vals[$i]['attributes']) ) { $children[$tagname][$size]['@'] = $vals[$i]['attributes']; } break; case 'close': return $children; break; } } return $children; } function traverse_xmlize($array, $arrName = "array", $level = 0) { foreach($array as $key=>$val) { if ( is_array($val) ) { traverse_xmlize($val, $arrName . "[" . $key . "]", $level + 1); } else { $GLOBALS['traverse_array'][] = '$' . $arrName . '[' . $key . '] = "' . $val . "\"\n"; } } return 1; } function error ($str) { print get_class ($this)." ".$this->version()." => $str"; exit(); } function version () { return "1.0"; } }; // EXAMPLE // $xmlreader = new xmlreader ($xmlurl); // $xml = $xmlreader->parse(); // $items = $xml["rss"]["#"]["channel"][0]["#"]["item"]; // echo "
";
//  echo "title \tdescription\n";
//  for ($i=0; $i";

$message = "";

	if($_POST['vx'] == null || $_POST['vy'] == null){
		$message .= "Lo siento el valor introducido para la suma no es correcto.";
	}
	else if(($_POST['vx'] + $_POST['vy']) != $_POST['vxvy']){
		$message .= "Lo siento el valor introducido para la suma no es correcto.";
	} else {

		$xmlreader = new xmlreader ($xmlurl);
		$xml = $xmlreader->parse();

  			//se añade la rss al opml
  			$sql="SELECT id FROM opml where xmlurl = '" . $xmlurl . "' LIMIT 0,1";
  			$res=mysql_query($sql, $db);
  			$linea = mysql_fetch_object ($res);
  			$idXML = $linea->id;
  			mysql_free_result ($res);

  			if($idXML == null){

  				$sql="INSERT INTO opml (origin,url,email,text,xmlurl,date,status,tags) " .
  				"VALUES ('" . $xml["rss"]["#"]["channel"][0]["#"]["itunes:author"][0]["#"] . "','" . $xml["rss"]["#"]["channel"][0]["#"]["link"][0]["#"] . "','" . $xml["rss"]["#"]["channel"][0]["#"]["itunes:owner"][0]["#"]["itunes:email"][0]["#"] . "','" .
  				$xml["rss"]["#"]["channel"][0]["#"]["title"][0]["#"] . "','" . $xmlurl . "',NOW(),'V','" . $feedtags . "')";

  				mysql_query($sql, $db);
  				$message .= "Tu podcast ha sido insertado en nuestra base de datos. En breve será validado y activado. Gracias.";

		$titulo = "folcast - nuevo podcast feed";
		$men = "\netiquetas: " . $_POST['feedtags'] . "\n";
		$men .= "\npodcast: " . $_POST['xmlurl'] . "\n";
		$otras_cabeceras = "from: info@folcast.com";
		mail("alvaromorala@yahoo.es", $titulo, $men, $otras_cabeceras);
  			}
  			else{
  				$message .= "Lo siento, el podcast enviado ya existe.";
  			}

	}
?>


	Micro - insertando podcast