信呼OA版本v2.3.8

This commit is contained in:
雨中磐石
2022-08-14 16:47:40 +08:00
parent 4640677d27
commit e3fcd913e3
1405 changed files with 133635 additions and 73 deletions

View File

@@ -0,0 +1,98 @@
<?php
/**
* 最新系统推送1.9.7后
* 软件信呼OA
* 最后更新2021-10-09
*/
class JPushChajian extends Chajian{
//-------------最新原生app推送app是1.2.3版本 和 最新app+---------------
public function push($title, $desc, $cont, $palias)
{
$alias = $palias['alias'];
$xmalias = $palias['xmalias']; //小米的
$newalias = $palias['newalias']; //最新使用的
$oldalias = $palias['oldalias']; //一般自己编译
$uids = $palias['uids'];
$alias2019 = $palias['alias2019'];
$pushuids = $palias['pushuids']; //可以推送的用户ID
$xmpush = c('xmpush');
$hwpush = c('hwpush');
//可推送判断
$ketualia = array();
foreach($alias2019 as $ali1){
$ali1aa = explode('|', $ali1);
$_uid = $ali1aa[2];
if(in_array($_uid, $pushuids))$ketualia[] = $ali1;
}
$alias2019 = $ketualia;
//$this->rock->debugs($palias,'pushalias');//判断能不能推送,打印这个
$xharr = array(
'uids' => $uids,
'title' => $this->rock->jm->base64encode($title),
'cont' => $this->rock->jm->base64encode($cont),
'desc' => $desc,
'systype'=> getconfig('systype')
);
$isuguanw = false;
//没有设置推送(走的信呼官网渠道)
if(!$xmpush->sendbool() && !$hwpush->sendbool()){
if($xmalias || $newalias || $oldalias || $alias2019){
if($xmalias)$xharr['xmalias'] = join(',', $xmalias);
if($newalias)$xharr['newalias'] = join(',', $newalias);
if($oldalias)$xharr['oldalias'] = join(',', $oldalias);
if($alias2019)$xharr['alias2019'] = join(',', $alias2019);
$isuguanw = true;
}
}else{
$desc = $this->rock->jm->base64decode($desc);
$xmarr = array();//小米的人员
$othar = array();//其他人用
$iosar = array(); //IOS
$hwarr = array(); //华为
$iospas= array();
if($alias2019)foreach($alias2019 as $ali1){
$ali1aa = explode('|', $ali1);
$regid = $ali1aa[0];
$sjlxx = $ali1aa[1];
if(contain($sjlxx,'xiaomi')){
$xmarr[] = $regid;
}else if(contain($sjlxx,'huawei')){
if(isset($ali1aa[3]) && $ali1aa[3])$hwarr[] = $ali1aa[3];
}else if(contain($sjlxx,'iphone')){
$iosar[] = $regid;
$iospas[]= $ali1;
}else{
$othar[] = $regid;
}
}
$msg = $msg1 = $msg2 = '';
if($oldalias)$msg = $xmpush->androidsend($oldalias, $title, $desc, $cont);
if($xmarr)$msg = $xmpush->androidsend($xmarr, $title, $desc);
if($iosar){
if(!$xmpush->jpushiosbool()){
$xharr['alias2019'] = join(',', $iospas);
$isuguanw = true;
}else{
$msg1= $xmpush->jpushiossend($iosar, $title, $desc);
}
}
if($hwarr)$msg2= $hwpush->androidsend($hwarr, $title, $desc);
$msg5 = $msg.$msg1.$msg2;
if($msg5)$this->rock->debugs($msg5,'mypush');
}
if($isuguanw){
$runurl = c('xinhu')->geturlstr('jpushplat', $xharr);
c('curl')->getcurl($runurl);
}
}
}

View File

@@ -0,0 +1,383 @@
<?php
/**
* PHPExcel类
*/
class PHPExcelChajian extends Chajian{
public $excel = null;
public $sheetObj;
public $headlen = 0;
public $headbgcolor = 'CDF79E';
public $bordercolor = '000000';
public $headfontcolor = '';
public $headfontbold = false;
public $borderbool = true;
public $title = '';
public $titlebool = true;
public $titlebgbool = false;
public $sheettitle = '';
public $headArr = array();
public $rows = array();
public $titleboolArray = array();
public $titleArray = array();
public $headArrArray = array();
public $rowsArray = array();
public $pageCode = 'utf-8';
public $code = 'utf-8';
public $createbool = false;
public function initChajian()
{
$this->A = explode(',','A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR,AS,AT,AU,AV,AW,AX,AY,AZ,BA,BB,BC,BD,BE,BF,BG,BH,BI,BJ,BK,BL,BM,BN,BO,BP,BQ,BR,BS,BT,BU,BV,BW,BX,BY,BZ,CA,CB,CC,CD,CE,CF,CG,CH,CI,CJ,CK,CL,CM,CN,CO,CP,CQ,CR,CS,CT,CU,CV,CW,CX,CY,CZ');
$this->headWidth= array();
$pastr = ROOT_PATH.'/include/PHPExcel.php';
if(file_exists($pastr)){
include_once($pastr);
$this->excel = new PHPExcel();
}
}
public function isBool()
{
if($this->excel==null){
return false;
}else{
return true;
}
}
/**
设置表头
*/
private function setHead($sheet=0)
{
$arrh = $this->headArr;
$title = $this->sheettitle;
if($title=='')$title = $this->title;
$this->headWidth = array();
if($sheet>0)$this->excel->createSheet();
$this->excel->setActiveSheetIndex($sheet);//设置当前的sheet工作簿
$this->sheetObj = $this->excel->getActiveSheet();
$this->sheetObj->setTitle($title);//设置sheet的工作簿标题
$k = 0;
if($sheet == 0){
$this->excel->getProperties()->setCreator('rock'); //创建者
$this->excel->getProperties()->setLastModifiedBy('rock'); //最后修改
$this->excel->getProperties()->setTitle('rock'); //设置标题
$this->excel->getProperties()->setSubject('rock'); //设置备注
$this->excel->getProperties()->setDescription('rock'); //设置描述
$this->excel->getProperties()->setKeywords('rock'); //设置关键字 | 标记
$this->excel->getProperties()->setCategory('rock'); //设置类别
}
$this->headlen = -1;
foreach($arrh as $_arrh)$this->headlen++;
$this->rowslen = 0;
if(is_array($this->rows))$this->rowslen=count($this->rows);//长度
if($this->headlen==-1)return false;
//整体添加边框颜色,居中
$zta = ($this->titlebool)?2:1;
$getStyle = $this->sheetObj->getStyle('A1:'.$this->A[$this->headlen].''.($this->rowslen+$zta).'');
$getStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);//垂直居中
$getStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::VERTICAL_CENTER);//水平居中
if($this->borderbool){
$getStyle->getBorders()->getAllborders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);//边框
if($this->bordercolor!='000000')$getStyle->getBorders()->getAllborders()->getColor()->setARGB('FF'.$this->bordercolor.'');//边框颜色
}
//设置头部标题
if($this->titlebool){
$this->sheetObj->mergeCells('A1:'.$this->A[$this->headlen].'1'); //合并单元格
$this->sheetObj->setCellValue('A1', $title);
$this->sheetObj->getRowDimension(1)->setRowHeight(30); //设置行高
$getStyle = $this->sheetObj->getStyle('A1');
$getStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$getStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);//垂直剧中
$getStyle->getFont()->setBold(true);
$getStyle->getFont()->setSize(16);
//标题背景颜色
if($this->titlebgbool){
$getStyle->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$getStyle->getFill()->getStartColor()->setARGB('FF'.$this->headbgcolor.'');
}
}
//设置表头列标题
if($this->headfontbold)$this->sheetObj->getStyle('A'.$zta.':'.$this->A[$this->headlen].''.$zta.'')->getFont()->setBold(true);//标题是否加粗
foreach($arrh as $key=>$_arrh){
$name = $_arrh;
$xlsfontcolor = $this->headfontcolor;
$xlsbgcolor = $this->headbgcolor;
$xlsbordercolor = $this->bordercolor;
$xlsfontsize = '';//字体大小
$xlswidth = 0; //宽度
$xlsalign = 'center'; //对齐方式
$xlsbold = false; //是否加粗
if(is_array($_arrh)){
if(isset($_arrh['xlsfontcolor']))$xlsfontcolor=$_arrh['xlsfontcolor'];
if(isset($_arrh['xlsbgcolor']))$xlsbgcolor=$_arrh['xlsbgcolor'];
if(isset($_arrh['xlsbordercolor']))$xlsbordercolor=$_arrh['xlsbordercolor'];
if(isset($_arrh['xlswidth']))$xlswidth=$_arrh['xlswidth'];
if(isset($_arrh['xlsalign']))$xlswidth=$_arrh['xlsalign'];
if(isset($_arrh['xlsbold']))$xlsbold=$_arrh['xlsbold'];
if(isset($_arrh['xlsfontsize']))$xlsfontsize=$_arrh['xlsfontsize'];
$name= $_arrh['name'];
}
$this->headWidth[$key] = array(strlen($name), $xlswidth); //设置宽度
//设置样式
$vk = ''.$this->A[$k].'2';
if(!$this->titlebool)$vk = ''.$this->A[$k].'1';
$getStyle = $this->sheetObj->getStyle($vk);
//边框
if($xlsbordercolor!='000000')$getStyle->getBorders()->getAllborders()->getColor()->setARGB('FF'.$xlsbordercolor.'');
//设置背景色
$getStyle->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$getStyle->getFill()->getStartColor()->setARGB('FF'.$xlsbgcolor.'');
//设置字体颜色加粗,大小
if($xlsfontcolor!='')$getStyle->getFont()->getColor()->setARGB('FF'.$xlsfontcolor.'');
if($xlsbold)$getStyle->getFont()->setBold(true);
if($xlsfontsize!='')$getStyle->getFont()->setSize($xlsfontsize);
//设置对齐方式
if($xlsalign!='center')$getStyle->getAlignment()->setHorizontal($xlsalign);
$this->sheetObj->setCellValue($vk, $name);
$k++;
}
}
/**
添加数据
*/
private function setData()
{
$rows = $this->rows;
if(!is_array($rows))return false;
$arrh = $this->headArr;
$zta = ($this->titlebool)?3:2;
//添加数据
foreach($rows as $r=>$rs){
if(!is_array($rs))continue;
$k = 0;
$xlsmerge = '';
$xlsbgcolor = '';
$xua = $r+$zta;
if(isset($rs['xlsmerge']))$xlsmerge=$rs['xlsmerge'];
if(isset($rs['xlsbgcolor']))$xlsbgcolor=$rs['xlsbgcolor'];
//整行背景色
if($xlsbgcolor!=''){
$this->sheetObj->getStyle('A'.$xua.':'.$this->A[$this->headlen].''.$xua.'')
->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
->getStartColor()->setARGB('FF'.$xlsbgcolor.'');
}
//判断是否有合并单元格的(A:D)
if($xlsmerge!=''){
$ncta = explode(':',$xlsmerge);
$this->sheetObj->mergeCells(''.$ncta[0].''.$xua.':'.$ncta[1].''.$xua.'');
}
foreach($arrh as $key=>$_arrh){
if(!isset($rs[$key])){
$k++;
continue;
}
$vk = ''.$this->A[$k].''.$xua.'';
$xlsfontcolor = $xlsbgcolor = '';
$xlsbordercolor = $this->bordercolor;
$xlsunderline = '';
$xlsfontsize = '';
$xlsalign = 'center'; //对齐方式
$xlsbold = false; //是否加粗
$xlsitalic = false; //是否斜体
$val = $rs[$key];
$vallen = strlen(''.$val.'');
if($this->headWidth[$key][0]<$vallen)$this->headWidth[$key][0]=$vallen;
if(is_array($_arrh)){
if(isset($_arrh['xlsfontcolor']))$xlsfontcolor=$_arrh['xlsfontcolor'];
if(isset($_arrh['xlsbgcolor']))$xlsbgcolor=$_arrh['xlsbgcolor'];
if(isset($_arrh['xlsbordercolor']))$xlsbordercolor=$_arrh['xlsbordercolor'];
if(isset($_arrh['xlsalign']))$xlsalign=$_arrh['xlsalign'];
}
if(isset($rs['xlsfontcolor']))$xlsfontcolor=$rs['xlsfontcolor'];
if(isset($rs['xlsbordercolor']))$xlsbordercolor=$rs['xlsbordercolor'];
if(isset($rs['xlsalign']))$xlsalign=$rs['xlsalign'];
if(isset($rs['xlsbold']))$xlsbold=$rs['xlsbold'];
if(isset($rs['xlsfontsize']))$xlsfontsize=$rs['xlsfontsize'];
if(isset($rs['xlsunderline']))$xlsunderline=$rs['xlsunderline'];
if(isset($rs[''.$key.'xlsfontcolor']))$xlsfontcolor=$rs[''.$key.'xlsfontcolor'];
if(isset($rs[''.$key.'xlsbgcolor']))$xlsbgcolor=$rs[''.$key.'xlsbgcolor'];
if(isset($rs[''.$key.'xlsbordercolor']))$xlsbordercolor=$rs[''.$key.'xlsbordercolor'];
if(isset($rs[''.$key.'xlsalign']))$xlsalign=$rs[''.$key.'xlsalign'];
if(isset($rs[''.$key.'xlsbold']))$xlsbold=$rs[''.$key.'xlsbold'];
if(isset($rs[''.$key.'xlsfontsize']))$xlsfontsize=$rs[''.$key.'xlsfontsize'];
if(isset($rs[''.$key.'xlsitalic']))$xlsitalic=$rs[''.$key.'xlsitalic'];
if(isset($rs[''.$key.'xlsunderline']))$xlsunderline=$rs[''.$key.'xlsunderline'];
$getStyle = $this->sheetObj->getStyle($vk);
//设置背景色
if($xlsbgcolor!=''){
$getStyle->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$getStyle->getFill()->getStartColor()->setARGB('FF'.$xlsbgcolor.'');
}
//字体颜色
if($xlsfontcolor!='')$getStyle->getFont()->getColor()->setARGB('FF'.$xlsfontcolor.'');
if($xlsbold)$getStyle->getFont()->setBold(true);
if($xlsitalic)$getStyle->getFont()->setItalic(true);//斜体
if($xlsfontsize!='')$getStyle->getFont()->setSize($xlsfontsize);
if($xlsunderline!='')$getStyle->getFont()->setUnderline($xlsunderline);//下划线情况double,双下划线、doubleAccounting,整个单元格双下划线、single,单下划线、singleAccounting,整个单元格单下划线
//设置边框颜色
if($xlsbordercolor!='000000')$getStyle->getBorders()->getAllborders()->getColor()->setARGB('FF'.$xlsbordercolor.'');
//对齐方式
if($xlsalign!='center')$getStyle->getAlignment()->setHorizontal($xlsalign);
$this->sheetObj->setCellValue($vk, $val);
$k++;
}
//设置行高
$xlsrowheight = 0;
if(isset($rs['xlsrowheight']))$xlsrowheight=$rs['xlsrowheight'];
if($xlsrowheight != 0)$this->sheetObj->getRowDimension($r+$zta)->setRowHeight($xlsrowheight);
}
}
/**
设置列宽
*/
private function setColwidth()
{
$k=0;
foreach($this->headWidth as $key=>$v){
$w = $v[1];
if($w<=0){
$w= $v[0] * 1.2;
}else{
$w= $w/70*12;
}
if($w>0)$this->sheetObj->getColumnDimension($this->A[$k])->setWidth($w);
$k++;
}
}
/**
创建数据
*/
public function createData()
{
$len1 = count($this->titleArray);
$len2 = count($this->headArrArray);
$len3 = count($this->rowsArray);
if($len1==$len2 && $len2==$len3 && $len1>0){
for($i=0; $i<$len1; $i++){
$this->sheettitle = $this->titleArray[$i];
$this->headArr = $this->headArrArray[$i];
$this->rows = $this->rowsArray[$i];
$this->titlebool = true;
if(isset($this->titleboolArray[$i]))$this->titlebool=$this->titleboolArray[$i];
$this->setHead($i);
$this->setData();
$this->setColwidth();
}
$this->excel->setActiveSheetIndex(0);
}else{
$this->setHead(0);
$this->setData();
$this->setColwidth();
}
$this->createbool = true;
}
/**
输出显示
@param string $ext 输出类型 xls,xlsx
@param string $type 是否直接下载
@return string 文件名
*/
public function display($ext='xls', $type='down')
{
if(!$this->createbool){
$this->createData();
}
$title = $this->title;
//有随机数
$rand = '';
if(contain($type,'rand'))$rand = date('YmdHis');
$filename = ''.$title.''.$rand.'.'.$ext.'';
//输出
if($ext!='xlsx'){
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
}else{
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel2007'); //保存excel—2007格式或者
}
$backfile = 'down';
//保存文件
if(contain($type,'savelogs')){
$dir = 'logs';
$path = ''.ROOT_PATH.'/'.UPDIR.'/'.$dir.'/';
if(!is_dir($path))mkdir($path);
$savefile = $path.''.$this->iconvstr($filename).'';
$objWriter->save($savefile); //是否保存本地
$backfile = ''.UPDIR.'/'.$dir.'/'.$filename.'';
}
//下载
if(contain($type, 'down')){
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="'.iconv('utf-8', 'gbk', $filename).'"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');
}
return $backfile;
}
/**
编码转化
*/
private function iconvstr($str)
{
if($this->pageCode=='utf-8')$str = iconv('utf-8', 'gbk', $str);
return $str;
}
/**
合并单元格
*/
public function mergeCells($cel1, $cel2, $val=null, $sheet=-1)
{
if($sheet != -1)$this->excel->setActiveSheetIndex($sheet);
$this->excel->getActiveSheet()->mergeCells(''.$cel1.':'.$cel2.'');
if($val != null)$this->sheetObj->setCellValue($cel1, $val);
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* PHPExcel 读取插件类
*/
class PHPExcelReaderChajian extends Chajian{
public $A;
public $AT;
protected function initChajian()
{
$this->Astr = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR,AS,AT,AU,AV,AW,AX,AY,AZ,BA,BB,BC,BD,BE,BF,BG,BH,BI,BJ,BK,BL,BM,BN,BO,BP,BQ,BR,BS,BT,BU,BV,BW,BX,BY,BZ,CA,CB,CC,CD,CE,CF,CG,CH,CI,CJ,CK,CL,CM,CN,CO,CP,CQ,CR,CS,CT,CU,CV,CW,CX,CY,CZ';
$this->A = explode(',', $this->Astr);
$this->AT = array('A'=>0,'B'=>1,'C'=>2,'D'=>3,'E'=>4,'F'=>5,'G'=>6,'H'=>7,'I'=>8,'J'=>9,'K'=>10,'L'=>11,'M'=>12,'N'=>13,'O'=>14,'P'=>15,'Q'=>16,'R'=>17,'S'=>18,'T'=>19,'U'=>20,'V'=>21,'W'=>22,'X'=>23,'Y'=>24,'Z'=>25,'AA'=>26,'AB'=>27,'AC'=>28,'AD'=>29,'AE'=>30,'AF'=>31,'AG'=>32,'AH'=>33,'AI'=>34,'AJ'=>35,'AK'=>36,'AL'=>37,'AM'=>38,'AN'=>39,'AO'=>40,'AP'=>41,'AQ'=>42,'AR'=>43,'AS'=>44,'AT'=>45,'AU'=>46,'AV'=>47,'AW'=>48,'AX'=>49,'AY'=>50,'AZ'=>51,'BA'=>52,'BB'=>53,'BC'=>54,'BD'=>55,'BE'=>56,'BF'=>57,'BG'=>58,'BH'=>59,'BI'=>60,'BJ'=>61,'BK'=>62,'BL'=>63,'BM'=>64,'BN'=>65,'BO'=>66,'BP'=>67,'BQ'=>68,'BR'=>69,'BS'=>70,'BT'=>71,'BU'=>72,'BV'=>73,'BW'=>74,'BX'=>75,'BY'=>76,'BZ'=>77,'CA'=>78,'CB'=>79,'CC'=>80,'CD'=>81,'CE'=>82,'CF'=>83,'CG'=>84,'CH'=>85,'CI'=>86,'CJ'=>87,'CK'=>88,'CL'=>89,'CM'=>90,'CN'=>91,'CO'=>92,'CP'=>93,'CQ'=>94,'CR'=>95,'CS'=>96,'CT'=>97,'CU'=>98,'CV'=>99,'CW'=>100,'CX'=>101,'CY'=>102,'CZ'=>103);
}
public function reader($filePath=null, $index=2)
{
if(file_exists(ROOT_PATH.'/include/PHPExcel/Reader/Excel2007.php'))include_once(ROOT_PATH.'/include/PHPExcel/Reader/Excel2007.php');
if(file_exists(ROOT_PATH.'/include/PHPExcel/Reader/Excel5.php'))include_once(ROOT_PATH.'/include/PHPExcel/Reader/Excel5.php');
$help = c('xinhu')->helpstr('phpexcel');
if(!class_exists('PHPExcel_Reader_Excel2007'))return '没有安装PHPExcel插件'.$help.'';
if($filePath==null)$filePath = $_FILES['file']['tmp_name'];
$PHPReader = new PHPExcel_Reader_Excel2007();
if(!$PHPReader->canRead($filePath)){
$PHPReader = new PHPExcel_Reader_Excel5();
if(!$PHPReader->canRead($filePath)){
return '不是正规的Excel文件'.$help.'';
}
}
$PHPExcel = $PHPReader->load($filePath);
$rows = array();
$sheet = $PHPExcel->getSheet(0); //第一个表
$allColumn = $sheet->getHighestColumn();
$allRow = $sheet->getHighestRow();
$allCell = $this->AT[$allColumn];
for($row = $index; $row <= $allRow; $row++){
$arr = array();
for($cell= 0; $cell<= $allCell; $cell++){
$val = $sheet->getCellByColumnAndRow($cell, $row)->getValue();
$arr[$this->A[$cell]] = $val;
}
$rows[] = $arr;
}
return $rows;
}
/**
导入到表
*/
public function importTable($table, $rows, $fields)
{
}
public function ExcelToDate($lx, $val)
{
if($lx=='date')$lx = 'Y-m-d';
if($lx=='datetime')$lx = 'Y-m-d H:i:s';
return date($lx, PHPExcel_Shared_Date::ExcelToPHP($val)-8*3600);
}
}

View File

@@ -0,0 +1,69 @@
<?php
/**
* PHPWord类
*/
class PHPWordChajian extends Chajian{
private $vendorbool=false;
protected function initChajian()
{
$path = ''.ROOT_PATH.'/include/vendor/autoload.php';
if(file_exists($path)){
require_once($path);
$this->vendorbool = true;
}
}
public function isbool()
{
return $this->vendorbool;
}
public function test()
{
if(!$this->vendorbool)return;
\PhpOffice\PhpWord\Settings::loadConfig();
\PhpOffice\PhpWord\Settings::setPdfRenderer(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF, ''.ROOT_PATH.'/include/vendor/dompdf/dompdf');
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
$languageEnGb = new \PhpOffice\PhpWord\Style\Language(\PhpOffice\PhpWord\Style\Language::EN_GB);
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->getSettings()->setThemeFontLang($languageEnGb);
$section = $phpWord->addSection();
// Adding Text element to the Section having font styled by default...
$section->addText(
'"Learn from yesterday, live for today, hope for tomorrow. '
. 'The important thing is信呼 not to stop questioning." '
. '(Albert Einstein)'
);
//$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
//$objWriter->save('wfewew.docx');
$phpWord->save('helloWorld'.time().'.pdf','PDF');
}
/**
* 只能替换.docx
*/
public function replaceWord($path, $data=array(), $npath='')
{
if(!$this->vendorbool)return returnerror('未安装插件');
$PhpWord = new \PhpOffice\PhpWord\TemplateProcessor($path);
foreach($data as $k=>$v)$PhpWord->setValue($k, $v);
if($npath=='')$npath = str_replace('.docx',''.rand(1000,9999).'.docx', $path);
$PhpWord->saveAs($npath);
return returnsuccess($npath);
}
}

View File

@@ -0,0 +1,180 @@
<?php
/**
* 阿里云短信服务api
*/
class alismsChajian extends Chajian{
private $accesskeyid;
private $accesskeysecret;
protected function initChajian()
{
$this->accesskeyid = getconfig('alisms_keyid');
$this->accesskeysecret = getconfig('alisms_keysecret');
}
/**
* 批量发送短信
*/
public function send($mobiles, $qianm, $tplid, $cans=array())
{
if(isempt($this->accesskeyid) || isempt($this->accesskeysecret))return returnerror('没有设置短信keyid或keysecret');
if(isempt($qianm))return returnerror('请设置短信签名');
if(isempt($tplid) || substr($tplid,0,4) != 'SMS_')return returnerror('短信模版CODE格式有误');
$mbarr = $this->getTplcont($tplid);
if(!$mbarr['success'])return $mbarr;
$tplcont = $mbarr['data']['TemplateContent'];
if(isset($cans['url']))$cans['url'] = c('xinhuapi')->urlsmall($cans['url']); //如果有短域名用这个生成,不要就删掉这行
//把没用参数删掉
$csarr = $this->rock->matcharr($tplcont);
foreach($csarr as $cs1)if(!isset($cans[$cs1]))return returnerror('模版里有{'.$cs1.'}参数,发送必须传');
foreach($cans as $k1=>$v1)if(!in_array($k1, $csarr))unset($cans[$k1]);
$params = array();
$shoujha= explode(',', $mobiles);
$params["PhoneNumberJson"] = $shoujha;
$params["TemplateCode"] = $tplid;
foreach($shoujha as $smid){
$params["SignNameJson"][] = $qianm;
if($cans)$params["TemplateParamJson"][] = $cans;
}
if($cans)$params["TemplateParamJson"] = json_encode($params["TemplateParamJson"], JSON_UNESCAPED_UNICODE);
$params["SignNameJson"] = json_encode($params["SignNameJson"], JSON_UNESCAPED_UNICODE);
$params["PhoneNumberJson"] = json_encode($params["PhoneNumberJson"], JSON_UNESCAPED_UNICODE);
$helper = new SignatureHelper();
$result = $helper->request(
$this->accesskeyid,
$this->accesskeysecret,
'dysmsapi.aliyuncs.com',
array_merge($params, array(
"RegionId" => "cn-hangzhou",
"Action" => "SendBatchSms",
"Version" => "2017-05-25",
))
);
if(!$result)return returnerror('发送失败');
$barr = json_decode($result, true);
if($barr['Code']=='OK')return returnsuccess($barr);
return returnerror('发送失败:'.$result.'');
}
public function getTplcont($tplid)
{
$num = 'alisms_'.$tplid.'';
$val = m('option')->getval($num);
if(!isempt($val)){
return returnsuccess(array('TemplateContent'=>$val));
}
if(isempt($this->accesskeyid) || isempt($this->accesskeysecret))return returnerror('没有设置短信keyid或keysecret');
$helper = new SignatureHelper();
$params['TemplateCode'] = $tplid;
$result = $helper->request(
$this->accesskeyid,
$this->accesskeysecret,
'dysmsapi.aliyuncs.com',
array_merge($params, array(
"RegionId" => "cn-hangzhou",
"Action" => "QuerySmsTemplate",
"Version" => "2017-05-25",
))
);
if(!$result)return returnerror('获取模版失败'.$tplid.'');
$barr = json_decode($result, true);
if($barr['Code']=='OK'){
m('option')->setval($num, $barr['TemplateContent']);
return returnsuccess($barr);
}
return returnerror('获取失败:'.$result.'');
}
}
/**
* 签名助手 2017/11/19
*
* Class SignatureHelper
*/
class SignatureHelper {
/**
* 生成签名并发起请求
*
* @param $accessKeyId string AccessKeyId (https://ak-console.aliyun.com/)
* @param $accessKeySecret string AccessKeySecret
* @param $domain string API接口所在域名
* @param $params array API具体参数
* @param $security boolean 使用https
* @return bool|\stdClass 返回API接口调用结果当发生错误时返回false
*/
public function request($accessKeyId, $accessKeySecret, $domain, $params, $security=false) {
$apiParams = array_merge(array (
"SignatureMethod" => "HMAC-SHA1",
"SignatureNonce" => uniqid(mt_rand(0,0xffff), true),
"SignatureVersion" => "1.0",
"AccessKeyId" => $accessKeyId,
"Timestamp" => gmdate("Y-m-d\TH:i:s\Z"),
"Format" => "JSON",
), $params);
ksort($apiParams);
$sortedQueryStringTmp = "";
foreach ($apiParams as $key => $value) {
$sortedQueryStringTmp .= "&" . $this->encode($key) . "=" . $this->encode($value);
}
$stringToSign = "GET&%2F&" . $this->encode(substr($sortedQueryStringTmp, 1));
$sign = base64_encode(hash_hmac("sha1", $stringToSign, $accessKeySecret . "&",true));
$signature = $this->encode($sign);
$url = ($security ? 'https' : 'http')."://{$domain}/?Signature={$signature}{$sortedQueryStringTmp}";
try {
$content = $this->fetchContent($url);
return $content;
} catch( \Exception $e) {
return false;
}
}
private function encode($str)
{
$res = urlencode($str);
$res = preg_replace("/\+/", "%20", $res);
$res = preg_replace("/\*/", "%2A", $res);
$res = preg_replace("/%7E/", "~", $res);
return $res;
}
private function fetchContent($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"x-sdk-client" => "php/2.0.0"
));
if(substr($url, 0,5) == 'https') {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
$rtn = curl_exec($ch);
if($rtn === false) {
trigger_error("[CURL_" . curl_errno($ch) . "]: " . curl_error($ch), E_USER_ERROR);
}
curl_close($ch);
return $rtn;
}
}

