[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/include/inc_module/mod_feedimport/inc/ -> functions.inc.php (source)

   1  <?php
   2  
   3  function decformat($num=0) {
   4  
   5      return number_format(floatval($num), $GLOBALS['BLM']['decimals'], $GLOBALS['BLM']['dec_point'], $GLOBALS['BLM']['thousands_sep']);
   6  
   7  }
   8  
   9  function clean_preformatted_number($number=0, $auto=true) {
  10      
  11      if(is_string($number) && strlen($number) > 3) {
  12          
  13          if($auto === true) {
  14              $test_decimal    = substr($number, -3, 1);
  15              $test_thousands    = substr($number, -4, 1);
  16          } elseif($auto == 'DEC2MET') {
  17              $test_decimal    = ',';
  18              $test_thousands    = '.';
  19          } else {
  20              $test_decimal    = '.';
  21              $test_thousands    = ',';
  22          }
  23          
  24          if($test_decimal == ',' || $test_thousands == '.') {
  25              
  26              $number = str_replace('.', '', $number);
  27              $number = str_replace(',', '.', $number);
  28              
  29          } elseif($test_decimal == '.' || $test_thousands == ',') {
  30          
  31              $number = str_replace(',', '', $number);
  32          
  33          }
  34          
  35      }
  36  
  37      return $number;
  38  
  39  }
  40  
  41  function feedimport_article_templates($tmpl='') {
  42      $templates    = array('default' => $GLOBALS['BL']['be_cnt_default']);
  43      if(!empty($tmpl)) {
  44          $tmplfiles    = get_tmpl_files($tmpl);
  45          if(count($tmplfiles)) {
  46              foreach($tmplfiles as $val) {
  47                  $templates[$val] = $val;
  48              }
  49          }
  50      }
  51      return $templates;
  52  }
  53  
  54  function is_feed_available($url, $timeout = 30) {
  55      $ch = curl_init(); // get cURL handle
  56      
  57      // set cURL options
  58      $opts = array(
  59          CURLOPT_RETURNTRANSFER    => true,    // do not output to browser
  60          CURLOPT_URL                => $url,    // set URL
  61          CURLOPT_NOBODY            => true,    // do a HEAD request only
  62          CURLOPT_TIMEOUT            => $timeout    // set timeout
  63      );   
  64      curl_setopt_array($ch, $opts); 
  65      
  66      curl_exec($ch); // do it!
  67      
  68      $retval = curl_getinfo($ch, CURLINFO_HTTP_CODE); // check if HTTP OK
  69      
  70      curl_close($ch); // close handle
  71      
  72      return $retval == 200 ? true : false;
  73  }
  74  
  75  function feedimport_article_authors() {
  76      
  77      $result = _dbGet('phpwcms_user', 'usr_id, usr_name, usr_login, usr_admin', 'usr_aktiv=1', '', 'usr_admin DESC, usr_name');
  78      
  79      if(!isset($result[0]['usr_id'])) {
  80          return array(0 => $GLOBALS['BL']['be_cnt_default']);
  81      }
  82      
  83      $users = array();
  84      
  85      foreach($result as $user) {
  86          
  87          $users[ $user['usr_id'] ] = $user['usr_name'] ? $user['usr_name'] : $user['usr_login'];
  88          if($user['usr_admin']) {
  89              $users[ $user['usr_id'] ] .= ' ('.$GLOBALS['BL']['be_article_adminuser'].')';
  90          }        
  91      }
  92      
  93      return $users;
  94  }
  95  
  96  
  97  ?>


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1