Search Results

Sort by: Date / Title /

  1. 3 weeks ago by sm0k1nggnu
    1. <html>
    2. <head>
    3. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    4.  
    5. <title>Blog Posts</title>
    6. <style type="text/css">
    7. <!--
    8. .rss{
    9. width:200px;
    10. display:block;
    11. float:left;}
    12.  
    13. .rss h3 a{
    14. color:#89b81d}
    15.  
    16. -->
    17. </style>
    18. </head>
    19. <body>
    20. <h2>Foo</h2>
    21. <?php
    22.  
    23. $insideitem = false;
    24. $tag = "";
    25. $title = "";
    26. $description = "";
    27. $link = "";
    28. $i = 0;
    29.  
    30.  
    31. function startElement($parser, $name, $attrs) {
    32.         global $insideitem, $tag, $title, $description, $link;
    33.         if ($insideitem) {
    34.                 $tag = $name;
    35.         } elseif ($name == "ITEM") {
    36.                 $insideitem = true;
    37.         }
    38. }
    39.  
    40. function endElement($parser, $name) {
    41.         global $insideitem, $tag, $title, $description, $link,$i;
    42.        
    43.                 if ($name == "ITEM" && $i < 1) {
    44.                 printf("<div class="rss"><h3 class="rssHeader"><a href='%s'>%s</a></h3>", trim($link),utf8_decode(htmlspecialchars(trim($title))));
    45.                
    46.                 //Ohne Beschränkung
    47.                 //printf("<p>%s</p></div>",utf8_decode(htmlspecialchars(trim($description))));
    48.                
    49.                 //Mit Beschränkung
    50.                 $short = explode("n", wordwrap($description, 150, "n")); //Ausgabe auf n Zeichen kürzen
    51.                 printf("<p>%s ...</p><a href='".trim($link)."'>mehr</a></div>",htmlspecialchars(trim($short[0])));
    52.                
    53.                 $title = "";
    54.                 $description = "";
    55.                 $link = "";
    56.                 $insideitem = false;
    57.                 $i++;
    58.         }
    59. }
    60.  
    61.  
    62. function characterData($parser, $data) {
    63.         global $insideitem, $tag, $title, $description, $link;
    64.         if ($insideitem) {
    65.         switch ($tag) {
    66.                 case "TITLE":
    67.                 $title .= $data;
    68.                 break;
    69.                 case "DESCRIPTION":
    70.                 $description .= $data;
    71.                 break;
    72.                 case "LINK":
    73.                 $link .= $data;
    74.                 break;
    75.         }
    76.         }
    77. }
    78.  
    79. $xml_parser = xml_parser_create();
    80. xml_set_element_handler($xml_parser, "startElement", "endElement");
    81. xml_set_character_data_handler($xml_parser, "characterData");
    82. $fp = fopen("http://blogurl.com/rss.php","r")
    83.         or die("Error reading RSS data.");
    84. while ($data = fread($fp, 4096))
    85.         xml_parse($xml_parser, $data, feof($fp))
    86.                 or die(sprintf("XML error: %s at line %d",
    87.                         xml_error_string(xml_get_error_code($xml_parser)),
    88.                         xml_get_current_line_number($xml_parser)));
    89. fclose($fp);
    90. xml_parser_free($xml_parser);
    91.  
    92. ?>
    93. </body>
    94. </html>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2054"></script>
  2. 3 weeks ago by cyo
    1. $videofile = "fichier.flv";
    2.  
    3. passthru("ffmpeg -i "{$videofile}" 2>&1");
    4. $duration = ob_get_contents();
    5.  
    6. $search='/Duration: (.*?),/';
    7. $duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE, 3);
    8.  
    9. echo $matches[1][0];
    10.  
    11.  
    12. Pour récupérer la durée, en seconde, on peut utiliser cette fonction :
    13.  
    14. echo hms2sec($matches[1][0]);
    15.  
    16.  
    17. function hms2sec ($hms) {
    18.         list($h, $m, $s) = explode (":", $hms);
    19.         $seconds = 0;
    20.         $seconds += (intval($h) * 3600);
    21.         $seconds += (intval($m) * 60);
    22.         $seconds += (intval($s));
    23.         return $seconds;
    24. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2052"></script>
  3. 1 month ago by spirit
    Prevents jobs to collide if they take longer to run than the frequency itself
    1. $fp = fopen('/tmp/lock.txt', 'r+')
    2.  
    3. if(!flock($fp, LOCK_EX | LOCK_NB)) { 
    4.    echo 'Unable to obtain lock'
    5.    exit(-1)
    6. } 
    7.    
    8. /* ... */ 
    9.  
    10. fclose($fp);
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2040"></script>
  4. sponsorised links
  5. 1 month ago by spirit
    it's also possibl with a .htaccess file and "deny from all " in that file
    1. 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>
  6. 1 month ago by sx
    1. echo substr($filename, strripos($filename, '.'),strlen($filename));
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2038"></script>
  7. 4 months ago by macks
    1. //MenuCardTable.class
    2. public function getMenuCardForCombo(){
    3.         $q = Doctrine_Query::create()
    4.           ->select('m.*')
    5.           ->from('MenuCard m');
    6.         $results = $q->execute();
    7.  
    8.         foreach($results as $menu){
    9.             $choice[$menu->getId()] = $menu->getName();
    10.         }
    11.  
    12.         return $choice;
    13.     }
    14.  
    15. ====================no funciona para validar "required"=========================================
    16. //DishesForm.class
    17.         $choices = array('Seleccione un item') + Doctrine::getTable('MenuCard')->getMenuCardForCombo();
    18.         $this->widgetSchema['menu_card_id'] = new sfWidgetFormSelect(array('choices' => $choices));
    19.         $this->validatorSchema['menu_card_id'] = new sfValidatorChoice(array('choices' => array_keys($choices)));
    20.  
    21. ====================otro metodo: validar "required"=========================================
    22. //el item x defecto sera en blanco (poner 'add_empty true')
    23. //BasesDishesForm.class
    24. 'menu_card_id' => new sfWidgetFormDoctrineChoice(array('model' => 'MenuCard', 'add_empty' => true)),
    25. //DishesForm.class
    26. $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>
  8. 4 months ago by macks
    1. Doctrine
    2. $eventName = Doctrine::getTable('Events')->find($id)->getName();
    3.  
    4. Propel
    5. $event = EventsPeer::RetriveByPk($id);
    6. $eventName = $event->getName();
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1896"></script>
  9. 5 months ago by macks
    1. /* lib/model/Industria.php
    2. - en el formulario de clientes hay un combo industrias (relacion bd)
    3. - descripcion se mostrara en el combo
    4. */
    5.  
    6. class Industria extends BaseIndustria {
    7.     public function __toString(){
    8.         return $this->getDescripcion();
    9.     }
    10. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1842"></script>
  10. 5 months ago by macks
    escapando y decodificando
    1. $specialCharacter = 'Fondo General de Contravalor Perú Japón - " FGCPJ "';
    2. $scape_decohtmlspecialchars(utf8_decode($specialCharacter));
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1840"></script>
  11. 5 months ago by macks
    recorriendo objetos decodificados del json
    1. <?php
    2. // arreglo
    3. $array['rows']= array('id_cuota' =>2883,'num_cuota' => 1,'monto_cuota' => 6250, 'fecha' => '2009-09', 'factura' => false);
    4. $array['rows']= array('id_cuota' =>2884,'num_cuota' => 2,'monto_cuota' => 6250, 'fecha' => '2009-09', 'factura' => true);
    5.  
    6. echo json_encode($array); //convirtiendo el arreglo en formato json
    7.  
    8. var data["rows"][{"id_cuota": 2883, "num_cuota": 1, "monto_cuota": 6250, "fecha": "2009-09", "factura": false}//var data['rows'] => variable referencia
    9.                     {"id_cuota": 2884, "num_cuota": 2, "monto_cuota": 6250, "fecha": "2009-09", "factura": true}]
    10.      
    11.  
    12. echo json_decode($data['rows']);
    13.  
    14. //decodificamos el json para convertirlo en un objeto
    15.   0 =>
    16.     object(stdClass)[178]
    17.       public 'id_cuota' => int 2887
    18.       public 'num_cuota' => int 1
    19.       public 'monto_cuota' => int 6250
    20.       public 'fecha' => string '2009-09' (length=7)
    21.       public 'factura' => boolean false
    22.   1 =>
    23.     object(stdClass)[179]
    24.       public 'id_cuota' => int 2888
    25.       public 'num_cuota' => int 2
    26.       public 'monto_cuota' => int 6250
    27.       public 'fecha' => string '2009-10' (length=7)
    28.       public 'factura' => boolean false
    29.  
    30.  
    31. //recorriendo y recuperando valores de un objeto
    32. foreach(json_decode($data['rows']) as $obj){
    33.         $idCuota = $obj->id_cuota;
    34.         $numCuota = $obj->num_cuota;
    35.         $monto = $obj->monto_cuota;
    36.         $fecha = $obj->fecha;
    37.         $factura = $obj->factura;
    38. } 
    39.  
    40. // yeah!!!!!!!
    41.  
    42. ?>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1838"></script>

First / Previous / Next / Last / Page 1 of 13 (130 posteets)