Skip to content

Commit

Permalink
//norms
Browse files Browse the repository at this point in the history
  • Loading branch information
PrestaEdit committed Mar 2, 2015
1 parent fabb6fe commit f566785
Show file tree
Hide file tree
Showing 115 changed files with 1,453 additions and 1,577 deletions.
4 changes: 2 additions & 2 deletions classes/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function validateController($htmlentities = true)
*/
public static function getZoneById($id_address)
{
if(!isset($id_address) || empty($id_address))
if (!isset($id_address) || empty($id_address))
return false;

if (isset(self::$_idZones[$id_address]))
Expand Down Expand Up @@ -273,7 +273,7 @@ public static function getZoneById($id_address)
*/
public static function isCountryActiveById($id_address)
{
if(!isset($id_address) || empty($id_address))
if (!isset($id_address) || empty($id_address))
return false;

$cache_id = 'Address::isCountryActiveById_'.(int)$id_address;
Expand Down
2 changes: 1 addition & 1 deletion classes/AddressFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public static function generateAddress(Address $address, $patternRules = array()
$addressText .= (!empty($tmpText)) ? $tmpText.$newLine: '';
}

$addressText = preg_replace('/'.preg_quote($newLine,'/').'$/i', '', $addressText);
$addressText = preg_replace('/'.preg_quote($newLine, '/').'$/i', '', $addressText);
$addressText = rtrim($addressText, $separator);

return $addressText;
Expand Down
196 changes: 95 additions & 101 deletions classes/AdminTab.php

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions classes/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function __construct($id = null, $alias = null, $search = null, $id_lang

if ($row)
{
$this->id = (int)($row['id_alias']);
$this->search = $search ? trim($search) : $row['search'];
$this->id = (int)$row['id_alias'];
$this->search = $search ? trim($search) : $row['search'];
$this->alias = $row['alias'];
}
else
Expand Down Expand Up @@ -144,5 +144,4 @@ public static function aliasExists($id_alias)

return isset($row['id_alias']);
}
}

}
25 changes: 12 additions & 13 deletions classes/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ class AttachmentCore extends ObjectModel
'file_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 128),
'file_size' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),

// Lang fields
/* Lang fields */
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),
'description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml'),
),
);

public function add($autodate = true, $null_values = false)
{
$this->file_size = filesize(_PS_DOWNLOAD_DIR_.$this->file);
return parent::add($autodate, $null_values);
}

public function update($null_values = false)
{
$this->file_size = filesize(_PS_DOWNLOAD_DIR_.$this->file);
Expand Down Expand Up @@ -124,26 +124,26 @@ public static function deleteProductAttachments($id_product)
WHERE id_product = '.(int)$id_product);

Product::updateCacheAttachment((int)$id_product);

return $res;
}

/**
* associate $id_product to the current object.
*
*
* @param int $id_product id of the product to associate
* @return boolean true if succed
*/
public function attachProduct($id_product)
{
$res = Db::getInstance()->execute('
INSERT INTO '._DB_PREFIX_.'product_attachment
INSERT INTO '._DB_PREFIX_.'product_attachment
(id_attachment, id_product) VALUES
('.(int)$this->id.', '.(int)$id_product.')');

Product::updateCacheAttachment((int)$id_product);
return $res;

return $res;
}

/**
Expand All @@ -170,11 +170,11 @@ public static function attachToProduct($id_product, $array)
$result2 = Db::getInstance()->insert('product_attachment', $ids);

}

Product::updateCacheAttachment((int)$id_product);
if (is_array($array))
return ($result1 && (!isset($result2) || $result2));

return $result1;
}

Expand All @@ -199,5 +199,4 @@ public static function getProductAttached($id_lang, $list)
else
return false;
}
}

}
2 changes: 1 addition & 1 deletion classes/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AttributeCore extends ObjectModel
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'),
'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),

// Lang fields
/* Lang fields */
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
)
);
Expand Down
15 changes: 7 additions & 8 deletions classes/AttributeGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