View File

@@ -0,0 +1,95 @@
<?php
/**
数组操作
*/
class arrayChajian extends Chajian{
/**
二维数组排序
*/
public function order($arr, $field, $tyee='desc')
{
$temp_a = array();
foreach ($arr as $arrs) {
$temp_a[] = $arrs[$field];
}
$tyee = strtolower($tyee);
if($tyee == 'desc'){
array_multisort($temp_a, SORT_DESC, $arr);
}else{
array_multisort($temp_a, SORT_ASC, $arr);
}
return $arr;
}
/**
转换为用数字做的键值
*/
public function tonumarray($arr, $otarr='')
{
$varr=array();
if(is_array($otarr))$varr[]=$otarr;
if(is_array($arr)){
foreach($arr as $da){
$key = array_keys($da);
$zarr=array();
for($i=0;$i<count($key);$i++)$zarr[$i]=$da[$key[$i]];
$varr[]=$zarr;
}
}
return $varr;
}
/**
$str 转化为 数组 0|昨天,2|d
*/
public function strtoarray($str)
{
$a = explode(',', $str);
$arr= array();
foreach($a as $a1){
$a2 = explode('|', $a1);
$k = $a2[0];
$v = $a2[0];
$c = '';
if(isset($a2[1]))$v = $a2[1];
if(isset($a2[2]))$c = $a2[2];
$arr[] = array($k, $v, $c);
}
return $arr;
}
/**
$str 转化为 数组对象 0|昨天,2|d
*/
public function strtoobject($str)
{
$rowa = $this->strtoarray($str);
$arr = array();
foreach($rowa as $k=>$rs){
$arr[$rs[0]] = $rs[1];
}
return $arr;
}
/**
[{}]数组转化为{ke1:ke2}
*/
public function arrrytoobject($arr, $lx=0)
{
$rows = array();
foreach($arr as $k=>$da){
$karr = array_keys($da);
$key = $da[$karr[0]];
$nav = $key;
if(count($karr)>1){
$nav = $da[$karr[1]];
}
if($lx == 1){
$rows[$key] = $da;
}else{
$rows[$key] = $nav;
}
}
return $rows;
}
}

View File

@@ -0,0 +1,123 @@
<?php
/**
* 缓存,目前是使用磁盘文件存储
*/
class cacheChajian extends Chajian{
private $dirvie = 'file'; //redis,file
/**
* 设置缓存
* $time 缓存时间(秒)
*/
public function set($key, $data, $time=0)
{
$this->del($key); //删除原来的
$sarr['key'] = $this->getkey($key);
$sarr['data'] = $data;
if($time>0){
$time = time()+$time;
}else{
$time = 0;
}
$sarr['time'] = $time;
if($time>0)$sarr['timedt'] = date('Y-m-d H:i:s', $time);
$sarr['url'] = $this->rock->nowurl();
$this->delexpire();
return $this->rock->createtxt($this->getpath($key, $time, 1), json_encode($sarr));
}
private function getkey($key)
{
return ''.QOM.''.$key.'';
}
private function getpath($key, $time=0, $lx=0)
{
$key = $this->getkey($key);
$ske = '';
if($time>0)$ske='_'.$time.'';
if($lx==0)return ''.ROOT_PATH.'/'.UPDIR.'/cache/'.md5($key).''.$ske.'';
return ''.UPDIR.'/cache/'.md5($key).''.$ske.'';
}
//获取文件名
private function getpaths($key)
{
$key = $this->getkey($key);
$file= ''.ROOT_PATH.'/'.UPDIR.'/cache/'.md5($key).'';
$bar = glob(''.$file.'*');
if(is_array($bar))foreach($bar as $k=>$fil1){
if($k==0){
$file = $fil1;
}else{
unlink($fil1);
}
}
return $file;
}
/**
* 获取缓存
*/
public function get($key, $dev='')
{
$file= $this->getpaths($key);
$data= $dev;
if(file_exists($file)){
$filea= explode('_', $file);
$time = (int)arrvalue($filea, count($filea)-1,'0');
if($time==0 || $time>=time()){
$cont = file_get_contents($file);
if(!isempt($cont)){
$sarr = json_decode($cont, true);
$data = arrvalue($sarr, 'data');
}
}else{
unlink($file); //已经过期了
}
}
return $data;
}
/**
* 删除缓存
*/
public function del($key)
{
$file= $this->getpaths($key);
if(file_exists($file))@unlink($file);
return true;
}
/**
* 删除所有缓存
*/
public function delall()
{
$bar = glob(''.ROOT_PATH.'/'.UPDIR.'/cache/*');
foreach($bar as $k=>$fil1){
unlink($fil1);
}
}
/**
* 删除过期的缓存
*/
public function delexpire()
{
$bar = glob(''.ROOT_PATH.'/'.UPDIR.'/cache/*');
$time= time();
foreach($bar as $k=>$fil1){
if(contain($fil1,'_')){
$fil11 = substr($fil1, strripos($fil1, '_')+1);
if(is_numeric($fil11)){
if($fil11<$time){
unlink($fil1);
}
}
}
}
}
}

View File

@@ -0,0 +1,247 @@
<?php
class calendarChajian extends Chajian{
//农历每月的天数
private $everyCMonth=array(
0=>array(8,0,0,0,0,0,0,0,0,0,0,0,29,30,7,1),
1=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,8,2),
2=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,9,3),
3=>array(5,29,30,29,30,29,29,30,29,29,30,30,29,30,10,4),
4=>array(0,30,30,29,30,29,29,30,29,29,30,30,29,0,1,5),
5=>array(0,30,30,29,30,30,29,29,30,29,30,29,30,0,2,6),
6=>array(4,29,30,30,29,30,29,30,29,30,29,30,29,30,3,7),
7=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,4,8),
8=>array(0,30,29,29,30,30,29,30,29,30,30,29,30,0,5,9),
9=>array(2,29,30,29,29,30,29,30,29,30,30,30,29,30,6,10),
10=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,7,11),
11=>array(6,30,29,30,29,29,30,29,29,30,30,29,30,30,8,12),
12=>array(0,30,29,30,29,29,30,29,29,30,30,29,30,0,9,1),
13=>array(0,30,30,29,30,29,29,30,29,29,30,29,30,0,10,2),
14=>array(5,30,30,29,30,29,30,29,30,29,30,29,29,30,1,3),
15=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,2,4),
16=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,3,5),
17=>array(2,30,29,29,30,29,30,30,29,30,30,29,30,29,4,6),
18=>array(0,30,29,29,30,29,30,29,30,30,29,30,30,0,5,7),
19=>array(7,29,30,29,29,30,29,29,30,30,29,30,30,30,6,8),
20=>array(0,29,30,29,29,30,29,29,30,30,29,30,30,0,7,9),
21=>array(0,30,29,30,29,29,30,29,29,30,29,30,30,0,8,10),
22=>array(5,30,29,30,30,29,29,30,29,29,30,29,30,30,9,11),
23=>array(0,29,30,30,29,30,29,30,29,29,30,29,30,0,10,12),
24=>array(0,29,30,30,29,30,30,29,30,29,30,29,29,0,1,1),
25=>array(4,30,29,30,29,30,30,29,30,30,29,30,29,30,2,2),
26=>array(0,29,29,30,29,30,29,30,30,29,30,30,29,0,3,3),
27=>array(0,30,29,29,30,29,30,29,30,29,30,30,30,0,4,4),
28=>array(2,29,30,29,29,30,29,29,30,29,30,30,30,30,5,5),
29=>array(0,29,30,29,29,30,29,29,30,29,30,30,30,0,6,6),
30=>array(6,29,30,30,29,29,30,29,29,30,29,30,30,29,7,7),
31=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,8,8),
32=>array(0,30,30,30,29,30,29,30,29,29,30,29,30,0,9,9),
33=>array(5,29,30,30,29,30,30,29,30,29,30,29,29,30,10,10),
34=>array(0,29,30,29,30,30,29,30,29,30,30,29,30,0,1,11),
35=>array(0,29,29,30,29,30,29,30,30,29,30,30,29,0,2,12),
36=>array(3,30,29,29,30,29,29,30,30,29,30,30,30,29,3,1),
37=>array(0,30,29,29,30,29,29,30,29,30,30,30,29,0,4,2),
38=>array(7,30,30,29,29,30,29,29,30,29,30,30,29,30,5,3),
39=>array(0,30,30,29,29,30,29,29,30,29,30,29,30,0,6,4),
40=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,7,5),
41=>array(6,30,30,29,30,30,29,30,29,29,30,29,30,29,8,6),
42=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,9,7),
43=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,10,8),
44=>array(4,30,29,30,29,30,29,30,29,30,30,29,30,30,1,9),
45=>array(0,29,29,30,29,29,30,29,30,30,30,29,30,0,2,10),
46=>array(0,30,29,29,30,29,29,30,29,30,30,29,30,0,3,11),
47=>array(2,30,30,29,29,30,29,29,30,29,30,29,30,30,4,12),
48=>array(0,30,29,30,29,30,29,29,30,29,30,29,30,0,5,1),
49=>array(7,30,29,30,30,29,30,29,29,30,29,30,29,30,6,2),
50=>array(0,29,30,30,29,30,30,29,29,30,29,30,29,0,7,3),
51=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,8,4),
52=>array(5,29,30,29,30,29,30,29,30,30,29,30,29,30,9,5),
53=>array(0,29,30,29,29,30,30,29,30,30,29,30,29,0,10,6),
54=>array(0,30,29,30,29,29,30,29,30,30,29,30,30,0,1,7),
55=>array(3,29,30,29,30,29,29,30,29,30,29,30,30,30,2,8),
56=>array(0,29,30,29,30,29,29,30,29,30,29,30,30,0,3,9),
57=>array(8,30,29,30,29,30,29,29,30,29,30,29,30,29,4,10),
58=>array(0,30,30,30,29,30,29,29,30,29,30,29,30,0,5,11),
59=>array(0,29,30,30,29,30,29,30,29,30,29,30,29,0,6,12),
60=>array(6,30,29,30,29,30,30,29,30,29,30,29,30,29,7,1),
61=>array(0,30,29,30,29,30,29,30,30,29,30,29,30,0,8,2),
62=>array(0,29,30,29,29,30,29,30,30,29,30,30,29,0,9,3),
63=>array(4,30,29,30,29,29,30,29,30,29,30,30,30,29,10,4),
64=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,1,5),
65=>array(0,29,30,29,30,29,29,30,29,29,30,30,29,0,2,6),
66=>array(3,30,30,30,29,30,29,29,30,29,29,30,30,29,3,7),
67=>array(0,30,30,29,30,30,29,29,30,29,30,29,30,0,4,8),
68=>array(7,29,30,29,30,30,29,30,29,30,29,30,29,30,5,9),
69=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,6,10),
70=>array(0,30,29,29,30,29,30,30,29,30,30,29,30,0,7,11),
71=>array(5,29,30,29,29,30,29,30,29,30,30,30,29,30,8,12),
72=>array(0,29,30,29,29,30,29,30,29,30,30,29,30,0,9,1),
73=>array(0,30,29,30,29,29,30,29,29,30,30,29,30,0,10,2),
74=>array(4,30,30,29,30,29,29,30,29,29,30,30,29,30,1,3),
75=>array(0,30,30,29,30,29,29,30,29,29,30,29,30,0,2,4),
76=>array(8,30,30,29,30,29,30,29,30,29,29,30,29,30,3,5),
77=>array(0,30,29,30,30,29,30,29,30,29,30,29,29,0,4,6),
78=>array(0,30,29,30,30,29,30,30,29,30,29,30,29,0,5,7),
79=>array(6,30,29,29,30,29,30,30,29,30,30,29,30,29,6,8),
80=>array(0,30,29,29,30,29,30,29,30,30,29,30,30,0,7,9),
81=>array(0,29,30,29,29,30,29,29,30,30,29,30,30,0,8,10),
82=>array(4,30,29,30,29,29,30,29,29,30,29,30,30,30,9,11),
83=>array(0,30,29,30,29,29,30,29,29,30,29,30,30,0,10,12),
84=>array(10,30,29,30,30,29,29,30,29,29,30,29,30,30,1,1),
85=>array(0,29,30,30,29,30,29,30,29,29,30,29,30,0,2,2),
86=>array(0,29,30,30,29,30,30,29,30,29,30,29,29,0,3,3),
87=>array(6,30,29,30,29,30,30,29,30,30,29,30,29,29,4,4),
88=>array(0,30,29,30,29,30,29,30,30,29,30,30,29,0,5,5),
89=>array(0,30,29,29,30,29,29,30,30,29,30,30,30,0,6,6),
90=>array(5,29,30,29,29,30,29,29,30,29,30,30,30,30,7,7),
91=>array(0,29,30,29,29,30,29,29,30,29,30,30,30,0,8,8),
92=>array(0,29,30,30,29,29,30,29,29,30,29,30,30,0,9,9),
93=>array(3,29,30,30,29,30,29,30,29,29,30,29,30,29,10,10),
94=>array(0,30,30,30,29,30,29,30,29,29,30,29,30,0,1,11),
95=>array(8,29,30,30,29,30,29,30,30,29,29,30,29,30,2,12),
96=>array(0,29,30,29,30,30,29,30,29,30,30,29,29,0,3,1),
97=>array(0,30,29,30,29,30,29,30,30,29,30,30,29,0,4,2),
98=>array(5,30,29,29,30,29,29,30,30,29,30,30,29,30,5,3),
99=>array(0,30,29,29,30,29,29,30,29,30,30,30,29,0,6,4),
100=>array(0,30,30,29,29,30,29,29,30,29,30,30,29,0,7,5),
101=>array(4,30,30,29,30,29,30,29,29,30,29,30,29,30,8,6),
102=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,9,7),
103=>array(0,30,30,29,30,30,29,30,29,29,30,29,30,0,10,8),
104=>array(2,29,30,29,30,30,29,30,29,30,29,30,29,30,1,9),
105=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,2,10),
106=>array(7,30,29,30,29,30,29,30,29,30,30,29,30,30,3,11),
107=>array(0,29,29,30,29,29,30,29,30,30,30,29,30,0,4,12),
108=>array(0,30,29,29,30,29,29,30,29,30,30,29,30,0,5,1),
109=>array(5,30,30,29,29,30,29,29,30,29,30,29,30,30,6,2),
110=>array(0,30,29,30,29,30,29,29,30,29,30,29,30,0,7,3),
111=>array(0,30,29,30,30,29,30,29,29,30,29,30,29,0,8,4),
112=>array(4,30,29,30,30,29,30,29,30,29,30,29,30,29,9,5),
113=>array(0,30,29,30,29,30,30,29,30,29,30,29,30,0,10,6),
114=>array(9,29,30,29,30,29,30,29,30,30,29,30,29,30,1,7),
115=>array(0,29,30,29,29,30,29,30,30,30,29,30,29,0,2,8),
116=>array(0,30,29,30,29,29,30,29,30,30,29,30,30,0,3,9),
117=>array(6,29,30,29,30,29,29,30,29,30,29,30,30,30,4,10),
118=>array(0,29,30,29,30,29,29,30,29,30,29,30,30,0,5,11),
119=>array(0,30,29,30,29,30,29,29,30,29,29,30,30,0,6,12),
120=>array(4,29,30,30,30,29,30,29,29,30,29,30,29,30,7,1)
);
//农历天干
private $mten=array("null","","","","","","","","","",""); //农历地支
private $mtwelve=array("null","子(鼠)","丑(牛)","寅(虎)","卯(兔)","辰(龙)",
"巳(蛇)","午(马)","未(羊)","申(猴)","酉(鸡)","戌(狗)","亥(猪)"); //农历月份
private $mmonth=array("","","","","","","",
"","","","","十一","十二","");
private $mday=array("null","初一","初二","初三","初四","初五","初六","初七","初八","初九","初十",
"十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
"廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十");//农历日
//赋给初值
//天干地支
private $ten=0;
private $twelve=0;
private function MyPub($cYear,$cMonth,$cDay)
{
$total=11;//阳历总天数 至1900年12月21日
$mtotal=0;//阴历总天数
for ($y=1901;$y<$cYear;$y++)
{
$total+=365;
if ($y%4==0) $total ++;
}
//再加当年的几个月
switch ($cMonth){
case 12:
$total+=30;
case 11:
$total+=31;
case 10:
$total+=30;
case 9:
$total+=31;
case 8:
$total+=31;
case 7:
$total+=30;
case 6:
$total+=31;
case 5:
$total+=30;
case 4:
$total+=31;
case 3:
$total+=28;
case 2:
$total+=31;
}
//如果当年是闰年还要加一天
if ($cYear%4==0 and $cMonth>2)
{
$total++;
}
$total+=$cDay-1;
$flag = 0;
//用农历的天数累加来判断是否超过阳历的天数
for($j=0;$j<=120;$j++)
{
$i=1;
for($i=1;$i<=13;$i++)
{
$mtotal+=$this->everyCMonth[$j][$i];
if ($mtotal>=$total)
{
$flag=1;
break;
}
}
if ($flag==1)break;
}
return array("m"=>$j,"d"=>$i,"t"=>$total,"n"=>$mtotal);
}
public function Cal($Year,$Month,$Day)
{
$Par=$this->MyPub($Year,$Month,$Day);
$md=$this->everyCMonth[$Par["m"]][$Par["d"]]-($Par["n"]-$Par["t"]);
$week=($Par["t"]+5)%7;
if ($this->everyCMonth[$Par["m"]][0]<>0 and $this->everyCMonth[$Par["m"]][0]<$Par["d"])
{
$mm=$Par["d"]-1;
}else{
$mm=$Par["d"];
}
if ($Par["d"]==$this->everyCMonth[$Par["d"]][0]+1 and $this->everyCMonth[$Par["d"]][0]<>0)
{
$cMonth=$this->mmonth[0].$this->mmonth[$mm];//闰月
}else{
$cMonth=$this->mmonth[$mm].$this->mmonth[13];
}
$mmd = ($mm<10)? '0'.$mm.'' : $mm;
$mdd = ($md<10)? '0'.$md.'' : $md;
return array("year"=>$this->mten[$this->everyCMonth[$Par["m"]][14]].$this->mtwelve[$this->everyCMonth[$Par["m"]][15]],
"month" =>$cMonth,
"day" =>$this->mday[$md],
"week" =>$week,
"m" =>$mm,
'd' =>$md,
'cal' => ''.$mmd.'-'.$mdd.''
);
}
public function toCalday($dt)
{
$dts = explode('-', $dt);
return $this->Cal((int)$dts[0],(int)$dts[1],(int)$dts[2]);
}
public function daytocal($dt)
{
$dts = explode('-', $dt);
$mm = (int)$dts[1];
$md = (int)$dts[2];
$my = (int)$dts[0];
return array(
'year' => $my,
'month' => $this->mmonth[$mm],
'day' => $this->mday[$md],
);
}
}

View File

