public function __construct($data)
 {
     $data = preg_replace('#\\"#', '\'', $data);
     parent::__construct($data);
     if ($this->getName() != self::ROOT_NAME) {
         $msg = "L'�l�ment racine n'est pas valide : " . $this->getName() . " trouve, " . self::ROOT_NAME . " attendu.";
         CertissimLogger::insertLog(__FILE__ . " - __construct()", $msg);
     }
 }
 /**
  * switch the status to $mode if available, to 'test' otherwise
  *
  * @version 3.1
  * @param bool $mode
  * @return bool vrai si la mise à jour est ok, faux sinon
  */
 public function switchMode($mode)
 {
     if (!$this->statusIsAvailable($mode)) {
         CertissimLogger::insertLog(__FILE__, "Le mode '{$mode}' n'est pas reconnu. 'test' défini à la place.");
         $mode = 'test';
     }
     //switch the status to $mode
     $this->setStatus($mode);
     //reload URLs
     $this->loadURLs();
 }
Esempio n. 3
0
 public function display()
 {
     if (Tools::isSubmit('action') && Tools::getValue('action') == 'viewLog') {
         //loads the log content
         $log_content = CertissimLogger::getLogContent();
         $log_txt = CertissimTools::convert_encoding($log_content, 'UTF-8');
         $url_back = 'index.php?tab=AdminModules&configure=fianetfraud&tab_module=payment_security&module_name=fianetfraud&token=' . Tools::getAdminTokenLite('AdminModules');
         echo "<center><a style='padding: 3px; margin: 6px; border: 1px solid black' href='" . $url_back . "'>" . $this->l('Back to configuration page') . "</a></center><textarea style='margin: 6px' cols='160' rows='50' readOnly>{$log_txt}</textarea><div class='clear'></div><center><a style='padding: 3px; margin: 6px; border: 1px solid black' href='" . $url_back . "'>" . $this->l('Back to configuration page') . "</a></center>";
     } else {
         echo parent::display();
     }
 }
 public function initContent()
 {
     if (Tools::isSubmit('action') && Tools::getValue('action') == 'viewLog') {
         //loads the log content
         $log_content = CertissimLogger::getLogContent();
         $log_txt = htmlspecialchars($log_content, ENT_QUOTES, 'UTF-8');
         $url_back = $this->context->link->getAdminLink('AdminModules') . '&configure=fianetfraud';
         $html = "<p><a href='" . $url_back . "'>" . $this->l('Back to configuration page') . "</a></p><textarea cols='180' rows='35' Readonly>{$log_txt}</textarea><p><a href='" . $url_back . "'>" . $this->l('Back to configuration page') . "</a></p>";
         $this->context->smarty->assign('content', $html);
     } else {
         parent::initContent();
     }
 }
 /**
  * creates the log file if it doesn't exist
  * rename the log file then creates a new one if the existing one has reached the max allowed size (100Ko)
  * open the log file
  * assigns the log file handle to the local var $_handle
  * 
  * @return void
  */
 private static function openHandle()
 {
     $log_filename = SAC_ROOT_DIR . '/logs/' . sha1(_COOKIE_KEY_ . 'fianet_log') . '.txt';
     //renames the log file and creates a new one if max allowed size reached
     if (file_exists($log_filename) && filesize($log_filename) > 100000) {
         $prefix = SAC_ROOT_DIR . '/logs/fianetlog-';
         $base = date('YmdHis');
         $sufix = '.txt';
         $filename = $prefix . $base . $sufix;
         for ($i = 0; file_exists($filename); $i++) {
             $filename = $prefix . $base . "-{$i}" . $sufix;
         }
         rename($log_filename, $filename);
     }
     self::$_handle = self::openFile($log_filename);
     register_shutdown_function('fclose', self::$_handle);
 }
 /**
  * updates a certissim order with the fields given as a paramater and returns true if success, false otherwiser
  * 
  * @param int $id_order id of the order to update
  * @param array $fields
  * @return boolean
  */
 public static function updateCertissimOrder($id_order, array $fields)
 {
     //if no fields to update, end of process
     if (empty($fields)) {
         CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Tableau de champs vide.");
         return false;
     }
     //initialization of the part of the SQL string that defines the updates
     $set_string = "";
     foreach ($fields as $fieldname => $fieldvalue) {
         $set_string .= "`{$fieldname}`='" . pSQL(CertissimTools::convert_encoding($fieldvalue, ini_get('default_charset'))) . "', ";
     }
     $set_string = substr($set_string, 0, -2);
     //removes the ', ' at the end of the string
     $sql = "UPDATE `" . _DB_PREFIX_ . self::CERTISSIM_ORDER_TABLE_NAME . "` SET {$set_string} WHERE `id_order`='{$id_order}'";
     //builds the total SQL string
     $updated = Db::getInstance()->execute($sql);
     //executes the SQL query
     if (!$updated) {
         CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Mise à jour échouée pour la requête : {$sql}");
     } else {
         CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Mise à jour OK pour la requête : {$sql}");
     }
     return $updated;
 }