class AttributeGroupCore extends ObjectModel
{
/** @var string Name */
/** @var string Name */
public $name;
public $is_color_group;
public $position;
Expand All @@ -47,7 +47,7 @@ class AttributeGroupCore extends ObjectModel
'group_type' => array('type' => self::TYPE_STRING, 'required' => true),
'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),

// Lang fields
/* Lang fields */
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
'public_name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64),
),
Expand All @@ -74,7 +74,7 @@ public function add($autodate = true, $nullValues = false)
$this->is_color_group = 1;
else
$this->is_color_group = 0;

if ($this->position <= 0)
$this->position = AttributeGroup::getHigherPosition() + 1;

Expand All @@ -89,12 +89,12 @@ public function update($nullValues = false)
$this->is_color_group = 1;
else
$this->is_color_group = 0;

$return = parent::update($nullValues);
Hook::exec('actionAttributeGroupSave', array('id_attribute_group' => $this->id));
return $return;
}

public static function cleanDeadCombinations()
{
$attribute_combinations = Db::getInstance()->executeS('
Expand Down Expand Up @@ -141,7 +141,7 @@ public function delete()
/* Remove combinations if they do not possess attributes anymore */
if (!AttributeGroup::cleanDeadCombinations())
return false;
/* Also delete related attributes */
/* Also delete related attributes */
if (count($to_remove))
if (!Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'attribute_lang`
Expand Down Expand Up @@ -333,5 +333,4 @@ public static function getHigherPosition()
$position = DB::getInstance()->getValue($sql);
return (is_numeric($position)) ? $position : -1;
}
}

}
64 changes: 35 additions & 29 deletions classes/Blowfish.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,33 @@

class BlowfishCore extends Crypt_Blowfish
{
function encrypt($plaintext)
public function encrypt($plaintext)
{
if (($length = strlen($plaintext)) >= 1048576)
if (($length = strlen($plaintext)) >= 1048576)
return false;

$ciphertext = '';
$paddedtext = $this->maxi_pad($plaintext);
$strlen = strlen($paddedtext);
for($x = 0; $x < $strlen; $x += 8)
for ($x = 0; $x < $strlen; $x += 8)
{
$piece = substr($paddedtext, $x, 8);
$cipher_piece = parent::encrypt($piece);
$encoded = base64_encode($cipher_piece);
$encoded = base64_encode($cipher_piece);
$ciphertext = $ciphertext.$encoded;
}
return $ciphertext.sprintf('%06d', $length);
return $ciphertext.sprintf('%06d', $length);
}

function decrypt($ciphertext)
public function decrypt($ciphertext)
{
$plainTextLength = intval(substr($ciphertext, -6));
$ciphertext = substr($ciphertext, 0, -6);

$plaintext = '';
$chunks = explode('=', $ciphertext);
$ending_value = sizeof($chunks) ;
for($counter = 0; $counter < ($ending_value - 1); $counter++)
$ending_value = count($chunks);
for ($counter = 0; $counter < ($ending_value - 1); $counter++)
{
$chunk = $chunks[$counter].'=';
$decoded = base64_decode($chunk);
Expand All @@ -64,12 +64,12 @@ function decrypt($ciphertext)
}
return substr($plaintext, 0, $plainTextLength);
}
function maxi_pad($plaintext)

public function maxi_pad($plaintext)
{
$str_len = sizeof($plaintext);
$str_len = count($plaintext);
$pad_len = $str_len % 8;
for($x = 0; $x < $pad_len; $x++)
for ($x = 0; $x < $pad_len; $x++)
$plaintext = $plaintext.' ';
return $plaintext;
}
Expand Down Expand Up @@ -353,11 +353,11 @@ class Crypt_Blowfish
)
);

var $_iv = NULL;
var $_iv = null;

protected $_unpackMode = PS_UNPACK_NATIVE;

