Skip to content

Commit

Permalink
Move security function into security.lib.php
Browse files Browse the repository at this point in the history
Split security.lib.php into 2 files: One always loaded, the other for
rare functions.
  • Loading branch information
eldy committed Feb 12, 2012
1 parent 2a5f299 commit 036e578
Show file tree
Hide file tree
Showing 17 changed files with 942 additions and 880 deletions.
3 changes: 2 additions & 1 deletion htdocs/adherents/class/adherent.class.php
Expand Up @@ -767,7 +767,8 @@ function setPassword($user, $password='', $isencrypted=0, $notrigger=0, $nosyncu
// If new password not provided, we generate one
if (! $password)
{
$password=getRandomPassword('');
require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
$password=getRandomPassword('');
}

// Cryptage mot de passe
Expand Down
3 changes: 2 additions & 1 deletion htdocs/adherents/fiche.php
Expand Up @@ -706,7 +706,8 @@
// Password
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
$generated_password=getRandomPassword('');
require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
$generated_password=getRandomPassword('');
print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
print '</td></tr>';
Expand Down
1 change: 1 addition & 0 deletions htdocs/admin/security.php
Expand Up @@ -24,6 +24,7 @@

require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");

$langs->load("users");
$langs->load("admin");
Expand Down
1 change: 1 addition & 0 deletions htdocs/cashdesk/class/Auth.class.php
Expand Up @@ -122,6 +122,7 @@ function verif($aLogin, $aPasswd)

if ($test && $goontestloop)
{
include_once(DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php');
$login = checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode);
if ($login)
{
Expand Down
19 changes: 10 additions & 9 deletions htdocs/contact/canvas/actions_contactcard_common.class.php
Expand Up @@ -42,10 +42,10 @@ abstract class ActionsContactCardCommon
//! Error array
var $errors=array();


/**
* Instantiation of DAO class
*
*
* @return void
*/
private function getInstanceDao()
Expand All @@ -66,7 +66,7 @@ private function getInstanceDao()
}
}
}

/**
* Get object
*
Expand All @@ -76,7 +76,7 @@ private function getInstanceDao()
function getObject($id)
{
$ret = $this->getInstanceDao();

if (is_object($this->object) && method_exists($this->object,'fetch'))
{
if (! empty($id)) $this->object->fetch($id);
Expand Down Expand Up @@ -192,7 +192,7 @@ function doActions(&$action, $id)
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$this->object->id);
exit;
}

if (empty($_POST["name"]))
{
$this->error=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
Expand Down Expand Up @@ -391,21 +391,22 @@ function assign_values(&$action)

$this->tpl['note'] = nl2br($this->object->note);
}

if ($action == 'create_user')
{
// Full firstname and name separated with a dot : firstname.name
include_once(DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
$login=dol_buildlogin($this->object->nom, $this->object->prenom);

$generated_password=getRandomPassword('');
$password=$generated_password;

// Create a form array
$formquestion=array(
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login),
array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password));

$this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion,'no');
}
}
Expand Down
3 changes: 2 additions & 1 deletion htdocs/contact/fiche.php
Expand Up @@ -705,7 +705,8 @@
$generated_password='';
if (! $ldap_sid) // TODO ldap_sid ?
{
$generated_password=getRandomPassword('');
require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
$generated_password=getRandomPassword('');
}
$password=$generated_password;

Expand Down
5 changes: 3 additions & 2 deletions htdocs/core/ajax/security.php
Expand Up @@ -43,11 +43,12 @@
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";

// Registering the location of boxes
if(isset($_GET['action']) && ! empty($_GET['action']))
if (isset($_GET['action']) && ! empty($_GET['action']))
{
if ($_GET['action'] == 'getrandompassword' && $user->admin)
{
$generic = $_GET['generic'];
require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
$generic = $_GET['generic'];
echo getRandomPassword($generic);
}
}
Expand Down

0 comments on commit 036e578

Please sign in to comment.