Esempio n. 7
0
 /**
  * builds the XML for the order $id_order and sends it to Certissim, then update the state of the order in Certissim table
  * 
  * @param int $id_order
  */
 public function sendAndUpdateOrder($id_order)
 {
     $sent = $this->module->buildAndSend($id_order);
     if ($sent) {
         fianetfraud::switchOrderToState($id_order, 'sent');
     } else {
         CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "L'envoi de la commande {$id_order} vers Certissim a échoué.");
     }
 }
	 */
    public function getChildrenByNameAndAttribute($name, $attributename, $attributevalue = null)
    {
        $children = $this->getChildrenByName($name);
        foreach ($children as $key => $child) {
            if (is_null($child->getAttribute($attributename)) || !is_null($attributevalue) && $child->getAttribute($attributename) != $attributevalue) {
                unset($children[$key]);
            }
        }
        return $children;
    }
    /**
	 * returns the first child with the name $name and attribute $attributename set to $attribute value
	 * 
	 * @param string $name
	 * @param string $attributename name of the wanted attribute
	 * @param string|null $attributevalue name of the wanted value, null if we're only looking for the attribute presence
	 * @return CertissimXMLElement
	 */
    public function getChildByNameAndAttribute($name, $attributename, $attributevalue = null)
    {
        $children = $this->getChildrenByNameAndAttribute($name, $attributename, $attributevalue);
        return array_pop($children);
    }
    /**
 /**
  * conects to a server, reach the script and returns the response
  *
  * @param string $header header to send to the server to reach the script
  * @return type
  */
 function connect($header)
 {
     $error = '';
     $errno = '';
     if ($this->is_ssl) {
         $socket = fsockopen('ssl://' . $this->host, $this->port, $errno, $error, CertissimFianetSocket::TIMEOUT);
     } else {
         $socket = fsockopen($this->host, $this->port);
     }
     if ($socket !== false) {
         $res = '';
         if (@fputs($socket, $header)) {
             while (!feof($socket)) {
                 $res .= fgets($socket, 128);
             }
         } else {
             CertissimLogger::insertLog(__METHOD__ . ' - ' . __LINE__, "Envoi des données impossible sur : " . $this->host);
             $res = false;
         }
         fclose($socket);
     } else {
         $msg = "Connexion socket impossible sur l'hôte " . $this->host . ". Erreur " . $errno . " : " . $error;
         CertissimLogger::insertLog(__METHOD__ . ' - ' . __LINE__, $msg);
         $res = false;
     }
     return $res;
 }
 /**
  * returns the evaluations list for all the orders made the date $date
  *
  * @param string $date
  * @param int $numpage page number to read
  * @param string $mode answer mode
  * @param bool $repFT display FT answer or not
  * @return string script response
  */
 public function getValidstackByDate($date, $numpage, $mode = Sac::CONSULT_MODE_MINI, $repFT = '0')
 {
     //checks the date format
     if (!preg_match('#^[0-9]{2}/[0-1][0-9]/[0-9]{4}$#', $date)) {
         $msg = "La date '{$date}' n'est pas au bon format. Format attendu : dd/mm/YYYY";
         CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, $msg);
         throw new Exception($msg);
     }
     $data = array('SiteID' => $this->getSiteId(), 'Pwd' => $this->getPassword(), 'Mode' => $mode, 'RepFT' => $repFT, 'DtStack' => $date, 'Ind' => $numpage);
     return $this->getValidstack($data);
 }
Esempio n. 11
0
 /**
  * Get all SoColissimo delivery information
  * 
  * @param type $id_order
  * @return array 
  */
 public function getSoColissimoInfo($id_order)
 {
     if (_PS_VERSION_ >= '1.5') {
         //check if socolissimo is enabled on PS 1.5
         $socolissimo_is_enabled = Module::isEnabled('socolissimo');
     } else {
         //check if socolissimo is enabled on PS 1.4
         $socolissimo_is_enabled = $this->checkModuleisEnabled('socolissimo');
     }
     if (Module::isInstalled('socolissimo') || $socolissimo_is_enabled) {
         $sql = "SELECT * FROM `" . _DB_PREFIX_ . "socolissimo_delivery_info` WHERE `id_cart`= " . (int) $id_order;
         $query_result = Db::getInstance()->executeS($sql);
         return $query_result;
     } else {
         CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Module SoColissimo non installé ou non activé");
         return false;
     }
 }