New: Ajout gestion de parametres sur les boxes
New: Possibilit de mettre plusieurs boites de diffrents flux RSS.
This commit is contained in:
parent
ac8c73555c
commit
d7b7a2da94
@ -193,7 +193,7 @@ if ($resql)
|
||||
$module=eregi_replace('.php$','',$obj->file);
|
||||
include_once(DOL_DOCUMENT_ROOT."/includes/boxes/".$module.".php");
|
||||
|
||||
$box=new $module();
|
||||
$box=new $module($db,$obj->note);
|
||||
|
||||
// if (in_array($obj->rowid, $actives) && $box->box_multiple <> 1)
|
||||
if (in_array($obj->rowid, $actives))
|
||||
@ -273,7 +273,7 @@ if ($resql)
|
||||
|
||||
$module=eregi_replace('.php$','',$obj->file);
|
||||
include_once(DOL_DOCUMENT_ROOT."/includes/boxes/".$module.".php");
|
||||
$box=new $module();
|
||||
$box=new $module($db,$obj->note);
|
||||
|
||||
$logo=eregi_replace("^object_","",$box->boximg);
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
@ -53,17 +53,21 @@ class InfoBox
|
||||
/**
|
||||
* \brief Retourne tableau des boites elligibles pour la zone
|
||||
* \param $zone ID de la zone (0 pour la Homepage, ...)
|
||||
* \return array Tableau des boites qualifiées
|
||||
* \return array Tableau d'objet box
|
||||
*/
|
||||
function listBoxes($zone)
|
||||
{
|
||||
$boxes=array();
|
||||
|
||||
$sql = "SELECT b.rowid, b.box_id, d.file";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
|
||||
$sql .= " WHERE b.box_id = d.rowid";
|
||||
$sql .= " AND position = ".$zone;
|
||||
$sql .= " ORDER BY box_order";
|
||||
$sql = "SELECT b.rowid, b.box_id,";
|
||||
$sql.= " d.file, d.note";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
|
||||
$sql.= " WHERE b.box_id = d.rowid";
|
||||
$sql.= " AND position = ".$zone;
|
||||
$sql.= " ORDER BY box_order";
|
||||
|
||||
dolibarr_syslog("InfoBox::listBoxes sql=$sql");
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -72,7 +76,12 @@ class InfoBox
|
||||
while ($j < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$boxes[$j]=eregi_replace('.php$','',$obj->file);
|
||||
$boxname=eregi_replace('.php$','',$obj->file);
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT."/includes/boxes/".$boxname.".php");
|
||||
$box=new $boxname($this->db,$obj->note);
|
||||
$boxes[$j]=$box;
|
||||
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,6 +36,9 @@ class box_actions extends ModeleBoxes {
|
||||
var $boximg="object_action";
|
||||
var $boxlabel;
|
||||
var $depends = array("action");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
@ -36,6 +36,9 @@ class box_bookmarks extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array();
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -36,6 +36,9 @@ class box_clients extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("societe");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -36,6 +36,9 @@ class box_commandes extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("commercial");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -32,111 +32,115 @@ include_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
|
||||
|
||||
class box_comptes extends ModeleBoxes {
|
||||
|
||||
var $boxcode="currentaccounts";
|
||||
var $boximg="object_bill";
|
||||
var $boxlabel;
|
||||
var $depends = array("banque"); // Box active si module banque actif
|
||||
var $boxcode="currentaccounts";
|
||||
var $boximg="object_bill";
|
||||
var $boxlabel;
|
||||
var $depends = array("banque"); // Box active si module banque actif
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
*/
|
||||
function box_comptes()
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
*/
|
||||
function box_comptes()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("boxes");
|
||||
|
||||
$this->boxlabel=$langs->trans('BoxCurrentAccounts');
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Charge les données en mémoire pour affichage ultérieur
|
||||
* \param $max Nombre maximum d'enregistrements à charger
|
||||
*/
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
$langs->load("boxes");
|
||||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts"));
|
||||
|
||||
if ($user->rights->banque->lire)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("boxes");
|
||||
$sql = "SELECT rowid, label, bank, number";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
|
||||
$sql .= " WHERE clos = 0 AND courant = 1";
|
||||
$sql .= " ORDER BY label";
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$this->boxlabel=$langs->trans('BoxCurrentAccounts');
|
||||
}
|
||||
$result = $db->query($sql);
|
||||
|
||||
/**
|
||||
* \brief Charge les données en mémoire pour affichage ultérieur
|
||||
* \param $max Nombre maximum d'enregistrements à charger
|
||||
*/
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
$langs->load("boxes");
|
||||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts"));
|
||||
|
||||
if ($user->rights->banque->lire)
|
||||
if ($result)
|
||||
{
|
||||
$sql = "SELECT rowid, label, bank, number";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
|
||||
$sql .= " WHERE clos = 0 AND courant = 1";
|
||||
$sql .= " ORDER BY label";
|
||||
$sql .= $db->plimit($max, 0);
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
$result = $db->query($sql);
|
||||
$i = 0;
|
||||
$solde_total = 0;
|
||||
|
||||
if ($result)
|
||||
while ($i < $num)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$objp = $db->fetch_object($result);
|
||||
$acc = new Account($db);
|
||||
$acc->fetch($objp->rowid);
|
||||
$solde_total += $acc->solde();
|
||||
|
||||
$i = 0;
|
||||
$solde_total = 0;
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => $this->boximg,
|
||||
'text' => stripslashes($objp->label),
|
||||
'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid);
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$acc = new Account($db);
|
||||
$acc->fetch($objp->rowid);
|
||||
$solde_total += $acc->solde();
|
||||
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => $this->boximg,
|
||||
'text' => stripslashes($objp->label),
|
||||
'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid);
|
||||
|
||||
$this->info_box_contents[$i][1] = array('align' => 'left',
|
||||
'text' => stripslashes($objp->bank)
|
||||
);
|
||||
|
||||
$this->info_box_contents[$i][2] = array('align' => 'left',
|
||||
'text' => stripslashes($objp->number)
|
||||
);
|
||||
|
||||
$this->info_box_contents[$i][3] = array('align' => 'right',
|
||||
'text' => price( $acc->solde() )
|
||||
);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Total
|
||||
$this->info_box_contents[$i][-1] = array('class' => 'liste_total');
|
||||
|
||||
$this->info_box_contents[$i][0] = array('align' => 'right',
|
||||
//'width' => '75%',
|
||||
'colspan' => '4',
|
||||
'class' => 'liste_total',
|
||||
'text' => $langs->trans('Total')
|
||||
$this->info_box_contents[$i][1] = array('align' => 'left',
|
||||
'text' => stripslashes($objp->bank)
|
||||
);
|
||||
|
||||
$this->info_box_contents[$i][1] = array('align' => 'right',
|
||||
'class' => 'liste_total',
|
||||
'text' => price($solde_total)
|
||||
$this->info_box_contents[$i][2] = array('align' => 'left',
|
||||
'text' => stripslashes($objp->number)
|
||||
);
|
||||
|
||||
$this->info_box_contents[$i][3] = array('align' => 'right',
|
||||
'text' => price( $acc->solde() )
|
||||
);
|
||||
|
||||
$i++;
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
// Total
|
||||
$this->info_box_contents[$i][-1] = array('class' => 'liste_total');
|
||||
|
||||
$this->info_box_contents[$i][0] = array('align' => 'right',
|
||||
//'width' => '75%',
|
||||
'colspan' => '4',
|
||||
'class' => 'liste_total',
|
||||
'text' => $langs->trans('Total')
|
||||
);
|
||||
|
||||
$this->info_box_contents[$i][1] = array('align' => 'right',
|
||||
'class' => 'liste_total',
|
||||
'text' => price($solde_total)
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
$this->info_box_contents[0][0] = array('align' => 'left',
|
||||
'text' => $langs->trans("ReadPermissionNotAllowed"));
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$this->info_box_contents[0][0] = array('align' => 'left',
|
||||
'text' => $langs->trans("ReadPermissionNotAllowed"));
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
}
|
||||
|
||||
function showBox()
|
||||
{
|
||||
parent::showBox($this->info_box_head, $this->info_box_contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -17,21 +17,24 @@
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT."/includes/boxes/modules_boxes.php");
|
||||
|
||||
class box_energie_graph extends ModeleBoxes {
|
||||
|
||||
var $boxcode="energie_graph";
|
||||
var $boximg="object_energie";
|
||||
var $boxlabel;
|
||||
|
||||
var $box_multiple = 1;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
var $boxcode="energie_graph";
|
||||
var $boximg="object_energie";
|
||||
var $boxlabel;
|
||||
var $depends = array("energie"); // Box active si module energie actif
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $box_multiple = 1;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
|
||||
@ -27,7 +27,11 @@ class box_energie_releve extends ModeleBoxes {
|
||||
var $boxcode="energie";
|
||||
var $boximg="object_energie";
|
||||
var $boxlabel;
|
||||
var $depends = array("energie");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -39,17 +39,23 @@ class box_external_rss extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array();
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
*/
|
||||
function box_external_rss()
|
||||
function box_external_rss($DB,$param)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("boxes");
|
||||
|
||||
$this->db=$DB;
|
||||
$this->param=$param;
|
||||
|
||||
$this->boxlabel=$langs->trans("BoxLastRssInfos");
|
||||
}
|
||||
|
||||
@ -59,38 +65,41 @@ class box_external_rss extends ModeleBoxes {
|
||||
*/
|
||||
function loadBox($max=5)
|
||||
{
|
||||
global $user, $langs, $db;
|
||||
global $user, $langs;
|
||||
$langs->load("boxes");
|
||||
|
||||
for($site = 0; $site < 1; $site++) {
|
||||
$rss = fetch_rss( @constant("EXTERNAL_RSS_URLRSS_" . $site) );
|
||||
|
||||
$title=$langs->trans("BoxTitleLastRssInfos",$max, @constant("EXTERNAL_RSS_TITLE_". $site));
|
||||
if ($rss->ERROR) {
|
||||
// Affiche warning car il y a eu une erreur
|
||||
$title.=" ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate",(isset($rss->date)?dolibarr_print_date($rss->date,"%d %b %Y %H:%M"):'unknown date')));
|
||||
$this->info_box_head = array('text' => $title,'limit' => 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->info_box_head = array('text' => $title);
|
||||
}
|
||||
|
||||
for($i = 0; $i < $max ; $i++){
|
||||
$item = $rss->items[$i];
|
||||
$href = $item['link'];
|
||||
$title = utf8_decode(urldecode($item['title']));
|
||||
$title=ereg_replace("([[:alnum:]])\?([[:alnum:]])","\\1'\\2",$title); // Gère problème des apostrophes mal codée/décodée par utf8
|
||||
$title=ereg_replace("^\s+","",$title); // Supprime espaces de début
|
||||
$this->info_box_contents["$href"]="$title";
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => $this->boximg,
|
||||
'text' => $title,
|
||||
'url' => $href,
|
||||
'target' => 'newrss');
|
||||
}
|
||||
|
||||
// On recupere numero de param de la boite
|
||||
ereg('^([0-9]+) ',$this->param,$reg);
|
||||
$site=$reg[1];
|
||||
|
||||
// Recupere flux RSS definie dans EXTERNAL_RSS_URLRSS_$site
|
||||
$rss = fetch_rss( @constant("EXTERNAL_RSS_URLRSS_".$site) );
|
||||
|
||||
$title=$langs->trans("BoxTitleLastRssInfos",$max, @constant("EXTERNAL_RSS_TITLE_". $site));
|
||||
if ($rss->ERROR)
|
||||
{
|
||||
// Affiche warning car il y a eu une erreur
|
||||
$title.=" ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate",(isset($rss->date)?dolibarr_print_date($rss->date,"%d %b %Y %H:%M"):'unknown date')));
|
||||
$this->info_box_head = array('text' => $title,'limit' => 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->info_box_head = array('text' => $title);
|
||||
}
|
||||
|
||||
for($i = 0; $i < $max ; $i++)
|
||||
{
|
||||
$item = $rss->items[$i];
|
||||
$href = $item['link'];
|
||||
$title = utf8_decode(urldecode($item['title']));
|
||||
$title=ereg_replace("([[:alnum:]])\?([[:alnum:]])","\\1'\\2",$title); // Gère problème des apostrophes mal codée/décodée par utf8
|
||||
$title=ereg_replace("^\s+","",$title); // Supprime espaces de début
|
||||
$this->info_box_contents["$href"]="$title";
|
||||
$this->info_box_contents[$i][0] = array('align' => 'left',
|
||||
'logo' => $this->boximg,
|
||||
'text' => $title,
|
||||
'url' => $href,
|
||||
'target' => 'newrss');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,9 @@ class box_factures extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("facture");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -38,6 +37,9 @@ class box_factures_fourn extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("facture","fournisseur");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -36,9 +36,13 @@ class box_factures_fourn_imp extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("facture","fournisseur");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
*/
|
||||
|
||||
@ -38,6 +38,9 @@ class box_factures_imp extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("facture");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -36,6 +36,9 @@ class box_fournisseurs extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("fournisseur");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -37,6 +36,9 @@ class box_osc_clients extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("boutique");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -36,6 +36,9 @@ class box_produits extends ModeleBoxes {
|
||||
var $boximg="object_product";
|
||||
var $boxlabel;
|
||||
var $depends = array("produit");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
@ -37,6 +37,9 @@ class box_propales extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("propale");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -39,6 +39,9 @@ class box_prospect extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("commercial");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -37,6 +37,9 @@ class box_services_vendus extends ModeleBoxes {
|
||||
var $boxlabel;
|
||||
var $depends = array("produit","service");
|
||||
|
||||
var $db;
|
||||
var $param;
|
||||
|
||||
var $info_box_head = array();
|
||||
var $info_box_contents = array();
|
||||
|
||||
|
||||
@ -65,6 +65,7 @@ class ModeleBoxes
|
||||
$nbcol=sizeof($contents[0])+1;
|
||||
$nblines=sizeof($contents);
|
||||
|
||||
print "\n<!-- Box start -->\n";
|
||||
print '<table width="100%" class="noborder">';
|
||||
|
||||
// Affiche titre de la boite
|
||||
@ -154,6 +155,9 @@ class ModeleBoxes
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
print "\n<!-- Box end -->\n";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
Snoopy - the PHP net client
|
||||
Author: Monte Ohrt <monte@ispi.net>
|
||||
Modification: Laurent Destailleur (See LDR mark to find bug fix)
|
||||
Copyright (c): 1999-2000 ispi, all rights reserved
|
||||
Version: 1.0
|
||||
|
||||
@ -260,7 +261,7 @@ class Snoopy
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================*\
|
||||
Private functions
|
||||
@ -497,7 +498,7 @@ class Snoopy
|
||||
|
||||
// if($currentHeader == "\r\n")
|
||||
if(preg_match("/^\r?\n$/", $currentHeader) )
|
||||
break;
|
||||
break;
|
||||
|
||||
// if a header begins with Location: or URI:, set the redirect
|
||||
if(preg_match("/^(Location:|URI:)/i",$currentHeader))
|
||||
@ -643,9 +644,10 @@ class Snoopy
|
||||
if(!empty($this->user) || !empty($this->pass))
|
||||
$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
|
||||
|
||||
for($curr_header = 0; $curr_header < count($headers); $curr_header++)
|
||||
for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
|
||||
$cmdline_params .= " -H \"".$headers[$curr_header]."\"";
|
||||
|
||||
}
|
||||
|
||||
if(!empty($body))
|
||||
$cmdline_params .= " -d \"$body\"";
|
||||
|
||||
@ -653,10 +655,10 @@ class Snoopy
|
||||
$cmdline_params .= " -m ".$this->read_timeout;
|
||||
|
||||
$headerfile = uniqid(time());
|
||||
|
||||
|
||||
# accept self-signed certs
|
||||
$cmdline_params .= " -k";
|
||||
exec($this->curl_path." -D \"/tmp/$headerfile\"".$cmdline_params." ".$URI,$results,$return);
|
||||
$cmdline_params .= " -k";
|
||||
exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI),$results,$return);
|
||||
|
||||
if($return)
|
||||
{
|
||||
@ -697,11 +699,11 @@ class Snoopy
|
||||
|
||||
if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
|
||||
{
|
||||
$this->response_code = $result_headers[$currentHeader];
|
||||
$this->response_code = $result_headers[$currentHeader];
|
||||
if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match))
|
||||
{
|
||||
$this->status= $match[1];
|
||||
}
|
||||
$this->status= $match[1];
|
||||
}
|
||||
}
|
||||
$this->headers[] = $result_headers[$currentHeader];
|
||||
}
|
||||
|
||||
@ -93,10 +93,14 @@ class RSSCache {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$data = fread( $fp, filesize($cache_file) );
|
||||
$rss = $this->unserialize( $data );
|
||||
if ($filesize = filesize($cache_file) ) {
|
||||
$data = fread( $fp, filesize($cache_file) );
|
||||
$rss = $this->unserialize( $data );
|
||||
|
||||
return $rss;
|
||||
return $rss;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
@ -130,6 +134,18 @@ class RSSCache {
|
||||
}
|
||||
}
|
||||
|
||||
function cache_age( $cache_key ) {
|
||||
$filename = $this->file_name( $url );
|
||||
if ( file_exists( $filename ) ) {
|
||||
$mtime = filemtime( $filename );
|
||||
$age = time() - $mtime;
|
||||
return $age;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: serialize
|
||||
\*=======================================================================*/
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
/*
|
||||
* Project: MagpieRSS: a simple RSS integration tool
|
||||
* File: rss_fetch.inc, a simple functional interface
|
||||
to fetching and parsing RSS files, via the
|
||||
function fetch_rss()
|
||||
to fetching and parsing RSS files, via the
|
||||
function fetch_rss()
|
||||
* Author: Kellan Elliott-McCrea <kellan@protest.net>
|
||||
* Modified by Laurent Destailleur <eldy@users.sourceforge.net> for Dolibarr
|
||||
* License: GPL
|
||||
* Modification: Laurent Destailleur (See LDR mark to find bug fix)
|
||||
* License: GPL
|
||||
*
|
||||
* The lastest version of MagpieRSS can be obtained from:
|
||||
* http://magpierss.sourceforge.net
|
||||
@ -21,7 +21,7 @@
|
||||
// the current path in include_path.
|
||||
// with thanks to rajiv and smarty
|
||||
if (!defined('DIR_SEP')) {
|
||||
define('DIR_SEP', DIRECTORY_SEPARATOR);
|
||||
define('DIR_SEP', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
if (!defined('MAGPIE_DIR')) {
|
||||
@ -63,147 +63,148 @@ require_once( MAGPIE_EXTLIB . 'Snoopy.class.inc');
|
||||
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: fetch_rss:
|
||||
Purpose: return RSS object for the give url
|
||||
maintain the cache
|
||||
Input: url of RSS file
|
||||
Output: parsed RSS object (see rss_parse.inc)
|
||||
Function: fetch_rss:
|
||||
Purpose: return RSS object for the give url
|
||||
maintain the cache
|
||||
Input: url of RSS file
|
||||
Output: parsed RSS object (see rss_parse.inc)
|
||||
|
||||
NOTES ON CACHEING:
|
||||
If caching is on (MAGPIE_CACHE_ON) fetch_rss will first check the cache.
|
||||
|
||||
NOTES ON RETRIEVING REMOTE FILES:
|
||||
If conditional gets are on (MAGPIE_CONDITIONAL_GET_ON) fetch_rss will
|
||||
return a cached object, and touch the cache object upon recieving a
|
||||
304.
|
||||
|
||||
NOTES ON FAILED REQUESTS:
|
||||
If there is an HTTP error while fetching an RSS object, the cached
|
||||
version will be return, if it exists (and if MAGPIE_CACHE_FRESH_ONLY is off)
|
||||
NOTES ON CACHEING:
|
||||
If caching is on (MAGPIE_CACHE_ON) fetch_rss will first check the cache.
|
||||
|
||||
NOTES ON RETRIEVING REMOTE FILES:
|
||||
If conditional gets are on (MAGPIE_CONDITIONAL_GET_ON) fetch_rss will
|
||||
return a cached object, and touch the cache object upon recieving a
|
||||
304.
|
||||
|
||||
NOTES ON FAILED REQUESTS:
|
||||
If there is an HTTP error while fetching an RSS object, the cached
|
||||
version will be return, if it exists (and if MAGPIE_CACHE_FRESH_ONLY is off)
|
||||
\*=======================================================================*/
|
||||
|
||||
define('MAGPIE_VERSION', '0.7');
|
||||
define('MAGPIE_VERSION', '0.72');
|
||||
|
||||
$MAGPIE_ERROR = "";
|
||||
|
||||
// LDR Added cachedir parameter to replace use of MAGPIE_CACHE_RSS and
|
||||
// allow several call to different url with different a cache foreach of
|
||||
// inside same PHP session.
|
||||
function fetch_rss ($url) {
|
||||
// initialize constants
|
||||
init();
|
||||
|
||||
if ( !isset($url) ) {
|
||||
error("fetch_rss called without a url");
|
||||
return false;
|
||||
}
|
||||
|
||||
// if cache is disabled
|
||||
if ( !MAGPIE_CACHE_ON ) {
|
||||
// fetch file, and parse it
|
||||
$resp = _fetch_remote_file( $url );
|
||||
if ( is_success( $resp->status ) ) {
|
||||
return _response_to_rss( $resp );
|
||||
}
|
||||
else {
|
||||
error("Failed to fetch $url and cache is off");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// else cache is ON
|
||||
else {
|
||||
// Flow
|
||||
// 1. check cache
|
||||
// 2. if there is a hit, make sure its fresh
|
||||
// 3. if cached obj fails freshness check, fetch remote
|
||||
// 4. if remote fails, return stale object, or error
|
||||
|
||||
$cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
|
||||
|
||||
// initialize constants
|
||||
init();
|
||||
|
||||
if ( !isset($url) ) {
|
||||
error("fetch_rss called without a url");
|
||||
return false;
|
||||
}
|
||||
|
||||
// if cache is disabled
|
||||
if ( !MAGPIE_CACHE_ON ) {
|
||||
// fetch file, and parse it
|
||||
$resp = _fetch_remote_file( $url );
|
||||
if ( is_success( $resp->status ) ) {
|
||||
return _response_to_rss( $resp );
|
||||
}
|
||||
else {
|
||||
error("Failed to fetch $url and cache is off");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// else cache is ON
|
||||
else {
|
||||
// Flow
|
||||
// 1. check cache
|
||||
// 2. if there is a hit, make sure its fresh
|
||||
// 3. if cached obj fails freshness check, fetch remote
|
||||
// 4. if remote fails, return stale object, or error
|
||||
|
||||
$cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
|
||||
|
||||
if (MAGPIE_DEBUG and $cache->ERROR) {
|
||||
debug($cache->ERROR, E_USER_WARNING);
|
||||
}
|
||||
|
||||
|
||||
$cache_status = 0; // response of check_cache
|
||||
$request_headers = array(); // HTTP headers to send with fetch
|
||||
$rss = 0; // parsed RSS object
|
||||
$errormsg = 0; // errors, if any
|
||||
|
||||
}
|
||||
|
||||
|
||||
$cache_status = 0; // response of check_cache
|
||||
$request_headers = array(); // HTTP headers to send with fetch
|
||||
$rss = 0; // parsed RSS object
|
||||
$errormsg = 0; // errors, if any
|
||||
|
||||
// store parsed XML by desired output encoding
|
||||
// as character munging happens at parse time
|
||||
$cache_key = $url . MAGPIE_OUTPUT_ENCODING;
|
||||
|
||||
if (!$cache->ERROR) {
|
||||
// return cache HIT, MISS, or STALE
|
||||
if (!$cache->ERROR) {
|
||||
// return cache HIT, MISS, or STALE
|
||||
$cache_status = $cache->check_cache( $cache_key);
|
||||
}
|
||||
|
||||
// if object cached, and cache is fresh, return cached obj
|
||||
if ( $cache_status == 'HIT' ) {
|
||||
}
|
||||
|
||||
// if object cached, and cache is fresh, return cached obj
|
||||
if ( $cache_status == 'HIT' ) {
|
||||
$rss = $cache->get( $cache_key );
|
||||
if ( isset($rss) and $rss ) {
|
||||
if ( isset($rss) and $rss ) {
|
||||
// should be cache age
|
||||
$rss->from_cache = 1;
|
||||
if ( MAGPIE_DEBUG > 1) {
|
||||
debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
|
||||
}
|
||||
return $rss;
|
||||
}
|
||||
}
|
||||
|
||||
// else attempt a conditional get
|
||||
|
||||
// setup headers
|
||||
if ( $cache_status == 'STALE' ) {
|
||||
$rss->from_cache = 1;
|
||||
if ( MAGPIE_DEBUG > 1) {
|
||||
debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
|
||||
}
|
||||
return $rss;
|
||||
}
|
||||
}
|
||||
|
||||
// else attempt a conditional get
|
||||
|
||||
// setup headers
|
||||
if ( $cache_status == 'STALE' ) {
|
||||
$rss = $cache->get( $cache_key );
|
||||
if ( $rss and $rss->etag and $rss->last_modified ) {
|
||||
$request_headers['If-None-Match'] = $rss->etag;
|
||||
$request_headers['If-Last-Modified'] = $rss->last_modified;
|
||||
}
|
||||
}
|
||||
|
||||
$resp = _fetch_remote_file( $url, $request_headers );
|
||||
|
||||
if (isset($resp) and $resp) {
|
||||
if ($resp->status == '304' ) {
|
||||
// we have the most current copy
|
||||
if ( MAGPIE_DEBUG > 1) {
|
||||
debug("Got 304 for $url");
|
||||
}
|
||||
// reset cache on 304 (at minutillo insistent prodding)
|
||||
$request_headers['If-None-Match'] = $rss->etag;
|
||||
$request_headers['If-Last-Modified'] = $rss->last_modified;
|
||||
}
|
||||
}
|
||||
|
||||
$resp = _fetch_remote_file( $url, $request_headers );
|
||||
|
||||
if (isset($resp) and $resp) {
|
||||
if ($resp->status == '304' ) {
|
||||
// we have the most current copy
|
||||
if ( MAGPIE_DEBUG > 1) {
|
||||
debug("Got 304 for $url");
|
||||
}
|
||||
// reset cache on 304 (at minutillo insistent prodding)
|
||||
$cache->set($cache_key, $rss);
|
||||
return $rss;
|
||||
}
|
||||
elseif ( is_success( $resp->status ) ) {
|
||||
$rss = _response_to_rss( $resp );
|
||||
if ( $rss ) {
|
||||
if (MAGPIE_DEBUG > 1) {
|
||||
debug("Fetch successful");
|
||||
}
|
||||
// add object to cache
|
||||
return $rss;
|
||||
}
|
||||
elseif ( is_success( $resp->status ) ) {
|
||||
$rss = _response_to_rss( $resp );
|
||||
if ( $rss ) {
|
||||
if (MAGPIE_DEBUG > 1) {
|
||||
debug("Fetch successful");
|
||||
}
|
||||
// add object to cache
|
||||
$cache->set( $cache_key, $rss );
|
||||
return $rss;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $rss;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errormsg = "Failed to fetch $url ";
|
||||
if ( $resp->status == '-100' ) {
|
||||
$errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)";
|
||||
}
|
||||
elseif ( $resp->error ) {
|
||||
# compensate for Snoopy's annoying habbit to tacking
|
||||
# on '\n'
|
||||
# compensate for Snoopy's annoying habbit to tacking
|
||||
# on '\n'
|
||||
$http_error = substr($resp->error, 0, -2);
|
||||
|
||||
// LDR FIX BUG (plus necessaire car corrigé par ligne du dessus)
|
||||
//$http_error = eregi_replace("\n","",$resp->error);
|
||||
$errormsg .= "(HTTP Error: $http_error)";
|
||||
}
|
||||
else {
|
||||
$errormsg .= "(HTTP Response: " . $resp->response_code .')';
|
||||
}
|
||||
|
||||
$errormsg .= "(HTTP Error: $http_error)";
|
||||
}
|
||||
else {
|
||||
$errormsg .= "(HTTP Response: " . $resp->response_code .')';
|
||||
}
|
||||
|
||||
// LDR FIX BUG Si echec recup http mais cache bien lu,
|
||||
// on stock erreur dans object rss
|
||||
// LDR FIX BUG If fails to get http url but cache file is read successfuly,
|
||||
// we store error as a property of $rss->ERROR and date of last successful
|
||||
// http access in $rss->date property.
|
||||
// This allows caller to trap error reasons and manage itself networks errors.
|
||||
if ($rss)
|
||||
{
|
||||
if ($cache && $cache_key) $rss->date=filemtime($cache->file_name($cache_key));
|
||||
@ -213,50 +214,50 @@ function fetch_rss ($url) {
|
||||
$rss=$cache;
|
||||
}
|
||||
$rss->ERROR=$errormsg;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errormsg = "Unable to retrieve RSS file for unknown reasons.";
|
||||
}
|
||||
|
||||
// else fetch failed
|
||||
|
||||
// attempt to return cached object
|
||||
if ($rss) {
|
||||
if ( MAGPIE_DEBUG ) {
|
||||
debug("Returning STALE object for $url");
|
||||
}
|
||||
return $rss;
|
||||
}
|
||||
|
||||
// else we totally failed
|
||||
error( $errormsg );
|
||||
|
||||
return false;
|
||||
|
||||
} // end if ( !MAGPIE_CACHE_ON ) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errormsg = "Unable to retrieve RSS file for unknown reasons.";
|
||||
}
|
||||
|
||||
// else fetch failed
|
||||
|
||||
// attempt to return cached object
|
||||
if ($rss) {
|
||||
if ( MAGPIE_DEBUG ) {
|
||||
debug("Returning STALE object for $url");
|
||||
}
|
||||
return $rss;
|
||||
}
|
||||
|
||||
// else we totally failed
|
||||
error( $errormsg );
|
||||
|
||||
return false;
|
||||
|
||||
} // end if ( !MAGPIE_CACHE_ON ) {
|
||||
} // end fetch_rss()
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: error
|
||||
Purpose: set MAGPIE_ERROR, and trigger error
|
||||
Function: error
|
||||
Purpose: set MAGPIE_ERROR, and trigger error
|
||||
\*=======================================================================*/
|
||||
|
||||
function error ($errormsg, $lvl=E_USER_WARNING) {
|
||||
global $MAGPIE_ERROR;
|
||||
|
||||
// append PHP's error message if track_errors enabled
|
||||
if ( isset($php_errormsg) ) {
|
||||
$errormsg .= " ($php_errormsg)";
|
||||
}
|
||||
if ( $errormsg ) {
|
||||
$errormsg = "MagpieRSS: $errormsg";
|
||||
$MAGPIE_ERROR = $errormsg;
|
||||
global $MAGPIE_ERROR;
|
||||
|
||||
// append PHP's error message if track_errors enabled
|
||||
if ( isset($php_errormsg) ) {
|
||||
$errormsg .= " ($php_errormsg)";
|
||||
}
|
||||
if ( $errormsg ) {
|
||||
$errormsg = "MagpieRSS: $errormsg";
|
||||
$MAGPIE_ERROR = $errormsg;
|
||||
// LDR BUG FIX On affiche erreur que si en mode debug
|
||||
if ( MAGPIE_DEBUG ) {
|
||||
trigger_error( $errormsg, $lvl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function debug ($debugmsg, $lvl=E_USER_NOTICE) {
|
||||
@ -265,134 +266,117 @@ function debug ($debugmsg, $lvl=E_USER_NOTICE) {
|
||||
trigger_error("MagpieRSS [debug] $debugmsg", $lvl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: magpie_error
|
||||
Purpose: accessor for the magpie error variable
|
||||
Function: magpie_error
|
||||
Purpose: accessor for the magpie error variable
|
||||
\*=======================================================================*/
|
||||
function magpie_error ($errormsg="") {
|
||||
global $MAGPIE_ERROR;
|
||||
|
||||
if ( isset($errormsg) and $errormsg ) {
|
||||
$MAGPIE_ERROR = $errormsg;
|
||||
}
|
||||
|
||||
return $MAGPIE_ERROR;
|
||||
global $MAGPIE_ERROR;
|
||||
|
||||
if ( isset($errormsg) and $errormsg ) {
|
||||
$MAGPIE_ERROR = $errormsg;
|
||||
}
|
||||
|
||||
return $MAGPIE_ERROR;
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: _fetch_remote_file
|
||||
Purpose: retrieve an arbitrary remote file
|
||||
Input: url of the remote file
|
||||
headers to send along with the request (optional)
|
||||
Output: an HTTP response object (see Snoopy.class.inc)
|
||||
Function: _fetch_remote_file
|
||||
Purpose: retrieve an arbitrary remote file
|
||||
Input: url of the remote file
|
||||
headers to send along with the request (optional)
|
||||
Output: an HTTP response object (see Snoopy.class.inc)
|
||||
\*=======================================================================*/
|
||||
function _fetch_remote_file ($url, $headers = "" ) {
|
||||
// Snoopy is an HTTP client in PHP
|
||||
$client = new Snoopy();
|
||||
$client->agent = MAGPIE_USER_AGENT;
|
||||
$client->read_timeout = MAGPIE_FETCH_TIME_OUT;
|
||||
$client->use_gzip = MAGPIE_USE_GZIP;
|
||||
if (is_array($headers) ) {
|
||||
$client->rawheaders = $headers;
|
||||
}
|
||||
|
||||
@$client->fetch($url);
|
||||
return $client;
|
||||
// Snoopy is an HTTP client in PHP
|
||||
$client = new Snoopy();
|
||||
$client->agent = MAGPIE_USER_AGENT;
|
||||
$client->read_timeout = MAGPIE_FETCH_TIME_OUT;
|
||||
$client->use_gzip = MAGPIE_USE_GZIP;
|
||||
if (is_array($headers) ) {
|
||||
$client->rawheaders = $headers;
|
||||
}
|
||||
|
||||
@$client->fetch($url);
|
||||
return $client;
|
||||
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: _response_to_rss
|
||||
Purpose: parse an HTTP response object into an RSS object
|
||||
Input: an HTTP response object (see Snoopy)
|
||||
Output: parsed RSS object (see rss_parse)
|
||||
Function: _response_to_rss
|
||||
Purpose: parse an HTTP response object into an RSS object
|
||||
Input: an HTTP response object (see Snoopy)
|
||||
Output: parsed RSS object (see rss_parse)
|
||||
\*=======================================================================*/
|
||||
function _response_to_rss ($resp) {
|
||||
$rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING );
|
||||
|
||||
// if RSS parsed successfully
|
||||
if ( $rss and !$rss->ERROR) {
|
||||
|
||||
// find Etag, and Last-Modified
|
||||
foreach($resp->headers as $h) {
|
||||
// 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
|
||||
if (strpos($h, ": ")) {
|
||||
list($field, $val) = explode(": ", $h, 2);
|
||||
}
|
||||
else {
|
||||
$field = $h;
|
||||
$val = "";
|
||||
}
|
||||
|
||||
if ( $field == 'ETag' ) {
|
||||
$rss->etag = $val;
|
||||
}
|
||||
|
||||
if ( $field == 'Last-Modified' ) {
|
||||
$rss->last_modified = $val;
|
||||
}
|
||||
}
|
||||
|
||||
return $rss;
|
||||
} // else construct error message
|
||||
else {
|
||||
$errormsg = "Failed to parse RSS file.";
|
||||
|
||||
if ($rss) {
|
||||
$errormsg .= " (" . $rss->ERROR . ")";
|
||||
}
|
||||
error($errormsg);
|
||||
|
||||
return false;
|
||||
} // end if ($rss and !$rss->error)
|
||||
|
||||
// if RSS parsed successfully
|
||||
if ( $rss and !$rss->ERROR) {
|
||||
|
||||
// find Etag, and Last-Modified
|
||||
foreach($resp->headers as $h) {
|
||||
// 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
|
||||
if (strpos($h, ": ")) {
|
||||
list($field, $val) = explode(": ", $h, 2);
|
||||
}
|
||||
else {
|
||||
$field = $h;
|
||||
$val = "";
|
||||
}
|
||||
|
||||
if ( $field == 'ETag' ) {
|
||||
$rss->etag = $val;
|
||||
}
|
||||
|
||||
if ( $field == 'Last-Modified' ) {
|
||||
$rss->last_modified = $val;
|
||||
}
|
||||
}
|
||||
|
||||
return $rss;
|
||||
} // else construct error message
|
||||
else {
|
||||
$errormsg = "Failed to parse RSS file.";
|
||||
|
||||
if ($rss) {
|
||||
$errormsg .= " (" . $rss->ERROR . ")";
|
||||
}
|
||||
error($errormsg);
|
||||
|
||||
return false;
|
||||
} // end if ($rss and !$rss->error)
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: init
|
||||
Purpose: setup constants with default values
|
||||
check for user overrides
|
||||
Function: init
|
||||
Purpose: setup constants with default values
|
||||
check for user overrides
|
||||
\*=======================================================================*/
|
||||
function init () {
|
||||
if ( defined('MAGPIE_INITALIZED') ) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if ( defined('MAGPIE_INITALIZED') ) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
define('MAGPIE_INITALIZED', true);
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_CACHE_ON') ) {
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_CACHE_ON') ) {
|
||||
define('MAGPIE_CACHE_ON', true);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_CACHE_DIR') ) {
|
||||
if ( !defined('MAGPIE_CACHE_DIR') ) {
|
||||
define('MAGPIE_CACHE_DIR', './cache');
|
||||
}
|
||||
|
||||
// Le rep de cache est defini dans DOL_DATA_ROOT
|
||||
$ret=true;
|
||||
if (! file_exists(DOL_DATA_ROOT)) {
|
||||
$ret=mkdir(DOL_DATA_ROOT);
|
||||
}
|
||||
if ($ret && ! file_exists(DOL_DATA_ROOT.'/rsscache')) {
|
||||
$ret=mkdir(DOL_DATA_ROOT.'/rsscache');
|
||||
}
|
||||
define('MAGPIE_CACHE_DIR', DOL_DATA_ROOT.'/rsscache');
|
||||
if ( !defined('MAGPIE_CACHE_AGE') ) {
|
||||
define('MAGPIE_CACHE_AGE', 60*60); // one hour
|
||||
}
|
||||
|
||||
// Si le rep de cache n'a pu etre trouvé ou créé, on utilise
|
||||
// l'ancien dans DOL_DOCUMENT_ROOT pour raison de compatibilite
|
||||
// avec anciennes versions
|
||||
if (! $ret) {
|
||||
define('MAGPIE_CACHE_DIR', DOL_DOCUMENT_ROOT.'/rsscache');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_CACHE_AGE') ) {
|
||||
define('MAGPIE_CACHE_AGE', 60*60); // one hour
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
|
||||
define('MAGPIE_CACHE_FRESH_ONLY', false);
|
||||
}
|
||||
if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
|
||||
define('MAGPIE_CACHE_FRESH_ONLY', false);
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_OUTPUT_ENCODING') ) {
|
||||
define('MAGPIE_OUTPUT_ENCODING', 'ISO-8859-1');
|
||||
@ -406,93 +390,93 @@ function init () {
|
||||
define('MAGPIE_DETECT_ENCODING', true);
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_DEBUG') ) {
|
||||
define('MAGPIE_DEBUG', 0);
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_USER_AGENT') ) {
|
||||
$ua = 'MagpieRSS/'. MAGPIE_VERSION . ' (+http://magpierss.sf.net';
|
||||
|
||||
if ( MAGPIE_CACHE_ON ) {
|
||||
$ua = $ua . ')';
|
||||
}
|
||||
else {
|
||||
$ua = $ua . '; No cache)';
|
||||
}
|
||||
|
||||
define('MAGPIE_USER_AGENT', $ua);
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
|
||||
define('MAGPIE_FETCH_TIME_OUT', 5); // 5 second timeout
|
||||
}
|
||||
|
||||
// use gzip encoding to fetch rss files if supported?
|
||||
if ( !defined('MAGPIE_USE_GZIP') ) {
|
||||
define('MAGPIE_USE_GZIP', true);
|
||||
}
|
||||
if ( !defined('MAGPIE_DEBUG') ) {
|
||||
define('MAGPIE_DEBUG', 0);
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_USER_AGENT') ) {
|
||||
$ua = 'MagpieRSS/'. MAGPIE_VERSION . ' (+http://magpierss.sf.net';
|
||||
|
||||
if ( MAGPIE_CACHE_ON ) {
|
||||
$ua = $ua . ')';
|
||||
}
|
||||
else {
|
||||
$ua = $ua . '; No cache)';
|
||||
}
|
||||
|
||||
define('MAGPIE_USER_AGENT', $ua);
|
||||
}
|
||||
|
||||
if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
|
||||
define('MAGPIE_FETCH_TIME_OUT', 5); // 5 second timeout
|
||||
}
|
||||
|
||||
// use gzip encoding to fetch rss files if supported?
|
||||
if ( !defined('MAGPIE_USE_GZIP') ) {
|
||||
define('MAGPIE_USE_GZIP', true);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: the following code should really be in Snoopy, or at least
|
||||
// somewhere other then rss_fetch!
|
||||
|
||||
/*=======================================================================*\
|
||||
HTTP STATUS CODE PREDICATES
|
||||
These functions attempt to classify an HTTP status code
|
||||
based on RFC 2616 and RFC 2518.
|
||||
|
||||
All of them take an HTTP status code as input, and return true or false
|
||||
HTTP STATUS CODE PREDICATES
|
||||
These functions attempt to classify an HTTP status code
|
||||
based on RFC 2616 and RFC 2518.
|
||||
|
||||
All of them take an HTTP status code as input, and return true or false
|
||||
|
||||
All this code is adapted from LWP's HTTP::Status.
|
||||
All this code is adapted from LWP's HTTP::Status.
|
||||
\*=======================================================================*/
|
||||
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: is_info
|
||||
Purpose: return true if Informational status code
|
||||
Function: is_info
|
||||
Purpose: return true if Informational status code
|
||||
\*=======================================================================*/
|
||||
function is_info ($sc) {
|
||||
return $sc >= 100 && $sc < 200;
|
||||
return $sc >= 100 && $sc < 200;
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: is_success
|
||||
Purpose: return true if Successful status code
|
||||
Function: is_success
|
||||
Purpose: return true if Successful status code
|
||||
\*=======================================================================*/
|
||||
function is_success ($sc) {
|
||||
return $sc >= 200 && $sc < 300;
|
||||
return $sc >= 200 && $sc < 300;
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: is_redirect
|
||||
Purpose: return true if Redirection status code
|
||||
Function: is_redirect
|
||||
Purpose: return true if Redirection status code
|
||||
\*=======================================================================*/
|
||||
function is_redirect ($sc) {
|
||||
return $sc >= 300 && $sc < 400;
|
||||
return $sc >= 300 && $sc < 400;
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: is_error
|
||||
Purpose: return true if Error status code
|
||||
Function: is_error
|
||||
Purpose: return true if Error status code
|
||||
\*=======================================================================*/
|
||||
function is_error ($sc) {
|
||||
return $sc >= 400 && $sc < 600;
|
||||
return $sc >= 400 && $sc < 600;
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: is_client_error
|
||||
Purpose: return true if Error status code, and its a client error
|
||||
Function: is_client_error
|
||||
Purpose: return true if Error status code, and its a client error
|
||||
\*=======================================================================*/
|
||||
function is_client_error ($sc) {
|
||||
return $sc >= 400 && $sc < 500;
|
||||
return $sc >= 400 && $sc < 500;
|
||||
}
|
||||
|
||||
/*=======================================================================*\
|
||||
Function: is_client_error
|
||||
Purpose: return true if Error status code, and its a server error
|
||||
Function: is_client_error
|
||||
Purpose: return true if Error status code, and its a server error
|
||||
\*=======================================================================*/
|
||||
function is_server_error ($sc) {
|
||||
return $sc >= 500 && $sc < 600;
|
||||
return $sc >= 500 && $sc < 600;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -60,7 +60,6 @@ class MagpieRSS {
|
||||
var $incontent = false; // if in Atom <content mode="xml"> field
|
||||
var $intextinput = false;
|
||||
var $inimage = false;
|
||||
var $current_field = '';
|
||||
var $current_namespace = false;
|
||||
|
||||
|
||||
@ -259,7 +258,6 @@ class MagpieRSS {
|
||||
|
||||
|
||||
function feed_cdata ($p, $text) {
|
||||
|
||||
if ($this->feed_type == ATOM and $this->incontent)
|
||||
{
|
||||
$this->append_content( $text );
|
||||
@ -391,7 +389,7 @@ class MagpieRSS {
|
||||
|
||||
$atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified'];
|
||||
if ( $atom_date ) {
|
||||
$epoch = @parse_w3cdtf($item['modified']);
|
||||
$epoch = @parse_w3cdtf($atom_date);
|
||||
if ($epoch and $epoch > 0) {
|
||||
$item['date_timestamp'] = $epoch;
|
||||
}
|
||||
@ -560,7 +558,7 @@ class MagpieRSS {
|
||||
|
||||
function error ($errormsg, $lvl=E_USER_WARNING) {
|
||||
// append PHP's error message if track_errors enabled
|
||||
if ( $php_errormsg ) {
|
||||
if ( isset($php_errormsg) ) {
|
||||
$errormsg .= " ($php_errormsg)";
|
||||
}
|
||||
if ( MAGPIE_DEBUG ) {
|
||||
@ -585,5 +583,23 @@ function map_attrs($k, $v) {
|
||||
return "$k=\"$v\"";
|
||||
}
|
||||
|
||||
// patch to support medieval versions of PHP4.1.x,
|
||||
// courtesy, Ryan Currie, ryan@digibliss.com
|
||||
|
||||
if (!function_exists('array_change_key_case')) {
|
||||
define("CASE_UPPER",1);
|
||||
define("CASE_LOWER",0);
|
||||
|
||||
|
||||
function array_change_key_case($array,$case=CASE_LOWER) {
|
||||
if ($case=CASE_LOWER) $cmd=strtolower;
|
||||
elseif ($case=CASE_UPPER) $cmd=strtoupper;
|
||||
foreach($array as $key=>$value) {
|
||||
$output[$cmd($key)]=$value;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -484,31 +484,30 @@ print '</td></tr></table>';
|
||||
*/
|
||||
include_once("./boxes.php");
|
||||
$infobox=new InfoBox($db);
|
||||
$boxes=$infobox->listboxes("0"); // 0 = valeur pour la page accueil
|
||||
$boxarray=$infobox->listboxes("0"); // 0 = valeur pour la page accueil
|
||||
|
||||
$NBCOLS=2; // Nombre de colonnes pour les boites
|
||||
|
||||
if (sizeof($boxes))
|
||||
if (sizeof($boxarray))
|
||||
{
|
||||
print '<br>';
|
||||
print_fiche_titre($langs->trans("OtherInformationsBoxes"));
|
||||
print '<table width="100%" class="notopnoleftnoright">';
|
||||
print '<br>';
|
||||
print_fiche_titre($langs->trans("OtherInformationsBoxes"));
|
||||
print '<table width="100%" class="notopnoleftnoright">';
|
||||
}
|
||||
for ($ii=0, $ni=sizeof($boxes); $ii<$ni; $ii++)
|
||||
for ($ii=0, $ni=sizeof($boxarray); $ii<$ni; $ii++)
|
||||
{
|
||||
if ($ii % $NBCOLS == 0) print "<tr>\n";
|
||||
print '<td valign="top" width="50%">';
|
||||
|
||||
// Affichage boite ii
|
||||
include_once(DOL_DOCUMENT_ROOT."/includes/boxes/".$boxes[$ii].".php");
|
||||
$box=new $boxes[$ii]();
|
||||
$box->loadBox();
|
||||
$box->showBox();
|
||||
|
||||
print "</td>";
|
||||
if ($ii % $NBCOLS == ($NBCOLS-1)) print "</tr>\n";
|
||||
if ($ii % $NBCOLS == 0) print "<tr>\n";
|
||||
print '<td valign="top" width="50%">';
|
||||
|
||||
// Affichage boite ii
|
||||
$box=$boxarray[$ii];
|
||||
$box->loadBox();
|
||||
$box->showBox();
|
||||
|
||||
print "</td>";
|
||||
if ($ii % $NBCOLS == ($NBCOLS-1)) print "</tr>\n";
|
||||
}
|
||||
if (sizeof($boxes))
|
||||
if (sizeof($boxarray))
|
||||
{
|
||||
if ($ii % $NBCOLS == ($NBCOLS-1)) print "</tr>\n";
|
||||
print "</table>";
|
||||
|
||||
@ -269,7 +269,7 @@ VATReceivedOnly=Taux special non factur
|
||||
VATManagement=Gestion TVA
|
||||
VATIsUsed=Assujéti à TVA
|
||||
VATIsNotUsed=Non assujéti à TVA
|
||||
VATIsUsedDesc=Le taux de TVA proposé par défaut lors de la création de propale, facture, commande, etc répond à la règle standard suivante:<br>Si vendeur non assujeti à TVA, TVA par défaut=0. Fin de règle.<br>Si le (pays vendeur = pays acheteur) alors la TVA par défaut=TVA du produit vendu. Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par défaut=0 (La TVA doit être payé par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et bien vendu autre que transport neuf alors la TVA par défaut=TVA du produit vendu. Fin de règle.<br>Sinon la TVA proposée par défaut=0. Fin de règle.
|
||||
VATIsUsedDesc=Le taux de TVA proposé par défaut lors de la création de propale, facture, commande, etc répond à la règle standard suivante:<br>Si le (pays vendeur = pays acheteur) alors la TVA par défaut=TVA du produit vendu. Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par défaut=0 (La TVA doit être payé par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et bien vendu autre que transport neuf alors la TVA par défaut=TVA du produit vendu. Fin de règle.<br>Sinon la TVA proposée par défaut=0. Fin de règle.
|
||||
VATIsNotUsedDesc=Le taux de TVA proposé par défaut est 0. C'est le cas d'associations, particuliers ou certaines petites sociétés.
|
||||
VATIsUsedExampleFR=En France, il s'agit des sociétés ou organismes ayant choisi un régime fiscale réel (Réel simplifié ou Réel normal), régime dans lequel la TVA est déclarée.
|
||||
VATIsNotUsedExampleFR=En France, il s'agit des associations ne déclarant pas de TVA ou sociétés, organismes ou professions libérales ayant choisi le régime fiscal micro entreprise (TVA en franchise) et payant une TVA en franchise sans faire de déclaration de TVA. Ce choix fait de plus apparaitre la mention "TVA non applicable - art-293B du CGI" sur les factures.
|
||||
|
||||
@ -145,14 +145,17 @@ $langs->setPhpLang($conf->global->MAIN_LANG_DEFAULT);
|
||||
* Pour PHPlot: PHPLOT_PATH
|
||||
* Pour MagpieRss: MAGPIERSS_PATH
|
||||
*/
|
||||
// Les path racines
|
||||
if (! defined('FPDF_PATH')) { define('FPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdf/fpdf/'); }
|
||||
if (! defined('PEAR_PATH')) { define('PEAR_PATH', DOL_DOCUMENT_ROOT .'/includes/pear/'); }
|
||||
if (! defined('PHP_WRITEEXCEL_PATH')) { define('PHP_WRITEEXCEL_PATH',DOL_DOCUMENT_ROOT .'/includes/php_writeexcel/'); }
|
||||
if (! defined('PHPLOT_PATH')) { define('PHPLOT_PATH', DOL_DOCUMENT_ROOT .'/includes/phplot/'); }
|
||||
if (! defined('MAGPIERSS_PATH')) { define('MAGPIERSS_PATH', DOL_DOCUMENT_ROOT .'/includes/magpierss/'); }
|
||||
if (! defined('JPGRAPH_PATH')) { define('JPGRAPH_PATH', DOL_DOCUMENT_ROOT .'/includes/jpgraph/'); }
|
||||
define('FPDF_FONTPATH', FPDF_PATH . 'font/');
|
||||
define('MAGPIE_DIR', MAGPIERSS_PATH);
|
||||
// Les autres path
|
||||
if (! defined('FPDF_FONTPATH')) { define('FPDF_FONTPATH', FPDF_PATH . 'font/'); }
|
||||
if (! defined('MAGPIE_DIR')) { define('MAGPIE_DIR', MAGPIERSS_PATH); }
|
||||
if (! defined('MAGPIE_CACHE_DIR')) { define('MAGPIE_CACHE_DIR', DOL_DATA_ROOT .'/rsscache'); }
|
||||
|
||||
// \todo Ajouter la ligne
|
||||
// require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user