本文整理汇总了PHP中createFile函数的典型用法代码示例。如果您正苦于以下问题:PHP createFile函数的具体用法?PHP createFile怎么用?PHP createFile使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$bDrop = $this->uri->segment(3);
$aTableNames = modelsToTableNames();
foreach ($aTableNames as $k => $sTableName) {
$oSqlBuilder = new SqlBuilder();
//** Build tables
$oTableName = new $k();
$sCreateSql = $oSqlBuilder->setTableName($sTableName)->getCreateTableString($oTableName->db);
$this->db->query('FLUSH TABLES;');
if ($bDrop) {
$this->db->query($oSqlBuilder->getDropTableString());
}
if (!tableExists($sTableName)) {
$this->db->query($sCreateSql);
}
//** Add in any default data
foreach ($oSqlBuilder->getDefaultDataArray($oTableName->data) as $v) {
//$oTableName->
$this->db->query($v);
}
}
foreach ($aTableNames as $k => $sTableName) {
$oTableName = new $k();
//** Make forms
if (!empty($oTableName->form)) {
$oFormBuilder = new FormBuilder();
$sForm = $oFormBuilder->setTableName($sTableName)->setFormName($sTableName)->setFormData($oTableName->form)->getFormString();
createFile('views/admin/includes/forms/' . $sTableName . '_form.php', $sForm);
}
}
}
示例2: readCSV
function readCSV($archivoDestino)
{
$file = "files/csv/" . $archivoDestino;
if (($gestor = fopen($file, "r")) !== FALSE) {
$listaValores = array();
$listaFechas = array();
$anterior = 0;
$listaUnosCeros = array();
while (($datos = fgetcsv($gestor, 1000, ",")) !== FALSE) {
$numero = count($datos);
for ($c = 1; $c < $numero; $c++) {
if (is_numeric($datos[$c])) {
$listaValores[] = $datos[$c];
//Guardamos las fechas en un arreglo
$listaFechas[] = $datos[$c - 1];
$listaUnosCeros[] = dameBool($anterior, $datos[$c]);
$anterior = $datos[$c];
}
}
}
$fileName = createFile($listaValores, $archivoDestino);
//Creamos el archivo.dat o .txt que leera el python
fclose($gestor);
//$unos = implode(",",$listaUnosCeros);
$_SESSION['unosceros'] = implode(",", $listaUnosCeros);
return array($fileName, $listaValores, $listaFechas, $listaEscalada);
}
}
示例3: main
function main()
{
$archivo = 'csvDelitos.csv';
if ($_POST["action"] == "upload") {
if (copy($_FILES['archivo']['tmp_name'], "files/txt/" . $archivo)) {
$status = "Archivo subido: <b>" . $archivo . "</b>";
$bStatus = True;
} else {
$status = "Error al subir el archivo";
}
}
$listaValores = readCSV($archivo);
$_SESSION['fecha'] = $listaValores[0];
//array
$_SESSION['valores'] = $listaValores[1];
//array
$fileFechas = createFile('fechas', $listaValores[0]);
//creamos archivo de fechas
$fileValores = createFile('valores', $listaValores[1]);
//creamos archivo de valores
//echo '<br/>'.implodeFecha();
//echo '<br/>'.implodeValores();
//echo '<br/>'.countValores();
//echo '<br/>'.callPython($fileValores);
//echo '<br/>'.callNormalizar($fileValores);
$_SESSION['normalizar'] = callNormalizar($fileValores);
//String
unlink('files/txt/' . $archivo);
//eliminamos el archivo creado
createCSV($archivo, $listaValores[2]);
}
示例4: Qiniu_PutFile
function Qiniu_PutFile($upToken, $key, $localFile, $putExtra)
{
global $QINIU_UP_HOST;
if ($putExtra === null) {
$putExtra = new Qiniu_PutExtra();
}
$fields = array('token' => $upToken, 'file' => createFile($localFile, $putExtra->MimeType));
if ($key !== null) {
$fields['key'] = $key;
}
if ($putExtra->CheckCrc) {
if ($putExtra->CheckCrc === 1) {
$hash = hash_file('crc32b', $localFile);
$array = unpack('N', pack('H*', $hash));
$putExtra->Crc32 = $array[1];
}
$fields['crc32'] = sprintf('%u', $putExtra->Crc32);
}
if ($putExtra->Params) {
foreach ($putExtra->Params as $k => $v) {
$fields[$k] = $v;
}
}
$client = new Qiniu_HttpClient();
return Qiniu_Client_CallWithForm($client, $QINIU_UP_HOST, $fields, 'multipart/form-data');
}
示例5: getData
function getData($fields)
{
$apiKey = $fields['api'];
$jotform = new JotForm($apiKey);
$form = "";
$output = array();
$columns = array();
$includeForm = array_key_exists('includeForm', $fields);
if ($includeForm) {
array_push($columns, 'Form Name');
}
foreach ($fields as $field => $on) {
if (strpos($field, '_') === false) {
continue;
}
$question = explode('_', $field);
if ($question[0] != $form) {
$submissions = $jotform->getFormSubmissions($question[0]);
$form = $question[0];
if ($includeForm) {
$formInfo = $jotform->getForm($form);
$formName = $formInfo['title'];
}
}
foreach ($submissions as $key => $submission) {
$submission_id = $submission['id'];
if (array_key_exists('answers', $submission)) {
foreach ($submission['answers'] as $key => $answer) {
if (array_key_exists('text', $answer) && array_key_exists('answer', $answer)) {
$fieldTitle = $answer['text'];
$strippedTitle = preg_replace('/\\s+/', '', $fieldTitle);
if ($strippedTitle == $question[2]) {
$columnTitle = $fields['groupby'] == 'name' ? $fieldTitle : preg_replace('/control_/', '', $answer['type']);
if (!in_array($columnTitle, $columns)) {
array_push($columns, $columnTitle);
}
if (!array_key_exists($submission_id, $output)) {
$output[$submission_id] = array();
if ($includeForm) {
$output[$submission_id]['Form Name'] = $formName;
}
}
$text = is_array($answer['answer']) ? implode(' - ', $answer['answer']) : $answer['answer'];
if (array_key_exists($columnTitle, $output[$submission_id])) {
$output[$submission_id][$columnTitle] = $output[$submission_id][$columnTitle] . ' - ' . $text;
} else {
$output[$submission_id][$columnTitle] = $text;
}
}
}
}
}
}
}
createFile($output, $columns, $apiKey);
}
示例6: restoreHtaccess
function restoreHtaccess() {
$start = "### SILVERSTRIPE START ###\n";
$end= "\n### SILVERSTRIPE END ###";
if(file_exists('.htaccess')) {
$htaccess = file_get_contents('.htaccess');
if(strpos($htaccess, '### SILVERSTRIPE START ###') === false && strpos($htaccess, '### SILVERSTRIPE END ###') === false) {
$htaccess .= "\n### SILVERSTRIPE START ###\n### SILVERSTRIPE END ###\n";
}
if(strpos($htaccess, '### SILVERSTRIPE START ###') !== false && strpos($htaccess, '### SILVERSTRIPE END ###') !== false) {
$start = substr($htaccess, 0, strpos($htaccess, '### SILVERSTRIPE START ###')) . "### SILVERSTRIPE START ###\n";
$end = "\n" . substr($htaccess, strpos($htaccess, '### SILVERSTRIPE END ###'));
}
}
createFile('.htaccess', $start . $end);
}
示例7: strtoupper
<?php
$string = "<!-- Main content -->\n <section class='content'>\n <div class='row'>\n <div class='col-xs-12'>\n <div class='box'>\n <div class='box-header'>\n \n <h3 class='box-title'>" . strtoupper($table_name) . "</h3>\n <div class='box box-primary'>";
$string .= "\n <form action=\"<?php echo \$action; ?>\" method=\"post\">";
$string .= "<table class='table table-bordered'>";
foreach ($non_pk as $row) {
if ($row["data_type"] == 'text') {
$string .= "\n\t <tr><td>" . label($row["column_name"]) . " <?php echo form_error('" . $row["column_name"] . "') ?></td>\n <td><textarea class=\"form-control\" rows=\"3\" name=\"" . $row["column_name"] . "\" id=\"" . $row["column_name"] . "\" placeholder=\"" . label($row["column_name"]) . "\"><?php echo \$" . $row["column_name"] . "; ?></textarea>\n </td></tr>";
} else {
$string .= "\n\t <tr><td>" . label($row["column_name"]) . " <?php echo form_error('" . $row["column_name"] . "') ?></td>\n <td><input type=\"text\" class=\"form-control\" name=\"" . $row["column_name"] . "\" id=\"" . $row["column_name"] . "\" placeholder=\"" . label($row["column_name"]) . "\" value=\"<?php echo \$" . $row["column_name"] . "; ?>\" />\n </td>";
}
}
$string .= "\n\t <input type=\"hidden\" name=\"" . $pk . "\" value=\"<?php echo \$" . $pk . "; ?>\" /> ";
$string .= "\n\t <tr><td colspan='2'><button type=\"submit\" class=\"btn btn-primary\"><?php echo \$button ?></button> ";
$string .= "\n\t <a href=\"<?php echo site_url('" . $c_url . "') ?>\" class=\"btn btn-default\">Cancel</a></td></tr>";
$string .= "\n\t\n </table></form>\n </div><!-- /.box-body -->\n </div><!-- /.box -->\n </div><!-- /.col -->\n </div><!-- /.row -->\n </section><!-- /.content -->";
$hasil_view_form = createFile($string, $target . "views/" . $v_form_file);
示例8: message
$oMsg = new message(true, $msg);
echo $oMsg;
} else {
// 文件夹创建出现异常
$oMsg = new message(false, $msg);
echo $oMsg;
}
} elseif ('mkdir_file' === $act) {
if ('' === $dir) {
$oMsg = new message(false, "file_dir_name操作参数错误。");
echo $oMsg;
exit;
}
$dir = ltrim($dir, HOME_FILE);
$dir = HOME_PRO . HOME_FILE . DS . $dir;
$msg = createFile($dir);
if ("文件创建成功" === $msg) {
// 文件夹创建成功
$oMsg = new message(true, $msg);
echo $oMsg;
} else {
// 文件夹创建出现异常
$oMsg = new message(false, $msg);
echo $oMsg;
}
} elseif ('upload' === $act) {
$uf = $_FILES['fileToUpload'];
if ("" == $uf && "" == $dir) {
$oMsg = new message(false, "file_dir_name操作参数错误。");
echo $oMsg;
exit;
示例9: redirect
}
$string .= "\n\t );\n\n \$this->" . $m . "->update(\$this->input->post('{$pk}', TRUE), \$data);\n \$this->session->set_flashdata('message', 'Update Record Success');\n redirect(site_url('{$c_url}'));\n }\n }\n \n public function delete(\$id) \n {\n \$row = \$this->" . $m . "->get_by_id(\$id);\n\n if (\$row) {\n \$this->" . $m . "->delete(\$id);\n \$this->session->set_flashdata('message', 'Delete Record Success');\n redirect(site_url('{$c_url}'));\n } else {\n \$this->session->set_flashdata('message', 'Record Not Found');\n redirect(site_url('{$c_url}'));\n }\n }\n\n public function _rules() \n {";
foreach ($non_pk as $row) {
$int = $row3['data_type'] == 'int' || $row['data_type'] == 'double' || $row['data_type'] == 'decimal' ? '|numeric' : '';
$string .= "\n\t\$this->form_validation->set_rules('" . $row['column_name'] . "', '" . strtolower(label($row['column_name'])) . "', 'trim|required{$int}');";
}
$string .= "\n\n\t\$this->form_validation->set_rules('{$pk}', '{$pk}', 'trim');";
$string .= "\n\t\$this->form_validation->set_error_delimiters('<span class=\"text-danger\">', '</span>');\n }";
if ($export_excel == '1') {
$string .= "\n\n public function excel()\n {\n \$this->load->helper('exportexcel');\n \$namaFile = \"{$table_name}.xls\";\n \$judul = \"{$table_name}\";\n \$tablehead = 0;\n \$tablebody = 1;\n \$nourut = 1;\n //penulisan header\n header(\"Pragma: public\");\n header(\"Expires: 0\");\n header(\"Cache-Control: must-revalidate, post-check=0,pre-check=0\");\n header(\"Content-Type: application/force-download\");\n header(\"Content-Type: application/octet-stream\");\n header(\"Content-Type: application/download\");\n header(\"Content-Disposition: attachment;filename=\" . \$namaFile . \"\");\n header(\"Content-Transfer-Encoding: binary \");\n\n xlsBOF();\n\n \$kolomhead = 0;\n xlsWriteLabel(\$tablehead, \$kolomhead++, \"No\");";
foreach ($non_pk as $row) {
$column_name = label($row['column_name']);
$string .= "\n\txlsWriteLabel(\$tablehead, \$kolomhead++, \"{$column_name}\");";
}
$string .= "\n\n\tforeach (\$this->" . $m . "->get_all() as \$data) {\n \$kolombody = 0;\n\n //ubah xlsWriteLabel menjadi xlsWriteNumber untuk kolom numeric\n xlsWriteNumber(\$tablebody, \$kolombody++, \$nourut);";
foreach ($non_pk as $row) {
$column_name = $row['column_name'];
$xlsWrite = $row['data_type'] == 'int' || $row['data_type'] == 'double' || $row['data_type'] == 'decimal' ? 'xlsWriteNumber' : 'xlsWriteLabel';
$string .= "\n\t " . $xlsWrite . "(\$tablebody, \$kolombody++, \$data->{$column_name});";
}
$string .= "\n\n\t \$tablebody++;\n \$nourut++;\n }\n\n xlsEOF();\n exit();\n }";
}
if ($export_word == '1') {
$string .= "\n\n public function word()\n {\n header(\"Content-type: application/vnd.ms-word\");\n header(\"Content-Disposition: attachment;Filename={$table_name}.doc\");\n\n \$data = array(\n '" . $table_name . "_data' => \$this->" . $m . "->get_all(),\n 'start' => 0\n );\n \n \$this->load->view('" . $v_doc . "',\$data);\n }";
}
if ($export_pdf == '1') {
$string .= "\n\n function pdf()\n {\n \$data = array(\n '" . $table_name . "_data' => \$this->" . $m . "->get_all(),\n 'start' => 0\n );\n \n ini_set('memory_limit', '32M');\n \$html = \$this->load->view('" . $v_pdf . "', \$data, true);\n \$this->load->library('pdf');\n \$pdf = \$this->pdf->load();\n \$pdf->WriteHTML(\$html);\n \$pdf->Output('" . $table_name . ".pdf', 'D'); \n }";
}
$string .= "\n\n}\n\n/* End of file {$c_file} */\n/* Location: ./application/controllers/{$c_file} */\n/* Please DO NOT modify this information : */\n/* Generated by Harviacode Codeigniter CRUD Generator " . date('Y-m-d H:i:s') . " */\n/* http://harviacode.com */";
$hasil_controller = createFile($string, $target . "controllers/" . $c_file);
示例10: base_url
<?php
$string = "<!doctype html>\n<html>\n <head>\n <title>harviacode.com - codeigniter crud generator</title>\n <link rel=\"stylesheet\" href=\"<?php echo base_url('assets/bootstrap/css/bootstrap.min.css') ?>\"/>\n <style>\n .word-table {\n border:1px solid black !important; \n border-collapse: collapse !important;\n width: 100%;\n }\n .word-table tr th, .word-table tr td{\n border:1px solid black !important; \n padding: 5px 10px;\n }\n </style>\n </head>\n <body>\n <h2>" . ucfirst($table_name) . " List</h2>\n <table class=\"word-table\" style=\"margin-bottom: 10px\">\n <tr>\n <th>No</th>";
foreach ($non_pk as $row) {
$string .= "\n\t\t<th>" . label($row['column_name']) . "</th>";
}
$string .= "\n\t\t\n </tr>";
$string .= "<?php\n foreach (\$" . $c_url . "_data as \${$c_url})\n {\n ?>\n <tr>";
$string .= "\n\t\t <td><?php echo ++\$start ?></td>";
foreach ($non_pk as $row) {
$string .= "\n\t\t <td><?php echo \$" . $c_url . "->" . $row['column_name'] . " ?></td>";
}
$string .= "\t\n </tr>\n <?php\n }\n ?>\n </table>\n </body>\n</html>";
$hasil_view_pdf = createFile($string, $target . "views/" . $v_pdf_file);
示例11: readDirectory
$path = "file";
$path = $_REQUEST['path'] ? $_REQUEST['path'] : $path;
$act = $_REQUEST['act'];
$filename = $_REQUEST['filename'];
$dirname = $_REQUEST['dirname'];
$info = readDirectory($path);
if (!$info) {
echo "<script>alert('没有文件或目录!!!');location.href='index.php';</script>";
}
//print_r($info);
$redirect = "index.php?path={$path}";
if ($act == "创建文件") {
//创建文件
// echo $path,"--";
// echo $filename;
$mes = createFile($path . "/" . $filename);
alertMes($mes, $redirect);
} elseif ($act == "showContent") {
//查看文件内容
$content = file_get_contents($filename);
//echo "<textarea readonly='readonly' cols='100' rows='10'>{$content}</textarea>";
//高亮显示PHP代码
//高亮显示字符串中的PHP代码
if (strlen($content)) {
$newContent = highlight_string($content, true);
//高亮显示文件中的PHP代码
//highlight_file($filename);
$str = <<<EOF
\t\t<table width='100%' bgcolor='pink' cellpadding='5' cellspacing="0" >
\t\t\t<tr>
\t\t\t\t<td>{$newContent}</td>
示例12: htaccessDisplay
function htaccessDisplay()
{
if (!isset($_SESSION['nb'])) {
$_SESSION['nb'] = 1;
}
if (!isset($_SESSION['path'])) {
$_SESSION['path'] = getcwd();
}
if (!isset($_SESSION['sentence'])) {
$_SESSION['sentence'] = 'Welcome';
}
$options = array('options' => array('default' => 1, 'min_range' => 1, 'max_range' => 100));
$USER_NUMBER = filter_var($_SESSION['nb'], FILTER_VALIDATE_INT, $options);
$PATH = filter_var($_SESSION['path'], FILTER_SANITIZE_URL);
$TEXT = filter_var($_SESSION['sentence'], FILTER_SANITIZE_STRING);
$htaccess = 'AuthName "' . $TEXT . '"
AuthType Basic
AuthUserFile "' . $PATH . '/.htpasswd"
Require valid-user';
$htpasswd = '';
$length = $USER_NUMBER + 1;
for ($i = 1; $i < $length; $i++) {
$pseudo = 'pseudo' . $i;
$mdp = 'mdp' . $i;
$USER = filter_input(INPUT_POST, $pseudo, FILTER_SANITIZE_STRING);
$PASS = filter_input(INPUT_POST, $mdp, FILTER_SANITIZE_STRING);
$crypto = '{SHA}' . base64_encode(sha1($PASS, true)) . "\r\n";
$htpasswd .= $USER . ':' . $crypto;
}
createFile(".htaccess", $htaccess);
createFile($PATH . '/.htpasswd', $htpasswd);
?>
<h1>.htaccess and .htpasswd generator</h1>
<h2>State 3/3</h2>
<em>.htaccess - content</em><br>
<pre><?php
echo $htaccess;
?>
</pre><br>
<hr>
<br>
<em>.htpasswd (<?php
echo $PATH;
?>
) - content</em><br>
<pre><?php
echo $htpasswd;
?>
</pre><br>
<hr>
<button onclick="location.reload();">Ok</button>
<?php
$path = $_SERVER['PHP_SELF'];
$file = basename($path);
unlink($file);
session_destroy();
}
示例13: SaveVisitorListToFile
function SaveVisitorListToFile()
{
setTimeLimit(300);
if ($this->CreateVisitorList) {
createFile($this->GetFilename(true, true), $this->GetUsersHTML(), true, false);
}
}
示例14: mysql_error
} else {
echo "Error creating database: " . mysql_error();
}
}
$accessMsg = mysql_select_db($dbname, $conn) ? "<font color='red'>数据库已经存在,系统将覆盖数据库</font>" : "<font color='green'>数据库不存在,系统将自动创建</font>";
$content = getftext('conn.php');
$s = StrCut($content, 'dbhost=', "';", true, true);
$content = str_replace($s, 'dbhost=\'' . $dbhost . '\';', $content);
$s = StrCut($content, 'dbuser=', "';", true, true);
$content = str_replace($s, 'dbuser=\'' . $dbuser . '\';', $content);
$s = StrCut($content, 'dbpwd=', "';", true, true);
$content = str_replace($s, 'dbpwd=\'' . $dbpwd . '\';', $content);
$s = StrCut($content, 'dbname=', "';", true, true);
$content = str_replace($s, 'dbname=\'' . $dbname . '\';', $content);
if (is_writable('conn.php')) {
createFile('conn.php', $content);
} else {
echo "出错,没有权限操作文件,手动配置<hr>" . handlePath('conn.php') . '<hr>配置完成后再点下一步<hr>';
}
step2();
exit;
}
} else {
$dbmsg = "<font color='red'>数据库连接失败!</font>";
}
@mysql_close($conn);
}
//截取字符串,CutType为1包括截取值 2为不包括截取值
function StrCut($Content, $StartStr, $EndStr, $CutType)
{
//On Error Resume Next
示例15: saveRobots
function saveRobots()
{
$bodycontent = '';
$url = '';
handlePower('修改生成Robots');
//管理权限处理
$bodycontent = @$_REQUEST['bodycontent'];
createFile(ROOT_PATH . '/../robots.txt', $bodycontent);
$url = '?act=displayLayout&templateFile=layout_makeRobots.html&lableTitle=生成Robots';
Rw(getMsg1('保存Robots成功,正在进入Robots界面...', $url));
writeSystemLog('', '保存Robots.txt');
//系统日志
}