Search Results

Sort by: Date / Title /

  1. 1 month ago by spirit
    1. function walkDom($node, $level = 0) {
    2.         $indent = '';
    3.         for ($i = 0; $i < $level; $i++)
    4.         $indent .= '&nbsp;&nbsp;&nbsp;&nbsp;'; //prettifying the output
    5.         if (true /*$node->nodeType == XML_TEXT_NODE*/) {
    6.                 echo $indent.'<b>'.$node->nodeName.'</b> - |'.$node->nodeValue.'|';
    7.  
    8.                 if ( $node->nodeType == XML_ELEMENT_NODE ) {
    9.                         $attributes = $node->attributes; // get all the attributes(eg: id, class)
    10.                         foreach($attributes as $attribute) {
    11.                                 echo ', '.$attribute->name.'='.$attribute->value;
    12.                         }                                                    
    13.                 }
    14.  
    15.                 echo '<br />';
    16.         }
    17.  
    18.         $cNodes = $node->childNodes;
    19.         if (count($cNodes) > 0) {
    20.                 $level++ ; // go one level deeper
    21.                 foreach($cNodes as $cNode)
    22.                         walkDom($cNode, $level);
    23.                 $level = $level - 1;
    24.         }
    25. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2092"></script>
  2. 6 months 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>
  3. 6 months 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>
  4. sponsorised links
  5. 7 months 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>
  6. 7 months 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>
  7. 7 months 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>
  8. 9 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>
  9. 9 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>
  10. 11 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>
  11. 11 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>

First / Previous / Next / Last / Page 1 of 14 (131 posteets)