public function remoteinstall() { //安全验证 $this->checksafeauth(); $url = $this->_get('url'); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { //兼容旧版本 $url = xbase64_decode($url); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { $this->error('远程文件格式必须为.zip'); } } $content = fopen_url($url); if (empty($content)) { $this->error('远程获取文件失败!'); } $filename = substr($filepath, 0, -4); File::write_file($filepath, $content); import('ORG.PclZip'); $zip = new PclZip($filepath); $zip->extract(PCLZIP_OPT_PATH, './'); @unlink($filepath); //删除安装文件 $this->success('操作成功!', U('App/index')); }
static function remotedownload() { import('ORG.File'); import('ORG.PclZip'); $url = "http://oss.aliyuncs.com/waikucms/htaccess.zip"; File::write_file('htaccess.zip', fopen_url($url)); $zip = new PclZip('htaccess.zip'); $zip->extract(PCLZIP_OPT_PATH, './'); @unlink('htaccess.zip'); return 1; }
public function remoteinstall() { $url = $this->_get('url'); if ($ext != '.zip') { //兼容旧版本 $url = xbase64_decode($url); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { $this->error('远程文件格式必须为.zip'); } } $content = fopen_url($url); if (empty($content)) { $this->assign('waitSecond', 20); $this->error('远程获取文件失败!,<a href="' . $url . '" target="_blank">本地下载安装</a>'); } $filename = substr($filepath, 0, -4); //检测是否已经安装 $model = M('arcmodel'); $id = $model->order('id desc')->getField('id') + 1; if ($model->where("nid='" . $filename . "'")->find()) { $this->error('系统已安装当前模型!'); } //获取数据并解压缩 $tplpath = './Public/Model/' . $filename; File::write_file($filepath, $content); import('ORG.PclZip'); $zip = new PclZip($filepath); $zip->extract(PCLZIP_OPT_PATH, $tplpath); //删除压缩包 @unlink($filepath); //导入数据 $sqlfile = $tplpath . '/data.sql'; if (is_file($sqlfile)) { $sql = explode('###', strtr(File::read_file($sqlfile), array('#@__' => C('DB_PREFIX'), '__LINE__' => $id))); foreach ($sql as $v) { $model->execute(trim($v)); } } //刷新缓存 jump(U('Arcmodel/over')); }
public function remoteinstall() { //安全验证 $this->checksafeauth(); $url = $this->_get('url'); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { //兼容旧版本 $url = xbase64_decode($url); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { $this->error('远程文件格式必须为.zip'); } } $content = fopen_url($url); if (empty($content)) { $this->assign('waitSecond', 20); $this->error('远程获取文件失败!,<a href="' . $url . '" target="_blank">本地下载安装</a>'); } $filename = substr($filepath, 0, -4); $tplpath = './Public/Wap/' . $filename; if (is_dir($tplpath)) { $this->error('模板目录已存在!'); } File::write_file($filepath, $content); import('ORG.PclZip'); $zip = new PclZip($filepath); $zip->extract(PCLZIP_OPT_PATH, $tplpath); @unlink($filepath); //删除安装文件 $this->success('操作成功!', U('Wap/index')); }
/** * [getShakeInfoShakeAroundUser 获取设备信息,包括UUID、major、minor,以及距离、openID 等信息。] * @param string $ticket 摇周边业务的ticket,可在摇到的URL 中得到,ticket生效时间为30 分钟 * @return boolean|mixed * 正确返回JSON 数据示例: * { "data": { "page_id ": 14211, "beacon_info": { "distance": 55.00620700469034, "major": 10001, "minor": 19007, "uuid": "FDA50693-A4E2-4FB1-AFCF-C6EB07647825" }, "openid": "oVDmXjp7y8aG2AlBuRpMZTb1-cmA" }, "errcode": 0, "errmsg": "success." } * 字段说明: * beacon_info 设备信息,包括UUID、major、minor,以及距离 * UUID、major、minor UUID、major、minor * distance Beacon 信号与手机的距离 * page_id 摇周边页面唯一ID * openid 商户AppID 下用户的唯一标识 * poi_id 门店ID,有的话则返回,没有的话不会在JSON 格式内 * @access public * @author polo<*****@*****.**> * @version 2015-3-25 下午3:28:20 * @copyright Show More */ public function getShakeInfoShakeAroundUser($ticket) { if (!$this->access_token && !$this->checkAuth()) { return false; } $data = array('ticket' => $ticket); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_USER_GETSHAKEINFO . 'access_token=' . $this->access_token, self::json_encode($data)); File::write_file(APP_PATH . 'log/error333.log', date("Y-m-d H:i:s") . " url=" . json_encode($result) . "--city: " . self::API_BASE_URL_PREFIX . self::SHAKEAROUND_USER_GETSHAKEINFO . 'access_token=' . $this->access_token, self::json_encode($data) . "\r\n", 'a+'); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
public function doedit() { $filename = $_POST['filename']; $content = $_POST['content']; if (empty($filename)) { $this->error('文件路径不正确!'); } MAGIC_QUOTES_GPC == true ? File::write_file($filename, stripslashes($content)) : File::write_file($filename, $content); $from = empty($_POST['from']) ? U('FileManage/index') : $_POST['from']; $this->success('操作成功!', $from); }
public function remoteinstall() { //安全验证 $this->checksafeauth(); $url = $this->_get('url'); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { //兼容旧版本 $url = xbase64_decode($url); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { $this->error('远程文件格式必须为.zip'); } } $content = fopen_url($url); if (empty($content)) { $this->assign('waitSecond', 20); $this->error('远程获取文件失败!,<a href="' . $url . '" target="_blank">本地下载安装</a>'); } $filename = substr($filepath, 0, -4); $tplpath = './Public/Special/' . $filename; if (is_dir($tplpath)) { $this->error('专题目录已存在!'); } File::write_file($filepath, $content); import('ORG.PclZip'); $zip = new PclZip($filepath); $zip->extract(PCLZIP_OPT_PATH, $tplpath); @unlink($filepath); //删除安装文件 //导入数据 $xmlpath = './Public/Special/' . $filename . '/special.xml'; if (is_file($xmlpath)) { $xml = simplexml_load_file($xmlpath); $data['title'] = (string) $xml->title; $data['seotitle'] = (string) $xml->seotitle; $data['keywords'] = (string) $xml->keywords; $data['description'] = (string) $xml->description; $data['content'] = (string) $xml->content; $data['tempindex'] = (string) $xml->tempindex; $data['waptempindex'] = (string) $xml->waptempindex; $data['pubdate'] = time(); $model = M('special'); $model->add($data); } $this->success('操作成功!', U('Special/index')); }
private function mkmodel($table) { $filepath = LIB_PATH . 'Model/' . $table . 'ViewModel.class.php'; if (file_exists($filepath)) { return true; } $truetablename = C('DB_PREFIX') . $table; $database = C('DB_NAME'); $model = M(); $sql = "SELECT COLUMN_NAME FROM `information_schema`.`COLUMNS` where `TABLE_SCHEMA`='{$database}' and `TABLE_NAME`='{$truetablename}' order by COLUMN_NAME;"; $list = $model->query($sql); if (!$list) { return false; } $fields = ''; foreach ($list as $v) { if ($v['COLUMN_NAME'] != 'id' && $v['COLUMN_NAME'] != 'typeid') { $fields .= ",'" . $v['COLUMN_NAME'] . "'"; } } $fields = ltrim($fields, ','); $fields .= ",'_on'=>'archive.id={$table}.id'), "; $addonsql = "'{$table}'=>array({$fields}"; $content = <<<DATA \t\t<?php \t\t\tclass {$table}ViewModel extends ViewModel \t\t\t{ \t\t\t\tpublic \$viewFields = array \t\t\t\t( \t\t\t\t\t'archive'=>array('id','typeid','flag','modelid','senddate', \t\t\t\t\t'pubdate','click','keywords','description','money','arcrank', \t\t\t\t\t'writer','title','shorttitle','color','source', \t\t\t\t\t'litpic','voteid','mid','_type'=>'LEFT'), \t\t\t\t\t'arctype'=>array('typename','temparticle','waptemparticle','_on'=>'archive.typeid=arctype.id','_type'=>'LEFT'), \t\t\t\t\t'member'=>array('username','_on'=>'archive.mid=member.id'), \t\t\t\t\t{$addonsql} \t\t\t\t); \t\t\t} DATA; File::write_file($filepath, $content); return true; }
public function backupsql($date) { //数据备份 $rs = new Model(); $list = $rs->query("SHOW TABLES FROM " . "`" . C('DB_NAME') . "`"); $filesize = 2048; $file = './Public/Backup/'; $random = mt_rand(1000, 9999); $sql = ''; $p = 1; $url = ''; foreach ($list as $k => $v) { $table = current($v); //仅备份当前系统的数据库表 $prefix = C('DB_PREFIX'); if (substr($table, 0, strlen($prefix)) == $prefix) { $rs = D(str_replace(C('DB_PREFIX'), '', $table)); $array = $rs->select(); $sql .= "TRUNCATE TABLE `{$table}`;\n"; foreach ($array as $value) { $sql .= $this->insertsql($table, $value); if (strlen($sql) >= $filesize * 1000) { $filename = $file . 'update_' . $date . '_' . date('Ymd') . '_' . $random . '_' . $p . '.sql'; $url .= "<a href='{$filename}'>" . $filename . '</a>,'; File::write_file($filename, $sql); $p++; $sql = ''; } } } } if (!empty($sql)) { $filename = $file . 'update_' . $date . '_' . date('Ymd') . '_' . $random . '_' . $p . '.sql'; $url .= "<a href='{$filename}'>" . $filename . '</a>,'; File::write_file($filename, $sql); } return $url; }
<?php include_once 'inc/classCaller.php'; if (isset($_POST['form_button'])) { switch ($_POST['form_button']) { case 'texto-inicial': $texto = new File('texto.txt', 'w'); $texto->write_file($_POST['texto_inicial']); header('location: index.php'); break; } } elseif (isset($_POST['matricula_remover'])) { echo $_POST['matricula_remover']; $csv = new parseCSV(); $csv->delimiter = ';'; $csv->parse('dados.csv'); $csvData = $csv->data; foreach ($csvData as $data_key => $data_value) { if ($data_value['matricula'] == $_POST['matricula_remover']) { unset($csvData[$data_key]); } } // NOTE: o código a seguir é gambiarrento // eu precisei apagar o dados.csv pra reescrever // com todos novos valores, pois não tem tempo // pra desenvolver algo mais bonito ou pensar // algo melhor e é o que a biblioteca do CSV ofereceu... unset($csv); $csv = new File('dados.csv', 'w'); $csv->write_file('matricula;email;nome;curso;turma' . PHP_EOL); unset($csv);
public function dobackup() { if (empty($_POST['ids'])) { $this->error("请选择需要备份的数据库表!"); } $filesize = intval($_POST['filesize']); if ($filesize < 512) { $this->error("出错了,请为分卷大小设置一个大于512的整数值!"); } $file = './Public/Backup/'; $random = mt_rand(1000, 9999); $sql = ''; $p = 1; foreach ($_POST['ids'] as $table) { $rs = D(str_replace(C('DB_PREFIX'), '', $table)); $array = $rs->select(); $sql .= "TRUNCATE TABLE `{$table}`;\n"; foreach ($array as $value) { $sql .= $this->insertsql($table, $value); if (strlen($sql) >= $filesize * 1000) { $filename = $file . date('Ymd') . '_' . $random . '_' . $p . '.sql'; File::write_file($filename, $sql); $p++; $sql = ''; } } } if (!empty($sql)) { $filename = $file . date('Ymd') . '_' . $random . '_' . $p . '.sql'; File::write_file($filename, $sql); } $this->success("数据库分卷备份已完成,共分成{$p}个sql文件存放!", U("Backup/restore")); }
// $json['data'] = $data; // break; $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; $returnData = $wechat->pay($url, $data, $options['zhifu'], $city_id); $json['ret'] = $returnData; if ($returnData) { if ($returnData['result_code'] != 'SUCCESS') { File::write_file($openid_path, json_encode([]), "w+"); $json['state'] = 101; $json['msg'] = '红包稍后到达你的账户~'; File::write_file("error.log", date("Y-m-d H:i:s=") . json_encode($returnData) . "\r\n", "a+"); break; } else { // 更改提现状态 $d = ['openid' => $FUserId, 'status' => 1, "amount" => $money]; File::write_file($openid_path, json_encode($d), "w+"); $json['msg'] = "恭喜您~ 获得1元现金红包"; break; } } else { $json['state'] = 101; $json['msg'] = '红包稍后到达你的账户'; break; } } while (false); echo json_encode($json); die; } // 进行授权 if (!$FUserId) { //
/** * 设置缓存,按需重载 * @param string $cachename * @param mixed $value * @param int $expired * @return boolean */ protected function setCache($cachename, $value, $expired) { $file = $cachename . ".json"; return File::write_file($cachename, json_encode($value), 'w+'); }
$cquery = "Update `{$dbprefix}config` set value='{$cfg_webname}' where id=4;"; mysql_query($cquery, $conn); $cquery = "Update `{$dbprefix}config` set value='{$cfg_basehost}' where id=1;"; mysql_query($cquery, $conn); $cquery = "Update `{$dbprefix}config` set value='{$cfg_cmspath}' where id=22;"; mysql_query($cquery, $conn); $cquery = "Update `{$dbprefix}config` set value='{$cfg_cmspath}' where id=2;"; mysql_query($cquery, $conn); //增加管理员帐号 $adminquery = "INSERT INTO `{$dbprefix}admin` (`id`, `name`, `password`, `logintime`, `loginip`, `status`) VALUES\n(1, '{$adminuser}', '" . xmd5($adminpwd) . "', " . time() . ", '127.0.0.1', '超级');"; $adminquery2 = "INSERT INTO `{$dbprefix}member` (`id`, `username`, `password`, `email`, `status`, `activekey`, `logintime`, `regtime`, `loginip`, `money`, `rankid`, `sex`, `province`, `city`, `qq`, `birthday`, `avtar`) VALUES\n(1, '{$adminuser}', '" . xmd5($adminpwd) . "', '*****@*****.**', 0, 'de90979d72b0d3b2cf4b3ccc0a3a632c', " . time() . ", " . time() . ", '127.0.0.1', 0, 23, 1, '山东', '济南', '634150845', '1988-01-23', '');"; mysql_query($adminquery, $conn); mysql_query($adminquery2, $conn); //安全密码设置 $safeadminpwd = empty($safeadminpwd) ? xmd5($adminpwd) : xmd5($safeadminpwd); File::write_file('../Admin/Common/safeauth.php', "<?php\treturn '{$safeadminpwd}';?>"); //安装体验数据 if ($installdemo == 1) { $query = ''; $fp = fopen(dirname(__FILE__) . '/sql-dfdemo.txt', 'r'); while (!feof($fp)) { $line = rtrim(fgets($fp, 1024)); if (preg_match("#;\$#", $line)) { $query .= $line; $query = str_replace('#@__', $dbprefix, $query); if ($mysqlVersion < 4.1) { $rs = mysql_query($query, $conn); } else { $rs = mysql_query(str_replace('#~lang~#', $dblang, $query), $conn); } $query = '';