function walkDom($node, $level = 0) {
$indent = '';
for ($i = 0; $i < $level; $i++)
$indent .= ' '; //prettifying the output
if (true /*$node->nodeType == XML_TEXT_NODE*/) {
echo $indent.
'<b>'.
$node->
nodeName.
'</b> - |'.
$node->
nodeValue.
'|';
if ( $node->nodeType == XML_ELEMENT_NODE ) {
$attributes = $node->attributes; // get all the attributes(eg: id, class)
foreach($attributes as $attribute) {
echo ', '.
$attribute->
name.
'='.
$attribute->
value;
}
}
}
$cNodes = $node->childNodes;
if (count($cNodes) >
0) {
$level++ ; // go one level deeper
foreach($cNodes as $cNode)
walkDom($cNode, $level);
$level = $level - 1;
}
}
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2092"></script>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Blog Posts</title>
<style type="text/css">
<!--
.rss{
width:200px;
display:block;
float:left;}
.rss h3 a{
color:#89b81d}
-->
</style>
</head>
<body>
<h2>Foo</h2>
<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$i = 0;
function startElement($parser, $name, $attrs) {
global $insideitem,
$tag,
$title,
$description,
$link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem,
$tag,
$title,
$description,
$link,
$i;
if ($name == "ITEM" && $i < 1) {
//Ohne Beschränkung
//printf("<p>%s</p></div>",utf8_decode(htmlspecialchars(trim($description))));
//Mit Beschränkung
$short =
explode("n",
wordwrap($description,
150,
"n"));
//Ausgabe auf n Zeichen kürzen
$title = "";
$description = "";
$link = "";
$insideitem = false;
$i++;
}
}
function characterData($parser, $data) {
global $insideitem,
$tag,
$title,
$description,
$link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$fp =
fopen("http://blogurl.com/rss.php",
"r")
or
die("Error reading RSS data.");
while ($data =
fread($fp,
4096))
?>
</body>
</html>
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2054"></script>
$videofile = "fichier.flv";
passthru("ffmpeg -i "{$videofile}" 2>&1");
$search='/Duration: (.*?),/';
$duration=
preg_match($search,
$duration,
$matches, PREG_OFFSET_CAPTURE,
3);
Pour récupérer la durée, en seconde, on peut utiliser cette fonction :
echo hms2sec
($matches[1][0]);
function hms2sec ($hms) {
$seconds = 0;
$seconds +=
(intval($h) *
3600);
$seconds +=
(intval($m) *
60);
return $seconds;
}
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2052"></script>
Prevents jobs to collide if they take longer to run than the frequency itself
$fp =
fopen('/tmp/lock.txt',
'r+');
if(!
flock($fp, LOCK_EX | LOCK_NB
)) {
echo 'Unable to obtain lock';
}
/* ... */
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2040"></script>
it's also possibl with a .htaccess file and "deny from all " in that file
if (isset($_SERVER['REMOTE_ADDR'])) die('Permission denied.');
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2039"></script>
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2038"></script>
//MenuCardTable.class
public function getMenuCardForCombo(){
$q = Doctrine_Query::create()
->select('m.*')
->from('MenuCard m');
$results = $q->execute();
foreach($results as $menu){
$choice[$menu->getId()] = $menu->getName();
}
return $choice;
}
====================no funciona para validar "required"=========================================
//DishesForm.class
$choices =
array('Seleccione un item') + Doctrine::
getTable('MenuCard')->
getMenuCardForCombo();
$this->
widgetSchema['menu_card_id'] =
new sfWidgetFormSelect
(array('choices' =>
$choices));
$this->
validatorSchema['menu_card_id'] =
new sfValidatorChoice
(array('choices' =>
array_keys($choices)));
====================otro metodo: validar "required"=========================================
//el item x defecto sera en blanco (poner 'add_empty true')
//BasesDishesForm.class
'menu_card_id' =>
new sfWidgetFormDoctrineChoice
(array('model' =>
'MenuCard',
'add_empty' =>
true)),
//DishesForm.class
$this->validatorSchema['menu_card_id']->setOption('required', true);
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1897"></script>
Doctrine
$eventName = Doctrine::getTable('Events')->find($id)->getName();
Propel
$event = EventsPeer::RetriveByPk($id);
$eventName = $event->getName();
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1896"></script>
/* lib/model/Industria.php
- en el formulario de clientes hay un combo industrias (relacion bd)
- descripcion se mostrara en el combo
*/
class Industria extends BaseIndustria {
public function __toString(){
return $this->getDescripcion();
}
}
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1842"></script>
escapando y decodificando
$specialCharacter = 'Fondo General de Contravalor Perú Japón - " FGCPJ "';
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1840"></script>