当前位置:首页 > CMS教程 > UCenter > 列表

ucenter忘记密码以后如何找回,重置更新密码源码

发布:smiling 来源: PHP粉丝网  添加日期:2014-04-22 10:57:31 浏览: 评论:0 

将以下内容另存为.php格式,放在ucenter根目录即可重置修改你的管理密码,用完记得删除.

  1. <?php 
  2. define(ROOT_DIR,dirname(__FILE__)."/"); 
  3. if(!file_exists('./data/config.inc.php') || !is_writeable('./data')){ 
  4.    $isucdir= 0; 
  5.    echo 'UCenter创始人密码重置工具必须放在UCenter根目录下才能正常使用.'; 
  6.    exit; 
  7.  
  8. }else{ 
  9.    $isucdir = 1; 
  10. } 
  11. $info=""; 
  12. setucadministrator(); 
  13. function setucadministrator(){ 
  14. global $isucdir; 
  15. global $info; 
  16. if($_POST['setucsubmit']){ 
  17.  
  18.    if($isucdir){ 
  19.     $configfile = ROOT_DIR."./data/config.inc.php"; 
  20.     $uc_password = $_POST["uc_password"]; 
  21.     $salt = substr(uniqid(rand()), 0, 6); 
  22.     if(!$uc_password){ 
  23.      $info = "密码不能为空"; 
  24.     
  25.     }else{ 
  26.     
  27.      $md5_uc_password = md5(md5($uc_password).$salt); 
  28.      $config = file_get_contents($configfile); 
  29.      $config = preg_replace("/define\('UC_FOUNDERSALT',\s*'.*?'\);/i", "define('UC_FOUNDERSALT', '$salt');", $config); 
  30.      $config = preg_replace("/define\('UC_FOUNDERPW',\s*'.*?'\);/i", "define('UC_FOUNDERPW', '$md5_uc_password');", $config); 
  31.      $fp = @fopen($configfile, 'w'); 
  32.      @fwrite($fp, $config); 
  33.      @fclose($fp); 
  34.      $info = "UCenter创始人密码更改成功为:$uc_password"; 
  35.     } 
  36.    }else{ 
  37.     $info = "本程序文件放置在UCenter跟目录,才能通过程序修改UCenter创始人管理员的密码<br />"; 
  38.    } 
  39. } 
  40. templates("setucadministrator"); 
  41. } 
  42. function errorpage($message,$title = '',$isheader = 1,$isfooter = 1){ 
  43.    $message = "<h4>$title</h4><br><br><table><tr><th> 提示信息</th></tr><tr><td>$message</td>< /tr></table>"; 
  44.    echo $message; 
  45.    exit; 
  46. } 
  47. function templates($tpl){ 
  48. switch ($tpl){ 
  49.    case "header": 
  50.     echo '<html> 
  51.     <head> 
  52.     <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
  53.     <title>UCenter 创始人密码更改工具</title> 
  54.     <style type="text/css"> 
  55.     <!-- 
  56.     body {font-family: Arial, Helvetica, sans-serif, "宋体";font-size: 12px;color:#000;line-height: 120%;padding:0;margin:0;background:#DDE0FF;overflow-x:hidden;word-break:break-all;white-space:normal;scrollbar-3d-light-color:#606BFF;scrollbar-highlight-color:#E3 EFF9;scrollbar-face-color:#CEE3F4;scrollbar-arrow-color:#509AD8;scrollbar-shadow-color:#F0F1FF;scrollbar-base-color:#CEE3F4;} 
  57.     a:hover {color:#60F;} 
  58.     ul {padding:2px 0 10px 0;margin:0;} 
  59.     textarea,table,td,th,select{border:1px solid #868CFF;border-collapse:collapse;} 
  60.     input{margin:10px 0 0px 30px;border-width:1px;border-style:solid;border-color:#FFF #64A7DD #64A7DD #FFF;padding:2px 8px;background:#E3EFF9;} 
  61.     input.radio,input.checkbox,input.textinput,input.specialsubmit {margin:0;padding:0;border:0;padding:0;background:none;} 
  62.     input.textinput,input.specialsubmit {border:1px solid #AFD2ED;background:#FFF;height:24px;} 
  63.     input.textinput {padding:4px 0;}     input.specialsubmit {border-color:#FFF #64A7DD #64A7DD #FFF;background:#E3EFF9;padding:0 5px;} 
  64.     option {background:#FFF;} 
  65.     select {background:#F0F1FF;} 
  66.     #header {height:60px;width:100%;padding:0;margin:0;} 
  67.       h2 {font-size:24px;font-weight:bold;position:absolute;top:24px;left:20px;padding:10px;margin:0;} 
  68.       h3 {font-size:14px;position:absolute;top:28px;right:20px;padding:10px;margin:0;} 
  69.     #content {height:510px;background:#F0F1FF;overflow-x:hidden;z-index:1000;} 
  70.       #nav {top:60px;left:0;height:510px;width:180px;border-right:1px solid #DDE0FF;position:absolute;z-index:2000;} 
  71.           #nav ul {padding:0 10px;padding-top:30px;} 
  72.           #nav li {list-style:none;} 
  73.           #nav li a {font-size:14px;line-height:180%;font-weight:400;color:#000;} 
  74.           #nav li a:hover {color:#60F;} 
  75.       #textcontent {padding-left:200px;height:510px;width:100%;line-height:160%;overflow-y:auto;overflow-x:hidden;} 
  76.        h4,h5,h6 {padding:4px;font-size:16px;font-weight:bold;margin-top:20px;margin-bottom:5px;color:#006;} 
  77.      h5,h6 {font-size:14px;color:#000;} 
  78.      h6 {color:#F00;padding-top:5px;margin-top:0;} 
  79.      .specialdiv {width:70%;border:1px dashed #C8CCFF;padding:0 5px;margin-top:20px;background:#F9F9FF;} 
  80.      #textcontent ul {margin-left:30px;} 
  81.      textarea {width:78%;height:320px;text-align:left;border-color:#AFD2ED;} 
  82.      select {border-color:#AFD2ED;} 
  83.      table {width:74%;font-size:12px;margin-left:18px;margin-top:10px;} 
  84.         table.specialtable,table.specialtable td {border:0;} 
  85.       td,th {padding:5px;text-align:left;} 
  86.         caption {font-weight:bold;padding:8px 0;color:#3544FF;text-align:left;} 
  87.         th {background:#D9DCFF;font-weight:600;} 
  88.       td.specialtd {text-align:left;} 
  89.      .specialtext {background:#FCFBFF;margin-top:20px;padding:5px 40px;width:64.5%;margin-bottom:10px;color:#006;} 
  90.     #footer p {padding:0 5px;text-align:center;} 
  91.     --> 
  92.     </style> 
  93.     </head> 
  94.     <body> 
  95.    
  96.    
  97.     <div id="content"> 
  98.     <div id="textcontent">'; 
  99.     break; 
  100.    case "footer": 
  101.     echo ' 
  102.       </div></div> 
  103.       <div id="footer"><p>UCenter 创始人密码更改工具 &nbsp; 
  104.       版权所有 &copy;2001-2007 <a href="http://www.comsenz.com" style="color: #888888; text-decoration: none"> 
  105.       康盛创想(北京)科技有限公司 Comsenz Inc.</a></font></td></tr><tr style="font-size: 0px; line-height: 0px; spacing: 0px; padding: 0px; background-color: #698CC3"> 
  106.       </p></div> 
  107.       </body> 
  108.       </html>'; 
  109.     exit; 
  110.     break; 
  111.  
  112.    case "setucadministrator": 
  113.     templates("header"); 
  114.     if(!emptyempty($_POST['setucsubmit'])){ 
  115.      echo "<h5>UCenter 创始人密码更改工具</h5><h5> <font color=red>使用完毕后请及时删除本文件,以免给您造成不必要的损失</font></h5>"; 
  116.      echo '<form action="?action=setadmin" method="post"><input type="hidden" name="action" value="login" />'; 
  117.      global $info; 
  118.      errorpage($info,'',0,0); 
  119.      echo '</form>'; 
  120.     }else{ 
  121.      echo '<form action="?action=setucadministrator" method="post"> 
  122.      <h5>UCenter 创始人密码更改工具</h5> 
  123.      <h5> <font color=red>使用完毕后请及时删除本文件,以免给您造成不必要的损失</font></h5> 
  124.      <table> 
  125.      <tr><th width="30%">用户名</th><td width="70%"><input class="textinput" readonly="readonly" disabled type="text" name="username" size="25" maxlength="40" value="UCenter Administrator"></td></tr> 
  126.      <tr><th width="30%">请输入密码</th><td width="70%"><input class="textinput" type="text" name="uc_password" size="25"></td></tr> 
  127.     
  128.      </table> 
  129.      <input type="submit" name="setucsubmit" value="提 &nbsp; 交"> 
  130.      </form>'; 
  131.     } 
  132.     templates("footer"); 
  133.     break; 
  134. } 
  135. } 
  136. ?> 

将这个文件另存为php后上传到ucenter目录运行即可.

Tags: ucenter 更新密码 源码

分享到: