<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>
recorriendo objetos decodificados del json
<?php
// arreglo
$array['rows']=
array('id_cuota' =>
2883,
'num_cuota' =>
1,
'monto_cuota' =>
6250,
'fecha' =>
'2009-09',
'factura' =>
false);
$array['rows']=
array('id_cuota' =>
2884,
'num_cuota' =>
2,
'monto_cuota' =>
6250,
'fecha' =>
'2009-09',
'factura' =>
true);
echo json_encode
($array);
//convirtiendo el arreglo en formato json
var data["rows"]: [{"id_cuota": 2883, "num_cuota": 1, "monto_cuota": 6250, "fecha": "2009-09", "factura": false}, //var data['rows'] => variable referencia
{"id_cuota": 2884, "num_cuota": 2, "monto_cuota": 6250, "fecha": "2009-09", "factura": true}]
echo json_decode
($data['rows']);
//decodificamos el json para convertirlo en un objeto
0 =>
object(stdClass)[178]
public 'id_cuota' => int 2887
public 'num_cuota' => int 1
public 'monto_cuota' => int 6250
public 'fecha' => string '2009-09' (length=7)
public 'factura' => boolean false
1 =>
object(stdClass)[179]
public 'id_cuota' => int 2888
public 'num_cuota' => int 2
public 'monto_cuota' => int 6250
public 'fecha' => string '2009-10' (length=7)
public 'factura' => boolean false
//recorriendo y recuperando valores de un objeto
foreach(json_decode($data['rows']) as $obj){
$idCuota = $obj->id_cuota;
$numCuota = $obj->num_cuota;
$monto = $obj->monto_cuota;
$fecha = $obj->fecha;
$factura = $obj->factura;
}
// yeah!!!!!!!
?>
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1838"></script>