function compare_array_in_html_js($fileName, $arr1, $arr2, $title = 'compare_array', $overWrite = false) { $content = ""; $jsArr1 = json_encode($arr1); $jsArr2 = json_encode($arr2); $content .= "\r\n\t\t<html>\r\n\t\t<head><title>" . $title . "</title></head>\r\n\t\t<body>\r\n\t\t\t<script type='text/javascript'>\r\n\t\t\tvar jsArr1 = " . $jsArr1 . ";\r\n\t\t\t\r\n\t\t\tvar jsArr2 = " . $jsArr2 . "\r\n\t\t\tdocument.write(jsArr1);\r\n\t\t\tdocument.write(jsArr2);\r\n\t\t\t</script>\r\n\t\t</body>\r\n\t\t</html>\r\n\t"; create_file($fileName, $content, $overWrite); }
function validate_post() { if (isset($_POST['input_first_name']) && isset($_POST['input_last_name']) && isset($_POST['input_birthday']) && isset($_POST['input_email']) && isset($_POST['input_telephone'])) { output_post(); create_file(); } else { echo "<h1>Error! Required fields are not filled!<h1>"; } }
/** * This contains all html specific functions * @version $Id: html.php 40 2011-02-09 14:10:00Z biyi $ * @package Platform * @category Function * @author Biyi Akinpelu * @link mailto:biyi@entilda.com * @copyright Copyright (C) 2011 - 2012 The Platform Authors. All rights reserved. * @license GNU Public Licence, see LICENSE.php * Platform is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ function html($title = 'Test Application', $file = 'index.html') { ob_start(); ?> <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <title><?php echo $title; ?> </title> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:400,500,700,regular,bold&subset=Latin"> <link rel="stylesheet" type="text/css" href="assets/css/app.css" /> <?php js_add_jquery(); ?> </head> <body> <h1>Hello World</h1> <p>This is a sample test application.</p> <p>Edit this content as you wish.</p> <p>Enjoy!</p> <div id="overlay_canvas"> <div id="app"> <span class="logo" style="background: transparent url('<?php echo image_data_uri("assets/images/icons/application-128x128.png", "png"); ?> ') no-repeat;"></span><span class="navigator text"><?php echo $title; ?> </span> </div> </div> <?php js_add('assets/js/app.js'); ?> </body> </html> <?php $html = ob_get_clean(); create_file($file, $html); }
function generate_application($app_path) { $app_name = strtolower(end(split(DIRECTORY_SEPARATOR, $app_path))); $app_real_path = realpath($app_path); p('info', sprintf('will generate application %s in %s ', ucfirst($app_name), $app_real_path)); create_folder($app_real_path); foreach (array('app', 'public', 'config', 'vendor', 'lib', 'log') as $f) { create_folder(make_path($app_real_path, $f)); } $medick_path = realpath(make_path(dirname(__FILE__), '..')); create_file($app_real_path, 'boot.php', 'boot.php', array('app_real_path' => $app_real_path, 'medick_path' => $medick_path)); create_file($app_real_path, 'config.xml', make_path('config', $app_name . '.xml'), array('app_name' => $app_name, 'app_real_path' => $app_real_path)); create_file($app_real_path, 'htaccess', make_path('public', '.htaccess'), array('app_name' => $app_name)); create_file($app_real_path, 'index.php', make_path('public', 'index.php'), array('app_name' => $app_name, 'app_real_path' => $app_real_path)); touch(make_path($app_real_path, 'log', 'localhost.log')); chmod(make_path($app_real_path, 'log', 'localhost.log'), 0777); exit; }
function Editor_CreateDirContent($d) { $tplDir = $this->TemplatesDir(); $index = get_file($tplDir . '/index'); $up = content_get_up_to_root($d); $index = preg_replace('/\\$\\{up_to_root\\}/', $up, $index); create_file($d . '/index.php', $index); for ($i = 0; $i < count($this->scripts); $i++) { $s = $this->scripts[$i]; $mk = dirname($s['file']); if ($mk != '' && $mk != '.' && !file_exists($d . '/' . $mk)) { mkdir($d . '/' . $mk); chmod($d . '/' . $mk, 0775); } $src = get_file($tplDir . '/' . $s['script']); if (preg_match('/index\\.php$/', $s['file'])) { $src = preg_replace('/\\$\\{up_to_root\\}/', $up, $src); } create_file($d . '/' . $s['file'], $src); } }
function write_csv() { global $programme_fields; global $programme_docs; $folder_name = '_executive_programme/'; $displayDate = strftime("%Y-%m-%d"); $displayTime = strftime("%H:%M:%S"); $filename = $folder_name . $displayDate . '.txt'; $data = ''; foreach ($programme_fields as $name => $options) { $data .= '"' . echo_value($name) . '",'; } foreach ($programme_docs as $name => $label) { if (isset($_POST[$name])) { $data .= '"' . $label . '"' . ','; } else { $data .= ','; } } $r = create_file($folder_name, $filename); $s = $displayDate . ',' . $displayTime . ','; $s .= $data . "\r\n"; $r = write_file($filename, $s); }
Author: Quoc Viet [aFeLiOn] Begin: 2006-04-02 Comment: -------------------------------------------------------------------------------- */ if (!defined('IN_EPS')) { exit; } $cur_time = time(); $today_str = date_string($cur_time + $eps_user['timezone'], false); $tomorrow_str = date_string($cur_time + $eps_user['timezone'] + 86400 * 2, false); @(include EPS_CACHE_DIR . 'cache_birth.php'); if (empty($eps_births) || !isset($eps_births['date']) || $eps_births['date'] != $today_str) { $eps_births = array('date' => $today_str, 'today' => array(), 'tomor' => array()); $result = $epsclass->db->query("SELECT name,DATE_FORMAT(birth,'%m%d') as date FROM " . TBL_K48HTD . " WHERE DATE_FORMAT(birth,'%m%d')='{$today_str}' OR DATE_FORMAT(birth,'%m%d')='{$tomorrow_str}'") or error('Unable to fetch student\'s birthday', __FILE__, __LINE__, $epsclass->db->error()); if ($epsclass->db->num_rows($result)) { while ($cur_std = $epsclass->db->fetch_assoc($result)) { if ($cur_std['date'] == $today_str) { $eps_births['today'][] = $cur_std['name']; } else { $eps_births['tomor'][] = $cur_std['name']; } } } $epsclass->db->free_result($result); create_file('<?php' . "\n" . '$eps_births = ' . var_export($eps_births, true) . ';' . "\n" . '?>', 'cache_birth.php', EPS_CACHE_DIR); } $smarty->assign('birth_list', $eps_births['today']); $smarty->assign('t_birth_list', $eps_births['tomor']); $smarty->display('module/birth.tpl');
<?php } else { //连接数据库 $sql = file_get_contents($sqlfile); //前置表前辍 if ($name == 'system') { $sql = str_replace("{TableAdmin}", $mysql_admin, $sql); $sql = str_replace("{TablePass}", md5($mysql_pass), $sql); } $sql = str_replace("{TableSysPre}", $mysql_manpre, $sql); $sql = str_replace("{TableModPre}", $mysql_modpre, $sql); $sql = str_replace("{TableBase}", url_base(), $sql); $array = Database::query($sql, $dbcharset); if (!$array["error"]) { //写入锁 create_file($lock, date("Y-m-d H:i:s")); } else { //安装出错 foreach ($array["fail"] as $arr) { //出错了 $error = true; ?> <p><?php echo $arr['query'] . '<br />' . $arr['error']; ?> </p> <?php } //安装成功
function create_config_file() { global $epsclass; // Get the forum config from the DB $result = $epsclass->db->query('SELECT * FROM ' . TBL_CONFIG, true) or error('Unable to fetch forum config', __FILE__, __LINE__, $epsclass->db->error()); while ($cur_config_item = $epsclass->db->fetch_row($result)) { $output[$cur_config_item[0]] = $cur_config_item[1]; } $epsclass->db->free_result($result); create_file('<?php' . "\n" . 'define(\'CONFIG_LOADED\', true);' . "\n" . '$eps_config = ' . var_export($output, true) . ';' . "\n" . '?>', FILE_CACHE_CONFIG, true); }
$epsclass->db->vupdate(TBL_NEWS, $updates, $nid); } else { if ($action == 'post') { $inserts = array('title' => $title, 'content' => $content, 'imgurl' => $imgurl, 'poster_id' => $eps_user['id'], 'post_time' => time(), 'type' => $type); $epsclass->db->vinsert(TBL_NEWS, $inserts); } } // Gen RSS $epsclass->load_class('class_xml'); $result = $epsclass->db->query("SELECT u.username, n.id,n.title,n.content,n.post_time FROM " . TBL_NEWS . " n LEFT JOIN " . TBL_USER . " u ON n.poster_id=u.id ORDER BY post_time DESC LIMIT 15"); $rss = array(); while ($cur_rss = $epsclass->db->fetch_assoc($result)) { $rss[] = array('title' => html_clean($cur_rss['title']), 'link' => $eps_config['base_url'] . 'index.php?nid=' . $cur_rss['id'], 'description' => $epsclass->bbcode->format($cur_rss['content'], 600), 'author' => html_clean($cur_rss['username']), 'pubDate' => format_time($cur_rss['post_time'])); } $epsclass->db->free_result($result); create_file($epsclass->xml->gen_rss($rss), 'eps_news.xml', EPS_DATA_DIR); $epsclass->antiflood->update('post', 1); redirect('index.php', $eps_lang['Redirect_news_' . $action]); } else { $errors = $epsclass->validate->errors; $epsclass->validate->data_reset(); } } } // For Select Box $news['type'] = isset($type) ? $type : $news['type']; $news['no_smiley'] = isset($no_smiley) ? $no_smiley : $news['no_smiley']; if ($action == 'edit') { $page_title = $eps_lang['Page_post_edit']; } else { if ($action == 'delete') {
public static function form($appid, $list) { global $_G; $sql = "SELECT * FROM `mod:form_form` WHERE appid='" . $appid . "' "; //读取表单信息 $list && ($sql .= " and id in(" . $list . ")"); //创建子文件夹 $folder = create_dir(self::direct($appid)); $result = System::$db->getAll($sql); foreach ($result as $form) { $file = $folder . "/form." . $form['id'] . ".php"; $part = array('form' => array(), 'group' => array(), 'option' => array()); //表单主体 foreach ($form as $key => $val) { if ($key == 'config') { $form[$key] = fix_json($val); } } $part['form'] = $form; //////////////// //选项组 $sql = "SELECT * FROM `mod:form_group` WHERE fid=" . $form['id'] . " and `state`>0 order BY sort ASC,id ASC"; $res = System::$db->getAll($sql, 'id'); foreach ($res as $gid => $group) { foreach ($group as $key => $val) { if ($key == 'config') { $group[$key] = fix_json($val); } if ($key == 'selected') { $group[$key] = explode(',', $val); } } $part['group'][$gid] = $group; } //////////////// //子选项 $sql = "SELECT * FROM `mod:form_option` WHERE fid=" . $form['id'] . " and `state`>0 order BY sort ASC,id ASC"; $res = System::$db->getAll($sql, 'id'); foreach ($res as $oid => $option) { foreach ($option as $key => $val) { if ($key == 'config') { $option[$key] = fix_json($val); } } $part['option'][$option['gid']][$oid] = $option; } //////////////// //写入缓存 create_file($file, '<?php /*' . date("Y-m-d H:i:s") . '*/ $_CACHE[\'' . $appid . '\'] = ' . var_export($part, true) . ';'); } }
function file_writeblock($fn, $data = '') { create_file($fn, $data); }
$dec = $return[2][0]; $colors = $return[3][0]; if (file_exists($image)) { // Create SVG $svg = substitute($image, $title, $subtitle, $dec, $colors, (int)$_POST['grad'], $data); $date = date('Ymd'); $img_path = $location_creation. $date.$file_title.$file_subtitle; $json_data = array($_POST, $title, $subtitle, $dec, $colors, (int)$_POST['grad'], $data); $return = create_file($svg, $img_path, $json_data); if (is_int($return)) { switch ($status) { case -1: $error[] = 'Konnte Datei nicht öffnen. '. 'Keine Zugriffsrechte.'; break; case -2: $error[] = 'Konnte Datei nicht schreiben. '. 'Keine Zugriffsrechte.'; break; case -3: $error[] = 'Tut uns leid. Es scheinen Parameter '. 'fehlerhaft sein. Konnte die Daten nicht '.
function update($file) { global $_CACHE; $base = self::direct('update'); $sqlfile = $base . $file; //锁文件 $lock = str_replace(".sql", ".lock", $sqlfile); if (file_exists($lock)) { //echo '<div id="state" class="failure">抱歉!安装已经存在。更新于早前已经安装,并在使用中:<span class="text-key">'.$update.'</span></div>'; return 'locked'; } else { if (file_exists($sqlfile)) { //日志开始时间 $time = time(); $text = sreadfile($sqlfile); ///////////////////////////// //获取全部参数 preg_match_all("/#\\[module=(.*?)\\](.+?)#\\[\\/module\\]/ism", $text, $match); //遍历模块 foreach ($match[1] as $index => $appid) { //不存在此模块 if (array_key_exists($appid, $_CACHE['system']['module']) === FALSE) { //从更新语句中移除,#[module=appid]...#[/module] $text = str_replace($match[0][$index], '', $text); } } ///////////////////////////// $res = self::query($text); if ($res['error'] == 0) { //写入锁 create_file($lock, date("Y-m-d H:i:s")); //写入日志 System::insert_event($func, $time, time(), "安装更新:" . $file); //搜索模块 //Module :: search(); //缓存系统用户组 //Cached :: table( 'system', 'sys:group', array( 'jsonde' => array('config') ) ); //echo '<div id="state">恭喜!成功安装更新:'.$update.'</div>'; return 'success'; } else { //echo '<div id="state" class="failure">抱歉!安装更新失败。以下是本错误信息详细报告:</div>'; return 'abort'; } } } }
<?php create_dir($target_dir); $out = array(); $tmp_dir = path(dirname(__DIR__), 'assets'); $base_dir = path($tmp_dir, 'static'); \IO\Dir::each($base_dir, '*', function ($file) use($target_dir, $base_dir) { $new = str_replace($base_dir . DIRECTORY_SEPARATOR, '', $file); $out = path($target_dir, $new); if (!is_dir($file)) { $path = dirname($out); if (!is_dir($path)) { status('create', $path); mkdir($path, 0755, TRUE); } status('copy', $out); copy($file, $out); } }); copy_file(path($target_dir, 'assets', 'css'), path($tmp_dir, 'sauce.less')); copy_file(path($target_dir, 'assets', 'css'), path($tmp_dir, 'base.less')); copy_file(path($target_dir, 'assets', 'css'), path($tmp_dir, 'media.less')); copy_file(path($target_dir, 'assets', 'css'), path($tmp_dir, 'styles.css.less')); copy_file(path($target_dir, 'assets', 'js', 'lib'), path($tmp_dir, 'console.js')); copy_file(path($target_dir, 'assets', 'js', 'lib'), path($tmp_dir, 'jquery.min.js')); copy_file(path($target_dir, 'assets', 'js', 'lib'), path($tmp_dir, 'modernizr.min.js')); copy_file(path($target_dir, 'assets', 'js'), path($tmp_dir, 'script.js.coffee')); $name = camelcase(basename($target_dir)); create_file(path($target_dir, '.gitignore'), ".cache\nstatic/*"); create_file(path($target_dir, 'config.php'), '<' . "?php\n\n\$config['title'] = '{$name}';\n\$config['base_url'] = '';\n");
<?php include_once __DIR__ . '/common.inc'; fix_acls(); $iteration = array(PHPT_ACL_READ => false, PHPT_ACL_NONE => false, PHPT_ACL_WRITE => true, PHPT_ACL_WRITE | PHPT_ACL_READ => true); echo "Testing file:\n"; $i = 1; $path = __DIR__ . '/a.txt'; foreach ($iteration as $perms => $exp) { create_file($path, $perms); clearstatcache(true, $path); echo 'Iteration #' . $i++ . ': '; if (is_writable($path) == $exp) { echo "passed.\n"; } else { var_dump(is_writable($path), $exp); echo "failed.\n"; } delete_file($path); } echo "Testing directory:\n"; $path = __DIR__ . '/adir'; $i = 1; foreach ($iteration as $perms => $exp) { create_dir($path, $perms); clearstatcache(true, $path); echo 'Iteration #' . $i++ . ': '; if (is_writable($path) == $exp) { echo "passed.\n"; } else { var_dump(is_writable($path), $exp);
function edit_attachment($sample_id, $attachment_id) { $sql = 'select * from attachment where sample_id=\'' . $sample_id . '\' and attachment_id=\'' . $attachment_id . '\''; //echo $sql; $link = start_nchsls(); if (!($result = mysql_query($sql, $link))) { echo 'No such attachment_id=\'' . $attachment_id . '\' , sample_id=' . $sample_id . '<br>'; return FALSE; } $array = mysql_fetch_assoc($result); echo '<table border=1 bgcolor=lightblue><form method=post enctype=\'multipart/form-data\'>'; echo '<tr><th>Edit Attachment</th></tr>'; echo ' <tr> <td>sample_id:</td> <td><font color=red>' . $array['sample_id'] . '</font></td> <input type=hidden name=sample_id value=\'' . $array['sample_id'] . '\'> <input type=hidden name=attachment_id value=\'' . $array['attachment_id'] . '\'>'; echo '<td align=top><button type=submit name=action value=save_attachment>Save Attachment</button></td> </tr>'; echo '<tr><td>attachment_id</td><td>' . $array['attachment_id'] . '</td></tr>'; echo '<tr><td>description</td><td><input type=text name=description value=\'' . $array['description'] . '\'></td></tr>'; echo '<tr><td>filetype</td><td><input type=text name=filetype value=\'' . $array['filetype'] . '\'></td></tr>'; $filetype = $array['filetype']; if ($filetype == 'jpeg' || $filetype == 'jpg' || $filetype == 'gif') { $filename = create_file($array['file'], $array['sample_id'], $array['attachment_id'], $array['filetype']); echo ' <tr> <td>file</td> <td><img src="' . $filename . '" height=300 width=300></td> <td valign=top>upload:<input type=file name=file></td> </tr>'; } elseif ($filetype == 'txt') { echo ' <tr> <td>file</td> <td><pre>' . htmlspecialchars($array['file']) . '</pre></td> <td valign=top>upload:<input type=file name=file></td> </tr>'; } else { echo ' <tr> <td>file</td> <td>cannot display</td> <td align=center>upload:<input type=file name=file></td> </tr>'; } echo '</form></table>'; }
), /* * Specifies whether audit trails should be run or not */ 'audit_trails' => false, /* * Specifies which theme to use for the user interface */ 'theme' => 'default' ); CONFIG; create_file($home . 'app/config.php', $config); create_file($home . 'app/includes.php', "<?php\n"); create_file($home . 'app/bootstrap.php', "<?php\n"); // Try to initialize the wyf framework. require "vendor/ekowabaka/wyf/wyf_bootstrap.php"; echo "\nSetting up the database ...\n"; Db::query(file_get_contents("lib/setup/schema.sql")); $username = get_response("Enter a name for the superuser account", 'super', null, true); $email = get_response('Provide your email address', null, null, true); Db::query("INSERT INTO system.roles(role_id, role_name) VALUES(1, 'Super User')"); Db::query(sprintf("INSERT INTO system.users\n \t\t(user_name, password, role_id, first_name, last_name, user_status, email) \n \tVALUES\n \t \t('%s', '%s', 1, 'Super', 'User', 2, '%s')", Db::escape($username), Db::escape($username), Db::escape($email))); Db::query("\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'can_log_in_to_web', 1, '/dashboard');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_audit_trail_can_add', 1, '/system/audit_trail');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_audit_trail_can_edit', 1, '/system/audit_trail');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_audit_trail_can_delete', 1, '/system/audit_trail');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_audit_trail_can_view', 1, '/system/audit_trail');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_audit_trail_can_export', 1, '/system/audit_trail');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_audit_trail_can_import', 1, '/system/audit_trail');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_roles_can_add', 1, '/system/roles');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_roles_can_edit', 1, '/system/roles');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_roles_can_delete', 1, '/system/roles');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_roles_can_view', 1, '/system/roles');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_roles_can_export', 1, '/system/roles');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_roles_can_import', 1, '/system/roles');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_users_can_add', 1, '/system/users');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_users_can_edit', 1, '/system/users');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_users_can_delete', 1, '/system/users');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_users_can_view', 1, '/system/users');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_users_can_export', 1, '/system/users');\n INSERT INTO permissions (role_id, permission, value, module) VALUES (1, 'system_users_can_import', 1, '/system/users');\n"); echo "\nDone! Happy programming ;)\n\n"; /** * A utility function for creating files. Checks if the files are writable and * goes ahead to create them. If they are not it just dies! */ function create_file($file, $contents)
public static function licence() { global $_G; $text = file_get_contents($_G['project']['home'] . 'api.php?action=service&execute=business&version=' . $_G['product']['version'] . '&charset=' . $_G['product']['charset'] . '&domain=' . urlencode(VI_HOST) . '&secret=' . VI_SECRET); $data = unserialize($text); if ($data) { $file = VI_ROOT . "config/licence.php"; //写入到缓存 create_file($file, '<?php $_G[\'licence\'] = ' . var_export($data, TRUE) . ';?>'); //刷新缓存 $_G['licence'] = $data; } return $data; }
<?php /* -------------------------------------------------------------------------------- File: w_o_t_d.php Module: WORD OF THE DAY Author: Quoc Viet [aFeLiOn] Begin: 2006-03-11 Comment: Get From dictionary.com -------------------------------------------------------------------------------- */ if (!defined('IN_EPS')) { exit; } $wotd_link = 'http://dictionary.reference.com/wordoftheday/wotd.rss'; $wotd_diff = -36000; @(include EPS_CACHE_DIR . 'cache_wotd.php'); $now_string = date_string(time() + $wotd_diff); if (!isset($wotd) || empty($wotd['desc']) || $wotd['date'] != $now_string) { $epsclass->load_class('class_xml'); $epsclass->xml->load_file($wotd_link); $wotd_rss = $epsclass->xml->get_rss(); $wotd = empty($wotd_rss) ? array() : array('date' => $now_string, 'link' => $wotd_rss['item']['link'], 'title' => html_clean($wotd_rss['item']['title']), 'desc' => preg_replace('#^(.+?):#i', '<strong>$1</strong>:', html_clean($wotd_rss['item']['description']))); create_file('<?php' . "\n" . '$wotd = ' . var_export($wotd, true) . ';' . "\n" . '?>', 'cache_wotd.php', EPS_CACHE_DIR); } $smarty->assign('wotd', $wotd); $smarty->display('module/w_o_t_d.tpl'); unset($wotd_link, $wotd_diff, $now_string, $wotd_rss, $wotd);
/** * Creates a file containing an html redirection to a given url * * @author Hugues Peeters <*****@*****.**> * @param string $filePath * @param string $url * @return void */ function create_link_file($filePath, $url) { $fileContent = '<html>' . '<head>' . '<meta http-equiv="content-Type" content="text/html;charset=' . get_locale('charset') . '">' . '<meta http-equiv="refresh" content="0;url=' . format_url($url) . '">' . '</head>' . '<body>' . '<div align="center">' . '<a href="' . format_url($url) . '">' . $url . '</a>' . '</div>' . '</body>' . '</html>'; create_file($filePath, $fileContent); }
/*------------------------------------------------------------------------ CREATE DOCUMENT : STEP 2 ------------------------------------------------------------------------*/ if ('exMkHtml' == $cmd) { $fileName = replace_dangerous_char(trim($_REQUEST['fileName'])); $cwd = secure_file_path($cwd); if (!empty($fileName)) { if (!in_array(strtolower(get_file_extension($_REQUEST['fileName'])), array('html', 'htm'))) { $fileName = $fileName . '.html'; } $cwd = secure_file_path($cwd); $htmlContent = claro_parse_user_text($_REQUEST['htmlContent']); $template = new PhpTemplate(get_path('incRepositorySys') . '/templates/document_create.tpl.php'); $template->assign('content', $htmlContent); $htmlContent = $template->render(); create_file($baseWorkDir . $cwd . '/' . $fileName, $htmlContent); $eventNotifier->notifyCourseEvent('document_htmlfile_created', claro_get_current_course_id(), claro_get_current_tool_id(), $cwd . '/' . $fileName, claro_get_current_group_id(), "0"); $dialogBox->success(get_lang('File created')); } else { $dialogBox->error(get_lang('File name is missing')); if (!empty($_REQUEST['htmlContent'])) { $dialogBox->info('<a href="' . claro_htmlspecialchars(Url::Contextualize('rqmkhtml.php?cmd=rqMkHtml&cwd=' . rawurlencode($cwd) . '&htmlContent=' . rawurlencode($_REQUEST['htmlContent']))) . '">' . get_lang('Back to the editor') . '</a>'); } } } /*------------------------------------------------------------------------ CREATE DOCUMENT : STEP 1 ------------------------------------------------------------------------*/ // see rqmkhtml.php ... /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = EDIT DOCUMENT CONTENT
is a heredoc string. <pg>ksklnm@@\$\$&\$&^%&^%&^%&</pg> <html> html </html> <?php echo "php"; ?> this line is without any html and php tags this is a line with more than eighty character,want to check line splitting correctly after 80 characters this is the text containing character this text contains some html tags <body> body </body> <br> br </br> this is the line with character. EOT; $filename = dirname(__FILE__) . "/fgetss_variation2.tmp"; /* try reading the file opened in different modes of reading */ $file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t"); for ($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) { echo "\n-- Testing fgetss() with file opened using {$file_modes[$mode_counter]} mode --\n"; /* create an empty file and write the strings with tags */ create_file($filename); //create an empty file file_put_contents($filename, $string_with_tags); $file_handle = fopen($filename, $file_modes[$mode_counter]); if (!$file_handle) { echo "Error: failed to open file {$filename}!\n"; exit; } // rewind the file pointer to beginning of the file var_dump(filesize($filename)); var_dump(rewind($file_handle)); var_dump(ftell($file_handle)); var_dump(feof($file_handle)); /* rewind the file and read the file line by line with allowable tags */ echo "-- Reading line by line with allowable tags: <test>, <html>, <?> --\n";
create_file($_POST['hostname'], $_POST['username'], $_POST['password'], $_POST['database']); } include '../application/config/database.php'; if (!($_POST['hostname'] == $db['default']['hostname'] && $_POST['username'] == $db['default']['username'] && $_POST['password'] == $db['default']['password'] && $_POST['database'] == $db['default']['database'])) { exit_error('Config file does not match with the given information'); } if ($server->select_db($_POST['database']) === FALSE) { exit_error("ERROR #3: Couldn't connect to database"); } $query = file_get_contents('database_tables.sql'); if ($server->multi_query($query) === FALSE) { exit_error("ERROR #4: Couldn't create the tables"); } } else { if (!file_exists('../application/config/database.php')) { create_file($_POST['hostname'], $_POST['username'], $_POST['password'], 'phpback'); } if ($server->select_db('phpback') === TRUE) { exit_error("ERROR #5: You already have a phpback database, please create another manually"); } if (!$server->query("CREATE DATABASE IF NOT EXISTS phpback")) { exit_error("ERROR #6: Could not create database"); } if ($server->select_db('phpback') === FALSE) { exit_error("ERROR #5: Generated database connection error"); } $sql = file_get_contents('database_tables.sql'); if ($server->multi_query($sql) === FALSE) { exit_error("ERROR #4: Couldn't create the tables"); } }
function save($method) { global $_G; if ($this->error) { return 'File not found!'; } $query = $method == 'POST' ? $_POST : $_GET; $data = array(); //清除转义字符 foreach ($query as $key => $val) { foreach ($val as $item => $set) { $data[$item][$key] = $set; } } //从小到大排序 function array_asc($a, $b) { if ($a["sort"] <= $b["sort"]) { return 0; } else { return $a["sort"] < $b["sort"] ? -1 : 1; } } //数据排序 uasort($data, "array_asc"); $str = '<?php' . chr(13); $str .= ' /*' . date("Y-m-t H:i:s") . '*/ ' . chr(13); $str .= '$_G[\'navigate\'][\'' . $this->appid . '\'] = '; $str .= var_export($data, TRUE); $str .= ';?>'; //写入缓存 return create_file($this->store, $str); }
} if (isset($_GET['o'])) { $o = $_GET['o']; } if (isset($o)) { if ($o == 'delete') { delete_task($t); success('successfully delete the task'); } if ($o == 'createf') { if (isset($_POST['name'])) { $uid = $_SESSION["user"]["uid"]; $name = $_POST['name']; $directory = $_POST['directory']; $description = $_POST['description']; $fid = create_file($uid, $t, $name, $directory, $fid, $description); goto_url("task.php?t={$t}"); } else { error('empty task name'); } } } if (fetch_task_history($t) == FALSE or fetch_task($t) == FALSE) { } else { //task name, start/end time, page title, page sub title $db_array_task_history = fetch_task_history($t); $db_array_task = fetch_task($t); $db_array_task_file = fetch_task_file($t); $db_array_task_directory = fetch_task_directory($t); $task_name = $db_array_task[0]['name']; $task_start = time_uk($db_array_task[0]['start']);
$smarty->assign('num_poll', $num_poll); $smarty->assign('vote_result', $poll_ans); $smarty->assign('polled', !$show); } if (!$show_result || IS_ADMIN) { if (isset($_POST['form_sent']) && $_POST['form_sent'] == 'poll') { if (isset($_POST['eps_poll'])) { $poll_ans[$_POST['eps_poll']]['vote']++; $poll_content = $poll_ques . "\n"; foreach ($poll_ans as $v) { $poll_content .= $v['ans'] . ' | ' . $v['vote'] . "\n"; } $polled_ips[] = $eps_user['ip_address']; if (!$eps_user['is_guest']) { $polled_ids[] = $eps_user['id']; } create_file($poll_content, FILE_POLL_DATA, true); create_file(implode("\n", $polled_ids), FILE_POLL_ID, true); create_file(implode("\n", $polled_ips), FILE_POLL_IP, true); redirect('index.php' . (isset($_GET['eps']) ? '?eps=' . $_GET['eps'] : ''), $eps_lang['Redirect_poll']); } } $smarty->assign('form_tag', auto_gen_form('index.php?eps=poll', 'poll', true)); $smarty->assign('poll_radios', $poll_radios); $smarty->assign('show_result_link', auto_gen_link('index.php?eps=poll&result=poll', $eps_lang['Show_result'], '', true)); } $smarty->assign('show_result', $show_result); $smarty->assign('is_admin', IS_ADMIN); $smarty->assign('poll_ques', $poll_ques); unset($show, $max_pixel, $poll_ques, $poll_ans, $poll_radios, $num_poll, $polled_ips, $polled_ids, $poll_content); $smarty->display('module/poll.tpl');
function content_recursive_move($src, $dst) { $dir = opendir($src); $oldUp = content_get_up_to_root($src) . 'globals.php'; $newUp = content_get_up_to_root($dst) . 'globals.php'; if (!file_exists($dst)) { mkdir($dst); chmod($dst, 0775); } while (($file = readdir($dir)) != false) { if ($file != '..' && $file != '.') { if (is_dir($src . "/{$file}")) { content_recursive_move($src . "/{$file}", $dst . "/{$file}"); } else { $data = get_file($src . "/{$file}"); if ($file == 'index.php') { $data = preg_replace('/\'' . prepare_pattern($oldUp) . '\'/', "'{$newUp}'", $data); } create_file($dst . "/{$file}", $data); } } } }
// not saving a file but still need to save the entity to push attributes to database $file->save(); } return array($file, $guid); } $container_guids = get_input("group_selection", array(), false); if (!is_array($container_guids)) { $container_guids = array_filter(array($container_guids)); } if (!in_array($context_container_guid, $container_guids)) { array_unshift($container_guids, $context_container_guid); } // register_error("Container guids: " . print_r($container_guids, true) . ", raw: " . print_r($_REQUEST["group_selection"], true)); $file = null; foreach ($container_guids as $container_guid) { list($file, $guid) = create_file($container_guid, $title, $desc, $access_id, $original_guid, $tags, $new_file); // make sure session cache is cleared unset($_SESSION['uploadtitle']); unset($_SESSION['uploaddesc']); unset($_SESSION['uploadtags']); unset($_SESSION['uploadaccessid']); // handle results differently for new files and file updates if ($new_file) { if ($guid) { system_message(elgg_echo("file:saved")); add_to_river('river/object/file/create', 'create', get_loggedin_userid(), $file->guid); } else { // failed to save file object - nothing we can do about this register_error(elgg_echo("file:uploadfailed") . "new"); } } else {
$local_file = fopen($file, 'w'); if (fwrite($local_file, strlen($source), 998) == false) { return false; } fclose($local_file); $c_permissions = chmod($new, 0666); } //else } catch (Exception $e) { echo $e->getMessage(); } return $file; } // create file $address = "http://content.guardianapis.com/search?show-elements=image&api-key=agu5esashhuk6yqngrwj4yt6"; @($getter = file_get_contents($address)); if (!$getter) { echo "unable open file "; exit; } else { if (create_file($getter) == true) { $dir = "json_dir/"; $files = scandir($dir); if (sizeof($files) < 0) { print "no files in this directory\n"; } else { print count($files); } print_r($files); } }