Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • vtiger/vtigercrm
  • varma/vtigercrm
  • alanbell/vtigercrm
  • mariusz.krzaczkowski/vtigercrm
  • manu.k/vtigercrm
  • adrgranado/vtigercrm
  • uma.s/vtigercrm
  • sardoj/vtigercrm
  • preexo/vtigercrm
  • david.valminos/vtigercrm
  • luca.saba/vtigercrm
  • dubwise/vtigercrm
  • valmir.ttcasolucoes/vtigercrm
  • lord_alan/vtigercrm
  • adrien.futschik/vtigercrm
  • edonit.rexhepi/vtigercrm
  • robert.heinze/vtigercrm
  • nrdimatteo/vtigercrm
  • sebastianzahan/vtigercrm
  • Miky/vtigercrm
  • germanf/vtigercrm
  • bernhardkau1/vtigercrm
  • olegtsoy/vtigercrm
  • grandel/vtigercrm
  • mario.thummler/vtigercrm
  • sutharsan/vtigercrm
  • james.douglas/vtigercrm
  • vikas/vtigercrm
  • jeffmchristensen/vtigercrm
  • lukasz.g/vtigercrm
  • nicolas.gasnier/vtigercrm
  • hamish.theitcompany/vtigercrm
  • engrbm87/vtigercrm
  • Quoc/vtigercrm
  • peter.maria.engeli/vtigercrm
  • kiranraju.j/vtigercrm
  • manuel.lozano/vtigercrm
  • dhaupin/vtigercrm
  • Ragupathyranesh/vtigercrm
  • Stefanbauer/vtigercrm
  • ruben.estrada/vtigercrm
  • sg_mwi1/vtigercrm
  • khaluk/vtigercrm
  • franzfroemel/vtigercrm
  • milan9615/vtigercrm
  • carlos.martin/vtigercrm
  • cmaggi/vtigercrm
  • Soltoon.theLeader/vtigercrm
  • alex.kaplun/vtigercrm
  • navid.hosseini/vtigercrm
  • maie/vtigercrm
  • simonetravaglini/vtigercrm
  • bertrand.wattel/vtigercrm
  • balaji.m/vtigercrm
  • mclarke4/vtigercrm
  • lajeeshk/vtigercrm
  • liam/vtigercrm
  • novikov.sergey/vtigercrm
  • johnwayne.williamson/vtigercrm
  • florian.strahberger-schramm/vtigercrm
  • daniel.schaefer/vtigercrm
  • christopher.gunther/vtigercrm
  • adrien.faveraux/vtigercrm
  • carsten.brandt/vtigercrm
  • stephane.molano/vtigercrm
  • krastan.petrov/vtigercrm
  • alfredo.bravo/vtigercrm
  • flipflop.Joe/vtigercrm
  • mirko.stagni/vtigercrm
  • remigio.ruberto/vtigercrm
  • gautam.dhudashiya/vtigercrm
  • manish.devitechnosolutions1/vtigercrm
  • matinbeigi/vtigercrm
  • devs/vtigercrm
  • happy.dev/vtigercrm
  • m.gigon/vtigercrm
  • manuelmigone/vtigercrm
  • eduardo.gqf/vtigercrm
  • elsayedEl-araby/vtigercrm
  • mirza.mehran/vtigercrm
  • maurice.courtois/vtigercrm
  • zuhri.utama/vtigercrm
  • shilpa.k/vtigercrm
  • Ignazio/vtigercrm
  • code80team/vtigercrm
  • code80/vtigercrm
  • nilay.automatesmb/cache
  • greeshma.kk/vtigercrm
  • vijay.tilak/vtigercrm
  • Paolo.Palamini/vtigercrm
  • estevan/vtigercrm
  • mobilcmcdk/vtigercrm
  • massimiliano.vessi/vtigercrm
  • daniel.voelskow/vtigercrm
  • james1/vtigercrm
  • lokesh.s/vtigercrm
  • rdb/vtigercrm
  • neftaliyagua/vtigercrm
  • angelo.paglialonga/vtigercrm
  • webmarka/vtigercrm
  • javanile/vtigercrm
  • akshath/vtigercrm
  • Hemanth/vtigercrm
  • opencrmitalia/vtigercrm
  • direzione/vtigercrm
  • umadas306/vtigercrm
  • jd-wraptec/vtigercrm
  • felipe.camacho/vtigercrm
  • Martin.allen/vtigercrm
  • amit.r/vtigercrm
  • vicus/vtigercrm
  • dev.osmi/vtigercrm
  • laurent.guillout/vtigercrm
  • christian.blaeul/vtigercrm
  • ap.js100/vtigercrm
  • yoann.mourot/vtigercrm-temp
  • christian.cruz/vtigercrm
  • zyli/vtigercrm
  • kaushik.p/vtigercrm
  • Madhuk/vtigercrm
  • cinakzm/vtigercrm
  • raquel.martinez/vtigercrm
  • tosajibadhi/vtigercrm
  • melvin.i/vtigercrm-melvin
  • ashashingadia/vtigercrm
  • stefanwarnat/vtigercrm
  • saran.s/vtigercrm
  • eduardomozart/vtigercrm
  • Daniel.Lennartz1/vtigercrm
  • juergen.fassmann/vtigercrm
  • Michel.Ram/vtigercrm
  • vincenzo.bruno/vtigercrm
