<?php
require ('authentication_manager.php');
?>
<?php

/* 管理商号 */
/* 162100源码 - 162100.com */



//处理关键字
function process_input() {
  $str = preg_replace('/[[:punct:]]/i', ' ', $_GET['keyword']);
  $str = preg_replace('/\pP/u', ' ', $str);
  $str=trim($str);
  //$str=str_replace(' ','|',$str);
  return $str;
}

if (isset($_GET['keyword']) && $_GET['keyword'] != '') {
  $keyword = process_input();
  $search_r = '搜索结果 - ';
  $whole_eval = ' company LIKE "%'.$keyword.'%" AND';

} else {
  $whole_eval = ' company<>"" AND';

}


@ require ('inc/function/get_page.php');

$n = 0;
$text = $err = '';
if (!isset($sql['db_err'])) {
  db_conn();
}

if ($sql['db_err'] == '') {

  $result = @mysql_query('SELECT COUNT(id) AS total FROM `'.$sql['pref'].''.$sql['data']['承载成员档案的表名'].'` WHERE'.$whole_eval.' check_reg="0"',$db);
  $row = @mysql_fetch_assoc($result);
  $n = abs($row['total']);
  @mysql_free_result($result);
  unset($row);

  if ($n > 0) {
    $p = get_page($n); //页数
    $seek = $web['pagesize'] * ($p-1);
    $result = @mysql_query('SELECT username,company,company_description,sign FROM `'.$sql['pref'].''.$sql['data']['承载成员档案的表名'].'` WHERE'.$whole_eval.' check_reg="0" ORDER BY id DESC LIMIT '.$seek.','.$web['pagesize'].'', $db);

    $text .= '
<div class="list_title_">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th width="50%">商户</th>
      <th width="50%">商户简介/网址</th>
    </tr>
  </table>
</div>
';

    while ($row = @mysql_fetch_assoc($result)) {
      $hurl = preg_replace('/^http(:|&#58;)\/\/|\/?$/i', '', $row['sign']);
      $text .= '
<div class="li">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="20"><input name="id[]" id="id[]" type="checkbox" class="checkbox" value="'.$row['username'].'" /></td>
       <td width="50%" style="text-align:left;"> <a href="user.php?get=company&username='.urlencode($row['username']).'" target="_blank">'.$row['company'].'</a> [<a class="grayword" href="user.php?get=card&username='.urlencode($row['username']).'" target="_blank" title="用户名">'.$row['username'].'</a>]</td>
      <td width="50%" style="text-align:left;">'.(!empty($row['company_description']) ? $row['company_description'] : '无商户简介').'<br />'.(!empty($hurl) ? '<a class="grayword" href="http://'.$hurl.'" target="_blank">'.$hurl.'</a>' : '网址未登记').'</td>
    </tr>
  </table>
</div>
';
      unset($row);
    }
    @mysql_free_result($result);

    $text .= @get_page_foot($n, $web['pagesize'], $p, '?get=member_company&keyword='.urlencode($_GET['keyword']).'&p=');

  } else {
    $err .= '暂无记录！';
  }

} else {
  $err .= $sql['db_err'];
}

@mysql_close();


?>
<div class="list_title"><a href="?get=member_company" class="list_title_in"><?php echo @$search_r; ?>商户列表<span>（<?php echo @$n; ?>）</span></a><a href="?get=member">成员管理</a><a href="?get=member_userface">成员头像管理</a></div>
<form method="post" id="manageform" name="manageform" action="?post=unity_run&dataname=member">
  
  <div class="manager_menu">
  <a href="javascript:void(0)" onclick="allChoose(true,true);return false;">全选</a>- <a href="javascript:void(0)" onclick="allChoose(true,false);return false;">反选</a>- <a href="javascript:void(0)" onclick="allChoose(false,false);return false;">不选</a> &nbsp;&nbsp;
  <button name="act" type="button" onclick="chk(this.form,this,'delcompany')"><b>删除</b></button>
  <input type="checkbox" class="checkbox" name="delsendmess" id="delsendmess" value="1" />
    同时发信 | 
  输入商号名<input name="keyword" id="usernamebox" value="<?php echo @$_GET['keyword']; ?>" type="text" size="20" onkeydown="if(event.keyCode==13){location.href='?get=member_company&keyword='+encodeURIComponent($('usernamebox').value)+'';return false;}" />
<button name="button" type="button" onclick="location.href='?get=member_company&keyword='+encodeURIComponent($('usernamebox').value)+'';"><b>搜索商号</b></button>
  </div>
  <?php
echo $text, $err;
?>
  <input type="hidden" name="limit" />
</form>
