本文整理汇总了PHP中dol_hash函数的典型用法代码示例。如果您正苦于以下问题:PHP dol_hash函数的具体用法?PHP dol_hash怎么用?PHP dol_hash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dol_hash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_to_spip
/**
* Fonction qui donne les droits redacteurs dans spip
*
* @param Object $object Object with data (->firstname, ->lastname, ->email and ->login)
* @return int =0 if KO, >0 if OK
*/
function add_to_spip($object)
{
dol_syslog(get_class($this)."::add_to_spip");
if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 &&
defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' &&
defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' &&
defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' &&
defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != ''
)
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
$mdpass=dol_hash($object->pass);
$htpass=crypt($object->pass,makesalt());
$query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$object->firstname." ".$object->lastname."\",\"".$object->email."\",\"".$object->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")";
$mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT);
if (! $mydb->ok)
{
$this->error=$mydb->lasterror();
return 0;
}
$result = $mydb->query($query);
if ($result)
{
$mydb->close();
return 1;
}
else
{
$this->error=$mydb->lasterror();
return 0;
}
}
}
示例2: dol_getprefix
/**
* Return a prefix to use for this Dolibarr instance for session or cookie names.
* This prefix is unique for instance and avoid conflict between multi-instances,
* even when having two instances with one root dir or two instances in virtual servers
*
* @return string A calculated prefix
*/
function dol_getprefix()
{
return dol_hash($_SERVER["SERVER_NAME"] . $_SERVER["DOCUMENT_ROOT"] . DOL_DOCUMENT_ROOT . DOL_URL_ROOT);
}
示例3: dol_print_error
if (empty($PAYPAL_API_PASSWORD)) {
dol_print_error('', "Paypal setup param PAYPAL_API_PASSWORD not defined");
return -1;
}
if (empty($PAYPAL_API_SIGNATURE)) {
dol_print_error('', "Paypal setup param PAYPAL_API_SIGNATURE not defined");
return -1;
}
// Check security token
$valid = true;
if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) {
if (!empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
if ($SOURCE && $REF) {
$token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $SOURCE . $REF, 2);
} else {
$token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
}
} else {
$token = $conf->global->PAYPAL_SECURITY_TOKEN;
}
if ($SECUREKEY != $token) {
$valid = false;
}
if (!$valid) {
print '<div class="error">Bad value for key.</div>';
//print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid;
exit;
}
}
/*
* Actions
示例4: add_to_spip
/**
* Fonction qui donne les droits redacteurs dans spip
*
* @param Adherent $object Object with data (->firstname, ->lastname, ->email and ->login)
* @return int =0 if KO, >0 if OK
*/
function add_to_spip($object)
{
dol_syslog(get_class($this) . "::add_to_spip");
if ($this->isSpipEnabled()) {
if ($this->checkSpipConfig()) {
$mydb = $this->connectSpip();
if ($mydb) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
$mdpass = dol_hash($object->pass);
$htpass = crypt($object->pass, makesalt());
$query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"" . dolGetFirstLastname($object->firstname, $object->lastname) . "\",\"" . $object->email . "\",\"" . $object->login . "\",\"{$mdpass}\",\"{$htpass}\",FLOOR(32000*RAND()),\"1comite\")";
$result = $mydb->query($query);
$mydb->close();
if ($result) {
return 1;
} else {
$this->error = $mydb->lasterror();
}
} else {
$this->error = 'Failed to connect to SPIP';
}
} else {
$this->error = 'BadSPIPConfiguration';
}
} else {
$this->error = 'SPIPNotEnabled';
}
return 0;
}
示例5: getRandomPassword
/**
* Return a generated password using default module
*
* @param boolean $generic true=Create generic password (use default crypt function), false=Use the configured password generation module
* @return string New value for password
*/
function getRandomPassword($generic = false)
{
global $db, $conf, $langs, $user;
$generated_password = '';
if ($generic) {
$generated_password = dol_hash(mt_rand());
} else {
if (!empty($conf->global->USER_PASSWORD_GENERATED)) {
$nomclass = "modGeneratePass" . ucfirst($conf->global->USER_PASSWORD_GENERATED);
$nomfichier = $nomclass . ".class.php";
//print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass;
require_once DOL_DOCUMENT_ROOT . "/core/modules/security/generate/" . $nomfichier;
$genhandler = new $nomclass($db, $conf, $langs, $user);
$generated_password = $genhandler->getNewGeneratedPassword();
unset($genhandler);
}
}
return $generated_password;
}
示例6: explode
$tmpfield = explode('=', $other[1], 2);
$other2 = isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0];
$tmpfield = explode('=', $other[2], 2);
$other3 = isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0];
$tmpfield = explode('=', $other[3], 2);
$other4 = isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0];
$tmpfield = explode('=', $other[4], 2);
$other5 = isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0];
// Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions)
$substitutionarray = array('__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, '__LASTNAME__' => $obj->lastname, '__FIRSTNAME__' => $obj->firstname, '__MAILTOEMAIL__' => '<a href="mailto:' . $obj->email . '">' . $obj->email . '</a>', '__OTHER1__' => $other1, '__OTHER2__' => $other2, '__OTHER3__' => $other3, '__OTHER4__' => $other4, '__OTHER5__' => $other5, '__CHECK_READ__' => '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $obj->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>', '__UNSUBSCRIBE__' => '<a href="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-unsubscribe.php?tag=' . $obj->tag . '&unsuscrib=1&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" target="_blank">' . $langs->trans("MailUnsubcribe") . '</a>');
if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) {
$substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
$substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
} else {
$substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
}
}
$substitutionisok = true;
complete_substitutions_array($substitutionarray, $langs);
$newsubject = make_substitutions($subject, $substitutionarray);
$newmessage = make_substitutions($message, $substitutionarray);
$arr_file = array();
$arr_mime = array();
$arr_name = array();
$arr_css = array();
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
if (count($listofpaths)) {
foreach ($listofpaths as $key => $val) {
$arr_file[] = $listofpaths[$key]['fullname'];
$arr_mime[] = dol_mimetype($listofpaths[$key]['name']);
示例7: User
/**
* Actions
*/
// Validate new password
if ($action == 'validatenewpassword' && $username && $passwordmd5)
{
$edituser = new User($db);
$result=$edituser->fetch('',$_GET["username"]);
if ($result < 0)
{
$message = '<div class="error">'.$langs->trans("ErrorLoginDoesNotExists",$username).'</div>';
}
else
{
if (dol_hash($edituser->pass_temp) == $passwordmd5)
{
$newpassword=$edituser->setPassword($user,$edituser->pass_temp,0);
dol_syslog("passwordforgotten.php new password for user->id=".$edituser->id." validated in database");
header("Location: ".DOL_URL_ROOT.'/');
exit;
}
else
{
$message = '<div class="error">'.$langs->trans("ErrorFailedToValidatePassword").'</div>';
}
}
}
// Action modif mot de passe
if ($action == 'buildnewpassword' && $username)
{
示例8: send_password
/**
* Send new password by email
*
* @param User $user Object user that send email
* @param string $password New password
* @param int $changelater 1=Change password only after clicking on confirm email
* @return int < 0 si erreur, > 0 si ok
*/
function send_password($user, $password = '', $changelater = 0)
{
global $conf, $langs;
global $dolibarr_main_url_root;
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
$msgishtml = 0;
// Define $msg
$mesg = '';
$outputlangs = new Translate("", $conf);
if (isset($this->conf->MAIN_LANG_DEFAULT) && $this->conf->MAIN_LANG_DEFAULT != 'auto') {
// If user has defined its own language (rare because in most cases, auto is used)
$outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT);
} else {
// If user has not defined its own language, we used current language
$outputlangs = $langs;
}
$outputlangs->load("main");
$outputlangs->load("errors");
$outputlangs->load("users");
$outputlangs->load("other");
$subject = $outputlangs->transnoentitiesnoconv("SubjectNewPassword");
// Define $urlwithroot
//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithroot = DOL_MAIN_URL_ROOT;
// This is to use same domain name than current
if (!$changelater) {
$mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived") . ".\n";
$mesg .= $outputlangs->transnoentitiesnoconv("NewKeyIs") . " :\n\n";
$mesg .= $outputlangs->transnoentitiesnoconv("Login") . " = " . $this->login . "\n";
$mesg .= $outputlangs->transnoentitiesnoconv("Password") . " = " . $password . "\n\n";
$mesg .= "\n";
$url = $urlwithroot . '/';
$mesg .= $outputlangs->transnoentitiesnoconv("ClickHereToGoTo", $conf->global->MAIN_APPLICATION_TITLE) . ': ' . $url . "\n\n";
$mesg .= "--\n";
$mesg .= $user->getFullName($outputlangs);
// Username that make then sending
} else {
$mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived") . "\n";
$mesg .= $outputlangs->transnoentitiesnoconv("NewKeyWillBe") . " :\n\n";
$mesg .= $outputlangs->transnoentitiesnoconv("Login") . " = " . $this->login . "\n";
$mesg .= $outputlangs->transnoentitiesnoconv("Password") . " = " . $password . "\n\n";
$mesg .= "\n";
$mesg .= $outputlangs->transnoentitiesnoconv("YouMustClickToChange") . " :\n";
$url = $urlwithroot . '/user/passwordforgotten.php?action=validatenewpassword&username=' . $this->login . "&passwordhash=" . dol_hash($password);
$mesg .= $url . "\n\n";
$mesg .= $outputlangs->transnoentitiesnoconv("ForgetIfNothing") . "\n\n";
dol_syslog(get_class($this) . "::send_password url=" . $url);
}
$mailfile = new CMailFile($subject, $this->email, $conf->notification->email_from, $mesg, array(), array(), array(), '', '', 0, $msgishtml);
if ($mailfile->sendfile()) {
return 1;
} else {
$langs->trans("errors");
$this->error = $langs->trans("ErrorFailedToSendPassword") . ' ' . $mailfile->error;
return -1;
}
}
示例9: showphoto
/**
* Return HTML code to output a photo
*
* @param string $modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto')
* @param object $object Object containing data to retrieve file name
* @param int $width Width of photo
* @return string HTML code to output photo
*/
function showphoto($modulepart, $object, $width = 100)
{
global $conf;
$entity = !empty($object->entity) ? $object->entity : $conf->entity;
$id = !empty($object->id) ? $object->id : $object->rowid;
$ret = '';
$dir = '';
$file = '';
$altfile = '';
$email = '';
if ($modulepart == 'societe') {
$dir = $conf->societe->multidir_output[$entity];
$smallfile = $object->logo;
$smallfile = preg_replace('/(\\.png|\\.gif|\\.jpg|\\.jpeg|\\.bmp)/i', '_small\\1', $smallfile);
if ($object->logo) {
$file = $id . '/logos/thumbs/' . $smallfile;
}
} else {
if ($modulepart == 'userphoto') {
$dir = $conf->user->dir_output;
if ($object->photo) {
$file = get_exdir($id, 2) . $object->photo;
}
if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
$altfile = $object->id . ".jpg";
}
// For backward compatibility
$email = $object->email;
} else {
if ($modulepart == 'memberphoto') {
$dir = $conf->adherent->dir_output;
if ($object->photo) {
$file = get_exdir($id, 2) . 'photos/' . $object->photo;
}
if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
$altfile = $object->id . ".jpg";
}
// For backward compatibility
$email = $object->email;
} else {
$dir = $conf->{$modulepart}->dir_output;
if ($object->photo) {
$file = get_exdir($id, 2) . 'photos/' . $object->photo;
}
if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
$altfile = $object->id . ".jpg";
}
// For backward compatibility
$email = $object->email;
}
}
}
if ($dir) {
$cache = '0';
if ($file && file_exists($dir . "/" . $file)) {
// TODO Link to large image
$ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($file) . '&cache=' . $cache . '">';
$ret .= '<img alt="Photo" id="photologo' . preg_replace('/[^a-z]/i', '_', $file) . '" class="photologo" border="0" width="' . $width . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($file) . '&cache=' . $cache . '">';
$ret .= '</a>';
} else {
if ($altfile && file_exists($dir . "/" . $altfile)) {
$ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($file) . '&cache=' . $cache . '">';
$ret .= '<img alt="Photo alt" id="photologo' . preg_replace('/[^a-z]/i', '_', $file) . '" class="photologo" border="0" width="' . $width . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($altfile) . '&cache=' . $cache . '">';
$ret .= '</a>';
} else {
if (!empty($conf->gravatar->enabled) && $email) {
global $dolibarr_main_url_root;
$ret .= '<!-- Put link to gravatar -->';
$ret .= '<img alt="Photo found on Gravatar" title="Photo Gravatar.com - email ' . $email . '" border="0" width="' . $width . '" src="http://www.gravatar.com/avatar/' . dol_hash($email, 3) . '?s=' . $width . '&d=' . urlencode(dol_buildpath('/theme/common/nophoto.jpg', 2)) . '">';
// gravatar need md5 hash
} else {
$ret .= '<img alt="No photo" border="0" width="' . $width . '" src="' . DOL_URL_ROOT . '/theme/common/nophoto.jpg">';
}
}
}
} else {
dol_print_error('', 'Call of showphoto with wrong parameters');
}
return $ret;
}
示例10: getPaypalPaymentUrl
/**
*
*/
function getPaypalPaymentUrl($source='',$ref='',$amount=0,$freetag='')
{
global $conf;
require_once(DOL_DOCUMENT_ROOT."/lib/security.lib.php");
if (! empty($source) && ! empty($ref))
{
$token='';
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) $token='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$source.$ref, 2);
if ($source == 'commande') $source = 'order';
if ($source == 'facture') $source = 'invoice';
$url = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source='.$source.'&ref='.$ref.$token;
return $url;
}
}
示例11: showphoto
//.........这里部分代码省略.........
$dir = $conf->adherent->dir_output;
if (!empty($object->photo)) {
if ((string) $imagesize == 'mini') {
$file = get_exdir($id, 2, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_mini');
} else {
if ((string) $imagesize == 'small') {
$file = get_exdir($id, 2, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_small');
} else {
$file = get_exdir($id, 2, 0, 0, $object, 'member') . 'photos/' . $object->photo;
}
}
$originalfile = get_exdir($id, 2, 0, 0, $object, 'member') . 'photos/' . $object->photo;
}
if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
$altfile = $object->id . ".jpg";
}
// For backward compatibility
$email = $object->email;
} else {
$dir = $conf->{$modulepart}->dir_output;
if (!empty($object->photo)) {
if ((string) $imagesize == 'mini') {
$file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_mini');
} else {
if ((string) $imagesize == 'small') {
$file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_small');
} else {
$file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo;
}
}
$originalfile = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo;
}
if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
$altfile = $object->id . ".jpg";
}
// For backward compatibility
$email = $object->email;
}
}
}
}
if ($dir) {
if ($file && file_exists($dir . "/" . $file)) {
if ($addlinktofullsize) {
$ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">';
}
$ret .= '<img alt="Photo" id="photologo' . preg_replace('/[^a-z]/i', '_', $file) . '" class="' . $cssclass . '" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($file) . '&cache=' . $cache . '">';
if ($addlinktofullsize) {
$ret .= '</a>';
}
} else {
if ($altfile && file_exists($dir . "/" . $altfile)) {
if ($addlinktofullsize) {
$ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">';
}
$ret .= '<img alt="Photo alt" id="photologo' . preg_replace('/[^a-z]/i', '_', $file) . '" class="' . $cssclass . '" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($altfile) . '&cache=' . $cache . '">';
if ($addlinktofullsize) {
$ret .= '</a>';
}
} else {
$nophoto = '/public/theme/common/nophoto.png';
if (in_array($modulepart, array('userphoto', 'contact'))) {
$nophoto = '/public/theme/common/user_anonymous.png';
if ($object->gender == 'man') {
$nophoto = '/public/theme/common/user_man.png';
}
if ($object->gender == 'woman') {
$nophoto = '/public/theme/common/user_woman.png';
}
}
if (!empty($conf->gravatar->enabled) && $email) {
/**
* @see https://gravatar.com/site/implement/images/php/
*/
global $dolibarr_main_url_root;
$ret .= '<!-- Put link to gravatar -->';
$ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="Gravatar avatar" title="' . $email . ' Gravatar avatar" border="0"' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="https://www.gravatar.com/avatar/' . dol_hash(strtolower(trim($email)), 3) . '?s=' . $width . '&d=' . urlencode(dol_buildpath($nophoto, 2)) . '">';
// gravatar need md5 hash
} else {
$ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . $nophoto . '">';
}
}
}
if ($caneditfield) {
if ($object->photo) {
$ret .= "<br>\n";
}
$ret .= '<table class="nobordernopadding hideonsmartphone">';
if ($object->photo) {
$ret .= '<tr><td align="center"><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> ' . $langs->trans("Delete") . '<br><br></td></tr>';
}
$ret .= '<tr><td>' . $langs->trans("PhotoFile") . '</td></tr>';
$ret .= '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
$ret .= '</table>';
}
} else {
dol_print_error('', 'Call of showphoto with wrong parameters');
}
return $ret;
}
示例12: getPaypalPaymentUrl
/**
* Return string with full Url
*
* @param int $mode 0=True url, 1=Url formated with colors
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...)
* @param string $ref Ref of object
* @param int $amount Amount
* @param string $freetag Free tag
* @return string Url string
*/
function getPaypalPaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_free_tag')
{
global $conf;
if ($type == 'free')
{
$out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':'');
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
else $out.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
}
}
if ($type == 'order')
{
$out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='order_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
else
{
$out.='&securekey='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + order + order_ref)";
if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'order' . $ref, 2);
$out.=($mode?'</font>':'');
}
}
}
if ($type == 'invoice')
{
$out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='invoice_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
else
{
$out.='&securekey='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + invoice + invoice_ref)";
if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'invoice' . $ref, 2);
$out.=($mode?'</font>':'');
}
}
}
if ($type == 'contractline')
{
$out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='contractline_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
else
{
$out.='&securekey='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + contactline + contractline_ref)";
if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $ref, 2);
$out.=($mode?'</font>':'');
}
}
}
if ($type == 'membersubscription')
{
$out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='member_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN;
else
{
$out.='&securekey='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + membersubscription + member_ref)";
if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $ref, 2);
$out.=($mode?'</font>':'');
}
}
}
return $out;
}
示例13: dolibarr_set_const
$error = 0;
$db->begin();
dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity);
$sql = "SELECT u.rowid, u.pass, u.pass_crypted";
$sql .= " FROM " . MAIN_DB_PREFIX . "user as u";
$sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32";
// Not a MD5 value
$resql = $db->query($sql);
if ($resql) {
$numrows = $db->num_rows($resql);
$i = 0;
while ($i < $numrows) {
$obj = $db->fetch_object($resql);
if (dol_hash($obj->pass)) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "user";
$sql .= " SET pass_crypted = '" . dol_hash($obj->pass) . "', pass = NULL";
$sql .= " WHERE rowid=" . $obj->rowid;
//print $sql;
$resql2 = $db->query($sql);
if (!$resql2) {
dol_print_error($db);
$error++;
break;
}
$i++;
}
}
} else {
dol_print_error($db);
}
//print $error." ".$sql;
示例14: dol_getprefix
/**
* Return a prefix to use for this Dolibarr instance for session or cookie names.
* This prefix is unique for instance and avoid conflict between multi-instances,
* even when having two instances with one root dir or two instances in virtual servers
*
* @return string A calculated prefix
*/
function dol_getprefix()
{
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) {
return dol_hash($_SERVER["SERVER_NAME"] . $_SERVER["DOCUMENT_ROOT"] . DOL_DOCUMENT_ROOT . DOL_URL_ROOT);
// Use this for a "clear" cookie name
//return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
} else {
return dol_hash(DOL_DOCUMENT_ROOT . DOL_URL_ROOT);
}
}
示例15: showphoto
/**
* Return HTML code to output a photo
*
* @param string $modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto')
* @param Object $object Object containing data to retrieve file name
* @param int $width Width of photo
* @return string HTML code to output photo
*/
function showphoto($modulepart, $object, $width = 100)
{
global $conf;
$ret = '';
$dir = '';
$file = '';
$altfile = '';
$email = '';
if ($modulepart == 'societe') {
$dir = $conf->societe->multidir_output[$object->entity];
$smallfile = $object->logo;
$smallfile = preg_replace('/(\\.png|\\.gif|\\.jpg|\\.jpeg|\\.bmp)/i', '_small\\1', $smallfile);
if ($object->logo) {
$file = $object->id . '/logos/thumbs/' . $smallfile;
}
} else {
if ($modulepart == 'userphoto') {
$dir = $conf->user->dir_output;
if ($object->photo) {
$file = get_exdir($object->id, 2) . $object->photo;
}
if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
$altfile = $object->id . ".jpg";
}
// For backward compatibility
$email = $object->email;
} else {
if ($modulepart == 'memberphoto') {
if ($object->photo) {
$file = $object->photo;
}
$email = $object->email;
}
}
}
if ($object->class) {
// Photo in the database
if ($file) {
$ret .= '<img alt="Photo" id="photologo' . preg_replace('/[^a-z]/i', '_', $file) . '" class="photologo" border="0" width="' . $width . '" src="' . $object->getFile($file) . '">';
} else {
$ret .= '<img alt="No photo" border="0" width="' . $width . '" src="' . DOL_URL_ROOT . '/theme/common/nophoto.jpg">';
}
} elseif ($dir) {
$cache = '0';
if ($file && file_exists($dir . "/" . $file)) {
// TODO Link to large image
$ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $object->entity . '&file=' . urlencode($file) . '&cache=' . $cache . '">';
$ret .= '<img alt="Photo" id="photologo' . preg_replace('/[^a-z]/i', '_', $file) . '" class="photologo" border="0" width="' . $width . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $object->entity . '&file=' . urlencode($file) . '&cache=' . $cache . '">';
$ret .= '</a>';
} elseif ($altfile && file_exists($dir . "/" . $altfile)) {
$ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $object->entity . '&file=' . urlencode($file) . '&cache=' . $cache . '">';
$ret .= '<img alt="Photo alt" id="photologo' . preg_replace('/[^a-z]/i', '_', $file) . '" class="photologo" border="0" width="' . $width . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $object->entity . '&file=' . urlencode($altfile) . '&cache=' . $cache . '">';
$ret .= '</a>';
} else {
if (!empty($conf->gravatar->enabled) && $email) {
global $dolibarr_main_url_root;
$ret .= '<!-- Put link to gravatar -->';
$ret .= '<img alt="Photo found on Gravatar" title="Photo Gravatar.com - email ' . $email . '" border="0" width="' . $width . '" src="http://www.gravatar.com/avatar/' . dol_hash($email) . '?s=' . $width . '&d=' . urlencode(dol_buildpath('/theme/common/nophoto.jpg', 2)) . '">';
} else {
$ret .= '<img alt="No photo" border="0" width="' . $width . '" src="' . DOL_URL_ROOT . '/theme/common/nophoto.jpg">';
}
}
} else {
dol_print_error('', 'Call of showphoto with wrong parameters');
}
/* Disabled. lightbox seems to not work. I don't know why.
$ret.="\n<script type=\"text/javascript\">
jQuery(function() {
jQuery('.photologo').lightBox();
});
</script>\n";
$ret.="\n<script type=\"text/javascript\">
jQuery(function() {
jQuery('.photologo').lightBox({
overlayBgColor: '#FFF',
overlayOpacity: 0.6,
imageLoading: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-ico-loading.gif',
imageBtnClose: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-close.gif',
imageBtnPrev: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-prev.gif',
imageBtnNext: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-next.gif',
containerResizeSpeed: 350,
txtImage: 'Imagem',
txtOf: 'de'
});
});
</script>\n";
*/
return $ret;
}