forked from Youngxj/YoungxjTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
444 changed files
with
197,995 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php include 'header.php';?> | ||
<style type="text/css"> | ||
.row{ | ||
display: table-cell; | ||
vertical-align: middle; | ||
} | ||
.container{ | ||
display:table; | ||
height:100%; | ||
} | ||
.row-centered { | ||
padding-top: 70px; | ||
text-align:center; | ||
} | ||
</style> | ||
<div class="container"> | ||
<div class="row row-centered"> | ||
<div class="form-group" id="input-wrap"> | ||
<h1 class="text-center" style="font-size: 112px;">404</h1> | ||
<h3 class="text-center"><script>text()</script></h3> | ||
</div> | ||
</div> | ||
</div> | ||
<script type="text/javascript"></script> | ||
<?php include 'footer.php';?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<?php | ||
$GLOBALS = require('config.php'); | ||
class Model{ | ||
public $page; | ||
public $table_name; | ||
|
||
private $sql = array(); | ||
|
||
public function __construct($table_name = null){if($table_name)$this->table_name = $table_name;} | ||
public function findAll($conditions = array(), $sort = null, $fields = '*', $limit = null){ | ||
$sort = !empty($sort) ? ' ORDER BY '.$sort : ''; | ||
$fields = !empty($fields) ? $fields : '*'; | ||
$conditions = $this->_where($conditions); | ||
|
||
$sql = ' FROM '.$this->table_name.$conditions["_where"]; | ||
if(is_array($limit)){ | ||
$total = $this->query('SELECT COUNT(*) as M_COUNTER '.$sql, $conditions["_bindParams"]); | ||
$limit = $limit + array(1, 10, 10); | ||
$limit = $this->pager($limit[0], $limit[1], $limit[2], $total[0]['M_COUNTER']); | ||
$limit = empty($limit) ? '' : ' LIMIT '.$limit['offset'].','.$limit['limit']; | ||
}else{ | ||
$limit = !empty($limit) ? ' LIMIT '.$limit : ''; | ||
} | ||
return $this->query('SELECT '. $fields . $sql . $sort . $limit, $conditions["_bindParams"]); | ||
} | ||
|
||
|
||
public function find($conditions = array(), $sort = null, $fields = '*'){ | ||
$res = $this->findAll($conditions, $sort, $fields, 1); | ||
return !empty($res) ? array_pop($res) : false; | ||
} | ||
|
||
public function update($conditions, $row){ | ||
$values = array(); | ||
foreach ($row as $k=>$v){ | ||
$values[":M_UPDATE_".$k] = $v; | ||
$setstr[] = "`{$k}` = ".":M_UPDATE_".$k; | ||
} | ||
$conditions = $this->_where( $conditions ); | ||
return $this->execute("UPDATE ".$this->table_name." SET ".implode(', ', $setstr).$conditions["_where"], $conditions["_bindParams"] + $values); | ||
} | ||
|
||
public function incr($conditions, $field, $optval = 1){ | ||
$conditions = $this->_where( $conditions ); | ||
return $this->execute("UPDATE ".$this->table_name." SET `{$field}` = `{$field}` + :M_INCR_VAL ".$conditions["_where"], $conditions["_bindParams"] + array(":M_INCR_VAL" => $optval)); | ||
} | ||
public function decr($conditions, $field, $optval = 1){return $this->incr($conditions, $field, - $optval);} | ||
|
||
public function delete($conditions){ | ||
$conditions = $this->_where( $conditions ); | ||
return $this->execute("DELETE FROM ".$this->table_name.$conditions["_where"], $conditions["_bindParams"]); | ||
} | ||
|
||
public function create($row){ | ||
$values = array(); | ||
foreach($row as $k=>$v){ | ||
$keys[] = "`{$k}`"; $values[":".$k] = $v; $marks[] = ":".$k; | ||
} | ||
$this->execute("INSERT INTO ".$this->table_name." (".implode(', ', $keys).") VALUES (".implode(', ', $marks).")", $values); | ||
return $this->dbInstance($GLOBALS['mysql'], 'master')->lastInsertId(); | ||
} | ||
|
||
public function findCount($conditions){ | ||
$conditions = $this->_where( $conditions ); | ||
$count = $this->query("SELECT COUNT(*) AS M_COUNTER FROM ".$this->table_name.$conditions["_where"], $conditions["_bindParams"]); | ||
return isset($count[0]['M_COUNTER']) && $count[0]['M_COUNTER'] ? $count[0]['M_COUNTER'] : 0; | ||
} | ||
|
||
public function dumpSql(){return $this->sql;} | ||
|
||
public function pager($page, $pageSize = 10, $scope = 10, $total){ | ||
$this->page = null; | ||
if($total > $pageSize){ | ||
$total_page = ceil($total / $pageSize); | ||
$page = min(intval(max($page, 1)), $total); | ||
$min=($page-1)*$pageSize+1; | ||
$max=$page*$pageSize; | ||
$max=$max>$total?$total:$max; | ||
$this->page = array( | ||
'total_count' => $total, | ||
'page_size' => $pageSize, | ||
'total_page' => $total_page, | ||
'first_page' => 1, | ||
'prev_page' => ( ( 1 == $page ) ? 1 : ($page - 1) ), | ||
'next_page' => ( ( $page == $total_page ) ? $total_page : ($page + 1)), | ||
'last_page' => $total_page, | ||
'current_page'=> $page, | ||
'all_pages' => array(), | ||
'offset' => ($page - 1) * $pageSize, | ||
'limit' => $pageSize, | ||
'controller' => arg('m')."/".arg('c'), | ||
'action' => arg('a'), | ||
'min' => $min, | ||
'max' => $max, | ||
); | ||
$scope = (int)$scope; | ||
if($total_page <= $scope ){ | ||
$this->page['all_pages'] = range(1, $total_page); | ||
}elseif( $page <= $scope/2) { | ||
$this->page['all_pages'] = range(1, $scope); | ||
}elseif( $page <= $total_page - $scope/2 ){ | ||
$right = $page + (int)($scope/2); | ||
$this->page['all_pages'] = range($right-$scope+1, $right); | ||
}else{ | ||
$this->page['all_pages'] = range($total_page-$scope+1, $total_page); | ||
} | ||
} | ||
return $this->page; | ||
} | ||
|
||
public function query($sql, $params = array()){return $this->execute($sql, $params, true);} | ||
public function execute($sql, $params = array(), $readonly = false){ | ||
$this->sql[] = $sql; | ||
//dump("dsdsds");exit; | ||
if($readonly && !empty($GLOBALS['mysql']['MYSQL_SLAVE'])){ | ||
$slave_key = array_rand($GLOBALS['mysql']['MYSQL_SLAVE']); | ||
$sth = $this->dbInstance($GLOBALS['mysql']['MYSQL_SLAVE'][$slave_key], 'slave_'.$slave_key)->prepare($sql); | ||
}else{ | ||
$sth = $this->dbInstance($GLOBALS['mysql'], 'master')->prepare($sql); | ||
} | ||
|
||
if(is_array($params) && !empty($params)){ | ||
foreach($params as $k=>&$v) $sth->bindParam($k, $v); | ||
} | ||
|
||
if($sth->execute())return $readonly ? $sth->fetchAll(PDO::FETCH_ASSOC) : $sth->rowCount(); | ||
$err = $sth->errorInfo(); | ||
err('Database SQL: "' . $sql. '", ErrorInfo: '. $err[2], 1); | ||
} | ||
|
||
public function dbInstance($db_config, $db_config_key, $force_replace = false){ | ||
if($force_replace || empty($GLOBALS['mysql_instances'][$db_config_key])){ | ||
try { | ||
$GLOBALS['mysql_instances'][$db_config_key] = new PDO('mysql:dbname='.$db_config['MYSQL_DB'].';host='.$db_config['MYSQL_HOST'].';port='.$db_config['MYSQL_PORT'], $db_config['MYSQL_USER'], $db_config['MYSQL_PASS'], array(PDO::MYSQL_ATTR_INIT_COMMAND=>'SET NAMES \''.$db_config['MYSQL_CHARSET'].'\'')); | ||
}catch(PDOException $e){err('Database Err: '.$e->getMessage());} | ||
} | ||
return $GLOBALS['mysql_instances'][$db_config_key]; | ||
} | ||
|
||
private function _where($conditions){ | ||
$result = array( "_where" => " ","_bindParams" => array()); | ||
if(is_array($conditions) && !empty($conditions)){ | ||
$fieldss = array(); $sql = null; $join = array(); | ||
if(isset($conditions[0]) && $sql = $conditions[0]) unset($conditions[0]); | ||
foreach( $conditions as $key => $condition ){ | ||
if(substr($key, 0, 1) != ":"){ | ||
unset($conditions[$key]); | ||
$conditions[":".$key] = $condition; | ||
} | ||
$join[] = "`{$key}` = :{$key}"; | ||
} | ||
if(!$sql) $sql = join(" AND ",$join); | ||
|
||
$result["_where"] = " WHERE ". $sql; | ||
$result["_bindParams"] = $conditions; | ||
} | ||
return $result; | ||
} | ||
} | ||
|
||
function err($msg){ | ||
if (ob_get_contents()) ob_end_clean(); | ||
function _err_highlight_code($code){if(preg_match('/\<\?(php)?[^[:graph:]]/i', $code)){return highlight_string($code, TRUE);}else{return preg_replace('/(<\?php )+/i', "", highlight_string("<?php ".$code, TRUE));}} | ||
function _err_getsource($file, $line){if(!(file_exists($file) && is_file($file))) {return '';}$data = file($file);$count = count($data) - 1;$start = $line - 5;if ($start < 1) {$start = 1;}$end = $line + 5;if ($end > $count) {$end = $count + 1;}$returns = array();for($i = $start; $i <= $end; $i++) {if($i == $line){$returns[] = "<div id='current'>".$i.". "._err_highlight_code($data[$i - 1], TRUE)."</div>";}else{$returns[] = $i.". "._err_highlight_code($data[$i - 1], TRUE);}}return $returns; | ||
}?> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="robots" content="noindex, nofollow, noarchive" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title><?php echo $msg;?></title><style>body{padding:0;margin:0;word-wrap:break-word;word-break:break-all;font-family:Courier,Arial,sans-serif;background:#EBF8FF;color:#5E5E5E;}div,h2,p,span{margin:0; padding:0;}ul{margin:0; padding:0; list-style-type:none;font-size:0;line-height:0;}#body{width:918px;margin:0 auto;}#main{width:918px;margin:13px auto 0 auto;padding:0 0 35px 0;}#contents{width:918px;float:left;margin:13px auto 0 auto;background:#FFF;padding:8px 0 0 9px;}#contents h2{display:block;background:#CFF0F3;font:bold 20px;padding:12px 0 12px 30px;margin:0 10px 22px 1px;}#contents ul{padding:0 0 0 18px;font-size:0;line-height:0;}#contents ul li{display:block;padding:0;color:#8F8F8F;background-color:inherit;font:normal 14px Arial, Helvetica, sans-serif;margin:0;}#contents ul li span{display:block;color:#408BAA;background-color:inherit;font:bold 14px Arial, Helvetica, sans-serif;padding:0 0 10px 0;margin:0;}#oneborder{width:800px;font:normal 14px Arial, Helvetica, sans-serif;border:#EBF3F5 solid 4px;margin:0 30px 20px 30px;padding:10px 20px;line-height:23px;}#oneborder span{padding:0;margin:0;}#oneborder #current{background:#CFF0F3;}</style></head><body><div id="main"><div id="contents"><h2><?php echo $msg?></h2><?php foreach($traces as $trace){if(is_array($trace)&&!empty($trace["file"])){$souceline = _err_getsource($trace["file"], $trace["line"]);if($souceline){?><ul><li><span><?php echo $trace["file"];?> on line <?php echo $trace["line"];?> </span></li></ul><div id="oneborder"><?php foreach($souceline as $singleline)echo $singleline;?></div><?php }}}?></div></div><div style="clear:both;padding-bottom:50px;" /></body></html><?php } | ||
//遇到错误 不结束掉页面 | ||
//exit; | ||
?> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
$id = '29'; | ||
include '../header.php'; | ||
|
||
?> | ||
|
||
|
||
<style> | ||
body{min-height:300px;background: #f6f6f6;}.container{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.CodeMirror{min-height:385px;font-family: Menlo,Monaco,Consolas,"Andale Mono","lucida console","Courier New",monospace;}.textareaCode{min-height:100%}#iframeResult{display: block;overflow: hidden;border:0!important;min-width:100px;width:100%;min-height:385px;background-color:#fff}@media screen and (max-width:768px){.textareaCode{height:300px}.CodeMirror{height:300px;font-family: Menlo,Monaco,Consolas,"Andale Mono","lucida console","Courier New",monospace;}#iframeResult{height:300px}.form-inline{padding:6px 0 2px 0}}.logo h1{background-image:url(/images/logo-domain-white.png);background-repeat:no-repeat;text-indent:-9999px;width:160px;height:39px;margin-top:10px;display:block} | ||
.iframewrapper{min-height:600px;} | ||
</style> | ||
<div class="container clearfix" > | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<form class="form-inline"> | ||
<div class="row"> | ||
<div class="col-xs-12"> | ||
<div style="min-height:34px;"> | ||
<span>输出类型:</span> | ||
<label><input type="radio" name="pinyin_type" value="0" checked/>带声调拼音</label> | ||
<label><input type="radio" name="pinyin_type" value="1"/>不带声调拼音</label> | ||
<label><input type="radio" name="pinyin_type" value="2"/>拼音首字母</label> | ||
<label><input type="checkbox" name="polyphone" title="支持多音字仅仅是将所有可能的组合列举出来,要做到准确识别多音字还需非常完善的词库"/>简单支持多音字</label> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="panel-body" style="height:400px;"> | ||
<textarea class="form-control textareaCode" id="textareaCode_zw" name="textareaCode"></textarea> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-sm-6"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"><button type="button" class="btn btn-default" onclick="layer.msg('如有问题请联系QQ1170535111');">拼音输出</button><button type="button" class="btn btn-default" onclick="copyUrl2();">复制内容</button><button type="button" class="btn btn-success" id="read">朗读</button></div> | ||
<div class="panel-body" style="height:400px;"><textarea class="form-control textareaCode" id="textareaCode_py"></textarea></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<audio id="voice" src=""></audio> | ||
<script type="text/javascript" src="dict/pinyin_dict_withtone.js"></script> | ||
<script type="text/javascript" src="pinyinUtil.js"></script> | ||
<script type="text/javascript" src="py.php?rand=<?php echo md5(md5((int)(time()/10)).encryption(1));?>&_=<?php echo randomFloat(1, 99999999);?>"></script> | ||
|
||
<?php include '../footer.php';?> |
Oops, something went wrong.