Location: PHPKode > projects > OpenBizMap > obm2007.1/mydata/script/run_forgot.txt
<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

$passwd_array=array();

$passwd_array=unserialize(base64_decode(file_get_contents(cfg_sso_path.'/data/.passwd.txt')));

$antibot='';
if(file_exists(cfg_sso_path.'/temp/antibot/'.$sid))
  $antibot=file_get_contents(cfg_sso_path.'/temp/antibot/'.$sid);

$user=get('username');
if((!$antibot or (strtolower($antibot)==strtolower(get('antibot')))) and isset($passwd_array[md5(purename($user.'email'))]))// and $passwd_array[md5(purename(get('username').email))]==strtolower(get('email')))
{
  $email=$passwd_array[md5(purename($user.'email'))]; //get('email');
  $rand_password='';
  for($ii=0;$ii<12;$ii++)
  {
    $letter1='ACDEFGHJKLMNPQRSTUWXYZabcdefghijkmnpqrstuwxyz123456789';
    $letter1=$letter1[rand(0,strlen($letter1)-1)];
    $rand_password.=$letter1;
  }

  sendmail($email,'passreset',array('USERNAME' => $user, 'PASSWORD' => $rand_password));
  mylog('PASSWORD RESET '.$user);

  $passwd_array[md5(purename(get('username')))]=md5(purename(get('username')).$rand_password);
  //$rand_password='';

  $fp=fopen(cfg_sso_path.'/data/.passwd.txt','w');
  fwrite($fp,base64_encode(serialize($passwd_array)));
  fclose($fp);
}
else
{
  if($antibot and strtolower($antibot)!=strtolower(get('antibot')))
  {
    $message='Antibot';
    mylog('PASSWORD RESET CANCELLED ('.$message.')');
  }

  if(!isset($passwd_array[md5(purename(get('username').email))]))//!=strtolower(get('email')))
  {
    $message='Wrong username';// / email';
    mylog('PASSWORD RESET CANCELLED ('.$message.')');
  }
}

$passwd_array=array();

?>
Return current item: OpenBizMap