$numero = mysql_num_rows($sql_existe); if ($numero > 0) { echo "2"; } else { function rand_code($chars, $long) { $code = ""; for ($x = 0; $x <= $long; $x++) { $rand = rand(1, strlen($chars)); $code .= substr($chars, $rand, 1); } return $code; } $caracteres = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012456789"; $longitud = 20; $codigoal = rand_code($caracteres, $longitud); $registrar = "INSERT into usuario(nom_us,cor_us,pass_us,cod_actv_us,estd_us,tip_us) \n\t\t\t\tvalues('{$a}','{$b}','{$c}','{$codigoal}','2','1')"; mysql_query($registrar, $conexion) or die(mysql_error()); $sacar_id = "SELECT * from usuario where cor_us='{$b}'"; $sql_id = mysql_query($sacar_id, $conexion) or die(mysql_error()); while ($did = mysql_fetch_array($sql_id)) { $idus = $did['id_us']; } include '../miler/class.phpmailer.php'; $mail = new PHPMailer(); $body = "<header bgcolor='#EC268F' color= '#fff'>\n\t\t\t\t\t<figure>\n\t\t\t\t\t\t<center>\n\t\t\t\t\t\t\t<img src='http://conaxport.com/angeles/imagenes/logo.png' alt='logo' width='40%' />\n\t\t\t\t\t\t</center>\n\t\t\t\t\t</figure>\n\t\t\t\t\t<h1>Registro Angeles Inc</h1>\n\t\t\t\t</header>\n\t\t\t\t<section>\n\t\t\t\t\t<article>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tHola {$a} te has registrado en la página de Angeles Inc para \n\t\t\t\t\t\t\tcompletar tu registro ingrese el siguiente link para activar tu cuenta.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tLink de activación: \n\t\t\t\t\t\t\t<a style='padding: 0.5em 1em;background: #EC268F;color:#fff;text-decoration: none;' \n\t\t\t\t\t\t\t\thref='http://conaxport.com/angeles/activacion.php?alg={$codigoal}&di={$idus}' target='_blank'>\n\t\t\t\t\t\t\t\tTerminar Registro\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t<b>Antención: </b>Si no te has registrado en la pagina y te llegó este correo ingnore el mensaje y borrelo inmediatamente. \n\t\t\t\t\t\t</p>\n\t\t\t\t\t</article>\n\t\t\t\t</section>\n\t\t\t\t<footer style='background:#EC268F;color:#fff;margin-top: 1em;padding-bottom: 1em;'>\n\t\t\t\t\t<article style='margin: 0 auto;max-width: 800px;display: flex;justify-content: space-around;'>\n\t\t\t\t\t\t<article>\n\t\t\t\t\t\t\t<h2>Contacto</h2>\n\t\t\t\t\t\t\t<div>Dirección</div>\n\t\t\t\t\t\t\t<div>Teléfonos</div>\n\t\t\t\t\t\t</article>\n\t\t\t\t\t\t<article>\n\t\t\t\t\t\t\t<h2>Diseño</h2>\n\t\t\t\t\t\t\t<a href='http://conaxport.com/' target='_blank' id='cnxpt'>Conaxport</a>\n\t\t\t\t\t\t</article>\n\t\t\t\t\t</article>\n\t\t\t\t</footer>"; $mail->SetFrom('*****@*****.**', 'Angeles Inc'); $mail->From = "*****@*****.**"; $mail->FromName = "Angeles Inc"; $mail->AddReplyTo('*****@*****.**', 'Angeles Inc'); $address = "{$b}";
return $code; } if ($a == "" || $b == "" || $c == "") { echo "1"; } else { $existe = "SELECT * from usuarios where cor_us='{$c}'"; $sql_existe = $conexion->query($existe) or die(mysqli_error()); $numero = $sql_existe->num_rows; if ($numero > 0) { echo "2|0"; } else { $caracteres = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012456789"; $longitud = 20; $longib = 8; $codigoal = rand_code($caracteres, $longitud); $e = rand_code($caracteres, $longib); $ingresar = "INSERT into usuarios(nom_ap_us,cor_us,mov_us,pass_us,tp_us,estd_us,cod_reg_us,fecr_us) \n\t\t\t\tvalues('{$nombreComp}','{$c}','{$d}','{$e}','1','2','{$codigoal}','{$hoy}')"; $conexion->query($ingresar) or die(mysqli_error()); $tomar_id = "SELECT id_us from usuarios where cor_us='{$c}'"; $sql_tomar = $conexion->query($tomar_id) or die(mysqli_error()); while ($fg = $sql_tomar->fetch_assoc()) { $idus = $fg['id_us']; } include '../miler/class.phpmailer.php'; $mail = new PHPMailer(); $body = "<section style='max-width:1100px;'>\n\t\t\t\t<header>\n\t\t\t\t\t<figure>\n\t\t\t\t\t\t<img src='http://inmobiliariaprovase.com.co/imagenes/logo.png' alt='logo' />\n\t\t\t\t\t</figure>\n\t\t\t\t\t<h1>Registro</h1>\n\t\t\t\t</header>\n\t\t\t\t<section>\n\t\t\t\t\t<article>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tHola {$a} {$b} te has registrado en la página de Inmobiliaria Provase poder \n\t\t\t\t\t\t\tingresar click en el siguiente link para activar tu cuenta y publicar mas inmuebles.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tEstos son su datos de acceso\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t<b>Nombre y apellidos:</b> {$a} {$b}<br />\n\t\t\t\t\t\t\t<b>Correo:</b> {$c}<br />\n\t\t\t\t\t\t\t<b>Contraseña:</b> {$e}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tLink de activación: \n\t\t\t\t\t\t\t<a style='background: #002457;color: #fff;text-decoration: none;padding: 0.5em 0;' \n\t\t\t\t\t\t\t\thref='http://inmobiliariaprovase.com.co/activacion.php?alg={$codigoal}&di={$idus}' target='_blank'>\n\t\t\t\t\t\t\t\tTerminar Registro\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</article>\n\t\t\t\t\t<article>\n\t\t\t\t\t\t<a herf='http://inmobiliariaprovase.com.co/' target='_blank'>Página</a>\n\t\t\t\t\t</article>\n\t\t\t\t</section>\n\t\t\t</section>"; $mail->SetFrom('*****@*****.**', 'Inmobiliaria Provase'); $mail->From = "*****@*****.**"; $mail->FromName = "Inmobiliaria Provase"; $mail->AddReplyTo('*****@*****.**', 'Inmobiliaria Provase'); $address = "{$c}";
/** * 发送找回密码的邮件 * @return */ public function sendFindPwdMail() { $adminService = D('Admin', 'Service'); if (!isset($_POST['admin']['email']) || !$adminService->existAccount($_POST['admin']['email'])) { return $this->errorReturn('登录邮箱不存在!'); } $email = $_POST['admin']['email']; $admin = M('Admin')->getByEmail($email); $randCode = rand_code(5); $hash = $admin['id'] . md5($randCode); $config = C('MAIL'); $target = U('Public/findPassword', array('hash' => $hash)); $url = $_SERVER['HTTP_HOST'] . $target; $body = str_replace('?', $url, $config['MAIL_BODY']); // 发送邮件 $result = smtp_mail($email, $email, C('SITE_TITLE'), $body, $config); if (true !== $result) { return $this->errorReturn('系统出错了,请稍后再试!'); } $admin['mail_hash'] = $hash; M('Admin')->save($admin); $info = "密码重置邮件已发,请到{$admin['email']}查收!"; return $this->successReturn($info); }
/** * 备份数据表 * @param array $tables * @return array */ public function backup($tables) { // 防止数据库备份超时 function_exists('set_time_limit') && set_time_limit(0); // 数据表操作模型 $M = D('Common'); // 备份开始时间 $time = time(); // 备份配置 $backupConfig = C('BACKUP'); // 备份文件路径 $sqlFile = $backupConfig['BACKUP_DIR_PATH'] . $backupConfig['BACKUP_PREFIX'] . date('Ymd') . '_' . rand_code($backupConfig['BACKUP_FILE_CODE_LENGTH']); // 分卷行数 $sqlListRows = $backupConfig['BACKUP_SQL_LIST_ROWS']; // 备份文件注释头 $descName = $backupConfig['BACKUP_DESCRIPTION_NAME']; $descUrl = $backupConfig['BACKUP_DESCRIPTION_URL']; $sqlFileHeader = $this->getSqlFileHeaderInfo($descName, $descUrl); // 备份文件注释头的长度 $headerLen = strlen($sqlFileHeader); $output = ''; // 重建数据表的sql $rebuildSql = $this->getRebuildTablesSql($tables); // 分卷数 $fileNo = 1; // 已备份的数据库 $backuped = array(); foreach ($tables as $table) { $backuped[] = $table; $output .= "\r\n# 数据表:{$table} 数据信息\r\n"; $output .= $M->hasRecord($table) ? "\r\n" : "# 没有数据记录\r\n\r\n"; // 得到数据表的信息 $tableInfo = $M->getTablesInfo($table); // 得到sql的分页数 $page = ceil($tableInfo['Rows'] / $sqlListRows) - 1; // 按分页获取sql数据 for ($i = 0; $i <= $page; $i++) { // 当前页中的$sqlListRows行数据 $rows = $this->queryTable($table, $i * $sqlListRows, $sqlListRows); foreach ($rows as $row) { // 得到insert sql $insertSql = $this->getInsertValueSql($table, $row); $insertSql .= "\r\n"; // sql备份文件的基本数据信息 $sqlInfo = $this->getSqlFileInfo($fileNo, $tables, $backuped); // 当前文件长度 $currentFileLen = strlen($sqlFileHeader . $sqlInfo . $rebuildSql . $output . $insertSql); if ($currentFileLen > $backupConfig['SQL_FILE_SIZE']) { // 达到分卷大小,写出备份文件 $file = $sqlFile . '_' . $fileNo . '.sql'; // 分卷为1,则需要写出重建表信息 $temp = $output; $output = $sqlFileHeader . $sqlInfo; $output .= 1 == $fileNo ? $rebuildSql : ''; $output .= $temp; // 写出sql文件 file_put_contents($file, $output, FILE_APPEND); $rebuildSql = $output = ''; $backuped = array(); $backuped[] = $table; $fileNo++; } $output .= $insertSql; } } } // 写出最后一个sql文件分卷 if (strlen($rebuildSql . $output) > 0) { $sqlInfo = $this->getSqlFileInfo($fileNo, $tables, $backuped); $file = $sqlFile . '_' . $fileNo . '.sql'; // 组装output $temp = $output; $output = $sqlFileHeader . $sqlInfo; $output .= 1 == $fileNo ? $rebuildSql : ''; $output .= $temp; // 写出sql文件 file_put_contents($file, $output, FILE_APPEND); $fileNo++; } $data['time'] = time() - $time; $data['backuped_conut'] = --$fileNo; return $this->resultReturn(self::EXECUTE_FINISH, $data); }
/** * 解压zip文件 * @return */ public function unzipFiles() { if (!IS_POST) { return $this->errorReturn('无效的操作!'); } $dataLogic = D('Data', 'Logic'); $result = $dataLogic->unzipFiles($_POST['zip_files']); switch ($result['status']) { case $dataLogic::FILE_NOT_FOUND: $this->errorReturn('请选择需要解压的zip文件!'); break; case $dataLogic::EXECUTE_NOT_FINISH: $info = '正在解压缩请耐心等待,解压期间请勿刷新本页 ' . '<font color="red">当前已经解压完' . "{$result['data']['file']}</font>"; $url = U('Data/unzipFiles', array('rand_code' => rand_code(5))); $this->successReturn($info, $url); break; case $dataLogic::EXECUTE_FINISH: $info = "已解压完成,耗时:{$result['data']['time']} 秒"; $this->successReturn($info, U('Data/restore')); break; default: $this->errorReturn('无效的操作!'); break; } }
/** * 生成编辑器 * @param string $name 文本域name * @param string $value 文本域value * @param int $rows 文本域rows * @param int $cols 文本域cols * @param string $type 编辑器类型 * @return string */ function genEditor($name, $value, $cols, $rows, $type = 'simple') { $id = rand_code(8); $html = "<textarea name='{$name}' id='{$id}' " . "rows='{$rows}' cols='{$cols}' "; if ('simple' == $type) { $js = "<script type='text/javascript'>\$(function(){KindEditor.ready(function(K) {K.create('#{$id}',{resizeType:1,items:['fontname','fontsize','|','forecolor','hilitecolor','bold','italic','underline','removeformat','|','justifyleft','justifycenter','justifyright','insertorderedlist','insertunorderedlist','|','emoticons','image','link'],afterBlur:function(){this.sync();}});});});</script>"; } else { $js = "<script type='text/javascript'>\$(function(){KindEditor.ready(function(K) {K.create('#{$id}',{resizeType:1,afterBlur:function(){this.sync();}});});});</script>"; } if (isset($value) && !empty($value)) { $html .= ">{$value}</textarea>"; } else { $html .= "></textarea>"; } return $html . $js; }