@@ -0,0 +1,122 @@
<?php
/**
* 字符检查插件
*/
class checkChajian extends Chajian{
/**
* 是否为邮箱
*/
public function isemail($str)
{
if(isempt($str))return false;
return filter_var($str, FILTER_VALIDATE_EMAIL);
}
/**
* 是否为手机号
*/
public function ismobile($str)
{
if(isempt($str))return false;
if(!is_numeric($str) || strlen($str)<5)return false;
return true;
}
/**
* 判断是否为国内手机号
*/
public function iscnmobile($str)
{
if(isempt($str))return false;
if(!is_numeric($str) || strlen($str)!=11)return false;
if(!preg_match("/1[3458769]{1}\d{9}$/", $str))return false;
return true;
}
/**
* 是否有中文
*/
public function isincn($str)
{
return preg_match("/[\x7f-\xff]/", $str);
}
//是否整个的英文a-z,0-9
public function iszgen($str)
{
if(isempt($str))return false;
if($this->isincn($str)){
return false;
}
return true;
}
//返回字符串编码
public function getencode($str)
{
$encode = mb_detect_encoding($str, array('ASCII','UTF-8','GB2312','GBK','BIG5'));
$encode = strtolower($encode);
return $encode;
}
/**
* 是否为数字
*/
public function isnumber($str)
{
if(isempt($str))return false;
return is_numeric($str);
}
/**
* 字符是否包含数字
*/
public function isinnumber($str)
{
return preg_match("/[0-9]/", $str);
}
/**
* 是否为日期
*/
public function isdate($str)
{
return preg_match("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/", $str);
}
/**
* 是否为日期时间
*/
public function isdatetime($str)
{
return preg_match("/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/", $str);
}
/**
* 是否为月份
*/
public function ismonth($str)
{
return preg_match("/^([0-9]{4})-([0-9]{2})$/", $str);
}
/**
* 过滤字母,只留数字
*/
public function onlynumber($str)
{
return preg_replace('/[a-zA-Z]/','', $str);
}
/**
* 替换空格
*/
public function replacekg($str)
{
$str = preg_replace('/\s*/', '', $str);
$qian = array(" "," ","\t","\n","\r");
return str_replace($qian, '', $str);
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
颜色操作
*/
class colorChajian extends Chajian{
/**
颜色
*/
public function color($color,$l=127.5)
{
$r=hexdec(substr($color,1,2));
$g=hexdec(substr($color,3,2));
$b=hexdec(substr($color,5));
$yb=127.5;
if($l > $yb){
$l = $l - $yb;
$r = ($r * ($yb - $l) + 255 * $l) / $yb;
$g = ($g * ($yb - $l) + 255 * $l) / $yb;
$b = ($b * ($yb - $l) + 255 * $l) / $yb;
}else{
$r = ($r * $l) / $yb;
$g = ($g * $l) / $yb;
$b = ($b * $l) / $yb;
}
$nr=$this->tohex($r);
$ng=$this->tohex($g);
$nb=$this->tohex($b);
return '#'.$nr.$ng.$nb;
}
private function tohex($n)
{
$hexch = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
$n = round($n);
$l = $n % 16;
$h = floor(($n / 16)) % 16;
return ''.$hexch[$h].''.$hexch[$l].'';
}
}

View File

@@ -0,0 +1,146 @@
<?php
/**
curl
*/
class curlChajian extends Chajian{
private $TIMEOUT = 30;
private function strurl($url)
{
$url = str_replace('&#47;', '/', $url);
$url = str_replace(' ', '', $url);
$url = str_replace("\n", '', $url);
return $url;
}
/**
* 设置超时是手机
* $ms 秒数
*/
public function setTimeout($ms)
{
$this->TIMEOUT = $ms;
return $this;
}
private function getdatastr($data)
{
$cont = '';
if(is_array($data)){
foreach($data as $k=>$v)$cont.='&'.$k.'='.$v.'';
if($cont!='')$cont=substr($cont,1);
}else{
$cont = $data;
}
return $cont;
}
public function getfilecont($url)
{
$url = $this->strurl($url);
@$result = file_get_contents($url);
return $result;
}
public function postfilecont($url, $data=array())
{
$url = $this->strurl($url);
$cont = $this->getdatastr($data);
$len = strlen($cont);
$opts = array(
'http' => array(
'method' => 'POST',
'header' =>
"Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: $len\r\n",
'content' => $cont,
)
);
$cxContext = stream_context_create($opts);
@$sFile = file_get_contents($url, false, $cxContext);
return $sFile;
}
public function getcurl($url, $headarr=array())
{
if(!function_exists('curl_init')){
return $this->getfilecont($url);
}
$url= $this->strurl($url);
$ishttps = 0;
if(substr($url,0, 5)=='https')$ishttps=1;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
if($ishttps==1){
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
//设置head
if($headarr){
$heads = array();
foreach($headarr as $k=>$v)$heads[] = ''.$k.':'.$v.'';
curl_setopt($ch, CURLOPT_HTTPHEADER, $heads);
}
curl_setopt($ch, CURLOPT_TIMEOUT, $this->TIMEOUT);
$output = curl_exec($ch);
$this->setResponseHeaders($ch);
curl_close($ch);
return $output;
}
public function postcurl($url, $data=array(), $lx=0, $headarr=array())
{
if(!function_exists('curl_init')){
return $this->postfilecont($url, $data);
}
$url = $this->strurl($url);
$cont = $data;
if($lx==0)$cont = $this->getdatastr($data);
$ishttps = 0;
if(substr($url,0, 5)=='https')$ishttps=1;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_HEADER, 0); //不返回header
curl_setopt($ch, CURLOPT_POST, 1);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $cont);
if($ishttps==1){
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
//设置head
if($headarr){
$heads = array();
foreach($headarr as $k=>$v)$heads[] = ''.$k.':'.$v.'';
curl_setopt($ch, CURLOPT_HTTPHEADER, $heads);
}
curl_setopt($ch, CURLOPT_TIMEOUT, $this->TIMEOUT);
$output = curl_exec($ch);
$curl_errno = curl_errno($ch);
$this->setResponseHeaders($ch);
curl_close($ch);
return $output;
}
/**
* postjson的类型
*/
public function postjson($url, $data=array())
{
return $this->postcurl($url, $data, 0, array(
'Content-Type' => 'application/json'
));
}
public function getResponseHeaders()
{
return $this->ResponseHeaders;
}
private function setResponseHeaders($ch)
{
$this->ResponseHeaders = curl_getinfo($ch);
}
}

View File

@@ -0,0 +1,313 @@
<?php
class dateChajian extends Chajian
{
public $now;
public $date;
protected function initChajian()
{
$this->now = $this->rock->now;
$this->date = $this->rock->date;
}
public function formatdt($dt='',$format='Y-m-d H:i:s')
{
return date($format,strtotime($dt));
}
/**
获取上月
*/
public function lastmonth($dt, $type='Y-m')
{
return $this->adddate($dt,'m',-1,$type);
}
/**
计算时间间隔
*/
public function datediff($type,$start,$end)
{
$time1 = strtotime($start);
$time2 = strtotime($end);
$val=0;
switch($type){
case 'Y'://
$Y1 = date('Y',$time1);
$Y2 = date('Y',$time2);
$val = $Y2 - $Y1;
break;
case 'm'://月份
$y1 = date('Y',$time1);
$y2 = date('Y',$time2);
$m1 = date('m',$time1);
$m2 = date('m',$time2);
$y = $y1 - $y2;
$mz = 0;
if($y1 == $y2){
$mz=$m2-$m1;
}elseif($y1<$y2){
$mz = 12-$m1+$m2+12*($y2-$y1-1);
}else{
$mz = -(12-$m2+$m1+12*($y1-$y2-1));
}
$val = $mz;
break;
case 'd'://
$dt1 = strtotime(date('Y-m-d',$time1));
$dt2 = strtotime(date('Y-m-d',$time2));
$time=$dt2-$dt1;
$val = $time/3600/24;
break;
case 'H'://小时
$time = $time2 - $time1;
$val = floor($time/3600);
break;
case 'i'://分钟
$time = $time2 - $time1;
$val = floor($time/60);
break;
case 's'://
$val = $time2 - $time1;
break;
}
return $val;
}
/**
时间计算添加
*/
public function adddate($dt,$lx,$v=0,$type='')
{
$time = strtotime($dt);
$arrn1 = explode(' ',$dt);
$arrn = explode('-',$arrn1[0]);
$Y = (int)$arrn[0];
$m = (int)$arrn[1];
$d = (int)$arrn[2];
$H=$i=$s=0;
if($this->contain($dt,':')){
$arrn2 = explode(':',$arrn1[1]);
$H = (int)$arrn2[0];
$i = (int)$arrn2[1];
$s = (int)$arrn2[2];
}
$rval = $dt;
if($type=='')$type=($H==0)?'Y-m-d':'Y-m-d H:i:s';
if($type=='datetime')$type='Y-m-d H:i:s';
if($v ==0)return date($type, $time);
switch($lx){
case 'm'://月份
$time = mktime($H, $i, $s, $m+$v, $d, $Y);
break;
case 'Y'://
$time = mktime($H, $i, $s, $m, $d, $Y+$v);
break;
case 'd'://日期
$time = mktime($H, $i, $s, $m, $d+$v, $Y);
break;
case 'H'://
$time = mktime($H+$v, $i, $s, $m, $d, $Y);
break;
case 'i'://
$time = mktime($H, $i+$v, $s, $m, $d, $Y);
break;
case 's'://
$time = mktime($H, $i, $s+$v, $m, $d, $Y);
break;
}
$rval = date($type,$time);
return $rval;
}
//是否包含返回bool
public function contain($str,$a)
{
return $this->rock->contain($str,$a);
}
//判断是否为空
public function isempt($str)
{
return $this->rock->isempt($str);
}
public function diffstr($start, $end, $str, $lx=0, $restr='')
{
$time1 = strtotime($start);
$time2 = strtotime($end);
$sj = $time1-$time2;
if($lx==1 && $sj<=0)return '';
return $this->sjdate($sj, $str, $restr);
}
public function sjdate($sj, $str='', $restr='')
{
$h = $i = $s = $d = 0;
$d = floor($sj/3600/24);
$sj = $sj - $d * 3600 * 24;
$h = floor($sj/3600);
$sj = $sj - $h*3600;
$i = floor($sj/60);
$s = $sj - $i * 60;
$str = str_replace(array('d','H','i','s'),array($d,$h,$i,$s), $str);
if($restr!=''){
$resta = explode(',', $restr);
foreach($resta as $restas)$str = str_replace($restas,'', $str);
}
return $str;
}
public function isdate($dt)
{
$bo = false;
if($this->isempt($dt))return $bo;
$arr = explode('-', $dt);
if(count($arr)>2)$bo = true;
$len = strlen($dt);
if($len>10){
$sfm = explode(' ', $dt);
if(!isset($sfm[1]))return false;
$arr = explode(':', $sfm[1]);
if(count($arr)<2)return false;
}
return $bo;
}
/**
返回月份最大日期
*/
public function getenddt($month)
{
$month = substr($month,0,7);
$max = $this->getmaxdt($month);
return ''.$month.'-'.$max.'';
}
public function getmaxdt($dt)
{
$d = explode('-', $dt);
$m = (int)$d[1];
$y = (int)$d[0];
$a = array(31,28,31,30,31,30,31,31,30,31,30,31);
$d = $a[$m-1];
if($y%4 == 0 && $m==2 && $y%100 != 0)$d++;
return $d;
}
public function cnweek($date)
{
$arr = array('日','一','二','三','四','五','六');
return $arr[date('w', strtotime($date))];
}
//读取本周日期
public function getweekarr($dt)
{
$w = date('w', strtotime($dt));
$a = array(-6,0,-1,-2,-3,-4,-5);
$oi = $a[$w];
$le = $oi+7;
for($j=$oi; $j<$le; $j++){
$arr[] = $this->adddate($dt, 'd', $j);
}
return $arr;
}
public function getweekfirst($dt)
{
$arr = $this->getweekarr($dt);
return $arr[0];
}
public function getweeklast($dt)
{
$arr = $this->getweekarr($dt);
return $arr[6];
}
/**
计算返回当前间隔分析:今天 10:20
*/
public function stringdt($dttime, $type='G H:i')
{
$s = '';$H=$s=$i='00';
$dts= explode(' ', $dttime);
$yms= explode('-', $dts[0]);
$Y = $yms[0];$m = $yms[1];$d = $yms[2];
$jg = $this->datediff('d', $dts[0], $this->date);
$G = '';
if($jg==0)$G='今天';
if($jg==1)$G='昨天';
if($jg==2)$G='前天';
if($jg==-1)$G='明天';
if($jg==-2)$G='后天';
$A = $G;
if($G=='')$G=substr($dts[0], 5);
if($A=='')$A=$dts[0];
$w = $this->cnweek($dts[0]);
if(isset($dts[1])){
$sjs = explode(':', $dts[1]);
$H = $sjs[0];
if(isset($sjs[1]))$i = $sjs[1];
if(isset($sjs[2]))$s = $sjs[2];
}
$str = str_replace(
array('A','G','H','i','s','w','Y','m','d'),
array($A,$G,$H,$i,$s,$w, $Y, $m, $d),
$type);
return $str;
}
/**
* 计算周期$rate:d1,d2,$dt开始时间
* 返回日期,根据日期判断是不是今天
*/
public function daterate($rate, $dt, $nowdt='')
{
if(isempt($rate) || isempt($dt))return false;//没有周期
$dt = substr($dt,0, 10);//日期的类型
if($nowdt=='')$nowdt = $this->rock->date;
$nowdt = substr($nowdt, 0, 10);
$jg = str_replace(array('m','d','w','y'),array('','','',''),$rate);
if($jg=='')$jg='1';
$jg = (int)$jg;
$lx = substr($rate, 0, 1);
if($lx=='d'){
$jge = $this->datediff('d', $dt, $nowdt);
if($jge % $jg==0 || $jge==0){
return $nowdt;
}
}
//每月
if($lx=='m'){
$jge = $this->datediff('m', $dt, $nowdt);
if($jge % $jg==0 || $jge==0){
$ndt = date('Y-m-'.substr($dt, 8).'');
if($ndt==$nowdt)return $nowdt;
}
}
//每年
if($lx=='y'){
$jge = $this->datediff('y', $dt, $nowdt);
if($jge % $jg==0 || $jge==0){
$ndt = date('Y-'.substr($dt, 5).'');
if($ndt==$nowdt)return $nowdt;
}
}
//每周
if($lx=='w'){
$w = (int)date('w', strtotime($nowdt));if($w==0)$w=7;//星期7
if($w==$jg){
return $nowdt;
}
}
return false;
}
}

View File

@@ -0,0 +1,219 @@
<?php
/**
下载文件类插件
*/
class downChajian extends Chajian{
private $upobj;
private $messign;
protected function initChajian()
{
$this->messign = '';
$this->upobj = c('upfile');
}
/**
* 获取随机文件名
*/
public function getallfilename($ext)
{
if(!is_dir(UPDIR))mkdir(UPDIR);
$mkdir = ''.UPDIR.'/'.date('Y-m').'';
if(!is_dir($mkdir))mkdir($mkdir);
$allfilename = ''.$mkdir.'/'.date('d_His').''.rand(10,99).'.'.$ext.'';
return $allfilename;
}
/**
* 根据扩展名保存文件(一般邮件附件下载)
*/
public function savefilecont($ext, $cont)
{
$bo = $this->upobj->issavefile($ext);
if(isempt($cont))return;
$file= '';
if(!$bo){
$file = $this->getallfilename('uptemp');
$bo = @file_put_contents($file, base64_encode($cont));
}else{
$file = $this->getallfilename($ext);
$bo = @file_put_contents($file, $cont);
}
if(!$bo){
$file = '';
}else{
if($this->upobj->isimg($ext)){
$bo = $this->upobj->isimgsave($ext, $file);
if(!$bo)$file = '';
}
}
return $file;
}
private function reutnmsg($msg)
{
$this->messign = $msg;
return false;
}
//获取提示内容
public function gettishi($msg1='')
{
$msg = $this->messign;
if(isempt($msg))$msg = $msg1;
return $msg;
}
/**
* 根据内容创建文件
*/
public function createimage($cont, $ext, $filename, $thumbnail='')
{
if(isempt($cont))return $this->reutnmsg('创建内容为空');
$allfilename = $this->getallfilename($ext);
$upses['oldfilename'] = $filename.'.'.$ext;
$upses['fileext'] = $ext;
@file_put_contents($allfilename, $cont);
if(!file_exists($allfilename))return $this->reutnmsg('无法写入:'.$allfilename.'');
$fileobj = getimagesize($allfilename);
$mime = strtolower($fileobj['mime']);
$next = 'jpg';
if(contain($mime,'bmp'))$next = 'bmp';
if($mime=='image/gif')$next = 'gif';
if($mime=='image/png')$next = 'png';
if($ext != $next){
@unlink($allfilename);
$ext = $next;
$allfilename = $this->getallfilename($ext);
$upses['oldfilename'] = $filename.'.'.$ext;
$upses['fileext'] = $ext;
@file_put_contents($allfilename, $cont);
if(!file_exists($allfilename))return $this->reutnmsg('无法写入:'.$allfilename.'');
}
$filesize = filesize($allfilename);
$filesizecn = $this->upobj->formatsize($filesize);
$picw = $fileobj[0];
$pich = $fileobj[1];
if($picw==0||$pich==0){
@unlink($allfilename);
return $this->reutnmsg('无效的图片');;
}
$upses['filesize'] = $filesize;
$upses['filesizecn'] = $filesizecn;
$upses['allfilename'] = $allfilename;
$upses['picw'] = $picw;
$upses['pich'] = $pich;
$arr = $this->uploadback($upses, $thumbnail);
return $arr;
}
public function uploadback($upses, $thumbnail='', $subo=true)
{
if($thumbnail=='')$thumbnail='150x150';
$msg = '';
$data = array();
if(is_array($upses)){
$noasyn = $this->rock->get('noasyn'); //=yes就不同步到文件平台
$noyaso = $this->rock->get('noyaso'); //=yes就不压缩
$fileext= substr($upses['fileext'],0,10);
$arrs = array(
'adddt' => $this->rock->now,
'valid' => 1,
'filename' => $this->replacefile($upses['oldfilename']),
'web' => $this->rock->web,
'ip' => $this->rock->ip,
'mknum' => $this->rock->get('sysmodenum'),
//'mid' => $this->rock->get('sysmid','0'),
'fileext' => $fileext,
'filesize' => (int)$this->rock->get('filesize', $upses['filesize']),
'filesizecn'=> $upses['filesizecn'],
'filepath' => str_replace('../','',$upses['allfilename']),
'optid' => $this->adminid,
'optname' => $this->adminname,
'comid' => m('admin')->getcompanyid(),
);
$arrs['filetype'] = m('file')->getmime($fileext);
$thumbpath = $arrs['filepath'];
$sttua = explode('x', $thumbnail);
$lw = (int)$sttua[0];
$lh = (int)$sttua[1];
//判断是不是需要压缩jpg和jpeg
$compress = getconfig('imgcompress');
if($compress && $noyaso!='yes' && ($fileext=='jpg' || $fileext=='jpeg') && $upses['picw']>0 && $upses['pich']>0){
$sttuc = explode('x', $compress);
$yw = (int)$sttuc[0];
$yh = (int)arrvalue($sttuc, 1, 0);
if($upses['picw'] > $yw || $upses['pich'] > $yh){
$imgac = c('image', true);
$imgac->createimg($thumbpath);
$yspaht = $imgac->compress($yw, $yh);
if($yspaht){
if($thumbpath != $yspaht)unlink($thumbpath);
$thumbpath = $yspaht;
$arrs['filepath'] = $yspaht;
$arrs['filesize'] = filesize($yspaht);
$arrs['filesizecn'] = $this->upobj->formatsize($arrs['filesize']);
}
}
}
if($upses['picw']>$lw || $upses['pich']>$lh){
$imgaa = c('image', true);
$imgaa->createimg($thumbpath);
$thumbpath = $imgaa->thumbnail($lw, $lh, 1);
}
if($upses['picw'] == 0 && $upses['pich']==0)$thumbpath = '';
$arrs['thumbpath'] = $thumbpath;
$bo = $this->db->record('[Q]file',$arrs);
if(!$bo)$this->reutnmsg($this->db->error());
$id = $this->db->insert_id();
$arrs['id'] = $id;
$arrs['picw'] = $upses['picw'];
$arrs['pich'] = $upses['pich'];
$data= $arrs;
//上传到上传的文件管理2021-08-09
if(getconfig('rockfile_autoup') && $noasyn != 'yes'){
$stime = time()+rand(3,6);
if($subo)$stime=0;
c('rockqueue')->push('flow,uptofile', array('fileid'=>$id), $stime);
}
//自动上传到腾讯云存储/阿里云oss存储
if((getconfig('qcloudCos_autoup') || getconfig('alioss_autoup')) && $noasyn != 'yes'){
$stime = time()+rand(3,6);
if($subo)$stime=0;
c('rockqueue')->sendfile($id, $stime);
}
}else{
$data['msg'] = $upses;
}
return $data;
}
//过滤特殊文件名
private function replacefile($str)
{
$s = strtolower($str);
$s2 = $s.'';
$lvlaraa = explode(',','user(),found_rows,(),select*from,select*,%20,<,>');
$s = str_replace($lvlaraa, '', $s);
if($s!=$s2)$str = $s;
return $str;
}
//获取扩展名
public function getext($file)
{
return strtolower(substr($file,strrpos($file,'.')+1));
}
}

View File

@@ -0,0 +1,113 @@
<?php
/**
修改记录插件
*/
class editChajian extends Chajian{
public $editarr = array();
/**
获取修改记录
$table 表
$id id值
$oners 旧数组
$newrs 新数组
return string
*/
public function record($table, $id, $oners, $newrs, $glx=1)
{
$str = '';
$db = m($table);
$this->editarr = array();
if($oners){
$farr = $this->getfield($table);
$str = $this->editcont($farr, $oners, $newrs);
}
if($glx == 1 && $str != ''){
$str = '['.$this->adminname.']('.$this->rock->now.')修改:'.$str.'';
}
if($glx == 2){
$this->addrecord($table, $id);
}
return $str;
}
public function records($farr,$table, $id, $oners, $newrs)
{
$this->editcont($farr, $oners, $newrs);
$this->addrecord($table, $id);
}
public function editcont($farr, $oners, $narr)
{
$str = '';
$this->editarr = array();
if($oners){
foreach($narr as $k=>$v){
if(!isset($farr[$k]))continue;
$fa = $farr[$k];
$nv = $v;
$ov = '';
if(isset($oners[$k]))$ov = $oners[$k];
if($nv != $ov){
$sel = array();
if(isset($fa['selarr']))$sel = $fa['selarr'];
if(isset($sel[$ov]))$ov = $sel[$ov];
if(isset($sel[$nv]))$nv = $sel[$nv];
$str .= ''.$fa['name'].':'.$ov.'→'.$nv.';';
$this->editarr[] = array(
'fieldsname' => $fa['name'],
'oldval' => $ov,
'newval' => $nv
);
}
}
}
return $str;
}
public function addrecord($table, $id)
{
$dbs = m('editrecord');
foreach($this->editarr as $k=>$rs){
$rs['optid'] = $this->adminid;
$rs['optname'] = $this->adminname;
$rs['optdt'] = $this->rock->now;
$rs['table'] = $table;
$rs['mid'] = $id;
$dbs->insert($rs);
}
}
/**
获取对应表上字段信息
$glx 0基本字段1流程上
return {字段名:对应信息}
*/
public function getfield($table, $glx=0)
{
$farr = $this->db->gettablefields($this->rock->T($table));
$rows = array();
$arrar = c('array');
foreach($farr as $k=>$rs){
$va = $rs['explain'];
$vn = $rs['name'];
$sel= array();
if(!$this->rock->isempt($va)){
$vas = explode('@', $va);
$va = $vas[0];
$len = count($vas);
if($len>1)$sel = $arrar->strtoobject($vas[1]);
if($len>2&&$glx==1&&$vas[2]=='not')$va='';
}
if(!$this->rock->isempt($va)){
$rows[$vn] = array(
'name' => $va,
'selarr' => $sel
);
}
}
return $rows;
}
}

View File

@@ -0,0 +1,366 @@
<?php
class fileChajian extends Chajian
{
public $path; //文件路径
public $name; //文件名称
public $ext; //扩展名
private $mimitype = array(
'unkown' => 'application/octet-stream',
'acx' => 'application/internet-property-stream',
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'asp' => 'text/plain',
'aspx' => 'text/plain',
'asf' => 'video/x-ms-asf',
'asr' => 'video/x-ms-asf',
'asx' => 'video/x-ms-asf',
'au' => 'audio/basic',
'avi' => 'video/x-msvideo',
'axs' => 'application/olescript',
'bas' => 'text/plain',
'bcpio' => 'application/x-bcpio',
'bin' => 'application/octet-stream',
'bmp' => 'image/bmp',
'c' => 'text/plain',
'cat' => 'application/vnd.ms-pkiseccat',
'cdf' => 'application/x-cdf',
'cer' => 'application/x-x509-ca-cert',
'class' => 'application/octet-stream',
'clp' => 'application/x-msclip',
'cmx' => 'image/x-cmx',
'cod' => 'image/cis-cod',
'cpio' => 'application/x-cpio',
'crd' => 'application/x-mscardfile',
'crl' => 'application/pkix-crl',
'crt' => 'application/x-x509-ca-cert',
'csh' => 'application/x-csh',
'css' => 'text/css',
'dcr' => 'application/x-director',
'der' => 'application/x-x509-ca-cert',
'dir' => 'application/x-director',
'dll' => 'application/x-msdownload',
'dms' => 'application/octet-stream',
'doc' => 'application/msword',
'docx' => 'application/msword',
'dot' => 'application/msword',
'dvi' => 'application/x-dvi',
'dxr' => 'application/x-director',
'eps' => 'application/postscript',
'etx' => 'text/x-setext',
'evy' => 'application/envoy',
'exe' => 'application/octet-stream',
'fif' => 'application/fractals',
'flr' => 'x-world/x-vrml',
'flv' => 'video/x-flv',
'gif' => 'image/gif',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'h' => 'text/plain',
'hdf' => 'application/x-hdf',
'hlp' => 'application/winhlp',
'hqx' => 'application/mac-binhex40',
'hta' => 'application/hta',
'htc' => 'text/x-component',
'htm' => 'text/html',
'html' => 'text/html',
'shtml' => 'text/html',
'htt' => 'text/webviewhtml',
'ico' => 'image/x-icon',
'ief' => 'image/ief',
'iii' => 'application/x-iphone',
'ins' => 'application/x-internet-signup',
'isp' => 'application/x-internet-signup',
'jfif' => 'image/pipeg',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'js' => 'application/x-javascript',
'latex' => 'application/x-latex',
'lha' => 'application/octet-stream',
'lsf' => 'video/x-la-asf',
'lsx' => 'video/x-la-asf',
'lzh' => 'application/octet-stream',
'm13' => 'application/x-msmediaview',
'm14' => 'application/x-msmediaview',
'm3u' => 'audio/x-mpegurl',
'man' => 'application/x-troff-man',
'mdb' => 'application/x-msaccess',
'me' => 'application/x-troff-me',
'mht' => 'message/rfc822',
'mhtml' => 'message/rfc822',
'mid' => 'audio/mid',
'mny' => 'application/x-msmoney',
'mov' => 'video/quicktime',
'movie' => 'video/x-sgi-movie',
'mp2' => 'video/mpeg',
'mp3' => 'audio/mpeg',
'mpa' => 'video/mpeg',
'mpe' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpp' => 'application/vnd.ms-project',
'mpv2' => 'video/mpeg',
'ms' => 'application/x-troff-ms',
'mvb' => 'application/x-msmediaview',
'nws' => 'message/rfc822',
'oda' => 'application/oda',
'p10' => 'application/pkcs10',
'p12' => 'application/x-pkcs12',
'p7b' => 'application/x-pkcs7-certificates',
'p7c' => 'application/x-pkcs7-mime',
'p7m' => 'application/x-pkcs7-mime',
'p7r' => 'application/x-pkcs7-certreqresp',
'p7s' => 'application/x-pkcs7-signature',
'pbm' => 'image/x-portable-bitmap',
'pdf' => 'application/pdf',
'pfx' => 'application/x-pkcs12',
'pgm' => 'image/x-portable-graymap',
'pko' => 'application/ynd.ms-pkipko',
'pma' => 'application/x-perfmon',
'pmc' => 'application/x-perfmon',
'pml' => 'application/x-perfmon',
'pmr' => 'application/x-perfmon',
'pmw' => 'application/x-perfmon',
'png' => 'image/png',
'pnm' => 'image/x-portable-anymap',
'pot,' => 'application/vnd.ms-powerpoint',
'ppm' => 'image/x-portable-pixmap',
'pps' => 'application/vnd.ms-powerpoint',
'ppt' => 'application/vnd.ms-powerpoint',
'pptx' => 'application/vnd.ms-powerpoint',
'prf' => 'application/pics-rules',
'ps' => 'application/postscript',
'pub' => 'application/x-mspublisher',
'qt' => 'video/quicktime',
'ra' => 'audio/x-pn-realaudio',
'ram' => 'audio/x-pn-realaudio',
'ras' => 'image/x-cmu-raster',
'rgb' => 'image/x-rgb',
'rmi' => 'audio/mid',
'roff' => 'application/x-troff',
'rtf' => 'application/rtf',
'rtx' => 'text/richtext',
'scd' => 'application/x-msschedule',
'sct' => 'text/scriptlet',
'setpay' => 'application/set-payment-initiation',
'setreg' => 'application/set-registration-initiation',
'sh' => 'application/x-sh',
'shar' => 'application/x-shar',
'sit' => 'application/x-stuffit',
'snd' => 'audio/basic',
'spc' => 'application/x-pkcs7-certificates',
'spl' => 'application/futuresplash',
'src' => 'application/x-wais-source',
'sst' => 'application/vnd.ms-pkicertstore',
'stl' => 'application/vnd.ms-pkistl',
'stm' => 'text/html',
'svg' => 'image/svg+xml',
'sv4cpio' => 'application/x-sv4cpio',
'sv4crc' => 'application/x-sv4crc',
'swf' => 'application/x-shockwave-flash',
't' => 'application/x-troff',
'tar' => 'application/x-tar',
'tcl' => 'application/x-tcl',
'tex' => 'application/x-tex',
'texi' => 'application/x-texinfo',
'texinfo' => 'application/x-texinfo',
'tgz' => 'application/x-compressed',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'tr' => 'application/x-troff',
'trm' => 'application/x-msterminal',
'tsv' => 'text/tab-separated-values',
'txt' => 'text/plain',
'uls' => 'text/iuls',
'ustar' => 'application/x-ustar',
'vcf' => 'text/x-vcard',
'vrml' => 'x-world/x-vrml',
'wav' => 'audio/x-wav',
'wcm' => 'application/vnd.ms-works',
'wdb' => 'application/vnd.ms-works',
'wks' => 'application/vnd.ms-works',
'wmf' => 'application/x-msmetafile',
'wmv' => 'video/x-ms-wmv',
'wps' => 'application/vnd.ms-works',
'wri' => 'application/x-mswrite',
'wrl' => 'x-world/x-vrml',
'wrz' => 'x-world/x-vrml',
'xaf' => 'x-world/x-vrml',
'xbm' => 'image/x-xbitmap',
'xla' => 'application/vnd.ms-excel',
'xlc' => 'application/vnd.ms-excel',
'xlm' => 'application/vnd.ms-excel',
'xls' => 'application/vnd.ms-excel',
'xlsx' => 'application/vnd.ms-excel',
'xlt' => 'application/vnd.ms-excel',
'xlw' => 'application/vnd.ms-excel',
'xof' => 'x-world/x-vrml',
'xpm' => 'image/x-xpixmap',
'xwd' => 'image/x-xwindowdump',
'z' => 'application/x-compress',
'zip' => 'application/zip',
'rar' => 'application/zip',
'php' => 'text/x-php',
);
public function getAllMime()
{
return $this->mimitype;
}
/**
文件信息
*/
public function fileinfo($path)
{
if($this->filebool($path)){
$arr=pathinfo($path);
$this->name = $arr['basename'];
$this->path = $arr['dirname'];
$this->ext = $arr['extension'];
}
}
/**
删除文件
*/
public function delfile($file)
{
$bool = false;
if($this->filebool($file)){
$bool = unlink($file);
}
return $bool;
}
/**
重命名
*/
public function rename($oldf,$newf)
{
$bool = false;
if($this->filebool($oldf)){
$bool = rename($oldf,$newf);
}
return $bool;
}
/**
判断文件是否存在
*/
public function filebool($path)
{
return file_exists($path);
}
/**
创建文件
@pamars $path 文件路径
@pamars $cont 内容
*/
public function caretefile($path,$cont)
{
}
public function createdir($path, $oi=1)
{
$zpath = explode('/', $path);
$len = count($zpath);
$mkdir = '';
for($i=0; $i<$len-$oi; $i++){
if(!$this->isempt($zpath[$i])){
$mkdir.='/'.$zpath[$i].'';
$wzdir = ROOT_PATH.''.$mkdir;
if(!is_dir($wzdir)){
mkdir($wzdir);
}
}
}
}
/**
* 获取某个目录下所有文件
*/
public function getfilerows($path)
{
$rows = array();
if(!is_dir($path))return $rows;
@$d = opendir($path);
$nyunf = array('.', '..');
while( false !== ($file = readdir($d))){
if(!in_array($file, $nyunf)){
$filess = $path.'/'.$file;
if(is_file($filess)){
$editdt = filectime($filess);//上次修改时间
$lastdt = filemtime($filess);//最后修改的时间
$rows[] = array(
'filename' => $file,
'editdt' => date('Y-m-d H:i:s', $editdt),
'lastdt' => date('Y-m-d H:i:s', $lastdt),
);
}
}
}
return $rows;
}
/**
* 获取某个目录下所有文件夹
*/
public function getfolderrows($path)
{
$rows = array();
if(!is_dir($path))return $rows;
@$d = opendir($path);
$nyunf = array('.', '..');
while( false !== ($file = readdir($d))){
if(!in_array($file, $nyunf)){
$filess = $path.'/'.$file;
if(is_dir($filess)){
$rows[] = array(
'filename' => $file,
);
}
}
}
return $rows;
}
/**
* 获取文件的mime类型
*/
public function getMime($file)
{
$mime = '';
if(!file_exists($file))return $mime;
if(class_exists('finfo')){
$fi = new finfo(FILEINFO_MIME_TYPE);
$mime = $fi->file($file);
}else{
$fobj = getimagesize($file);
$mime = strtolower($fobj['mime']);
}
return $mime;
}
/**
* 根据文件获取对应扩展名
*/
public function getfiletoExt($file, $ext='')
{
$mime = $this->getMime($file);
if($mime=='')return $ext;
foreach($this->mimitype as $kz=>$mita){
if($mita == $mime){
$ext = $kz;
break;
}
}
return $ext;
}
}

View File

@@ -0,0 +1,245 @@
<?php
/**
html相关插件
*/
class htmlChajian extends Chajian{
public function replace($cont)
{
if(isempt($cont))return '';
//$cont = str_replace(array('<', '>'), array('&lt;', '&gt;'), $cont);
//$cont = str_replace(array('[B]','[/B]', '[/A]', "\n"), array('<B>','</B>', '</A>','</p><p>'), $cont);
$cont = str_replace(array('[B]','[/B]', '[/A]'), array('<B>','</B>', '</A>'), $cont);
preg_match_all('/\[(.*?)\]/', $cont, $list);
foreach($list[0] as $k=>$nrs){
if($this->rock->contain($nrs, '[A,')){
$url = str_replace('[A,', '', $nrs);
$url = str_replace(']', '', $url);
$cont = str_replace($nrs, '<A href="'.$url.'" target="_blank">', $cont);
}
if($this->rock->contain($nrs, '[IMG,')){
$url = str_replace('[IMG,', '', $nrs);
$url = str_replace(']', '', $url);
$a = explode(',', $url);
$str = '<img src="'.$a[0].'"';
if(isset($a[1]))$str.=' width="'.$a[1].'"';
if(isset($a[2]))$str.=' height="'.$a[2].'"';
$str.='>';
$cont = str_replace($nrs, $str, $cont);
}
}
return $cont;
}
public function createtable($fields, $arr, $title='',$lx='',$bcolor='')
{
if(isempt($bcolor))$bcolor = '#cccccc';
if($lx=='print'){
$bcolor = '#000000';
$title='';
}
$s = '<table border="0" class="createtable" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">';
if($title != ''){
$s .= '<tr><td colspan="2" align="center" style="border:1px '.$bcolor.' solid;padding:10px;font-size:16px;background:#D2E9FF;">'.$title.'</td></tr>';
}
foreach($fields as $fid=>$na){
$val = '';
$sty = 'padding:8px;';
if(isset($arr[$fid]))$val = $arr[$fid];
if(isset($arr[$fid.'_style']))$sty .= $arr[$fid.'_style'];
$s .= '<tr><td align="right" nowrap style="border:1px '.$bcolor.' solid;padding:5px 8px;">'.$na.'</td><td style="border:1px '.$bcolor.' solid;'.$sty.'" align="left">'.$val.'</td></tr>';
}
$s .='</table>';
return $s;
}
/**
* 单据详情默认展示的
*/
public function xiangtable($fields, $arr,$bcolor='', $lx='')
{
return $this->createtable($fields, $arr,'',$lx, $bcolor);
}
/**
创建table表格数据
@param string $rows 下载导出数据
@param string $headstr 表格表头(如lie1,列1,left@lie2,列2,center)
@return string
*/
public function createrows($rows, $headstr='', $bor='#C9ECFF',$lx='')
{
if($headstr == '')$headstr = $this->request('header');
if($headstr == '')return '';
$arrh = explode('@', $headstr);
$thead = count($arrh);
$lens = $thead-1;
$rlen = count($rows);
for($i=0; $i<$thead; $i++){
$te_str = $arrh[$i];
if(count(explode(',', $te_str)) < 3)$te_str.=',center';
$head[] = explode(',', $te_str);
}
$txt = '';
$style = "padding:3px;border:1px ".$bor." solid";
if($lx=='print')$style = "border:.5pt #000000 solid";
$txt .= '<table width="100%" class="createrows" border="0" cellspacing="0" cellpadding="0" align="center" style="border-collapse:collapse;" >';
$txt .= '<tr>';
for($h=0; $h<$thead; $h++){
$stls= $style;
if($lx=='noborder'){
$stls.=';border-top:none';
if($h==0)$stls.=';border-left:none';
if($h==$lens)$stls.=';border-right:none';
}
$txt.= '<td style="'.$stls.'" bgcolor="#eeeeee" align="'.$head[$h][2].'"><b>'.$head[$h][1].'</b></td>';
}
$txt .= '</tr>';
foreach($rows as $k=>$rs){
$txt .= '<tr>';
$rs['xuhaos'] = $k+1;
for($h=0; $h<$thead; $h++){
$stls= $style;
$stls.='';
if($lx=='noborder'){
if($h==0)$stls.=';border-left:none';
if($h==$lens)$stls.=';border-right:none';
if($k==$rlen-1)$stls.=';border-bottom:none';
}
$val = isset($rs[$head[$h][0]]) ? $rs[$head[$h][0]] : '';
$txt .= '<td style="'.$stls.'" align="'.$head[$h][2].'">'.$val.'</td>';
}
$txt .= '</tr>';
}
$txt .= '</table>';
return $txt;
}
/**
* 创建excel导出表格
*/
public function execltable($title, $headArr, $rows, $lx='')
{
if($lx=='')$lx='xls';
$borst = '.5pt';
$sty = 'style="white-space:nowrap;border:'.$borst.' solid #000000;font-size:12px;"';
$s = '<html><head><meta charset="utf-8"><title>'.$title.'</title></head><body>';
$s .= '<table border="0" style="border-collapse:collapse;">';
$hlen = 1;
$s1='<tr height="30"><td '.$sty.'>序号</td>';
foreach($headArr as $na){
$hlen++;
$s1.='<td '.$sty.'>'.$na.'</td>';
}
$s1.='</tr>';
$s.='<tr height="40"><td '.$sty.' colspan="'.$hlen.'">'.$title.'</td></tr>';
$s.=$s1;
foreach($rows as $k=>$rs){
$atr = '';
if(isset($rs['trbgcolor']))$atr=' bgcolor="'.$rs['trbgcolor'].'"';
$s.='<tr height="26"'.$atr.'>';
$s.='<td align="center" '.$sty.'>'.($k+1).'</td>';
foreach($headArr as $kf=>$na){
$val = '';
if(isset($rs[$kf]))$val=$rs[$kf];
$s.='<td '.$sty.'>'.$this->execelval($val).'</td>';
}
$s.='</tr>';
}
$s.='</table>';
$s.='</body></html>';
$mkdir = ''.UPDIR.'/logs/'.date('Y-m').'';
if(!contain(strtolower(PHP_OS),'win')){
$title = c('pingyin')->get($title, 1);//linux要用拼音不然会乱码
}
$filename = ''.$title.'_'.date('d_His').'.'.$lx.'';
$filename = str_replace('/','',$filename);
$url = ''.$mkdir.'/'.$filename.'';
$bo = $this->rock->createtxt(iconv('utf-8','gb2312',$url), $s);
return $url;
}
//超过11位的数字就会变型处理
private function execelval($str)
{
if($str!=''){
if(is_numeric($str) && strlen($str)>11)$str=''.$str.'&nbsp;';
}
return $str;
}
public function htmlremove($str)
{
$str = preg_replace("/<[^>]*>/si",'',$str);
$str = str_replace(array(' ',"\n"),'', $str);
return $str;
}
public function substrstr($str, $start, $length=null) {
preg_match_all('/./us', $str, $match);
$chars = is_null($length)? array_slice($match[0], $start ) : array_slice($match[0], $start, $length);
unset($str);
return implode('', $chars);
}
//判断字符串是否包含html代码
public function ishtml($val)
{
$bo = false;
if(isempt($val))return $bo;
$valstr = strtolower($val);
$sparr = explode(',','p,div,span,font,table,b,a');
foreach($sparr as $sp){
if(contain($valstr,'<'.$sp.'')){
$bo=true;
break;
}
}
return $bo;
}
public function importdata($fields,$btfid='', $fid='')
{
if($fid=='')$fid='importcont';
$rows = array();
$val = $this->rock->post($fid);
if($val=='')return $rows;
$arrs = explode("\n", $val);
$farr = explode(',', $fields);
$fars = explode(',', $btfid);
foreach($arrs as $valss){
$dars = explode(' ', $valss);
$barr = array();
foreach($farr as $k=>$fid){
$barr[$fid] = isset($dars[$k]) ? $dars[$k] : '';
$barr[$fid] = str_replace('[XINHUBR]', "\n", $barr[$fid]);
}
$bos = true;
foreach($fars as $fids){
if(isset($barr[$fids]) && isempt($barr[$fids]))$bos = false;
}
if($bos)$rows[] = $barr;
}
return $rows;
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* 来自:信呼开发团队
* 作者:磐石(rainrock)
* 网址http://www.rockoa.com/
* 华为的推送服务
* 参考的开发https://developer.huawei.com/consumer/cn/service/hms/catalog/huaweipush_v3.html?page=hmssdk_huaweipush_api_reference_messagesend
*/
class hwpushChajian extends Chajian{
//华为推送的设置【自己编译app】以下2个必须设置
private $appid = '';
private $appsecret = '';
/**
* 相关域名定义
*/
private $tokenurl = 'https://login.cloud.huawei.com/oauth2/v2/token';
private $pushurl = 'https://push-api.cloud.huawei.com/v1/{appid}/messages:send';
protected function initChajian()
{
if(!$this->appid)$this->appid = getconfig('hw_appid');
if(!$this->appsecret)$this->appsecret = getconfig('hw_appsecret');
}
public function sendbool()
{
if($this->appsecret=='')return false;
return true;
}
public function setinfo($apid,$apse)
{
$this->appid = $apid;
$this->appsecret = $apse;
return $this;
}
/**
* 获取token
*/
public function gettoken(){
if($this->appid=='' || $this->appsecret=='')return '';
$token = c('cache')->get('hwtoken');
if(isempt($token)){
$result = c('curl')->postcurl($this->tokenurl, array(
"grant_type" => "client_credentials",
"client_secret" => $this->appsecret,
"client_id" => $this->appid,
));
if($result){
$barr = json_decode($result, true);
$token = $barr['access_token'];
c('cache')->set('hwtoken',$token, $barr['expires_in']-1);
}
}
return $token;
}
/**
* 安卓推送通知
*/
public function androidsend($alias, $title, $cont)
{
if(!$this->sendbool())return '';
$url = str_replace('{appid}',$this->appid, $this->pushurl);
$token = $this->gettoken();
if(!$token)return '';
$data = '{"validate_only": false, "message": {"android": { "notification": { "title": "'.$title.'", "body": "'.$cont.'", "click_action": { "type": 1, "intent": "#Intent;compo=com.rvr/.Activity;S.W=U;end" } } }, "token": '.json_encode($alias).' }}';
$result = c('curl')->postcurl($url, $data, 0, array(
"Content-Type" => 'application/json',
"Authorization" => "Bearer {$token}"
));
return $result;
}
}

View File

@@ -0,0 +1,352 @@
<?php
/**
gd2库图片处理添加水印
*/
class imageChajian extends Chajian
{
public $ext; //图片类型
public $img; //图片对象
public $mime; //图片对象
public $path; //图片地址
public $w = 0;
public $h = 0;
public $bool = false;
public $size = 0;
public $whbili = 0;//高和宽的比例
protected function initChajian()
{
$this->bool = function_exists('ImageCreate');
}
/**
创建图片对象$rotate旋转角度
*/
public function createimg($path,$rotate=0)
{
if(!$this->bool)return false;
$this->bool = false;
if(!file_exists($path))return false;
$this->ext = $this->getext($path);
$this->path = $path;
$img = $this->createimgobj($path);
$this->img = $img;
if(!$img)return false;
//判断是否旋转
if($rotate != 0 && $rotate<360 && $rotate>-360){
$white = $this->color('#ffffff',$img);
$img = imagerotate($img, $rotate, $white);//旋转
}
$this->w = imagesx($this->img);
$this->h = imagesy($this->img);
$this->size = ceil(filesize($this->path)/1024);
$this->whbili = $this->w/$this->h;
$this->bool = true;
}
/**
获取图片对象
*/
public function createimgobj($path)
{
$ext = $this->getmime($path);
$img = false;
switch ($ext){
case 'image/gif':
$img=imagecreatefromgif($path);
break;
case 'image/png':
$img=imagecreatefrompng($path);
break;
default:
$img=imagecreatefromjpeg($path);
break;
}
return $img;
}
public function conver($opath, $npath)
{
if(!file_exists($opath))return;
$img = $this->createimgobj($opath);
$this->saveas($npath, $img);
}
/**
获取图片的格式
*/
public function getext($img_name)
{
$type = strtolower(substr($img_name,strrpos($img_name,'.')+1));
return $type;
}
public function getmime($img_name)
{
$mime = '';
if(file_exists($img_name)){
$fileobj = getimagesize($img_name);
$mime = strtolower($fileobj['mime']);
$this->mime = $mime;
}
return $mime;
}
/**
添加文字水印
$str 添加文字
*/
public function addwater($str,$color='#000000',$size=20,$align='rb')
{
if(!$this->bool)return;
$font = '../fonts/FZZHYJW.TTF'; //方正稚艺简体
$lw = strlen($str)*($size/2);
$lh = $size*0.5;
$color = $this->color($color,$this->img);
$x = 2;
$y = 2;
switch($align){
case 'rb'://右下角
$x = $this->w - $lw-2;
$y = $this->h - $lh-2;
break;
case 'tr'://右上角
$x = $this->w - $lw-2;
break;
case 'lb'://左下角
$y = $this->h - $lh-2;
break;
case 'cn'://居中
$x = ($this->w - $lw) * 0.5;
$y = ($this->h - $lh) * 0.5;
break;
}
imagettftext($this->img, $size,0, $x, $y, $color, $font, $str);
$sapath = str_replace('.'.$this->ext.'', '_water.'.$this->ext.'', $this->path);
$sapath = $this->path;
$this->saveas($sapath, $this->img);//另存为
}
/**
添加图片水印
@params $align 图片位置
*/
public function imgwater($imgpath,$align='rb')
{
if(!$this->bool || !file_exists($imgpath))return;
list($lw, $lh) = getimagesize($imgpath);
$logoimg = $this->createimgobj($imgpath);
$x = 2;
$y = 2;
switch($align){
case 'rb'://右下角
$x = $this->w - $lw-2;
$y = $this->h - $lh-2;
break;
case 'tr'://右上角
$x = $this->w - $lw-2;
break;
case 'lb'://左下角
$y = $this->h - $lh-2;
break;
case 'cn'://居中
$x = ($this->w - $lw) * 0.5;
$y = ($this->h - $lh) * 0.5;
break;
}
imagecopymerge($this->img, $logoimg, $x ,$y ,0 ,0 ,$lw ,$lh, 100);
$this->saveas($this->path, $this->img);
}
/**
创建颜色
*/
public function color($color,$img)
{
if(!empty($color)&&(strlen($color)==7)){
$r=hexdec(substr($color,1,2));
$g=hexdec(substr($color,3,2));
$b=hexdec(substr($color,5));
}else{
$r=$g=$b='00';
}
return imagecolorallocate($img, $r, $g, $b);
}
public function colorTorgb($color)
{
if(!empty($color)&&(strlen($color)==7)){
$r=hexdec(substr($color,1,2));
$g=hexdec(substr($color,3,2));
$b=hexdec(substr($color,5));
}else{
$r=$g=$b='00';
}
return array($r, $g, $b);
}
public function colorToHsl($color)
{
$rgba = $this->colorTorgb($color);
$r = floatval($rgba[0])/255;
$g = floatval($rgba[1])/255;
$b = floatval($rgba[2])/255;
$rgb = array($r, $g, $b);
$max = max($rgb);
$min = min($rgb);
$diff = $max - $min;
if ($max == $min) {
$h = 0;
} else if ($max == $r && $g >= $b) {
$h = 60 * (($g - $b) / $diff);
} else if ($max == $r && $g < $b) {
$h = 60 * (($g - $b) / $diff) + 360;
} else if ($max == $g) {
$h = 60 * (($b - $r) / $diff) + 120;
} else if ($max == $b) {
$h = 60 * (($r - $g) / $diff) + 240;
}
$l = ($max + $min) / 2;
if ($l == 0 || $max == $min) {
$s = 0;
} else if (0 < $l && $l <= 0.5) {
$s = $diff / (2 * $l);
} else if ($l > 0.5) {
$s = $diff / (2 - 2 * $l);
}
return array($h, round($s*100,2), round($l*100,2));
}
/**
注销图片
*/
private function destroy()
{
imagedestroy($this->img);
}
/**
另存图片
*/
private function saveas($spath,$img)
{
$ext = $this->getmime($spath);
$this->saveass($ext, $img, $spath);
}
private function saveass($ext,$img, $spath)
{
switch($ext){
case 'image/gif':
imagegif($img,$spath);
break;
case 'image/png':
imagepng($img,$spath);
break;
case 'image/bmp':
imagewbmp($img,$spath);
break;
default:
imagejpeg($img,$spath,80);
break;
}
}
/**
* 压缩图片
*/
public function compress($w,$h)
{
if(!$this->bool)return '';
$bili = 1;
$nh = $h;
$nw = $w;
if($w < $this->w){
$bili = $w / $this->w;
$nh = $bili * $this->h;
}
if($h>0 && $nh > $h){
$bili = $h / $this->h;
$nh = $h;
$nw = $bili * $this->w;
}
if($bili==1)return '';
$yspath = str_replace('.'.$this->ext.'', 'y.'.$this->ext.'', $this->path);
return $this->thumbnail($nw, $nh, 0, $yspath);
}
/**
图片缩略图
@param $w 宽
@param $h 高
*/
public function thumbnail($w,$h,$lx=0, $sapath='')
{
if(!$this->bool)return '';
list($mw, $mh, $bili) = $this->imgwh($w,$h);
$tmpimg = imagecreatetruecolor($w,$h);
imagefill($tmpimg,0,0,$this->color('#ffffff',$tmpimg));
$tx = 0;
$ty = 0;
//开始截的位置
$sx = 0;
$sy = 0;
if($w > $mw){
if($lx==1){//整图缩略可以看到白边
$tx = ($w-$mw)/2;
}else if($lx == 0){//可能去掉看不到的
$mw = $w;
$mh = $mw/$this->whbili;
$nbl= $mh/$this->h;
$sy = ($mh-$h)/2/$nbl; //当前缩放比例
}
}
if($h > $mh){
if($lx==1){
$ty = ($h-$mh)/2;
}else if($lx == 0){
$mh = $h;
$mw = $mh*$this->whbili;
$nbl= $mw/$this->w;
$sx = ($mw-$w)/2/$nbl; //当前缩放比例
}
}
//imagecopyresized
imagecopyresampled($tmpimg, $this->img, $tx,$ty, $sx,$sy, $mw,$mh,$this->w,$this->h);//生成缩略图
//$sapath = str_replace('.'.$this->ext.'', '_thumb'.$w.'x'.$h.'.'.$this->ext.'', $this->path);
if($sapath=='')$sapath = str_replace('.'.$this->ext.'', '_s.'.$this->ext.'', $this->path);
$this->saveass($this->mime ,$tmpimg, $sapath);//保存图片
return $sapath;
}
/**
图片显示宽高
*/
public function imgwh($mw,$mh)
{
$w = $this->w;
$h = $this->h;
$bili=1;
if($w>$mw){
$bili=($mw/$w);
$h=$bili*$h;
$w=$mw;
}
if($h>$mh){
$bili=($mh/$this->h);
$w=$bili*$this->w;
$h=$mh;
}
return array($w,$h,$bili);
}
}

View File

@@ -0,0 +1,317 @@
<?php
/**
* imap 收邮件扩展
imap_search 使用返回Id
http://php.net/manual/en/function.imap-search.php
ALL 返回所有合乎标准的信件
ANSWERED 信件有配置 \\ANSWERED 标志者
BCC "字符串" Bcc 栏中有指定 "字符串" 的信件
BEFORE "日期" 指定 "日期" 以前的信件
BODY "字符串" 内文字段中有指定 "字符串" 的信件
CC "字符串" Cc 栏中有指定 "字符串" 的信件
DELETED 合乎已删除的信件
FLAGGED 信件有配置 \\FLAGGED 标志者
FROM "字符串" From 栏中有指定 "字符串" 的信件
KEYWORD "字符串" 关键字为指定 "字符串" 者
NEW 新的信件
OLD 旧的信件
ON "日期" 指定 "日期" 的信件
RECENT 信件有配置 \\RECENT 标志者
SEEN 信件有配置 \\SEEN 标志者
SINCE "日期" 指定 "日期" 之后的信件
SUBJECT "字符串" Subject 栏中有指定 "字符串" 的信件
TEXT "字符串" Text 栏中有指定 "字符串" 的信件
TO "字符串" To 栏中有指定 "字符串" 的信件
UNANSWERED 未回应的信件
UNDELETED 未删除的信件
UNFLAGGED 未配置标志的信件
UNKEYWORD "字符串" 未配置关键 "字符串" 的信件
UNSEEN 未读取的信件
*/
class imapChajian extends Chajian
{
private $supportbool = true;
protected function initChajian()
{
$this->supportbool = $this->isimap();
$this->marubox = false;
}
public function isimap()
{
return function_exists('imap_open');
}
/**
* 读取某日期后的邮件
* @params $link 服务器
* @params $user 邮箱
* @params $pass 邮箱密码
* @params $time 时间戳默认7天前的
*/
public function receemail($link, $user, $pass, $time=0)
{
if(isempt($link))return '未设置收邮件imap服务器';
if(isempt($user))return '用户未设置邮箱';
if(isempt($pass))return '邮箱['.$user.']未设置密码';
if(!$this->supportbool)return '系统未开启imap收邮件扩展';
$this->marubox = @imap_open($link,$user,$pass);
$this->struck_tearr = array();
if(!$this->marubox)return '不能连接到['.$link.']可能帐号密码有错';
if($time == 0)$time = time() - 7*24*3600;
$ondt = date('j M Y', $time);
$searcharr = imap_search($this->marubox, 'SINCE "'.$ondt.'"');//指定日期之后
$rows = array();
//return $searcharr;
if($searcharr)foreach($searcharr as $k=>$i){
$headers = $this->getheader($i);
$body = $this->getBody($i);
$headers['body'] = $body;
$headers['num'] = $i;
$headers['attach'] = $this->getattach($i);
$rows[] = $headers;
}
imap_close($this->marubox, CL_EXPUNGE);
return $rows;
$totalrows = imap_num_msg($this->marubox); //取得信件数
$rows = array();
for ($i=1;$i<=$totalrows;$i++){
$headers = $this->getheader($i); //获取某信件的标头信息
$body = $this->getBody($i); //获取信件正文
$headers['body'] = $body;
$headers['num'] = $i;
$headers['attach'] = $this->getattach($i);
$rows[] = $headers;
}
imap_close($this->marubox, CL_EXPUNGE);
return $rows;
}
/**
* 下载附件
*/
public function downattach($link, $user, $pass, $num, $key)
{
}
private function getfetchstructure($i)
{
if(!isset($this->struck_tearr[$i])){
$struck = imap_fetchstructure($this->marubox,$i);
}else{
$struck = $this->struck_tearr[$i];
}
return $struck;
}
/**
* 获取附件
*/
private function getattach($i)
{
$arr = array();
$struck = $this->getfetchstructure($i);
if($struck && isset($struck->parts))foreach($struck->parts as $key=>$val){
if($val->subtype=='OCTET-STREAM'){
if(isset($val->dparameters[0]))$arr[] = array(
'filename' => $this->_imap_utf8($val->dparameters[0]->value),
'filesize' => $val->bytes,
'encoding' => $val->encoding,
'filekey' => $key,
'attachcont' => $this->getattachcont($i, $key, $val->encoding) //获取附件内容
);
}
}
return $arr;
}
/**
* 附件内容读取,需要额外读取
*/
public function getattachcont($i, $key, $encoding)
{
$message = imap_fetchbody($this->marubox, $i, $key + 1);
switch ($encoding) {
case 0:
$message = imap_8bit($message);
break;
case 1:
$message = imap_8bit($message);
break;
case 2:
$message = imap_binary($message);
break;
case 3:
$message = imap_base64($message);
break;
case 4:
$message = quoted_printable_decode($message);
break;
case 5:
$message = $message;
break;
}
return $message;
}
private function getkevel($st, $kdy, $dev='')
{
return objvalue($st, $kdy, $dev);
}
/**
* 获取某信件的标头信息
*/
private function getheader($i)
{
$headers = imap_header($this->marubox, $i);
$arr['subject'] = $this->_imap_utf8($this->getkevel($headers,'subject'));//标题
$arr['message_id'] = $this->getkevel($headers,'message_id');//邮件ID
$arr['size'] = $this->getkevel($headers,'Size','0'); //邮件大小
$arr['date'] = date('Y-m-d H:i:s', strtotime($this->getkevel($headers,'date')));
$arr['to'] = array();
$arr['from'] = array();
//发给
if(isset($headers->to)){
$arr['to'] = $headers->to;
foreach($arr['to'] as $k=>$rs){
$arr['to'][$k]->personal = $this->_imap_utf8($this->getkevel($rs, 'personal'));
$arr['to'][$k]->email = ''.$rs->mailbox.'@'.$rs->host.'';
}
}
$arr['toemail'] = $this->stremail($arr['to']);
//发件人
if(isset($headers->from)){
$arr['from'] = $headers->from;
foreach($arr['from'] as $k=>$rs){
$arr['from'][$k]->personal = $this->_imap_utf8($this->getkevel($rs, 'personal'));
$arr['from'][$k]->email = ''.$rs->mailbox.'@'.$rs->host.'';
}
}
$arr['fromemail'] = $this->stremail($arr['from']);
//回复的邮件
if(isset($headers->reply_to)){
$arr['reply_to'] = $headers->reply_to;
foreach($arr['reply_to'] as $k=>$rs){
$arr['reply_to'][$k]->personal = $this->_imap_utf8($this->getkevel($rs, 'personal'));
$arr['reply_to'][$k]->email = ''.$rs->mailbox.'@'.$rs->host.'';
}
$arr['reply_toemail'] = $this->stremail($arr['reply_to']);
}else{
$arr['reply_toemail'] = $arr['fromemail'];
}
//抄送
$arr['cc'] = array();
if(isset($headers->cc)){
$arr['cc'] = $headers->cc;
foreach($arr['cc'] as $k=>$rs){
$arr['cc'][$k]->personal = $this->_imap_utf8($this->getkevel($rs, 'personal'));
$arr['cc'][$k]->email = ''.$rs->mailbox.'@'.$rs->host.'';
}
}
$arr['ccemail'] = $this->stremail($arr['cc']);
$arr['headers'] = $headers;
return $arr;
}
private function stremail($arr)
{
$str = '';
if(is_array($arr))foreach($arr as $k=>$rs){
$str.=','.$rs->personal.'('.$rs->mailbox.'@'.$rs->host.')';
}
if($str!='')$str = substr($str, 1);
return $str;
}
private function _imap_utf8($text) {
$text = iconv_mime_decode($text,0, 'UTF-8');
return $text;
}
private function _iconv_utf8($text) {
$encode = mb_detect_encoding($text, array('ASCII','UTF-8','GB2312','GBK','BIG5'));
if($encode != 'UTF-8'){
return @iconv($encode, 'utf-8', $text);
}else{
return $text;
}
@$s1 = iconv('gbk', 'utf-8', $text);
$s0 = iconv('utf-8', 'gbk', $s1);
if ($s0 == $text) {
return $s1;
} else {
return $text;
}
}
function get_mime_type(&$structure) { //Get Mime type Internal Private Use
$primary_mime_type = array("TEXT", "MULTIPART", "MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER");
if ($structure->subtype) {
return $primary_mime_type[(int) $structure->type] . '/' . $structure->subtype;
}
return "TEXT/PLAIN";
}
private function get_part($stream, $msg_number, $mime_type, $structure = false, $part_number = false) { //Get Part Of Message Internal Private Use
if (!$structure) {
$structure = $this->getfetchstructure($msg_number);;
}
if ($structure) {
if ($mime_type == $this->get_mime_type($structure)) {
if (!$part_number) {
$part_number = "1";
}
$text = imap_fetchbody($stream, $msg_number, $part_number);
if ($structure->encoding == 3) {
return imap_base64($text);
} else if ($structure->encoding == 4) {
return imap_qprint($text);
} else {
return $text;
}
}
if ($structure->type == 1) /* multipart */ {
while (list($index, $sub_structure) = each($structure->parts)) {
$prefix = '';
if ($part_number) {
$prefix = $part_number . '.';
}
$data = $this->get_part($stream, $msg_number, $mime_type, $sub_structure, $prefix . ($index + 1));
if ($data) {
return $data;
}
}
}
}
return false;
}
/**
* 获取邮件内容
*/
private function getBody($mid) {
$body = $this->get_part($this->marubox, $mid, "TEXT/HTML");
if ($body == "") {
$body = $this->get_part($this->marubox, $mid, "TEXT/PLAIN");
}
if ($body == "") {
return "";
}
return $this->_iconv_utf8($body);
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* 图片验证码
*/
class imgcodeChajian extends Chajian{
public function check($key,$val)
{
if(isempt($val))return false;
$code = 'abc'.$val.'';
$geval = c('cache')->get('code'.$key.'');
if(md5($code)!=$geval)return false;
c('cache')->del('code'.$key.'');
return true;
}
public function show($key)
{
header("Content-type:image/gif");
$a = rand(0,9);
$b = rand(0,9);
$h = 30;
$code = 'abc'.($a+$b).'';
$w = 70;
$im = imagecreatetruecolor($w,$h);
c('cache')->set('code'.$key.'', md5($code), 5*60);
$bg = imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$bg); //添加背景颜色
$black = imagecolorallocate($im,0,0,0);
for($i=0;$i<2;$i++){//画线条
$at1=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imageline($im,0,rand(0,$h),$w,rand(0,$h),$at1);
}
for($i=0;$i<200;$i++){//画点
$at1=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im,rand(0,$w),rand(0,$h),$at1);
}
imagestring($im,5,rand(0,30),rand(0,$h-15),''.$a.'+'.$b.'=?',$black);
imagegif($im);
imagedestroy($im);
}
}

View File

@@ -0,0 +1,443 @@
<?php
/**
* 系统表单插件
*/
class inputChajian extends Chajian
{
public $fieldarr = array();
public $flow = null;
public $ismobile = 0;
public $urs = array();
public $mid = 0;
protected function initChajian()
{
$this->date = $this->rock->date;
$this->now = $this->rock->now;
$this->option = m('option');
}
public function initUser($uid)
{
$this->adminid = $uid;
$this->urs = m('admin')->getone($uid, '`name`,`deptname`');
$this->adminname= $this->urs['name'];
}
public function initFields($stwhe='')
{
$fieldarr = m('flow_element')->getrows($stwhe,'*','`sort`');
foreach($fieldarr as $k=>$rs){
$this->fieldarr[$rs['fields']] = $rs;
}
return $fieldarr;
}
/**
* 读取表单样式(有默认值的)
*/
public function getfieldcontval($fid, $val=false, $objs=null)
{
return $this->getfieldcont($fid, $objs,'',0, $val);
}
/**
* 读取表单样式
*/
public function getfieldcont($fid, $objs=null, $leox='', $iszb=0, $deval=false)
{
$fida= explode(',', $fid);$xu0='0';
$ism = $this->ismobile;
$fid = $fida[0];
$str = $val ='';
if(isset($fida[1]))$xu0=$fida[1];
if($fid=='base_name'){
$str = '<input class="inputs" style="border:none;background:none" name="base_name" value="'.$this->adminname.'" readonly>';
}
if($fid=='base_deptname'){
$str = '<input class="inputs" style="border:none;background:none" name="base_deptname" value="'.$this->urs['deptname'].'" readonly>';
}
if($fid=='base_sericnum'){
$str = '<input class="inputs" style="border:none;background:none" name="base_sericnum" value="'.$this->flow->createnum().'" readonly>';
}
if($fid=='file_content'){
$str = '<input name="fileid" type="hidden" id="fileidview-inputEl"><div id="view_fileidview" style="width:98%;height:auto;min-height:60px;border:1px #cccccc solid; background:white;overflow:auto"></div><div id="fileupaddbtn"><a href="javascript:;" class="blue" onclick="c.upload()"><u>+添加文件</u></a></div>';
}
if($fid=='删'){
$str='<a href="javascript:;" onclick="c.delrow(this,'.$xu0.')">删</a>';
}
if($fid=='新增'){
$str='<a href="javascript:;" onclick="c.addrow(this,'.$xu0.')">+新增</a>';
}
if($str!='')return $str;
if(!isset($this->fieldarr[$fid]))return '';
$isasm = 1;
$a = $this->fieldarr[$fid];
$fname = $fid.$leox;
$type = $a['fieldstype'];
$placeholder = arrvalue($a, 'placeholder');
$isbt = arrvalue($a, 'isbt');
$data = $a['data'];
$val = $a['dev'];
if(isset($a['value']))$val=$a['value'];
$attr = $a['attr'];
$lens = (int)arrvalue($a, 'lens','0');
$styles = '';
$style = '';
if(contain($attr,',')){
$attra = explode(',', $a['attr']);
$style = $attra[1];
$attr = $attra[0];
}
if(!isempt($style))$styles=' style="'.$style.'"';
$fnams = $this->rock->arrvalue($a,'name');$fieldname = $fnams;
if($isbt==1)$fnams='*'.$fnams.'';
$val = $this->rock->get('def_'.$fname.'', $val);
if(isempt($val))$val='';
if($deval !== false)$val = $deval; //设置默认值
if(isempt($attr))$attr='';
if($val!='' && contain($val,'{')){
$val = m('base')->strreplace($val, $this->adminid, 1);
if($val=='{sericnum}' && $this->flow!=null)$val = $this->flow->createnum();
}
if($type=='num'){
if($this->flow != null){
$val = $this->flow->createinputnum($data, $fid);
}
}
//读默认值
if($objs != null && method_exists($objs, 'inputfieldsval')){
$_vals = $objs->inputfieldsval($fname, $a);
if(!isempt($_vals))$val = $_vals;
}
if(!isempt($placeholder))$attr.=' placeholder="'.$placeholder.'"';
if($type=='email' || $type=='tel' || $type=='mobile' || $type=='url'){
$attr.=' inputtype="'.$type.'"';
}
$lenstr = '';
if($lens>0)$lenstr=' maxlength="'.$lens.'"';
$onblue = ' onblur="c.inputblur(this, '.$iszb.')"';
$iszhang= false;
$str = '<input class="inputs" type="text" value="'.$val.'" '.$attr.''.$onblue.''.$styles.''.$lenstr.' name="'.$fname.'">';
if($type=='fixed'||$type=='hidden'){
$str = '<input value="'.$val.'" '.$attr.' type="hidden" name="'.$fname.'">';
$isasm=0;
}
if($type=='textarea'){
$iszhang= false;
$str = '<textarea class="textarea" onblur="js.changdu(this)" style="height:80px;'.$style.'" '.$attr.''.$lenstr.' name="'.$fname.'">'.$val.'</textarea>';
}
if($type=='rockcombo' || $type=='select' || $type=='checkboxall' || $type=='radio'){
$attr.=' onchange="c.inputblur(this, '.$iszb.')"';
$str ='<select style="width:99%;'.$style.'" '.$attr.' name="'.$fname.'" class="inputs">';
$str.='<option value="">-请选择-</option>';
$str1= '';
$str2= '';
$datanum = $data;
$fopt = $this->getdatastore($type, $objs, $datanum, $fid);
$optgroup = '';
if($fopt)foreach($fopt as $k=>$rs){
$_val= arrvalue($rs,'value', $rs['name']);
$sel = ($_val==$val)?'selected':'';
$sel2 = ($_val==$val)?'checked':'';
$ocn = '';
if($type=='select')foreach($rs as $k1=>$v1)if($k1!='id'&&$k1!='value'&&$k1!='name')$ocn.=' '.$k1.'="'.$v1.'"';
if($type=='select' && isset($rs['optgroup']) && !isempt($rs['optgroup'])){
if($optgroup!=$rs['optgroup']){
if($optgroup!='')$str.='</optgroup>';
$str.='<optgroup label="'.$rs['optgroup'].'">';
}
$optgroup = $rs['optgroup'];
}
$str.='<option'.$ocn.' value="'.$_val.'" '.$sel.'>'.$rs['name'].'</option>';
$str1.='<label><input name="'.$fname.'[]" value="'.$_val.'" type="checkbox">'.$rs['name'].'</label>&nbsp;&nbsp;';
$str2.='<label><input'.$ocn.' name="'.$fname.'" '.$sel2.' value="'.$_val.'" type="radio">'.$rs['name'].'</label>&nbsp;&nbsp;';
}
if($type=='select' && $optgroup!='')$str.='</optgroup>';
$str.='</select>';
if($type=='checkboxall')$str = $str1;
if($type=='radio')$str = $str2;
}
if($type=='datetime'||$type=='date'||$type=='time'||$type=='month'){
$str = '<input onclick="js.datechange(this,\''.$type.'\')" value="'.$val.'" '.$attr.''.$onblue.''.$styles.' class="inputs datesss" inputtype="'.$type.'" readonly name="'.$fname.'">';
}
//数字类型
if($type=='number'){
$str = '<input class="inputs" '.$attr.''.$styles.' value="'.$val.'" type="number" onfocus="js.focusval=this.value" '.$lenstr.' onblur="js.number(this);c.inputblur(this,'.$iszb.')" name="'.$fname.'">';
}
if($type=='xuhao'){
$str = '<input class="inputs xuhao" '.$attr.' type="text" value="'.$val.'" name="'.$fname.'">';
$str.= '<input value="0" type="hidden" name="'.$a['fieldss'].$leox.'">';
}
if($type=='changeusercheck'||$type=='changeuser'||$type=='changedept'||$type=='changedeptcheck'||$type=='changedeptusercheck'){
$zbnae = $data;
if($iszb>0)$zbnae = $data.''.($iszb-1).''.$leox.'';
$str = $this->inputchangeuser(array(
'name' => $fname,
'id' => $zbnae,
'value' => $val,
'type' => $type,
'title' => $fieldname,
'changerange' => arrvalue($a, 'gongsi'),
'placeholder' => $placeholder,
'attr' => $onblue,
'style' => '',
));
}
if($type=='selectdatafalse' || $type=='selectdatatrue'){
$str = '<table width="98%" cellpadding="0" border="0"><tr><td width="100%"><input '.$attr.''.$onblue.''.$styles.' class="inputs" style="width:99%" value="'.$val.'" readonly type="text" name="'.$fname.'"></td>';
$str .= '<td nowrap>';
if($isbt=='0')$str .= '<button onclick="c.selectdataclear(\''.$fname.'\',\''.$data.'\','.$iszb.')" class="webbtn" type="button">x</button>';
$str .= '<button type="button" onclick="c.selectdata(\''.$data.'\','.substr($type,10).',\''.$fname.'\',\''.$fieldname.'\','.$iszb.')" class="webbtn">选</button></td></tr></table>';
}
if($type=='ditumap'){
$zbnae = $data;
if($iszb>0)$zbnae = ''.($iszb-1).''.$leox.'';
$str = '<table width="99%" cellpadding="0" border="0"><tr><td width="100%"><input '.$attr.''.$onblue.''.$styles.''.$lenstr.' class="inputs" style="width:99%" value="'.$val.'" type="text" name="'.$fname.'"></td>';
$str .= '<td nowrap>';
if($isbt=='0')$str .= '<button onclick="c.selectmapclear(\''.$fname.'\',\''.$zbnae.'\','.$iszb.')" class="webbtn" type="button">x</button>';
$str .= '<button type="button" onclick="c.selectmap(\''.$fname.'\',\''.$zbnae.'\',\''.$fieldname.'\','.$iszb.')" class="webbtn">选</button></td></tr></table>';
}
if($type=='htmlediter'){
$iszhang= false;
$str = '<textarea class="textarea" style="height:130px;'.$style.'" '.$attr.' name="'.$fname.'">'.$val.'</textarea>';
}
if($type=='checkbox'){
$chk = '';
if($val=='1'||$val=='true')$chk='checked';
$str = '<input name="'.$fname.'" '.$chk.' '.$attr.''.$styles.' type="checkbox" value="1"> ';
}
if($type=='uploadimg'){
$str = '<input name="'.$fname.'" value="'.$val.'" type="hidden">';
$str.= '<img src="images/noimg.jpg" onclick="c.showviews(this)" id="imgview_'.$fname.'" height="100">';
$str.= '<div style="display:" tsye="img" tnam="'.$fname.'" id="filed_'.$fname.'"><a href="javascript:;" onclick="c.uploadimgclear(\''.$fname.'\')">删</a>&nbsp;<input onclick="c.initupss(\''.$fname.'\');" type="file" style="width:120px" accept="image/jpg,image/jpeg,image/png" id="filed_'.$fname.'_inp"></div>';
}
if($type=='uploadfile'){
$str = '<input name="'.$fname.'" value="'.$val.'" type="hidden">';
$str.= '<div style="display:inline-block" id="fileview_'.$fname.'"><div onclick="c.uploadfilei(\''.$fname.'\')" style="display:;border:dashed 1px #cccccc" id="'.$fname.'_divadd" class="upload_items"><img class="imgs" src="images/jia.png"></div></div>';
$str.= '<div style="display:none" tsye="file" tnam="'.$fname.'" tdata="'.$data.'" id="filed_'.$fname.'"><input type="file" style="width:120px" multiple="multiple" id="filed_'.$fname.'_inp"></div>';
}
if($type=='graph'){
$str = '<input name="'.$fname.'" value="'.$val.'" type="hidden">';
$str.= '<div id="graphview_'.$fname.'" >';
$str.= '<button type="button" onclick="c.autograph(\''.$fname.'\',0)" class="webbtn">手写</button><button type="button" onclick="c.autograph(\''.$fname.'\',1)" class="webbtn">引入</button><button onclick="c.autograph(\''.$fname.'\',2)" class="webbtn" type="button">x</button></div>';
}
if($type=='auto'){
$datanum = $data;
if(!isempt($datanum)){
if($objs!=null && method_exists($objs, $datanum)){
$str = $objs->$datanum($this->mid, $this->flow);
}
}
}
if($iszb>0)return $str;
if($isasm==1){
$lx = 'span';if($ism==1)$lx='div';
$str = '<'.$lx.' id="div_'.$fname.'" class="divinput">'.$str.'</'.$lx.'>';
if($ism==1 && $iszb==0){
if($iszhang){
$str = '<tr class="lumtr"><td colspan="2"><div style="padding-left:10px;padding-top:10px">'.$fnams.'</div>'.$str.'</td></tr>';
}else{
$str = '<tr class="lumtr"><td class="lurim" nowrap>'.str_replace(' ','<br>', $fnams).'</td><td width="90%">'.$str.'</td></tr>';
}
}
}
return $str;
}
/**
* 输出选择人员html
*/
public function inputchangeuser($arr=array())
{
$oarr = array(
'name'=>'',
'id'=>'',
'type'=>'changeuser',
'value'=> '',
'valueid'=> '',
'title' => '',
'changerange' => '',
'placeholder' => '',
'attr' => '',
);
foreach($arr as $k=>$v)$oarr[$k]=$v;
$fname = $oarr['name'];
$zbnae = $oarr['id'];
$type = $oarr['type'];
$valea = explode('|', $oarr['value']);
$_vals0 = $valea[0];
$_vals1 = arrvalue($valea,1, $oarr['valueid']);
$str = '<table width="99%" cellpadding="0" border="0"><tr><td width="100%"><input class="inputs" style="width:99%" '.$oarr['attr'].' placeholder="'.$oarr['placeholder'].'" id="change'.$fname.'" value="'.$_vals0.'" readonly type="text" name="'.$fname.'"><input name="'.$zbnae.'" value="'.$_vals1.'" id="change'.$fname.'_id" type="hidden"></td>';
$str .= '<td nowrap><button onclick="js.changeclear(\'change'.$fname.'\')" class="webbtn" type="button">x</button><button id="btnchange_'.$fname.'" onclick="js.changeuser(\'change'.$fname.'\',\''.$type.'\',\''.$oarr['title'].'\' ,{changerange:\''.$oarr['changerange'].'\'})" type="button" class="webbtn">选</button></td></tr></table>';
return $str;
}
private function issql($str)
{
$bo = false;
$str = strtoupper($str);
if(contain($str,' FROM '))$bo=true;
return $bo;
}
public function getdatastore($type, $objs, $datanum, $fid='')
{
$fopt = array();
$tyepa = explode(',','rockcombo,select,checkboxall,radio');
if(!in_array($type, $tyepa) || isempt($datanum))return $fopt;
//判断是不是SQL([SQL] name,value from [Q]abc)
if($this->issql($datanum)){
$sql = str_replace('[SQL]','select ', $datanum);
$sql = m('base')->strreplace($sql);
$rows = $this->db->getall($sql);
if($rows)foreach($rows as $k=>$rs){
$nam = arrvalue($rs,'name');
$val = $nam;
if(isset($rs['id']))$val = $rs['id'];
if(isset($rs['value']))$val = $rs['value'];
$fopt[] = array(
'name' => $nam,
'value' => $val,
);
}
}
//2021-02-26新增新的数据源,开头
if(substr($datanum,0,1)==','){
return $this->sqlstore($datanum);
}
//用:读取model上的数据
if(!$fopt && !isempt($datanum) && contain($datanum,':')){
$tata = explode(',', $datanum);
$acta = explode(':', $tata[0]);
$objs = m($acta[0]);
$tacs = $acta[1];
$cshu1= arrvalue($tata, 1);
if(method_exists($objs, $tacs)){
$fopt = $objs->$tacs($cshu1);
if(is_array($fopt)){
return $fopt;
}
}
}
//自定义方法读取数据源
if(!$fopt && $objs!=null && method_exists($objs, $datanum)){
$fopt = $objs->$datanum($fid,$this->mid);
if(is_array($fopt)){
return $fopt;
}
}
//从flow上读取
if(!$fopt && $this->flow!=null && method_exists($this->flow, $datanum)){
$fopt = $this->flow->$datanum($fid,$this->mid);
if(is_array($fopt)){
return $fopt;
}
}
if(!$fopt && ($type=='rockcombo' || $type=='checkboxall' || $type=='radio')){
$_ars = explode(',', $datanum);
$fopt = $this->option->getselectdata($_ars[0], isset($_ars[2]));
$fvad = 'name';
if(isset($_ars[1])&&($_ars[1]=='value'||$_ars[1]=='id'||$_ars[1]=='num'))$fvad=$_ars[1];
if($fopt){
foreach($fopt as $k=>$rs){
$fopt[$k]['value'] = $rs[$fvad];
}
if($type=='rockcombo' && $fvad=='name' && M=='input'){
//$fopt[] = array('name' => '其它..','value' => $_ars[0],);
}
}
}
if(!$fopt && ($type=='select' || $type=='checkboxall' || $type=='radio')){
$fopt = c('array')->strtoarray($datanum);
$barr = array();
foreach($fopt as $k=>$rs){
$barr[] = array(
'name' => $rs[1],
'value' => $rs[0],
);
}
$fopt = $barr;
}
return $fopt;
}
/**
* 新的获取数据源方法
*/
public function sqlstore($actstr1)
{
$rows = array();
$acta = explode(',', $actstr1);
if(count($acta)>=3){
if($acta[1]){
$cats = explode(','.$acta[1].',', $actstr1);
$sqlw = $cats[1];
}else{
$sqlw = substr($actstr1,2);
}
$sqla = explode('|', $sqlw);
$wher = arrvalue($sqla,2,'1=1');
if(contain($wher,'{'))$wher = m('where')->getstrwhere($wher,$this->adminid);
$wher = str_replace('$','"', $wher);
$rowa = m($sqla[0])->getall($wher,$sqla[1]);
$ndf = 'name';
$vdf = 'id';
if($rowa)foreach($rowa as $k=>$rs1){
if($k==0){
if(!isset($rs1[$ndf])){
foreach($rs1 as $k1=>$v1){$ndf = $k1;break;}
}
if(!isset($rs1[$vdf])){
$xus = 0;
foreach($rs1 as $k1=>$v1){
$xus++;
$vdf = $k1;
if($xus>=2)break;
}
}
}
$rs1['name'] = $rs1[$ndf];
$rs1['value'] = $rs1[$vdf];
$rows[] = $rs1;
}
}
return $rows;
}
/**
* 创建签名图片生成的
*/
public function createqianming($_val)
{
if(isempt($_val))return '';
if(substr($_val,0,10)=='data:image'){
$_vlu = ''.UPDIR.'/'.date('Y-m').'/qmimg'.time().''.rand(10,99).'.png';
$bar= explode(',', $_val);
$bo = $this->rock->createtxt($_vlu, base64_decode($bar[1]));
if($bo)$_val = $_vlu;
}
return $_val;
}
}

View File

@@ -0,0 +1,290 @@
<?php
/**
加密解密插件
*/
class jmChajian extends Chajian{
private $keystr = 'abcdefghijklmnopqrstuvwxyz';
private $jmsstr = '';
public $rocktokenarr = array();
protected function initChajian()
{
$this->initJm();
}
public function initJm()
{
$this->jmsstr = getconfig('randkey');
$this->setRandkey($this->jmsstr);
$this->getkeyshow();
}
public function setRandkey($str)
{
$this->jmsstr = $str;
if(strlen($this->jmsstr)!=26)$this->jmsstr = $this->keystr;
$this->getrocktoken();
}
public function getRandkey()
{
$str = $this->keystr;
$s = '';$len = strlen($str);
$j = $len-1;
for($i=0; $i<$len; $i++){
$r = rand(0, $j);
$zm= substr($str, $r, 1);
$s.= $zm;
$str = str_replace($zm,'',$str);
$j--;
}
return $s;
}
public function getint($str)
{
$len = strlen($str);
$oi = 0;
for($i=0; $i<$len; $i++){
$l = substr($str,$i,1);
$j = ord($l)-90;
$oi+=$j;
}
if($oi<0)$oi=0-$oi;
return $oi;
}
private function getrandstr($oi, $str='')
{
if($str=='')$str=$this->keystr;
if($oi>100)$oi=100;
$len = strlen($str);
$qs = 6;
$s1 = substr($str, 0, $qs);
$s2 = substr($str, $qs, $qs);
$s3 = substr($str, $qs*2, $len-$qs*2);
$s = $s3.$s2.$s1;
if($oi>0)$s=$this->getrandstr($oi-1, $s);
return $s;
}
public function getkeyshow()
{
$str = '~!@#$%^&*()_+{}[];"<>?:-=.';
$len = strlen($this->jmsstr);
$s = '';
for($i=0;$i<$len;$i++){
$l = substr($this->jmsstr,$i,1);
$j = ord($l)-97;
$s.= substr($str,$j,1);
}
return $s;
}
public function base64encode($str)
{
if(isempt($str))return '';
$str = base64_encode($str);
$str = str_replace(array('+', '/', '='), array('!', '.', ':'), $str);
return $str;
}
public function base64decode($str)
{
if(isempt($str))return '';
$str = str_replace(array('!', '.', ':'), array('+', '/', '='), $str);
$str = base64_decode($str);
return $str;
}
private function _getss($lx)
{
$st = '';
if(is_numeric($lx)&&$lx>0){
$st = $this->getrandstr($lx);
}else if(is_string($lx)){
if(strlen($lx)==26)$st=$lx;
}
return $st;
}
public function encrypt($str, $lx='')
{
$st = $this->_getss($lx);
$s = $this->base64encode($str);
$s = $this->encrypts($s, $st);
return $s;
}
public function uncrypt($str, $lx='')
{
$st = $this->_getss($lx);
$s = $this->uncrypts($str, $st);
$s = $this->base64decode($s);
return $s;
}
public function encrypts($str, $a='')
{
if($a=='')$a = $this->jmsstr;
$nstr = '';
if($this->rock->isempt($str)) return $nstr;
$len = strlen($str);
$t = rand(1, 14);
if($t == 10)$t++;
for($i=0; $i<$len; $i++){
$nstr.='0';
$sta = substr($str,$i,1);
$orstr = ''.ord($sta).'';
$ile = strlen($orstr);
for($j=0; $j<$ile; $j++){
$oi = (int)substr($orstr,$j,1)+$t;
$nstr.= substr($a,$oi,1);
}
}
if($nstr != ''){
$nstr = substr($nstr,1);
$nstr.= '0'.$t.'';
}
return $nstr;
}
public function uncrypts($str, $a1='')
{
$nstr = '';
if($this->rock->isempt($str)) return $nstr;
if($a1=='')$a1 = $this->jmsstr;
$a = array();
for($i=0; $i<strlen($a1); $i++)$a[substr($a1, $i, 1)] = ''.$i.'';
$na = explode('0', $str);
$len= count($na);
$r = (int)$na[$len-1];
for($i=0; $i<$len-1; $i++){
$st = $na[$i];
$sl = strlen($st);
$sa = '';
for($j=0; $j<$sl; $j++){
$ha = substr($st,$j,1);
if(isset($a[$ha]))$ha = $a[$ha] - $r;
$sa.=$ha;
}
$sa = (int)$sa;
$nstr.=chr($sa);
}
return $nstr;
}
public function getrocktoken()
{
$toke = $this->rock->get('rocktoken');
$str = $this->uncrypt($toke);
if($toke!='' && !$this->contain($str,'&'))exit('sorry,not found!');
$arr = array('m'=>'index','a'=>'default','d'=>'');
if($str){
$a = explode('&', $str);
foreach($a as $a1){
$a2 = explode('=', $a1);
$arr[$a2[0]] = $a2[1];
}
}
$this->rocktokenarr = $arr;
return $arr;
}
public function gettoken($na, $dev='')
{
$s = $dev;
if(isset($this->rocktokenarr[$na])){
$s = $this->rocktokenarr[$na];
}else{
$s = $this->rock->get($na, $dev);
}
return $s;
}
public function strrocktoken($a=array())
{
$s = '';
foreach($a as $k=>$v){
$s .='&'.$k.'='.$v.'';
}
if($s!=''){
$s = $this->encrypt(substr($s, 1));
}
return $s;
}
public function mcrypt_encrypt($str)
{
if(isempt($str))return '';
if(!function_exists('mcrypt_encrypt'))return $str;
$key = substr(md5($this->jmsstr),0,8);
$getstr = mcrypt_encrypt(MCRYPT_DES, $key, $str, MCRYPT_MODE_ECB);
return $this->base64encode($getstr);
}
public function mcrypt_decrypt($str)
{
if(isempt($str))return '';
if(!function_exists('mcrypt_decrypt'))return $str;
$str = $this->base64decode($str);
$key = substr(md5($this->jmsstr),0,8);
$getstr = mcrypt_decrypt(MCRYPT_DES, $key, $str, MCRYPT_MODE_ECB);
return trim($getstr);
}
/**
* 字符串加密处理
*/
public function strlook($data,$key='')
{
if(isempt($data))return '';
if($key=='')$key = md5($this->jmsstr);
$x = 0;
$len = strlen($data);
$l = strlen($key);
$char = $str = '';
for ($i = 0; $i < $len; $i++){
if ($x == $l) {
$x = 0;
}
$char .= $key[$x];
$x++;
}
for ($i = 0; $i < $len; $i++){
$str .= chr(ord($data[$i]) + (ord($char[$i])) % 256);
}
return $this->base64encode($str);
}
/**
* 字符串解密
*/
public function strunlook($data,$key='')
{
if(isempt($data))return '';
if($key=='')$key = md5($this->jmsstr);
$x = 0;
$data = $this->base64decode($data);
$len = strlen($data);
$l = strlen($key);
$char = $str = '';
for ($i = 0; $i < $len; $i++){
if ($x == $l) {
$x = 0;
}
$char .= substr($key, $x, 1);
$x++;
}
for ($i = 0; $i < $len; $i++){
if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))){
$str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1)));
}else{
$str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
}
}
return $str;
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* 语言包
*/
class langChajian extends Chajian{
//支持的语言包
private $langArray = array('zh-CN','en-US','zh-TW','jp');
private $locallang = 'zh-CN'; //默认的语言包
/**
* 初始化语言包
*/
public function initLang()
{
$moren= getconfig('locallang', $this->locallang);
$lang = $this->rock->get('locallang', $moren);
if(!in_array($lang, $this->langArray))$lang = $moren;
if(!defined('LANG'))define('LANG', $lang);
$langs = str_replace('-','_', $lang);
$langr = str_replace('-','_', $moren);
$obj = c('lang_'.$langs.'');
$objmr = c('lang_'.$langr.'');
$data[$moren] = method_exists($objmr, 'getLang') ? $objmr->getLang() : array();
$data[$lang] = method_exists($obj, 'getLang') ? $obj->getLang() : $data[$moren];
$GLOBALS['langdata'] = $data;
}
}