function __construct($key, $iv)
public function __construct($key, $iv)
{
$_iv = $iv;

Expand All @@ -368,7 +368,7 @@ function __construct($key, $iv)
$datal = 0;
$datar = 0;

if (PHP_VERSION_ID == '50201' OR PHP_VERSION_ID == '50206')
if (PHP_VERSION_ID == '50201' || PHP_VERSION_ID == '50206')
$this->_unpackMode = PS_UNPACK_MODIFIED;

for ($i = 0; $i < 18; $i++)
Expand All @@ -382,36 +382,42 @@ function __construct($key, $iv)
$this->_P[$i] ^= $data;
}

for ($i = 0; $i <= 16; $i += 2) {
for ($i = 0; $i <= 16; $i += 2)
{
$this->_encipher($datal, $datar);
$this->_P[$i] = $datal;
$this->_P[$i+1] = $datar;
}
for ($i = 0; $i < 256; $i += 2) {
for ($i = 0; $i < 256; $i += 2)
{
$this->_encipher($datal, $datar);
$this->_S[0][$i] = $datal;
$this->_S[0][$i+1] = $datar;
}
for ($i = 0; $i < 256; $i += 2) {
for ($i = 0; $i < 256; $i += 2)
{
$this->_encipher($datal, $datar);
$this->_S[1][$i] = $datal;
$this->_S[1][$i+1] = $datar;
}
for ($i = 0; $i < 256; $i += 2) {
for ($i = 0; $i < 256; $i += 2)
{
$this->_encipher($datal, $datar);
$this->_S[2][$i] = $datal;
$this->_S[2][$i+1] = $datar;
}
for ($i = 0; $i < 256; $i += 2) {
for ($i = 0; $i < 256; $i += 2)
{
$this->_encipher($datal, $datar);
$this->_S[3][$i] = $datal;
$this->_S[3][$i+1] = $datar;
}
}

function _encipher(&$Xl, &$Xr)
public function _encipher(&$Xl, &$Xr)
{
for ($i = 0; $i < 16; $i++) {
for ($i = 0; $i < 16; $i++)
{
$temp = $Xl ^ $this->_P[$i];
$Xl = ((($this->_S[0][($temp>>24) & 255] +
$this->_S[1][($temp>>16) & 255]) ^
Expand All @@ -423,7 +429,7 @@ function _encipher(&$Xl, &$Xr)
$Xl = $temp ^ $this->_P[17];
}

function _decipher(&$Xl, &$Xr)
public function _decipher(&$Xl, &$Xr)
{
for ($i = 17; $i > 1; $i--)
{
Expand All @@ -438,7 +444,7 @@ function _decipher(&$Xl, &$Xr)
$Xl = $temp ^ $this->_P[0];
}

function encrypt($plainText)
public function encrypt($plainText)
{
$cipherText = '';
$len = strlen($plainText);
Expand All @@ -452,7 +458,7 @@ function encrypt($plainText)
return $cipherText;
}

function decrypt($cipherText)
public function decrypt($cipherText)
{
$plainText = '';
$len = strlen($cipherText);
Expand All @@ -466,15 +472,15 @@ function decrypt($cipherText)
return $plainText;
}

function myUnpackN($str)
public function myUnpackN($str)
{
if (pack('L', 0x6162797A) == pack('V', 0x6162797A))
return ((ord($str) << 24) | (ord(substr($str, 1)) << 16) | (ord(substr($str, 2)) << 8) | ord(substr($str, 3)));
else
return (ord($str) | (ord(substr($str, 1)) << 8) | (ord(substr($str, 2)) << 16) | (ord(substr($str, 3)) << 24));
}

function myUnpackN2($str)
public function myUnpackN2($str)
{
return array('1' => $this->myUnpackN($str), '2' => $this->myUnpackN(substr($str, 4)));
}
Expand Down
Loading

0 comments on commit f566785

Please sign in to comment.