132 results
Show changes
Commits on Source (51)
Showing
with 326 additions and 962 deletions
vendor/*
!vendor/.htaccess
Vtiger CRM
==========
# Vtiger CRM
Vtiger is a PHP based web application that enables businesses to increase sales wins, marketing ROI, and support satisfaction by providing tools for employees and management work more effectively, capture more data, and derive new actionable insights from across the customer lifecycle.
Get involved
------------
## Get involved
Development on vtiger is done at https://code.vtiger.com
......@@ -40,6 +38,8 @@ you will switch to that branch using the checkout command
git branch fix_projects_on_calendar
git checkout fix_projects_on_calendar
Before you install, you need to run ```composer update```
Now you can make your changes and commit all changed files with
git commit -a
......
{
"name": "vtiger/vtigercrm",
"description": "Vtiger CRM",
"type": "project",
"license": "VPL",
"authors": [
{
"name": "Vtiger",
"email": "info@vtiger.com"
}
],
"autoload": {
"files": ["includes/Loader.php"]
},
"minimum-stability": "stable",
"require": {
"php": ">=7.2.0",
"ext-mysqli": "*",
"ext-imap": "*",
"ext-curl": "*",
"smarty/smarty": "^4.3",
"dg/rss-php": "^1.5",
"ezyang/htmlpurifier": "^4.16",
"tecnickcom/tcpdf": "^6.6"
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "74af97ed9d563a7f2dd29a31b422cbe4",
"packages": [
{
"name": "dg/rss-php",
"version": "v1.5",
"source": {
"type": "git",
"url": "https://github.com/dg/rss-php.git",
"reference": "18f00ab1828948a8cfe107729ca1f11c20129b47"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dg/rss-php/zipball/18f00ab1828948a8cfe107729ca1f11c20129b47",
"reference": "18f00ab1828948a8cfe107729ca1f11c20129b47",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"php": ">=5.3"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
}
],
"description": "RSS & Atom Feeds for PHP is a very small and easy-to-use library for consuming an RSS and Atom feed",
"homepage": "https://github.com/dg/rss-php",
"keywords": [
"atom",
"feed",
"rss"
],
"support": {
"source": "https://github.com/dg/rss-php/tree/v1.5"
},
"time": "2020-11-25T22:57:16+00:00"
},
{
"name": "ezyang/htmlpurifier",
"version": "v4.16.0",
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/523407fb06eb9e5f3d59889b3978d5bfe94299c8",
"reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8",
"shasum": ""
},
"require": {
"php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0"
},
"require-dev": {
"cerdic/css-tidy": "^1.7 || ^2.0",
"simpletest/simpletest": "dev-master"
},
"suggest": {
"cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.",
"ext-bcmath": "Used for unit conversion and imagecrash protection",
"ext-iconv": "Converts text to and from non-UTF-8 encodings",
"ext-tidy": "Used for pretty-printing HTML"
},
"type": "library",
"autoload": {
"files": [
"library/HTMLPurifier.composer.php"
],
"psr-0": {
"HTMLPurifier": "library/"
},
"exclude-from-classmap": [
"/library/HTMLPurifier/Language/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-or-later"
],
"authors": [
{
"name": "Edward Z. Yang",
"email": "admin@htmlpurifier.org",
"homepage": "http://ezyang.com"
}
],
"description": "Standards compliant HTML filter written in PHP",
"homepage": "http://htmlpurifier.org/",
"keywords": [
"html"
],
"support": {
"issues": "https://github.com/ezyang/htmlpurifier/issues",
"source": "https://github.com/ezyang/htmlpurifier/tree/v4.16.0"
},
"time": "2022-09-18T07:06:19+00:00"
},
{
"name": "smarty/smarty",
"version": "v4.3.2",
"source": {
"type": "git",
"url": "https://github.com/smarty-php/smarty.git",
"reference": "1d9cda2be34fd6edb74924684260636fd0b89288"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/smarty-php/smarty/zipball/1d9cda2be34fd6edb74924684260636fd0b89288",
"reference": "1d9cda2be34fd6edb74924684260636fd0b89288",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^7.5",
"smarty/smarty-lexer": "^3.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
}
},
"autoload": {
"classmap": [
"libs/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"authors": [
{
"name": "Monte Ohrt",
"email": "monte@ohrt.com"
},
{
"name": "Uwe Tews",
"email": "uwe.tews@googlemail.com"
},
{
"name": "Rodney Rehm",
"email": "rodney.rehm@medialize.de"
},
{
"name": "Simon Wisselink",
"homepage": "https://www.iwink.nl/"
}
],
"description": "Smarty - the compiling PHP template engine",
"homepage": "https://smarty-php.github.io/smarty/",
"keywords": [
"templating"
],
"support": {
"forum": "https://github.com/smarty-php/smarty/discussions",
"issues": "https://github.com/smarty-php/smarty/issues",
"source": "https://github.com/smarty-php/smarty/tree/v4.3.2"
},
"time": "2023-07-19T10:27:36+00:00"
},
{
"name": "tecnickcom/tcpdf",
"version": "6.6.2",
"source": {
"type": "git",
"url": "https://github.com/tecnickcom/TCPDF.git",
"reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/e3cffc9bcbc76e89e167e9eb0bbda0cab7518459",
"reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"classmap": [
"config",
"include",
"tcpdf.php",
"tcpdf_parser.php",
"tcpdf_import.php",
"tcpdf_barcodes_1d.php",
"tcpdf_barcodes_2d.php",
"include/tcpdf_colors.php",
"include/tcpdf_filters.php",
"include/tcpdf_font_data.php",
"include/tcpdf_fonts.php",
"include/tcpdf_images.php",
"include/tcpdf_static.php",
"include/barcodes/datamatrix.php",
"include/barcodes/pdf417.php",
"include/barcodes/qrcode.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-only"
],
"authors": [
{
"name": "Nicola Asuni",
"email": "info@tecnick.com",
"role": "lead"
}
],
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
"homepage": "http://www.tcpdf.org/",
"keywords": [
"PDFD32000-2008",
"TCPDF",
"barcodes",
"datamatrix",
"pdf",
"pdf417",
"qrcode"
],
"support": {
"issues": "https://github.com/tecnickcom/TCPDF/issues",
"source": "https://github.com/tecnickcom/TCPDF/tree/6.6.2"
},
"funding": [
{
"url": "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20tcpdf%20project",
"type": "custom"
}
],
"time": "2022-12-17T10:28:59+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.2.0",
"ext-mysqli": "*",
"ext-imap": "*",
"ext-curl": "*"
},
"platform-dev": [],
"plugin-api-version": "2.2.0"
}
......@@ -22,6 +22,11 @@ include('config.inc.php');
$THIS_DIR = dirname(__FILE__);
/* Pre-install overrides */
if (!isset($dbconfig)) {
error_reporting(E_ERROR & ~E_NOTICE & ~E_DEPRECATED);
}
if (file_exists($THIS_DIR.'/config_override.php')) {
include_once $THIS_DIR.'/config_override.php';
}
......
......@@ -2398,7 +2398,7 @@ class CRMEntity {
where vtiger_role.parentrole like '" . $current_user_parent_role_seq . "::%') or vtiger_crmentity.smownerid
in(select shareduserid from vtiger_tmp_read_user_sharing_per
where userid=" . $current_user->id . " and tabid=" . $tabid . ") or (";
if (sizeof($current_user_groups) > 0) {
if (php7_sizeof($current_user_groups) > 0) {
$sec_query .= " vtiger_crmentity.smownerid in (" . implode(",", $current_user_groups) . ") or ";
}
$sec_query .= " vtiger_crmentity.smownerid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid
......@@ -3121,7 +3121,7 @@ class TrackableObject implements ArrayAccess, IteratorAggregate {
}
function offsetExists($key) {
return isset($this->storage[$key]);
return isset($this->storage[$key]) || array_key_exists($key, $this->storage);
}
function offsetSet($key, $value) {
......@@ -3142,7 +3142,7 @@ class TrackableObject implements ArrayAccess, IteratorAggregate {
}
public function offsetGet($key) {
return isset($this->storage[$key]) ? $this->storage[$key] : null;
return isset($this->storage[$key]) || array_key_exists($key, $this->storage) ? $this->storage[$key] : null;
}
public function getIterator() {
......
......@@ -1379,7 +1379,7 @@ class QueryGenerator {
global $mod_strings;
// Get all the keys for the for the Picklist value
$mod_keys = array_keys($mod_strings, $value);
if(sizeof($mod_keys) >= 1) {
if(php7_sizeof($mod_keys) >= 1) {
// Iterate on the keys, to get the first key which doesn't start with LBL_ (assuming it is not used in PickList)
foreach($mod_keys as $mod_idx=>$mod_key) {
$stridx = strpos($mod_key, 'LBL_');
......
......@@ -72,7 +72,7 @@ function vtws_create($elementType, $element, $user) {
if ($meta->hasMandatoryFields($element)) {
$ownerFields = $meta->getOwnerFields();
if (is_array($ownerFields) && sizeof($ownerFields) > 0) {
if (is_array($ownerFields) && php7_sizeof($ownerFields) > 0) {
foreach ($ownerFields as $ownerField) {
if (isset($element[$ownerField]) && $element[$ownerField] !== null &&
!$meta->hasAssignPrivilege($element[$ownerField])) {
......
......@@ -78,7 +78,7 @@
$meta->isUpdateMandatoryFields($element);
$ownerFields = $meta->getOwnerFields();
if(is_array($ownerFields) && sizeof($ownerFields) >0){
if(is_array($ownerFields) && php7_sizeof($ownerFields) >0){
foreach($ownerFields as $ownerField){
if(isset($element[$ownerField]) && $element[$ownerField]!==null &&
!$meta->hasAssignPrivilege($element[$ownerField])){
......
......@@ -79,7 +79,7 @@
$meta->hasMandatoryFields($element);
$ownerFields = $meta->getOwnerFields();
if(is_array($ownerFields) && sizeof($ownerFields) >0){
if(is_array($ownerFields) && php7_sizeof($ownerFields) >0){
foreach($ownerFields as $ownerField){
if(isset($element[$ownerField]) && $element[$ownerField]!==null &&
!$meta->hasAssignPrivilege($element[$ownerField])){
......
......@@ -12,7 +12,7 @@ incState($lexer);
}
function incState($lexer){
$lexer->current_state++;
if($lexer->current_state === sizeof($lexer->mandatory_states)){
if($lexer->current_state === php7_sizeof($lexer->mandatory_states)){
$lexer->mandatory = false;
}
}
......
......@@ -208,14 +208,14 @@ function buildSelectStmt($sqlDump){
// ensure init before use
if(!isset($sqlDump['where_condition']['operators'])) $sqlDump['where_condition']['operators'] = array();
if((sizeof($sqlDump['where_condition']['column_names']) ==
sizeof($sqlDump['where_condition']['column_values'])) &&
(sizeof($sqlDump['where_condition']['column_operators']) == sizeof($sqlDump['where_condition']['operators'])+1)){
if((php7_sizeof($sqlDump['where_condition']['column_names']) ==
php7_sizeof($sqlDump['where_condition']['column_values'])) &&
(php7_sizeof($sqlDump['where_condition']['column_operators']) == php7_sizeof($sqlDump['where_condition']['operators'])+1)){
$this->query = $this->query.' WHERE (';
$i=0;
$referenceFields = $meta->getReferenceFieldDetails();
$ownerFields = $meta->getOwnerFields();
for(;$i<sizeof($sqlDump['where_condition']['column_values']);++$i){
for(;$i<php7_sizeof($sqlDump['where_condition']['column_values']);++$i){
if(!$fieldcol[$sqlDump['where_condition']['column_names'][$i]]){
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to access ".$sqlDump['where_condition']['column_names'][$i]." attribute denied.");
}
......@@ -256,7 +256,7 @@ function buildSelectStmt($sqlDump){
}
$this->query = $this->query.$columnTable[$fieldcol[$whereField]].'.'.
$fieldcol[$whereField]." ".$whereOperator." ".$whereValue;
if($i <sizeof($sqlDump['where_condition']['column_values'])-1){
if($i <php7_sizeof($sqlDump['where_condition']['column_values'])-1){
$this->query = $this->query.' ';
$this->query = $this->query.$sqlDump['where_condition']['operators'][$i].' ';
}
......@@ -301,7 +301,7 @@ function buildSelectStmt($sqlDump){
if($sqlDump['limit']){
$i=0;
$offset =false;
if(sizeof($sqlDump['limit'])>1){
if(php7_sizeof($sqlDump['limit'])>1){
$offset = true;
}
$this->query = $this->query.' LIMIT ';
......@@ -1215,7 +1215,7 @@ $this->out['where_condition']['operators'][] = $this->yystack[$this->yyidx + 0]-
$this->out['columnDone']=true;
$this->out['where_condition']['column_names'][] = $this->yystack[$this->yyidx + -2]->minor;
if(strcmp($this->yystack[$this->yyidx + -2]->minor, 'id')===0){
$prev = $this->out['where_condition']['column_values'][sizeof($this->out['where_condition']['column_values'])-1];
$prev = $this->out['where_condition']['column_values'][php7_sizeof($this->out['where_condition']['column_values'])-1];
if(is_array($prev)){
$new = array();
foreach($prev as $ind=>$val){
......@@ -1223,21 +1223,21 @@ $val = trim($val,'\'"');
$value = vtws_getIdComponents($val);
$new[] = $value[1];
}
$this->out['where_condition']['column_values'][sizeof($this->out['where_condition']['column_values'])-1] = $new;
$this->out['where_condition']['column_values'][php7_sizeof($this->out['where_condition']['column_values'])-1] = $new;
}else{
$prev = trim($prev,'\'"');
$value = vtws_getIdComponents($prev);
if(strcasecmp($this->out['where_condition']['column_operators'][sizeof($this->out['where_condition']['column_operators'])-1],'like')===0){
if(strcasecmp($this->out['where_condition']['column_operators'][php7_sizeof($this->out['where_condition']['column_operators'])-1],'like')===0){
$value[1] = "'".$value[1]."'";
}
$this->out['where_condition']['column_values'][sizeof($this->out['where_condition']['column_values'])-1] = $value[1];
$this->out['where_condition']['column_values'][php7_sizeof($this->out['where_condition']['column_values'])-1] = $value[1];
}
}
}
#line 1240 "e:\workspace\nonadmin\pkg\vtiger\extensions\Webservices\VTQL_parser.php"
#line 82 "e:\workspace\nonadmin\pkg\vtiger\extensions\Webservices\VTQL_parser.y"
function yy_r17(){
$length = ($this->out['where_condition']['column_values'])? sizeof($this->out['where_condition']['column_values']):0;
$length = ($this->out['where_condition']['column_values'])? php7_sizeof($this->out['where_condition']['column_values']):0;
$pos = $length - 1;
if($pos < 0){
$pos = 0;
......
......@@ -412,7 +412,7 @@ class WebserviceField{
}else{
$user = VTWS_PreserveGlobal::getGlobal('current_user');
$details = getPickListValues($fieldName,$user->roleid);
for($i=0;$i<sizeof($details);++$i){
for($i=0;$i<php7_sizeof($details);++$i){
$elem = array();
$picklistValue = decode_html($details[$i]);
$elem["label"] = getTranslatedString($picklistValue, $moduleName, $language);
......
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Crypt
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Crypt.php 25024 2012-07-30 15:08:15Z rob $
*/
/**
* @category Zend
* @package Zend_Crypt
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Crypt
{
const TYPE_OPENSSL = 'openssl';
const TYPE_HASH = 'hash';
const TYPE_MHASH = 'mhash';
protected static $_type = null;
/**
* @var array
*/
protected static $_supportedAlgosOpenssl = array(
'md2',
'md4',
'mdc2',
'rmd160',
'sha',
'sha1',
'sha224',
'sha256',
'sha384',
'sha512'
);
/**
* @var array
*/
protected static $_supportedAlgosMhash = array(
'adler32',
'crc32',
'crc32b',
'gost',
'haval128',
'haval160',
'haval192',
'haval256',
'md4',
'md5',
'ripemd160',
'sha1',
'sha256',
'tiger',
'tiger128',
'tiger160'
);
/**
* @param string $algorithm
* @param string $data
* @param bool $binaryOutput
* @return unknown
*/
public static function hash($algorithm, $data, $binaryOutput = false)
{
$algorithm = strtolower($algorithm);
if (function_exists($algorithm)) {
return $algorithm($data, $binaryOutput);
}
self::_detectHashSupport($algorithm);
$supportedMethod = '_digest' . ucfirst(self::$_type);
$result = self::$supportedMethod($algorithm, $data, $binaryOutput);
return $result;
}
/**
* @param string $algorithm
* @throws Zend_Crypt_Exception
*/
protected static function _detectHashSupport($algorithm)
{
if (function_exists('hash')) {
self::$_type = self::TYPE_HASH;
if (in_array($algorithm, hash_algos())) {
return;
}
}
if (function_exists('mhash')) {
self::$_type = self::TYPE_MHASH;
if (in_array($algorithm, self::$_supportedAlgosMhash)) {
return;
}
}
if (function_exists('openssl_digest')) {
if ($algorithm == 'ripemd160') {
$algorithm = 'rmd160';
}
self::$_type = self::TYPE_OPENSSL;
if (in_array($algorithm, self::$_supportedAlgosOpenssl)) {
return;
}
}
/**
* @see Zend_Crypt_Exception
*/
require_once 'Zend/Crypt/Exception.php';
throw new Zend_Crypt_Exception('\'' . $algorithm . '\' is not supported by any available extension or native function');
}
/**
* @param string $algorithm
* @param string $data
* @param bool $binaryOutput
* @return string
*/
protected static function _digestHash($algorithm, $data, $binaryOutput)
{
return hash($algorithm, $data, $binaryOutput);
}
/**
* @param string $algorithm
* @param string $data
* @param bool $binaryOutput
* @return string
*/
protected static function _digestMhash($algorithm, $data, $binaryOutput)
{
$constant = constant('MHASH_' . strtoupper($algorithm));
$binary = mhash($constant, $data);
if ($binaryOutput) {
return $binary;
}
return bin2hex($binary);
}
/**
* @param string $algorithm
* @param string $data
* @param bool $binaryOutput
* @return string
*/
protected static function _digestOpenssl($algorithm, $data, $binaryOutput)
{
if ($algorithm == 'ripemd160') {
$algorithm = 'rmd160';
}
return openssl_digest($data, $algorithm, $binaryOutput);
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Crypt
* @subpackage DiffieHellman
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DiffieHellman.php 24593 2012-01-05 20:35:02Z matthew $
*/
/**
* PHP implementation of the Diffie-Hellman public key encryption algorithm.
* Allows two unassociated parties to establish a joint shared secret key
* to be used in encrypting subsequent communications.
*
* @category Zend
* @package Zend_Crypt
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Crypt_DiffieHellman
{
/**
* Static flag to select whether to use PHP5.3's openssl extension
* if available.
*
* @var boolean
*/
public static $useOpenssl = true;
/**
* Default large prime number; required by the algorithm.
*
* @var string
*/
private $_prime = null;
/**
* The default generator number. This number must be greater than 0 but
* less than the prime number set.
*
* @var string
*/
private $_generator = null;
/**
* A private number set by the local user. It's optional and will
* be generated if not set.
*
* @var string
*/
private $_privateKey = null;
/**
* BigInteger support object courtesy of Zend_Crypt_Math
*
* @var Zend_Crypt_Math_BigInteger
*/
private $_math = null;
/**
* The public key generated by this instance after calling generateKeys().
*
* @var string
*/
private $_publicKey = null;
/**
* The shared secret key resulting from a completed Diffie Hellman
* exchange
*
* @var string
*/
private $_secretKey = null;
/**
* Constants
*/
const BINARY = 'binary';
const NUMBER = 'number';
const BTWOC = 'btwoc';
/**
* Constructor; if set construct the object using the parameter array to
* set values for Prime, Generator and Private.
* If a Private Key is not set, one will be generated at random.
*
* @param string $prime
* @param string $generator
* @param string $privateKey
* @param string $privateKeyType
* @return void
*/
public function __construct($prime, $generator, $privateKey = null, $privateKeyType = self::NUMBER)
{
$this->setPrime($prime);
$this->setGenerator($generator);
if ($privateKey !== null) {
$this->setPrivateKey($privateKey, $privateKeyType);
}
$this->setBigIntegerMath();
}
/**
* Generate own public key. If a private number has not already been
* set, one will be generated at this stage.
*
* @return Zend_Crypt_DiffieHellman
*/
public function generateKeys()
{
if (function_exists('openssl_dh_compute_key') && self::$useOpenssl !== false) {
$details = array();
$details['p'] = $this->getPrime();
$details['g'] = $this->getGenerator();
if ($this->hasPrivateKey()) {
$details['priv_key'] = $this->getPrivateKey();
}
$opensslKeyResource = openssl_pkey_new( array('dh' => $details) );
$data = openssl_pkey_get_details($opensslKeyResource);
$this->setPrivateKey($data['dh']['priv_key'], self::BINARY);
$this->setPublicKey($data['dh']['pub_key'], self::BINARY);
} else {
// Private key is lazy generated in the absence of PHP 5.3's ext/openssl
$publicKey = $this->_math->powmod($this->getGenerator(), $this->getPrivateKey(), $this->getPrime());
$this->setPublicKey($publicKey);
}
return $this;
}
/**
* Setter for the value of the public number
*
* @param string $number
* @param string $type
* @return Zend_Crypt_DiffieHellman
*/
public function setPublicKey($number, $type = self::NUMBER)
{
if ($type == self::BINARY) {
$number = $this->_math->fromBinary($number);
}
if (!preg_match("/^\d+$/", $number)) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
}
$this->_publicKey = (string) $number;
return $this;
}
/**
* Returns own public key for communication to the second party to this
* transaction.
*
* @param string $type
* @return string
*/
public function getPublicKey($type = self::NUMBER)
{
if ($this->_publicKey === null) {
require_once 'Zend/Crypt/DiffieHellman/Exception.php';
throw new Zend_Crypt_DiffieHellman_Exception('A public key has not yet been generated using a prior call to generateKeys()');
}
if ($type == self::BINARY) {
return $this->_math->toBinary($this->_publicKey);
} elseif ($type == self::BTWOC) {
return $this->_math->btwoc($this->_math->toBinary($this->_publicKey));
}
return $this->_publicKey;
}
/**
* Compute the shared secret key based on the public key received from the
* the second party to this transaction. This should agree to the secret
* key the second party computes on our own public key.
* Once in agreement, the key is known to only to both parties.
* By default, the function expects the public key to be in binary form
* which is the typical format when being transmitted.
*
* If you need the binary form of the shared secret key, call
* getSharedSecretKey() with the optional parameter for Binary output.
*
* @param string $publicKey
* @param string $type
* @return mixed
*/
public function computeSecretKey($publicKey, $type = self::NUMBER, $output = self::NUMBER)
{
if ($type == self::BINARY) {
$publicKey = $this->_math->fromBinary($publicKey);
}
if (!preg_match("/^\d+$/", $publicKey)) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
}
if (function_exists('openssl_dh_compute_key') && self::$useOpenssl !== false) {
$this->_secretKey = openssl_dh_compute_key($publicKey, $this->getPublicKey());
} else {
$this->_secretKey = $this->_math->powmod($publicKey, $this->getPrivateKey(), $this->getPrime());
}
return $this->getSharedSecretKey($output);
}
/**
* Return the computed shared secret key from the DiffieHellman transaction
*
* @param string $type
* @return string
*/
public function getSharedSecretKey($type = self::NUMBER)
{
if (!isset($this->_secretKey)) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('A secret key has not yet been computed; call computeSecretKey()');
}
if ($type == self::BINARY) {
return $this->_math->toBinary($this->_secretKey);
} elseif ($type == self::BTWOC) {
return $this->_math->btwoc($this->_math->toBinary($this->_secretKey));
}
return $this->_secretKey;
}
/**
* Setter for the value of the prime number
*
* @param string $number
* @return Zend_Crypt_DiffieHellman
*/
public function setPrime($number)
{
if (!preg_match("/^\d+$/", $number) || $number < 11) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number or too small: should be a large natural number prime');
}
$this->_prime = (string) $number;
return $this;
}
/**
* Getter for the value of the prime number
*
* @return string
*/
public function getPrime()
{
if (!isset($this->_prime)) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('No prime number has been set');
}
return $this->_prime;
}
/**
* Setter for the value of the generator number
*
* @param string $number
* @return Zend_Crypt_DiffieHellman
*/
public function setGenerator($number)
{
if (!preg_match("/^\d+$/", $number) || $number < 2) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number greater than 1');
}
$this->_generator = (string) $number;
return $this;
}
/**
* Getter for the value of the generator number
*
* @return string
*/
public function getGenerator()
{
if (!isset($this->_generator)) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('No generator number has been set');
}
return $this->_generator;
}
/**
* Setter for the value of the private number
*
* @param string $number
* @param string $type
* @return Zend_Crypt_DiffieHellman
*/
public function setPrivateKey($number, $type = self::NUMBER)
{
if ($type == self::BINARY) {
$number = $this->_math->fromBinary($number);
}
if (!preg_match("/^\d+$/", $number)) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
}
$this->_privateKey = (string) $number;
return $this;
}
/**
* Getter for the value of the private number
*
* @param string $type
* @return string
*/
public function getPrivateKey($type = self::NUMBER)
{
if (!$this->hasPrivateKey()) {
$this->setPrivateKey($this->_generatePrivateKey(), self::BINARY);
}
if ($type == self::BINARY) {
return $this->_math->toBinary($this->_privateKey);
} elseif ($type == self::BTWOC) {
return $this->_math->btwoc($this->_math->toBinary($this->_privateKey));
}
return $this->_privateKey;
}
/**
* Check whether a private key currently exists.
*
* @return boolean
*/
public function hasPrivateKey()
{
return isset($this->_privateKey);
}
/**
* Setter to pass an extension parameter which is used to create
* a specific BigInteger instance for a specific extension type.
* Allows manual setting of the class in case of an extension
* problem or bug.
*
* @param string $extension
* @return void
*/
public function setBigIntegerMath($extension = null)
{
/**
* @see Zend_Crypt_Math
*/
require_once 'Zend/Crypt/Math.php';
$this->_math = new Zend_Crypt_Math($extension);
}
/**
* In the event a private number/key has not been set by the user,
* or generated by ext/openssl, a best attempt will be made to
* generate a random key. Having a random number generator installed
* on linux/bsd is highly recommended! The alternative is not recommended
* for production unless without any other option.
*
* @return string
*/
protected function _generatePrivateKey()
{
$rand = $this->_math->rand($this->getGenerator(), $this->getPrime());
return $rand;
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Crypt
* @subpackage DiffieHellman
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 24593 2012-01-05 20:35:02Z matthew $
*/
/**
* @see Zend_Crypt_Exception
*/
require_once 'Zend/Crypt/Exception.php';
/**
* @category Zend
* @package Zend_Crypt
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Crypt_DiffieHellman_Exception extends Zend_Crypt_Exception
{
}
\ No newline at end of file
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Crypt
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 24593 2012-01-05 20:35:02Z matthew $
*/
/**
* @see Zend_Exception
*/
require_once 'Zend/Exception.php';
/**
* @category Zend
* @package Zend_Crypt
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Crypt_Exception extends Zend_Exception
{
}
\ No newline at end of file
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Crypt
* @subpackage Hmac
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Hmac.php 24593 2012-01-05 20:35:02Z matthew $
*/
/**
* @see Zend_Crypt
*/
require_once 'Zend/Crypt.php';
/**
* PHP implementation of the RFC 2104 Hash based Message Authentication Code
* algorithm.
*
* @todo Patch for refactoring failed tests (key block sizes >80 using internal algo)
* @todo Check if mhash() is a required alternative (will be PECL-only soon)
* @category Zend
* @package Zend_Crypt
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Crypt_Hmac extends Zend_Crypt
{
/**
* The key to use for the hash
*
* @var string
*/
protected static $_key = null;
/**
* pack() format to be used for current hashing method
*
* @var string
*/
protected static $_packFormat = null;
/**
* Hashing algorithm; can be the md5/sha1 functions or any algorithm name
* listed in the output of PHP 5.1.2+ hash_algos().
*
* @var string
*/
protected static $_hashAlgorithm = 'md5';
/**
* List of algorithms supported my mhash()
*
* @var array
*/
protected static $_supportedMhashAlgorithms = array('adler32',' crc32', 'crc32b', 'gost',
'haval128', 'haval160', 'haval192', 'haval256', 'md4', 'md5', 'ripemd160',
'sha1', 'sha256', 'tiger', 'tiger128', 'tiger160');
/**
* Constants representing the output mode of the hash algorithm
*/
const STRING = 'string';
const BINARY = 'binary';
/**
* Performs a HMAC computation given relevant details such as Key, Hashing
* algorithm, the data to compute MAC of, and an output format of String,
* Binary notation or BTWOC.
*
* @param string $key
* @param string $hash
* @param string $data
* @param string $output
* @param boolean $internal
* @return string
*/
public static function compute($key, $hash, $data, $output = self::STRING)
{
// set the key
if (!isset($key) || empty($key)) {
require_once 'Zend/Crypt/Hmac/Exception.php';
throw new Zend_Crypt_Hmac_Exception('provided key is null or empty');
}
self::$_key = $key;
// set the hash
self::_setHashAlgorithm($hash);
// perform hashing and return
return self::_hash($data, $output);
}
/**
* Setter for the hash method.
*
* @param string $hash
* @return Zend_Crypt_Hmac
*/
protected static function _setHashAlgorithm($hash)
{
if (!isset($hash) || empty($hash)) {
require_once 'Zend/Crypt/Hmac/Exception.php';
throw new Zend_Crypt_Hmac_Exception('provided hash string is null or empty');
}
$hash = strtolower($hash);
$hashSupported = false;
if (function_exists('hash_algos') && in_array($hash, hash_algos())) {
$hashSupported = true;
}
if ($hashSupported === false && function_exists('mhash') && in_array($hash, self::$_supportedAlgosMhash)) {
$hashSupported = true;
}
if ($hashSupported === false) {
require_once 'Zend/Crypt/Hmac/Exception.php';
throw new Zend_Crypt_Hmac_Exception('hash algorithm provided is not supported on this PHP installation; please enable the hash or mhash extensions');
}
self::$_hashAlgorithm = $hash;
}
/**
* Perform HMAC and return the keyed data
*
* @param string $data
* @param string $output
* @param bool $internal Option to not use hash() functions for testing
* @return string
*/
protected static function _hash($data, $output = self::STRING, $internal = false)
{
if (function_exists('hash_hmac')) {
if ($output == self::BINARY) {
return hash_hmac(self::$_hashAlgorithm, $data, self::$_key, 1);
}
return hash_hmac(self::$_hashAlgorithm, $data, self::$_key);
}
if (function_exists('mhash')) {
if ($output == self::BINARY) {
return mhash(self::_getMhashDefinition(self::$_hashAlgorithm), $data, self::$_key);
}
$bin = mhash(self::_getMhashDefinition(self::$_hashAlgorithm), $data, self::$_key);
return bin2hex($bin);
}
}
/**
* Since MHASH accepts an integer constant representing the hash algorithm
* we need to make a small detour to get the correct integer matching our
* algorithm's name.
*
* @param string $hashAlgorithm
* @return integer
*/
protected static function _getMhashDefinition($hashAlgorithm)
{
for ($i = 0; $i <= mhash_count(); $i++)
{
$types[mhash_get_hash_name($i)] = $i;
}
return $types[strtoupper($hashAlgorithm)];
}
}
\ No newline at end of file
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Crypt
* @subpackage Hmac
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 24593 2012-01-05 20:35:02Z matthew $
*/
/**
* @see Zend_Crypt_Exception
*/
require_once 'Zend/Crypt/Exception.php';
/**
* @category Zend
* @package Zend_Crypt
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Crypt_Hmac_Exception extends Zend_Crypt_Exception
{
}
\ No newline at end of file
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Crypt
* @subpackage Math
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Math.php 24593 2012-01-05 20:35:02Z matthew $
*/
/**
* @see Zend_Crypt_Math_BigInteger
*/
require_once 'Zend/Crypt/Math/BigInteger.php';
/**
* @category Zend
* @package Zend_Crypt
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Crypt_Math extends Zend_Crypt_Math_BigInteger
{
/**
* Generate a pseudorandom number within the given range.
* Will attempt to read from a systems RNG if it exists or else utilises
* a simple random character to maximum length process. Simplicity
* is a factor better left for development...
*
* @param string|int $minimum
* @param string|int $maximum
* @return string
*/
public function rand($minimum, $maximum)
{
if (file_exists('/dev/urandom')) {
$frandom = fopen('/dev/urandom', 'r');
if ($frandom !== false) {
return fread($frandom, strlen($maximum) - 1);
}
}
if (strlen($maximum) < 4) {
return mt_rand($minimum, $maximum - 1);
}
$rand = '';
$i2 = strlen($maximum) - 1;
for ($i = 1;$i < $i2;$i++) {
$rand .= mt_rand(0,9);
}
$rand .= mt_rand(0,9);
return $rand;
}
/**
* Get the big endian two's complement of a given big integer in
* binary notation
*
* @param string $long
* @return string
*/
public function btwoc($long) {
if (ord($long[0]) > 127) {
return "\x00" . $long;
}
return $long;
}
/**
* Translate a binary form into a big integer string
*
* @param string $binary
* @return string
*/
public function fromBinary($binary) {
return $this->_math->binaryToInteger($binary);
}
/**
* Translate a big integer string into a binary form
*
* @param string $integer
* @return string
*/
public function toBinary($integer)
{
return $this->_math->integerToBinary($integer);
}
}