View File

@@ -0,0 +1,15 @@
<?php
/**
* 语言包(英文),需要自行翻译
*/
class lang_en_USChajian extends Chajian{
public function getLang()
{
$da = array(
);
return $da;
}
}

View File

@@ -0,0 +1,15 @@
<?php
/**
* 语言包
*/
class lang_zh_CNChajian extends Chajian{
public function getLang()
{
$da = array(
);
return $da;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* 用libreoffice相关linux和win都可以用
*/
class libreofficeChajian extends Chajian{
/**
* 转pdf
*/
public function filetopdf($fileid)
{
$path = getconfig('libreoffice_path');
if(isempt($path))return returnerror('未配置libreoffice的路径');
$frs = m('file')->getone($fileid);
if(!$frs)return returnerror('文件不存在');
$filepath = $frs['filepath'];
$pdfpath = $frs['pdfpath'];
if(!isempt($pdfpath) && file_exists($pdfpath))return returnerror('已经转化过了');;
$fpath = ''.ROOT_PATH.'/'.$filepath.'';
$outdir = substr($fpath,0, strripos($fpath,'/'));
if(contain(PHP_OS,'WIN')){
$cmd = '"'.str_ireplace('LibreOffice','libreoffice',$path).'\program\soffice.exe"';
$fpath = str_replace('/','\\', $fpath);
$outdir = str_replace('/','\\', $outdir);
}else{
$cmd = $path;
}
$cmd .=' --headless --invisible --convert-to pdf:writer_pdf_Export "'.$fpath.'" --outdir "'.$outdir.'"';
return c('rockqueue')->pushcmd($cmd);
}
}

View File

@@ -0,0 +1,115 @@
<?php
/**
PHPMailer 读取插件类
*/
include_once(ROOT_PATH.'/include/PHPMailer/class.phpmailer.php');
include_once(ROOT_PATH.'/include/PHPMailer/class.smtp.php');
class mailerChajian extends Chajian{
private $mail;
private $mailbool;
public function initChajian(){
$this->mail = new PHPMailer();
$this->mail->IsSMTP();
$this->mail->SMTPAuth = true;
$this->mail->SMTPDebug = 0;
$this->mail->CharSet = 'UTF-8';
$this->mailbool = false;
}
public function setHost($host, $port=25, $secure=''){
$this->mail->Host = $host;
$this->mail->SMTPSecure = $secure;
$this->mail->Port = (int)$port;
}
public function setUser($email, $pass){
$this->mail->Username = $email;
$this->mail->Password = $pass;
$this->setFrom($email);
$this->addReplyTo($email);
}
//发件人邮箱地址
public function setFrom($from, $name=''){
$this->mail->SetFrom($from, $this->tojoin($name));
}
//设置回复
public function addReplyTo($address, $name=''){
$this->mail->AddReplyTo($address, $this->tojoin($name));
}
//添加抄送
public function addCC($address, $name=''){
$a1 = explode(',', $address);
$n1 = array();
if($name != '')$n1 = explode(',', $name);
for($i=0; $i<count($a1); $i++){
$na = '';
if(isset($n1[$i]))$na = $n1[$i];
$this->mail->AddCC($a1[$i], $this->tojoin($na));
}
}
//添加秘密送
public function addBCC($address, $name=''){
$a1 = explode(',', $address);
$n1 = array();
if($name != '')$n1 = explode(',', $name);
for($i=0; $i<count($a1); $i++){
$na = '';
if(isset($n1[$i]))$na = $n1[$i];
$this->mail->AddBCC($a1[$i], $this->tojoin($na));
}
}
//添加收件人
public function addAddress($address, $name=''){
$a1 = explode(',', $address);
$n1 = array();
if($name != '')$n1 = explode(',', $name);
for($i=0; $i<count($a1); $i++){
$na = '';
if(isset($n1[$i]))$na = $n1[$i];
$this->mail->AddAddress($a1[$i], $this->tojoin($na));
}
}
//添加附件
public function addAttachment($address, $name=''){
if($this->rock->isempt($address))return;
$a1 = explode(',', $address);
$n1 = array();
if($name != '')$n1 = explode(',', $name);
for($i=0; $i<count($a1); $i++){
$na = '';
if(isset($n1[$i]))$na = $n1[$i];
$this->mail->AddAttachment(ROOT_PATH.'/'.$a1[$i], $this->tojoin($na));
}
}
//发送邮件
public function sendMail($Subject, $body=''){
$this->mail->Subject = $this->tojoin($Subject);
$this->mail->Body = $body;
$this->mail->IsHTML(true);
$this->mailbool = $this->mail->Send();
}
public function isSuccess(){
return $this->mailbool;
}
public function getErrror(){
return $this->mail->ErrorInfo;
}
private function tojoin($name='')
{
if($name=='')return '';
return "=?UTF-8?B?".base64_encode($name)."?=";
}
}

View File

@@ -0,0 +1,13 @@
<?php
class mapqqChajian extends Chajian{
private $mapqqkey = 'I3EBZ-TYP6F-RGZJI-J3W3V-ERKDT-PTBK4';
public function geocoder($location)
{
$url = 'http://apis.map.qq.com/ws/geocoder/v1/?location='.$location.'&coord_type=5&key='.$this->mapqqkey.'';
$result = c('curl')->getcurl($url);
echo $result;
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* 来自:信呼开发团队
* 作者:磐石(rainrock)
* 网址http://www.rockoa.com/
* 自己短信服务
* 此文件放到include/chajian/mysmsChajian.php 下
* 开发帮助地址http://www.rockoa.com/view_mysms.html
*/
class mysmsChajian extends Chajian{
/**
* 短信模版写这里的
*/
protected function initChajian()
{
$mobian['defyzm'] = '您短信验证码为:#code#请勿将验证码提供给他人5分钟内有效。';
$mobian['defsucc'] = '您提交单据(#modename#,单号:#sericnum#)已全部处理完成,可登录系统查看详情。';
$mobian['default'] = '您有单据(#modename#,单号:#sericnum#)需要处理,请登录系统及时去处理。';
$mobian['birthday'] = '尊敬的#name#,今天是#dt#,农历#dtnong#,是您的生日,我们在这里祝您生日快乐。';
$mobian['defnum'] = '您有#applyname#的(#modename#)单据需要您处理,详情:#url#';
$mobian['defurls'] = '您有单据(#modename#,单号:#sericnum#)需要处理,请及时去处理,详情:#url#。';
$mobian['gongsms'] = '您收到一条“#title#”的通知,详情:#url#';
$mobian['meetapply'] = '#optname#发起会议“#title#”在#hyname#,时间#startdt#至#enddt#';
$mobian['meetcancel'] = '#optname#取消会议“#title#”,时间#startdt#至#enddt#,请悉知。';
$mobian['meettodo'] = '会议“#title#”将在#fenz#分钟后的#time#开始请做好准备,在会议室“#hyname#”';
$this->mobianarr = $mobian;
}
/**
* 批量发送短信
* $mobiles 接收人手机号多个,分开
* $qianm 签名
* $tplid 模版编号在上面initChajian()数组中查找
* $cans 模版中的参数数组
* 例子c('mysms')->send('15800000000,15800000001','信呼', 'default', array('modename'=>'模块名','sericnum'=>'单号')); 这例子是不需要自己调用,只要短信设置下切换为“我的短信服务”就可以了
*/
public function send($mobiles, $qianm, $tplid, $cans=array())
{
//要发送短信的内容
$text = arrvalue($this->mobianarr, $tplid);
if(isempt($text))return returnerror('模版'.$tplid.'不存在');
foreach($cans as $k=>$v)$text = str_replace('#'.$k.'#', $v, $text);
//这里你要自己写你发送短信的代码------------
return returnerror('你没有开发自己短信接口,查看'.c('xinhu')->helpstr('mysms').'看如何开发');
//------------------------------------------
return returnsuccess();
}
}

View File

@@ -0,0 +1,17 @@
<?php
/**
* win下将word转html
*/
class officeChajian extends Chajian{
public function tohtml($path)
{
if(!class_exists('COM'))return '没有开启COM组件';
$word = new COM('Word.Application');
$word->Visible = true; //可看见
$word->Documents->Open($path);
$word->Documents[1]->SaveAs('upload/abc.html',8);
}
}

View File

@@ -0,0 +1,449 @@
<?php
class pingyinChajian extends Chajian
{
private $PinYinDB=array(
array("a",-20319),
array("ai",-20317),
array("an",-20304),
array("ang",-20295),
array("ao",-20292),
array("ba",-20283),
array("bai",-20265),
array("ban",-20257),
array("bang",-20242),
array("bao",-20230),
array("bei",-20051),
array("ben",-20036),
array("beng",-20032),
array("bi",-20026),
array("bian",-20002),
array("biao",-19990),
array("bie",-19986),
array("bin",-19982),
array("bing",-19976),
array("bo",-19805),
array("bu",-19784),
array("ca",-19775),
array("cai",-19774),
array("can",-19763),
array("cang",-19756),
array("cao",-19751),
array("ce",-19746),
array("ceng",-19741),
array("cha",-19739),
array("chai",-19728),
array("chan",-19725),
array("chang",-19715),
array("chao",-19540),
array("che",-19531),
array("chen",-19525),
array("cheng",-19515),
array("chi",-19500),
array("chong",-19484),
array("chou",-19479),
array("chu",-19467),
array("chuai",-19289),
array("chuan",-19288),
array("chuang",-19281),
array("chui",-19275),
array("chun",-19270),
array("chuo",-19263),
array("ci",-19261),
array("cong",-19249),
array("cou",-19243),
array("cu",-19242),
array("cuan",-19238),
array("cui",-19235),
array("cun",-19227),
array("cuo",-19224),
array("da",-19218),
array("dai",-19212),
array("dan",-19038),
array("dang",-19023),
array("dao",-19018),
array("de",-19006),
array("deng",-19003),
array("di",-18996),
array("dian",-18977),
array("diao",-18961),
array("die",-18952),
array("ding",-18783),
array("diu",-18774),
array("dong",-18773),
array("dou",-18763),
array("du",-18756),
array("duan",-18741),
array("dui",-18735),
array("dun",-18731),
array("duo",-18722),
array("e",-18710),
array("en",-18697),
array("er",-18696),
array("fa",-18526),
array("fan",-18518),
array("fang",-18501),
array("fei",-18490),
array("fen",-18478),
array("feng",-18463),
array("fo",-18448),
array("fou",-18447),
array("fu",-18446),
array("ga",-18239),
array("gai",-18237),
array("gan",-18231),
array("gang",-18220),
array("gao",-18211),
array("ge",-18201),
array("gei",-18184),
array("gen",-18183),
array("geng",-18181),
array("gong",-18012),
array("gou",-17997),
array("gu",-17988),
array("gua",-17970),
array("guai",-17964),
array("guan",-17961),
array("guang",-17950),
array("gui",-17947),
array("gun",-17931),
array("guo",-17928),
array("ha",-17922),
array("hai",-17759),
array("han",-17752),
array("hang",-17733),
array("hao",-17730),
array("he",-17721),
array("hei",-17703),
array("hen",-17701),
array("heng",-17697),
array("hong",-17692),
array("hou",-17683),
array("hu",-17676),
array("hua",-17496),
array("huai",-17487),
array("huan",-17482),
array("huang",-17468),
array("hui",-17454),
array("hun",-17433),
array("huo",-17427),
array("ji",-17417),
array("jia",-17202),
array("jian",-17185),
array("jiang",-16983),
array("jiao",-16970),
array("jie",-16942),
array("jin",-16915),
array("jing",-16733),
array("jiong",-16708),
array("jiu",-16706),
array("ju",-16689),
array("juan",-16664),
array("jue",-16657),
array("jun",-16647),
array("ka",-16474),
array("kai",-16470),
array("kan",-16465),
array("kang",-16459),
array("kao",-16452),
array("ke",-16448),
array("ken",-16433),
array("keng",-16429),
array("kong",-16427),
array("kou",-16423),
array("ku",-16419),
array("kua",-16412),
array("kuai",-16407),
array("kuan",-16403),
array("kuang",-16401),
array("kui",-16393),
array("kun",-16220),
array("kuo",-16216),
array("la",-16212),
array("lai",-16205),
array("lan",-16202),
array("lang",-16187),
array("lao",-16180),
array("le",-16171),
array("lei",-16169),
array("leng",-16158),
array("li",-16155),
array("lia",-15959),
array("lian",-15958),
array("liang",-15944),
array("liao",-15933),
array("lie",-15920),
array("lin",-15915),
array("ling",-15903),
array("liu",-15889),
array("long",-15878),
array("lou",-15707),
array("lu",-15701),
array("lv",-15681),
array("luan",-15667),
array("lue",-15661),
array("lun",-15659),
array("luo",-15652),
array("ma",-15640),
array("mai",-15631),
array("man",-15625),
array("mang",-15454),
array("mao",-15448),
array("me",-15436),
array("mei",-15435),
array("men",-15419),
array("meng",-15416),
array("mi",-15408),
array("mian",-15394),
array("miao",-15385),
array("mie",-15377),
array("min",-15375),
array("ming",-15369),
array("miu",-15363),
array("mo",-15362),
array("mou",-15183),
array("mu",-15180),
array("na",-15165),
array("nai",-15158),
array("nan",-15153),
array("nang",-15150),
array("nao",-15149),
array("ne",-15144),
array("nei",-15143),
array("nen",-15141),
array("neng",-15140),
array("ni",-15139),
array("nian",-15128),
array("niang",-15121),
array("niao",-15119),
array("nie",-15117),
array("nin",-15110),
array("ning",-15109),
array("niu",-14941),
array("nong",-14937),
array("nu",-14933),
array("nv",-14930),
array("nuan",-14929),
array("nue",-14928),
array("nuo",-14926),
array("o",-14922),
array("ou",-14921),
array("pa",-14914),
array("pai",-14908),
array("pan",-14902),
array("pang",-14894),
array("pao",-14889),
array("pei",-14882),
array("pen",-14873),
array("peng",-14871),
array("pi",-14857),
array("pian",-14678),
array("piao",-14674),
array("pie",-14670),
array("pin",-14668),
array("ping",-14663),
array("po",-14654),
array("pu",-14645),
array("qi",-14630),
array("qia",-14594),
array("qian",-14429),
array("qiang",-14407),
array("qiao",-14399),
array("qie",-14384),
array("qin",-14379),
array("qing",-14368),
array("qiong",-14355),
array("qiu",-14353),
array("qu",-14345),
array("quan",-14170),
array("que",-14159),
array("qun",-14151),
array("ran",-14149),
array("rang",-14145),
array("rao",-14140),
array("re",-14137),
array("ren",-14135),
array("reng",-14125),
array("ri",-14123),
array("rong",-14122),
array("rou",-14112),
array("ru",-14109),
array("ruan",-14099),
array("rui",-14097),
array("run",-14094),
array("ruo",-14092),
array("sa",-14090),
array("sai",-14087),
array("san",-14083),
array("sang",-13917),
array("sao",-13914),
array("se",-13910),
array("sen",-13907),
array("seng",-13906),
array("sha",-13905),
array("shai",-13896),
array("shan",-13894),
array("shang",-13878),
array("shao",-13870),
array("she",-13859),
array("shen",-13847),
array("sheng",-13831),
array("shi",-13658),
array("shou",-13611),
array("shu",-13601),
array("shua",-13406),
array("shuai",-13404),
array("shuan",-13400),
array("shuang",-13398),
array("shui",-13395),
array("shun",-13391),
array("shuo",-13387),
array("si",-13383),
array("song",-13367),
array("sou",-13359),
array("su",-13356),
array("suan",-13343),
array("sui",-13340),
array("sun",-13329),
array("suo",-13326),
array("ta",-13318),
array("tai",-13147),
array("tan",-13138),
array("tang",-13120),
array("tao",-13107),
array("te",-13096),
array("teng",-13095),
array("ti",-13091),
array("tian",-13076),
array("tiao",-13068),
array("tie",-13063),
array("ting",-13060),
array("tong",-12888),
array("tou",-12875),
array("tu",-12871),
array("tuan",-12860),
array("tui",-12858),
array("tun",-12852),
array("tuo",-12849),
array("wa",-12838),
array("wai",-12831),
array("wan",-12829),
array("wang",-12812),
array("wei",-12802),
array("wen",-12607),
array("weng",-12597),
array("wo",-12594),
array("wu",-12585),
array("xi",-12556),
array("xia",-12359),
array("xian",-12346),
array("xiang",-12320),
array("xiao",-12300),
array("xie",-12120),
array("xin",-12099),
array("xing",-12089),
array("xiong",-12074),
array("xiu",-12067),
array("xu",-12058),
array("xuan",-12039),
array("xue",-11867),
array("xun",-11861),
array("ya",-11847),
array("yan",-11831),
array("yang",-11798),
array("yao",-11781),
array("ye",-11604),
array("yi",-11589),
array("yin",-11536),
array("ying",-11358),
array("yo",-11340),
array("yong",-11339),
array("you",-11324),
array("yu",-11303),
array("yuan",-11097),
array("yue",-11077),
array("yun",-11067),
array("za",-11055),
array("zai",-11052),
array("zan",-11045),
array("zang",-11041),
array("zao",-11038),
array("ze",-11024),
array("zei",-11020),
array("zen",-11019),
array("zeng",-11018),
array("zha",-11014),
array("zhai",-10838),
array("zhan",-10832),
array("zhang",-10815),
array("zhao",-10800),
array("zhe",-10790),
array("zhen",-10780),
array("zheng",-10764),
array("zhi",-10587),
array("zhong",-10544),
array("zhou",-10533),
array("zhu",-10519),
array("zhua",-10331),
array("zhuai",-10329),
array("zhuan",-10328),
array("zhuang",-10322),
array("zhui",-10315),
array("zhun",-10309),
array("zhuo",-10307),
array("zi",-10296),
array("zong",-10281),
array("zou",-10274),
array("zu",-10270),
array("zuan",-10262),
array("zui",-10260),
array("zun",-10256),
array("zuo",-10254)
);
private function GetPinYin($num,$type){
$PinYinDB = $this->PinYinDB;
$string='';
if($num>0&&$num<160){
return chr($num);
}
elseif($num<-20319||$num>-10247){
return "";
}else{
for($i=count($PinYinDB)-1;$i>=0;$i--)
{
if($PinYinDB[$i][1]<=$num)break;
}
if($type==1){
for($ii=0;$ii<strlen($PinYinDB[$i][0]);$ii++){
$letter=substr($PinYinDB[$i][0],$ii,1);
if($ii==0){
$letter=strtoupper($letter);
}
$string.=$letter;
}
return $string;
}else if($type == 2){
return substr($PinYinDB[$i][0], 0, 1);
}else{
return $PinYinDB[$i][0];
}
}
}
public function get($str,$type=''){
$ret = '';
@$str = iconv('utf-8','gb2312',$str);
for($i=0;$i<strlen($str);$i++){
$p=ord(substr($str,$i,1));
if($p>160){
$q=ord(substr($str,++$i,1));
$p=$p*256+$q-65536;
}
$ret.=$this->GetPinYin($p,$type);
}
$ret = strtolower($ret);
return $ret;
}
}
//echo get('中国人',1);

View File

@@ -0,0 +1,123 @@
<?php
/**
* 腾讯云上文件存储上传管理
*/
include_once(ROOT_PATH.'/include/cos-php-sdk-v4-master/include.php');
use Qcloud\Cos\Api;
class qcloudCosChajian extends Chajian{
private $bucket = 'xinhuoa';
private $folder = 'defile'; //默认目录
private $region = 'sh'; //默认分区
protected function initChajian()
{
$this->bucket = getconfig('qcloudCos_bucket', $this->bucket);
$this->region = getconfig('qcloudCos_region', $this->region);
$this->folder = getconfig('qcloudCos_folder', $this->folder);
$this->app_id = getconfig('qcloudCos_APPID');
$config = array(
'app_id' => $this->app_id,
'secret_id' => getconfig('qcloudCos_SecretId'),
'secret_key'=> getconfig('qcloudCos_SecretKey'),
'region' => $this->region,
'timeout' => 180
);
$this->cosApi = new Api($config);
}
/**
* 上传文件
* filepath 要上传的文件全路径
* updir 上传到哪个目录
* upname 上传后保存文件名
*/
public function upload($filepath, $updir='', $upname='')
{
if(!file_exists($filepath))return false;
$filea = explode('/', $filepath);
if($upname=='')$upname = $filea[count($filea)-1];
if($updir=='')$updir = $this->folder;
$ret = $this->cosApi->upload($this->bucket, $filepath, ''.$updir.'/'.$upname.'');
if($ret['code']==0)$ret['url'] = $this->geturl().'/'.$updir.'/'.$upname.'';
return $ret;
}
/**
* 创建文件夹
*/
public function createFolder($folder)
{
$ret = Cosapi::createFolder($this->bucket, $folder);
return $ret;
}
/**
* 获取目录下的文件
*/
public function listFolder($folder='', $num=20)
{
if($folder=='')$folder = $this->folder;
$ret = $this->cosApi->listFolder($this->bucket, $folder, $num);
if($ret['code'] != 0){
return returnerror($ret['message']);
}else{
$barr = returnsuccess($ret['data']['infos']);
$barr['folder'] = $folder;
return $barr;
}
}
/**
* 删除文件
*/
public function delFile($path)
{
$ret = $this->cosApi->delFile($this->bucket, $path);
return $ret;
}
public function delListFile()
{
$barr = $this->listFolder('',100);
if($barr['success']){
foreach($barr['data'] as $k=>$rs){
$this->delFile($this->folder.'/'.$rs['name']);
}
}
}
/**
* 下载文件到服务器本地
*/
public function download($srcPath, $dstPath)
{
$res = $this->cosApi->download($this->bucket, $srcPath, $dstPath);
return $res;
}
/**
* 获取外网访问地址
*/
public function geturl()
{
$xarr['nj'] = 'ap-nanjing';
$xarr['cd'] = 'ap-chengdu';
$xarr['bj'] = 'ap-beijing';
$xarr['gz'] = 'ap-guangzhou';
$xarr['sh'] = 'ap-shanghai';
$xarr['cq'] = 'ap-chongqing';
$xarr['bjfsi'] = 'ap-beijing-fsi';
$xarr['szfsi'] = 'ap-shenzhen-fsi';
$xarr['shfsi'] = 'ap-shanghai-fsi';
$xarr['hk'] = 'ap-hongkong';
$qustr = arrvalue($xarr, $this->region,'ap-shanghai');
$url = 'https://'.$this->bucket.'-'.$this->app_id.'.cos.'.$qustr.'.myqcloud.com';
return $url;
}
}

View File

@@ -0,0 +1,17 @@
<?php
/**
* 创建二维码
*/
include_once(ROOT_PATH.'/include/phpqrcode/phpqrcode.php');
class qrcodeChajian extends Chajian
{
public function show($url='')
{
if($url=='')$url = URL;
$errorCorrectionLevel = 'L'; // 纠错级别L、M、Q、H
$matrixPointSize = 6; // 点的大小1到10
$margin = 1; //表示二维码周围边框空白区域间距值;
$bo = QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize, $margin, false);
return $bo;
}
}

View File

@@ -0,0 +1,124 @@
<?php
/**
* 连接官网在线编辑文档
*/
class rockeditChajian extends Chajian{
protected function initChajian()
{
$urs = $this->rock->jm->base64decode('aHR0cDovL29mZmljZS5yb2Nrb2EuY29tLw::');
$url = getconfig('officebj_url', $urs);
$this->agentkey = getconfig('officebj_key');
if(substr($url,-1)!='/')$url.='/';
$this->updatekel = $url;
$this->updatekey = $url.'api.php';
}
public function geturlstr($mod, $act, $can=array())
{
$url = $this->updatekey;
$url.= '?m='.$mod.'&a='.$act.'';
$url.= '&host='.$this->rock->jm->base64encode(HOST).'&ip='.$this->rock->ip.'&xinhukey='.getconfig('xinhukey').'';
$url.= '&adminid='.$this->adminid.'';
$url.= '&agentkey='.$this->agentkey.'';
foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
return $url;
}
/**
* get获取数据
*/
public function getdata($mod, $act, $can=array())
{
$url = $this->geturlstr($mod, $act, $can);
$cont = c('curl')->getcurl($url);
if(!isempt($cont) && contain($cont, 'success')){
$data = json_decode($cont, true);
}else{
$data = returnerror('无法访问,'.$cont.'');
}
return $data;
}
/**
* post发送数据
*/
public function postdata($mod, $act, $can=array())
{
$url = $this->geturlstr($mod, $act);
$cont = c('curl')->postcurl($url, $can);
if(!isempt($cont) && contain($cont, 'success')){
$data = json_decode($cont, true);
}else{
$data = returnerror('无法访问,'.$cont.'');
}
return $data;
}
public function sendedit($id, $admintoken='', $otype=0)
{
$frs = m('file')->getone($id);
if(!$frs)return returnerror('文件不存在');
$filepath = $frs['filepath'];
$filepathout= arrvalue($frs, 'filepathout');
$onlynum = $frs['onlynum'];
$recedata = '';
if(substr($filepath,0,4)!='http' && !file_exists($filepath)){
if(isempt($filepathout))return returnerror('文件不存在2');
$filepath = $filepathout;
$recedata = $filepath;
}
if(isempt($onlynum)){
$onlynum = md5(''.$this->rock->jm->getRandkey().date('YmdHis').'file'.$id.'');
m('file')->update("`onlynum`='$onlynum'", $id);
}
$urs = m('admin')->getone($this->adminid);
$barr = $this->getdata('file','change', array(
'filenum' => $onlynum,
'optid' => $this->adminid,
'optname' => $this->rock->jm->base64encode($this->adminname),
'face' => $this->rock->jm->base64encode(m('admin')->getface($urs['face'])),
));
if(!$barr['success'])return $barr;
$data = $barr['data'];
$type = $data['type'];
$gokey = $data['gokey'];
$gourl = arrvalue($data,'gourl');
if(isempt($gourl))$gourl = $this->updatekel;
$bsar = $data;
if($type=='0'){
if($recedata=='')$recedata = $this->rock->jm->base64encode(file_get_contents($filepath));
$barr = $this->postdata('file','recedata', array(
'data' => $recedata,
'fileid' => $id,
'filenum' => $onlynum,
'fileext' => $frs['fileext'],
'filename' => $frs['filename'],
'optid' => $frs['optid'],
'optname' => $frs['optname'],
'filesize' => $frs['filesize'],
'filesizecn'=> $frs['filesizecn'],
));
if(!$barr['success'])return $barr;
$bsar['type'] = '1';
}
if($bsar['type']=='1'){
$url = $gourl.'api.php?m=file&a=goto&filenum='.$onlynum.'&sign='.md5($this->rock->HTTPweb).'';
$url.= '&optid='.$this->adminid.'';
$url.= '&gokey='.$gokey.'';
$url.= '&otype='.$otype.'';
if($otype==0){
$callurl = $this->rock->getouturl().'api.php?m=upload&a=upfilevb&fileid='.$id.'&adminid='.$this->adminid.'&token='.$admintoken.'';
$url.='&callurl='.$this->rock->jm->base64encode($callurl).'';
}
$bsar['url'] = $url;
}
return returnsuccess($bsar);
}
}

View File

@@ -0,0 +1,155 @@
<?php
/**
* 文件上传管理中心相关接口
*/
class rockfileChajian extends Chajian{
protected function initChajian()
{
$url = getconfig('rockfile_url');
$urlb = getconfig('rockfile_localurl');
if($urlb)$url = $urlb;
$this->agentkey = getconfig('rockfile_key');
if(substr($url,-1)!='/')$url.='/';
$this->updatekel = $url;
$this->updatekey = $url.'api.php';
}
public function geturlstr($mod, $act, $can=array())
{
$url = $this->updatekey;
$url.= '?m='.$mod.'&a='.$act.'';
$url.= '&agentkey='.$this->agentkey.'';
$url.= '&websign='.md5($this->rock->HTTPweb).'';
foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
return $url;
}
/**
* get获取数据
*/
public function getdata($mod, $act, $can=array())
{
$url = $this->geturlstr($mod, $act, $can);
$cont = c('curl')->getcurl($url);
if(!isempt($cont) && contain($cont, 'success')){
$data = json_decode($cont, true);
}else{
$data = returnerror('无法访问,'.$cont.'');
}
return $data;
}
/**
* post发送数据
*/
public function postdata($mod, $act, $can=array(), $cans=array())
{
$url = $this->geturlstr($mod, $act, $cans);
$cont = c('curl')->postcurl($url, $can);
if(!isempt($cont) && contain($cont, 'success')){
$data = json_decode($cont, true);
}else{
$data = returnerror('无法访问,'.$cont.'');
}
return $data;
}
/**
* 同步保存到自己的库
*/
public function getsave($fnum)
{
if(!$fnum)return $fnum;
$nums = '';
$fanu = explode(',', $fnum);
$ids = '';
foreach($fanu as $st1){
if(is_numeric($st1)){
$ids.=','.$st1.'';
}else{
$nums.=','.$st1.'';
}
}
if($nums){
$nums = substr($nums, 1);
$barr = $this->getdata('upload','filesaveinfo',array('nums'=>$nums));
return $barr;
}else{
return returnerror('error');
}
}
/**
* 删除文件
*/
public function filedel($nums)
{
$barr = $this->getdata('upload','filedel',array('nums'=>$nums));
return $barr;
}
/**
* 上传
*/
public function uploadfile($fileid)
{
$frs = m('file')->getone($fileid);
if(!$frs)return returnerror('1');
$path = ROOT_PATH.'/'.$frs['filepath'];
if(!file_exists($path))return returnerror('404');
$barr = $this->upload($path, array(
'optid' => $frs['optid'],
'noasyn' => 'no', //no和yes
'fileexs' => $frs['fileext'],
'optname' => $this->rock->jm->base64encode($frs['optname']),
'filename' => $this->rock->jm->base64encode($frs['filename']),
));
if(!$barr['success'])return $barr;
$data = $barr['data'];
$filenum = arrvalue($data, 'filenum');
$thumbpath = arrvalue($data, 'thumbpath');
if($filenum){
$guar['filenum'] = $filenum;
if($thumbpath)$guar['thumbplat'] = $thumbpath;
m('file')->update($guar,$fileid);
unlink($path);
$path = ROOT_PATH.'/'.$frs['thumbpath'];
if($path && file_exists($path))unlink($path);
}
return $barr;
}
/**
* 上传文件(分割发送)
*/
public function upload($path,$upcs=array(), $fcs=0.5)
{
if(!file_exists($path))return returnerror('404');
$oi = 0;
$fp = fopen($path,'rb');
$filesize= filesize($path);
$fileext = c('upfile')->getext($path);
$size = $fcs*1024*1024;
$zong = ceil($filesize/$size);
if($zong<=0)$zong = 1;
$barr = false;
$biaoshi = rand(100000,999999);
while(!feof($fp)){
$cont = fread($fp, $size);
$conts= base64_encode($cont);
$upcan= array('ci'=>$oi,'biaoshi'=>$biaoshi,'zong'=>$zong,'filesize' => $filesize,'fileext'=>$fileext);
foreach($upcs as $k=>$v)$upcan[$k] = $v;
$barr = $this->postdata('upfile','index', $conts, $upcan);
if(!$barr['success'])break;
$oi++;
}
fclose ($fp);
if($barr)return $barr;
return returnerror('无效文件');
}
}

View File

@@ -0,0 +1,175 @@
<?php
/**
* 信呼中node队列的处理
*/
class rockqueueChajian extends Chajian
{
//队列服务器主机
private $rockqueue_host = '127.0.0.1';
//队列服务端口数字类型为0从服务器设置上读取
private $rockqueue_port = 0;
//初始化配置读取
protected function initChajian()
{
$this->rockqueue_host = getconfig('rockqueue_host', $this->rockqueue_host);
$this->rockqueue_port = getconfig('rockqueue_port', $this->rockqueue_port);
if($this->rockqueue_port==0){
$reim = m('reim');
$reimhot = $reim->getpushhostport($reim->serverpushurl);
$this->rockqueue_host = $reimhot['host'];
$this->rockqueue_port = $reimhot['port'];
}
$this->cmdshell = array(
array('soffice.exe','php.exe'), //win下必须包含
array('libreoffice'), //Linux下包含
array('pdf:writer_pdf_Export') //命令里至少要有一个
);
}
/**
* 发送队列信息
* $cont 内容可以是http地址也可以如:cli,run
* $param 参数
* 使用 c('rockqueue')->push('cli,run');
*/
public function push($cont, $param=array(), $runtime=0, $id=0)
{
$type = 'cmd';
$url = $cont;
$queuelogid = 0;
if(!isset($param['nolog'])){
$queuelogid= m('log')->addlogs('异步队列','', 3);
$param['queuelogid'] = $queuelogid;
}
if(substr($cont,0,4)=='http'){
$type='url';
}else{
if(!contain($url, ','))$url='cli,'.$url.'';
$phppath = getconfig('phppath');
if(!contain($this->rockqueue_host, '127.0.0.1') || isempt($phppath)){
$urla= explode(',', $url);
$url = URL.'task.php?m='.$urla[0].'|runt&a='.$urla[1].'';
$type= 'url';
}else{
$st1 = '';
$check = c('check');
foreach($param as $k=>$v)$st1.=' -'.$k.'='.$v.'';
if(contain($phppath,' ') || $check->isincn($phppath))
return returnerror('配置文件phppath不能有空格请加入环境变量设置并为php');
if(contain(ROOT_PATH,' ') || $check->isincn(ROOT_PATH))
return returnerror('OA系统目录“'.ROOT_PATH.'”有空格,无法使用');
$url = ''.$phppath.' '.ROOT_PATH.'/task.php '.$url.''.$st1.'';
}
}
if($type=='url'){
$jg = contain($url,'?')?'&':'?';
$st1 = '';
foreach($param as $k=>$v)$st1.='&'.$k.'='.$v.'';
if($st1!='')$url.=''.$jg.''.substr($st1,1).'';
}
if($id==0)$id = rand(1,99999);
$rarr[] = array(
'qtype' => $type,
'runtime' => $runtime,
'url' => $url,
'id' => $id
);
$barr = $this->pushdata($rarr);
$barr['cmdurl'] = ''.$type.':'.$url;
if($runtime==0)$runtime = time();
if($queuelogid>0){
m('log')->update(array(
'url' => $url,
'remark'=> '['.$type.']'.date('Y-m-d H:i:s', $runtime).'',
),$queuelogid);
}
return $barr;
}
/**
* 执行shell命令
*/
public function pushcmd($cmd)
{
if(contain(PHP_OS,'WIN')){
$cmdshell = $this->cmdshell[0];
}else{
$cmdshell = $this->cmdshell[1];
}
$qianz = explode(' ', $cmd);
$qianz = $qianz[0];
//$boa = false;
//foreach($cmdshell as $sell)if(contain($qianz, $sell))$boa = true;
//if(!$boa)return returnerror('非法操作');
$boa = false;
foreach($this->cmdshell[2] as $sell)if(contain($cmd, $sell))$boa = true;
if(!$boa)return returnerror('无效参数');
$id = rand(1,99999);
$rarr[] = array(
'qtype' => 'cmd',
'runtime' => '0',
'url' => escapeshellcmd($cmd),
'id' => $id
);
return $this->pushdata($rarr);
}
/**
* 推送数据过去
*/
public function pushdata($rarr)
{
if(is_array($rarr))$rarr = json_encode($rarr);
$url = 'http://'.$this->rockqueue_host.':'.$this->rockqueue_port.'/?atype=send&data='.urlencode($rarr).'';
$reqult = c('curl')->setTimeout(3)->getcurl($url);
if($reqult){
return returnsuccess($reqult);
}else{
return returnerror('服务端配置不能用');
}
//return c('socket')->udppush($rarr, $this->rockqueue_host, $this->rockqueue_port);
}
/**
* 推送类型
*/
public function pushtype($type, $url, $can=array())
{
$can['qtype'] = $type;
$can['url'] = $url;
$rarr[] = $can;
return $this->pushdata($rarr);
}
/**
* 发送腾讯云存储
* 调用c('rockqueue')->sendfile(文件Id);
*/
public function sendfile($fileid, $runtime=0)
{
return $this->push('qcloudCos,run', array('fileid'=>$fileid), $runtime);
}
public function senddown($fileid)
{
return $this->push('qcloudCos,down', array('fileid'=>$fileid));
}
/**
* 在信呼文件管理平台上删除对应文件
* 调用c('rockqueue')->delfile(文件编号);
*/
public function delfile($fileid)
{
return $this->push('qcloudCos,del', array('fileid'=>$fileid));
}
}

View File

@@ -0,0 +1,68 @@
<?php
class socketChajian extends Chajian
{
//UDP服务器主机不需要修改
private $serverhost = '127.0.0.1';
//UDP服务端口数字类型
private $serverport = 780;
/**
* UDP发送文本
*/
public function udpsend($str)
{
if(!function_exists('socket_create'))return '没有开启Socket组件';
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$len = strlen($str);
$bo = socket_sendto($sock, $str, $len, 0, $this->serverhost, $this->serverport);
socket_close($sock);
return $bo;
}
/**
* 转pdf发送命令
*/
public function topdf($path, $fid, $type)
{
$flx = 'doc';
if($type=='xls' || $type=='xlsx')$flx='xls';
if($type=='ppt' || $type=='pptx')$flx='ppt';
$topah = ''.ROOT_PATH.'/mode/pdfjs/topdf/'.$flx.'.js';
if(!file_exists($topah))return '没有安装转化插件';
$url = m('base')->getasynurl('asynrun', 'topdfok', array('id'=>$fid,'type'=>'pdf'));
$url = URL;
$path = ''.ROOT_PATH.'/mode/pdfjs/topdf/start.bat "'.$topah.'" "'.ROOT_PATH.'/'.$path.'" "'.$url.'"';
$bo = $this->udpsend($path);
return $bo;
}
/**
* 用udp推送
*/
public function udppush($str, $host='', $port=0)
{
$msg = $bstr = '';
if(!function_exists('stream_socket_client'))$msg= '没有开启Socket组件';
if($msg==''){
$handle = stream_socket_client("udp://{$host}:{$port}", $errno, $errstr);
if(!$handle){
$msg = "ERROR: {$errno} - {$errstr}";
}
if($msg==''){
fwrite($handle, $str);
//$bstr = fread($handle, 1024); //去掉这个,不然容易阻塞
fclose($handle);
}
}
$barr['code'] = 0;
$barr['success'] = true;
$barr['msg'] = 'ok';
$barr['data'] = $bstr;
if($msg!=''){
$barr['code'] = 2;
$barr['msg'] = $msg;
}
return $barr;
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* pThread 多线程插件php.ini需要开启php_pthreads.dll扩展
* 来自:信呼开发团队
* 使用方法 c('thread')->startrun('http://127.0.0.1/');
*/
class threadChajian extends Thread{
private $urlstr = '';
private $result = '';
/**
* 执行的地址
* isback 是否等待返回内容
*/
public function startrun($url, $isback=false){
$this->urlstr = $url;
$this->start();
if($isback)while($this->isRunning())usleep(10);
return $this->result;
}
public function run(){
@$this->result = c('curl')->getcurl($this->urlstr);
}
public function getresult()
{
return $this->result;
}
}
if(!class_exists('Thread')){
abstract class Thread {
public function run(){}
public function start(){
$this->run();
}
public function join(){return true;}
public function isRunning(){return false;}
}
}

View File

@@ -0,0 +1,263 @@
<?php
/**
上传文件类upfileChajian
createchenxihu
createdt2013-11-15
explain上传文件类可上传任何文件类型
*/
class upfileChajian extends Chajian{
public $ext; //上传类型
public $maxsize; //上传大小(MB)
public $path; //文件夹
private $jpgallext = '|jpg|png|gif|bmp|jpeg|'; //图片格式
//可上传文件类型也就是不保存为uptemp的文件
private $upallfile = '|doc|docx|xls|xlsx|ppt|pptx|pdf|swf|rar|zip|txt|gz|wav|mp3|avi|mp4|flv|wma|chm|apk|amr|log|json|cdr|psd|';
/**
初始化
@param $ext string 上传类型
@param $path string 上传目录 如upload|e|ee
@param $maxsize ing 上传大小(MB)
*/
public function initupfile($ext,$path,$maxsize=1)
{
if($ext=='image')$ext = $this->jpgallext;
$this->ext = $ext;
$this->maxsize = $maxsize;
$this->path = $path;
}
private function _getmaxupsize($lx)
{
$iniMax = strtolower(ini_get($lx));
if ('' === $iniMax) {
return PHP_INT_MAX;
}
$max = ltrim($iniMax, '+');
if (0 === strpos($max, '0x')) {
$max = intval($max, 16);
} elseif (0 === strpos($max, '0')) {
$max = intval($max, 8);
} else {
$max = (int) $max;
}
switch (substr($iniMax, -1)) {
case 't': $max *= 1024;
case 'g': $max *= 1024;
case 'm': $max *= 1024;
case 'k': $max *= 1024;
}
return $max;
}
public function getmaxupsize()
{
$post = $this->_getmaxupsize('post_max_size');
$upmx = $this->_getmaxupsize('upload_max_filesize');
if($post < $upmx)$upmx = $post;
return $upmx;
}
public function getmaxzhao()
{
$size = $this->getmaxupsize();
$size = $size / 1024 / 1024;
return (int)$size;
}
/**
* 是否在可保存范围内容
*/
public function issavefile($ext)
{
$bo = false;
$upallfile = $this->jpgallext.$this->upallfile;
if($this->contain($upallfile, '|'.$ext.'|'))$bo = true;
return $bo;
}
public function isimg($ext)
{
return $this->contain($this->jpgallext, '|'.$ext.'|');
}
/**
* 判断是不是图片
*/
public function isimgsave($ext, $file)
{
$arr = array();
if(!file_exists($file))return $arr;
if($this->isimg($ext)){
list($picw,$pich) = getimagesize($file);
if($picw==0||$pich==0){
@unlink($file);
}
$arr[0] = $picw;
$arr[1] = $pich;
}
return $arr;
}
public function isoffice($ext)
{
return contain('|doc|docx|xls|xlsx|ppt|pptx|pdf|', '|'.$ext.'|');
}
/**
上传
@param $name string 对应文本框名称
@param $cfile string 文件名心的文件名,不带扩展名的
@return string/array
*/
public function up($name,$cfile='')
{
if(!$_FILES)return 'sorry!';
$file_name = $_FILES[$name]['name'];
$file_size = $_FILES[$name]['size'];//字节
$file_type = $_FILES[$name]['type'];
$file_error = $_FILES[$name]['error'];
$file_tmp_name = $_FILES[$name]['tmp_name'];
$zongmax = $this->getmaxupsize();
if($file_size<=0 || $file_size > $zongmax){
return '文件为0字节/超过'.$this->formatsize($zongmax).',不能上传';
}
$file_sizecn = $this->formatsize($file_size);
$file_ext = $this->getext($file_name);//文件扩展名
$file_img = $this->isimg($file_ext);
$file_kup = $this->issavefile($file_ext);
if(!$file_img && !$this->isoffice($file_ext) && getconfig('systype')=='demo')return '演示站点禁止文件上传';
if($file_error>0){
$rrs = $this->geterrmsg($file_error);
return $rrs;
}
if(!$this->contain('|'.$this->ext.'|', '|'.$file_ext.'|') && $this->ext != '*'){
return '禁止上传文件类型['.$file_ext.']';
}
if($file_size>$this->maxsize*1024*1024){
return '上传文件过大,限制在:'.$this->formatsize($this->maxsize*1024*1024).'内,当前文件大小是:'.$file_sizecn.'';
}
//创建目录
$zpath=explode('|',$this->path);
$mkdir='';
for($i=0;$i<count($zpath);$i++){
$mkdir.=''.$zpath[$i].'/';
if(!is_dir($mkdir))mkdir($mkdir);
}
//新的文件名
$file_newname = $file_name;
$randname = $file_name;
if(!$cfile==''){
$file_newname=''.$cfile.'.'.$file_ext.'';
}else{
$_oldval = m('option')->getval('randfilename');
$randname = $this->getrandfile(1, $_oldval);
m('option')->setval('randfilename', $randname);
$file_newname=''.$randname.'.'.$file_ext.'';
}
$save_path = ''.str_replace('|','/',$this->path);
//if(!is_writable($save_path))return '目录'.$save_path.'无法写入不能上传';
$allfilename= $save_path.'/'.$file_newname.'';
$uptempname = $save_path.'/'.$randname.'.uptemp';
$upbool = true;
if(!$file_kup){
$allfilename= $this->filesave($file_tmp_name, $file_newname, $save_path, $file_ext);
if(isempt($allfilename))return '无法保存到'.$save_path.'';
}else{
$upbool = @move_uploaded_file($file_tmp_name,$allfilename);
}
if($upbool){
$picw=0;$pich=0;
if($file_img){
$fobj = $this->isimgsave($file_ext, $allfilename);
if(!$fobj){
return 'error:非法图片文件';
}else{
$picw = $fobj[0];
$pich = $fobj[1];
}
}
return array(
'newfilename' => $file_newname,
'oldfilename' => $file_name,
'filesize' => $file_size,
'filesizecn' => $file_sizecn,
'filetype' => $file_type,
'filepath' => $save_path,
'fileext' => $file_ext,
'allfilename' => $allfilename,
'picw' => $picw,
'pich' => $pich
);
}else{
return '上传失败:'.$this->geterrmsg($file_error).'';
}
}
private function getrandfile($xu, $val)
{
$randname = ''.date('d_His').''.rand(10,99*$xu).'';
if($val==$randname)return $this->getrandfile($xu+1, $val);
return $randname;
}
private function geterrmsg($code)
{
$arrs[1] = '上传文件大小超过服务器允许上传的最大值';
$arrs[2] = '上传文件大小超过HTML表单中隐藏域MAX_FILE_SIZE选项指定的值';
$arrs[6] = '没有找不到临时文件夹';
$arrs[7] = '文件写入失败';
$arrs[8] = 'php文件上传扩展没有打开';
$arrs[3] = '文件只有部分被上传';
$rrs = '上传失败,可能是服务器内部出错,请重试';
if(isset($arrs[$code]))$rrs=$arrs[$code];
return $rrs;
}
//返回文件大小
public function formatsize($size)
{
return $this->rock->formatsize($size);
}
//获取扩展名
public function getext($file)
{
return strtolower(substr($file,strrpos($file,'.')+1));
}
/**
* 非法文件保存为临时uptemp的形式
*/
public function filesave($oldfile, $filename, $savepath, $ext)
{
$file_kup = $this->issavefile($ext);
$ldisn = strrpos($filename, '.');
if($ldisn>0)$filename = substr($filename, 0, $ldisn);
$filepath = ''.$savepath.'/'.$filename.'.'.$ext.'';
if(!$file_kup){
$filebase64 = base64_encode(file_get_contents($oldfile));
$filepath = ''.$savepath.'/'.$filename.'.uptemp';
$bo = $this->rock->createtxt($filepath, $filebase64);
@unlink($oldfile);
if(!$bo)$filepath = '';
}else{
}
return $filepath;
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* 微信小程序接口
*/
class wxxcyChajian extends Chajian{
protected function initChajian()
{
$this->wxxcy_url = getconfig('wxxcy_url'); //微信小程序地址
if(getconfig('systype')=='dev')$this->wxxcy_url='http://localhost/app/xcy_hosh/';
}
/**
* 发送订阅消息
* $xcytype 类型入hetong
* $mobile 接收人员手机号
* $params 参数,多个|分开
* $tplid 发给哪个模版用0,1,2,3等
*/
public function subscribe($xcytype, $mobile, $params,$tplid='0',$path='')
{
if(!$this->wxxcy_url)return returnerror('wxxcy_url empty');
$onr = m('wxxcyus')->getone("`xcytype`='$xcytype' and `mobile`='$mobile'");
if(!$onr)return returnerror('no subscribe');
$url = ''.$this->wxxcy_url.'api.php?m=weixin&a=subscribe&xcytype='.$xcytype.'';
$data['mobile'] = $mobile;
$data['params'] = $params;
$data['tplid'] = $tplid;
$data['path'] = $path;
$result = c('curl')->postcurl($url, $data);
if(!$result)return returnerror('api not data');
if(substr($result,0,1)!='{')return returnerror('err:'.$result.'');
return json_decode($result, true);
}
}

View File

@@ -0,0 +1,50 @@
<?php
class xinhuChajian extends Chajian{
private $updatekey = '';
private $updatekeys = 'aHR0cDovLzEyNy4wLjAuMS9hcHAvcm9ja3hpbmh1d2ViLw::';
protected function initChajian()
{
if(getconfig('systype')=='dev'){
$this->updatekey = $this->rock->jm->base64decode($this->updatekeys);
}else{
$this->updatekey = URLY;
}
if(isempt($this->updatekey))$this->updatekey=$this->rock->jm->base64decode('aHR0cDovL3d3dy5yb2Nrb2EuY29tLw::');
}
public function getwebsite()
{
return $this->updatekey;
}
public function geturlstr($act, $can=array())
{
$url = $this->updatekey;
$url.= 'api.php?a='.$act.'';
$url.= '&host='.$this->rock->jm->base64encode(HOST).'&version='.VERSION.'&time='.time().'&web='.$this->rock->web.'&ipstr='.$this->rock->ip.'&randkey='.getconfig('randkey').'&xinhukey='.getconfig('xinhukey').'';
$url.= '&authorkey='.getconfig('authorkey').'&cfrom='.getconfig('xinhutype').'';
if($act!='xinhuinstall')$url.= '&aukey='.m('option')->getval('auther_aukey').'';
foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
return $url;
}
public function getdata($act, $can=array())
{
$url = $this->geturlstr($act, $can);
$cont = c('curl')->getcurl($url);
$data = array('code'=>199,'msg'=>'出错'.URLY.',返回:'.htmlspecialchars($cont).'');
if($cont!='' && substr($cont,0,1)=='{'){
$data = json_decode($cont, true);
}
return $data;
}
public function helpstr($num, $na='')
{
if($na=='')$na='帮助';
return '<a style="color:blue" href="'.$this->updatekey.'view_'.$num.'.html" target="_blank">['.$na.']</a>';
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
<?php
/**
* 连接信呼文件管理平台
*/
class xinhudocChajian extends Chajian{
public function geturlstr($mod, $act, $can=array())
{
$url = getconfig('xinhudoc_platurl');
$key = getconfig('xinhudoc_openkey');
if(substr($url,-1)!='/')$url.='/';
$url .= 'openapi/'.$mod.'/'.$act.'?openkey='.md5($key).'';
foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
return $url;
}
/**
* 返回内容处理
*/
public function returnresult($result)
{
if($result && contain($result,'success')){
$stat = strpos($result,'{');
if(!$stat)$stat=0;
$barr = json_decode(substr($result, $stat), true);
if(isset($barr['success']))return $barr;
}
return returnerror('returnerr:'.$result.'');
}
}

View File

@@ -0,0 +1,131 @@
<?php
/**
* 小米推送
* 参考的开发https://dev.mi.com/console/doc/detail?pId=1163
*/
class xmpushChajian extends Chajian{
private $api_url = 'https://api.xmpush.xiaomi.com/v2/message/alias';
private $api_urltest = 'https://sandbox.xmpush.xiaomi.com/v2/message/alias';
//安卓的
private $android_secret = ''; //安卓小米的secret
private $android_package = ''; //包名
//IOS苹果(弃用不要去设置修改)
private $ios_secret = ''; //IOS的secret
private $ios_bundleid = '';
//2021-10-09最新IOS推送使用极光的如果自己编译IOS就要配置
private $jpush_app_key = '';
private $jpush_master_secret = '';
private $jpush_ios_ver = ''; //IOS编译的版本1正式版
protected function initChajian()
{
if(!$this->android_secret)$this->android_secret = getconfig('xm_android_secret');
if(!$this->android_package)$this->android_package = getconfig('xm_android_package');
$this->jpush_app_key = getconfig('jpush_app_key');
$this->jpush_master_secret = getconfig('jpush_master_secret');
$this->jpush_ios_ver = getconfig('jpush_ios_ver');
}
public function sendbool()
{
if($this->android_secret=='')return false;
return true;
}
/**
* 安卓推送通知
*/
public function androidsend($alias, $title, $cont, $payload='')
{
if(!$alias || !$this->sendbool())return '';
if(is_array($alias))$alias = join(',', $alias);
$data = array(
'payload' => '',
'restricted_package_name' => $this->android_package,
'pass_through' => '0', // 0 表示通知栏消息1表示透传消息
'title' => $title,
'description' => $cont,
'alias' => $alias,
'notify_type' => '1', //提示语就好了
'notify_id' => rand(1,45), //可多条显示
'extra.notify_foreground' => '1',
'extra.notify_effect' => '1',
);
if($payload)$data['payload'] = urlencode($payload);
return c('curl')->postcurl($this->api_url, $data, 0, array(
'Authorization'=> 'key='.$this->android_secret
));
}
//弃用(2021-10-09)
public function iossend($alias, $title, $cont)
{
if(!$alias || $this->ios_secret=='')return '';
if(is_array($alias))$alias = join(',', $alias);
$data = array(
'title' => $title,
'aps_proper_fields.title' => $title,
'description' => $cont,
'aps_proper_fields.body' => $cont,
'alias' => $alias,
'extra.badge'=>'1'
);
return c('curl')->postcurl($this->api_url, $data, 0, array(
'Authorization'=> 'key='.$this->ios_secret
));
}
/**
* 推送以下,你用不到不要去管和修改
*/
public function jpushiosbool()
{
if($this->jpush_app_key=='')return false;
return true;
}
public function jpushiossend($alias, $title, $cont, $iszs=false)
{
if(!$this->jpushiosbool())return '';
if($this->jpush_ios_ver==1)$iszs = true;
$url = 'https://api.jpush.cn/v3/push';
$body = array();
$base64_auth_string = base64_encode(''.$this->jpush_app_key.':'.$this->jpush_master_secret.'');
$headarr['Authorization'] = 'Basic '.$base64_auth_string.'';
if(is_string($alias))$alias = explode(',', $alias);
$body['platform'] = array('ios');
$body['audience'] = array(
'alias' => $alias
);
$sound = 'widget/res/sound/sound.aif';
if($cont=='邀请与您视频通话...' || $cont=='邀请与您语音通话...')$sound='widget/res/sound/call.mp3';
$body['notification'] = array(
'ios' => array(
'alert' => array(
'title' => $title,
'body' => $cont,
),
'sound' => $sound,
'badge' => '+1',
'thread-id' => 'default',
)
);
$body['options'] = array(
'time_to_live' => 60,
'apns_production' => $iszs, //false测试环境
);
$result = c('curl')->postcurl($url, json_encode($body, JSON_UNESCAPED_UNICODE), 0, $headarr);
return $result;
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* 来自:信呼开发团队
* 作者:磐石(rainrock)
* 网址http://www.rockoa.com/
* 云片网短信服务
* 此文件放到include/chajian/yunpsmsChajian.php 下
* 开发帮助地址http://www.rockoa.com/view_yunpsms.html
*/
class yunpsmsChajian extends Chajian{
private $sendurl = 'https://sms.yunpian.com/v2/sms/batch_send.json';
private $yunpian_key = '你的短信apikey'; //这里填写你的云片网的apikey
/**
* 短信模版写这里的
*/
protected function initChajian()
{
$mobian['defyzm'] = '欢迎使用,您的短信验证码为:#code#,为保障系统安全,请勿将验证码和办公系统网址提供给他人,祝您工作愉快。';
$mobian['defsucc'] = '您提交单据(#modename#,单号:#sericnum#)已全部处理完成,可登录系统查看详情。';
$mobian['default'] = '您有单据(#modename#,单号:#sericnum#)需要处理,请登录系统及时去处理。';
$mobian['birthday'] = '尊敬的#name#,今天是#dt#,农历#dtnong#,是您的生日,我们在这里祝您生日快乐。';
$mobian['defnum'] = '您有#applyname#的(#modename#)单据需要您处理,详情:#url#';
$mobian['defurls'] = '您有单据(#modename#,单号:#sericnum#)需要处理,请及时去处理,详情:#url#。';
$mobian['gongsms'] = '您收到一条“#title#”的通知,详情:#url#';
$mobian['meetapply'] = '#optname#发起会议“#title#”在#hyname#,时间#startdt#至#enddt#';
$mobian['meetcancel'] = '#optname#取消会议“#title#”,时间#startdt#至#enddt#,请悉知。';
$mobian['meettodo'] = '会议“#title#”将在#fenz#分钟后的#time#开始请做好准备,在会议室“#hyname#”';
//上面加你的模版
$this->mobianarr = $mobian;
}
/**
* 批量发送短信
* $mobiles 接收人手机号多个,分开
* $qianm 签名
* $tplid 模版编号在上面initChajian()数组中查找
* $cans 模版中的参数数组
* 例子c('mysms')->send('15800000000,15800000001','信呼', 'default', array('modename'=>'模块名','sericnum'=>'单号')); 这例子是不需要自己调用,只要短信设置下切换为“我的短信服务”就可以了
*/
public function send($mobiles, $qianm, $tplid, $cans=array())
{
//要发送短信的内容
$text = arrvalue($this->mobianarr, $tplid);
if(isempt($text))return returnerror('模版'.$tplid.'不存在');
foreach($cans as $k=>$v)$text = str_replace('#'.$k.'#', $v, $text);
if(isempt($qianm))return returnerror('没有设置短信签名');
if(isempt($this->yunpian_key))return returnerror('没有设置云片网的apikey');
$text = '【'.$qianm.'】'.$text.''; //发的短信
$arr['apikey'] = $this->yunpian_key;
$arr['mobile'] = $mobiles;
$arr['text'] = $text;
$result = c('curl')->postcurl($this->sendurl, $arr);
if(isempt($result))return returnerror('发送失败');
$barr = json_decode($result, true);
$data = arrvalue($barr,'data');
$total_count = 0; //总发送条数
$sendbo = false;
$msg = '';
if(is_array($data))foreach($data as $k=>$rs){
if($rs['code']==0){
$sendbo = true;
}else{
$msg .= $rs['msg'].';';
}
}
//成功
if($sendbo){
return returnsuccess(array(
'count' => $barr['total_count'],
'text' => $text,
'mobile'=> $mobiles,
));
}else{
return returnerror('发送失败:'.$msg.'('.$text.')', 202);
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
class zipChajian extends Chajian{
/**
* 解压zip文件
*/
public function unzip($filename, $path){
if(!function_exists('zip_open'))return 'php未开启zip模块';
if(!file_exists($filename))return '文件不存在';
@$resource = zip_open($filename);
if(!$resource)return '无法打开文件';
while ($dir_resource = zip_read($resource)){
if(zip_entry_open($resource,$dir_resource)){
$file_name = $path.zip_entry_name($dir_resource);
$file_path = substr($file_name,0,strrpos($file_name, "/"));
if(!is_dir($file_path))mkdir($file_path,0777,true);
if(!is_dir($file_name)){
$file_size = zip_entry_filesize($dir_resource);
$file_content = zip_entry_read($dir_resource, $file_size);
$bos = $this->writefile($file_name, $file_content);
if(!$bos)return '无权限写入文件:'.$file_name.'';
}
zip_entry_close($dir_resource);
}
}
zip_close($resource);
return 'ok';
}
private function writefile($file_name, $file_content)
{
$oldcont = '';
if(file_exists($file_name)){
$oldcont = file_get_contents($file_name);
if($oldcont != $file_content){
$barfile = ''.UPDIR.'/upage/'.$file_name.'';
$this->rock->createdir($barfile);
copy($file_name, $barfile);
}
}
@$bos = file_put_contents($file_name,$file_content);
return $bos;
}
/**
* 获取zip上文件
*/
public function zipget($filename){
if(!function_exists('zip_open'))return 'php未开启zip模块';
if(!file_exists($filename))return '文件不存在';
@$resource = zip_open($filename);
if(!$resource)return '无法打开文件';
$farr = array();
while ($dir_resource = zip_read($resource)){
if(zip_entry_open($resource,$dir_resource)){
$file_name = zip_entry_name($dir_resource);
$file_path = substr($file_name,0,strrpos($file_name, "/"));
if(!is_dir($file_name) && substr($file_name,-1)!='/'){
$file_size = zip_entry_filesize($dir_resource);
$file_content = zip_entry_read($dir_resource, $file_size);
if(substr($file_name,0,1)=='/')$file_name = substr($file_name,1);
$farr[] = array(
'filepath' => $file_name,
'filesize' => $file_size,
'filecontent' => base64_encode($file_content),
);
}
zip_entry_close($dir_resource);
}
}
zip_close($resource);
return $farr;
}
private function addFileToZip($path, $zip, $wz){
$handler = opendir($path);
while(($filename=readdir($handler))!==false){
if($filename != '.' && $filename != '..'){
$addfile = $path.'/'.$filename;
if(is_dir($addfile)){
$this->addFileToZip($addfile, $zip, $wz);
}else{
$localwz = substr($addfile, $wz);
$zip->addFile($addfile, $localwz);
}
}
}
@closedir($path);
}
/**
* zip打包
*/
public function packzip($path, $topath)
{
$zip = new ZipArchive();
if($zip->open($topath, ZipArchive::OVERWRITE)=== TRUE){
$this->addFileToZip($path, $zip, strlen($path));
$zip->close();
}
if(!file_exists($topath))$topath='';
return $topath;
}
}