/** * 直接输出日志 * @param string $message 日志内容 * @param string $level 日志输出级别 * @param int $type 存储日志类型 * @param string $file 写入文件位置 * @param string $extra 额外参数 */ public static function write($message, $level = self::DEBUG, $type = self::FILE, $file = '', $extra = '') { if (empty($file)) { $file = LOG_PATH . date("y_m_d") . ".log"; } $dir = dirname($file); is_dir($dir) or createFolders(dirname($dir)) and mkdir($dir, 0777); $now = date(self::$format); error_log("{$now} {$level}: {$message}\r\n", $type, $file, $extra); }
function main(array $args = array()) { $defaults = array('install-dir' => getcwd()); $args += $defaults; if (!createFolders($args['install-dir'])) { return 1; } if (!download($args['install-dir'])) { return 1; } if (!install($args['install-dir'])) { return 1; } return 0; }
/** * draw the object. */ function draw() { /** Create the value array **/ global $db; $folders = null; $folders[0][0] = ">"; $folders[0][1] = $this->baseNode; createFolders($folders, ">", $this->baseNode, $this->stopNode); // set the values $this->v_wuiobject->value = $folders; // draw the object DBO::draw(); return 2; }
/** * 获取上传的图片 * @param string $fileKey * @return array * @throws Exception */ public static function getPic($fileKey = "file") { //允许的后缀 $exts = array("gif", "jpeg", "jpg", "png"); //允许的文件格式 $types = array("image/gif", "image/jpeg", "image/jpg", "image/pjpeg", "image/x-png", "image/png"); //最大大小 $maxSize = 20 * 1000; $error = ""; if (isset($_FILES) && isset($_FILES[$fileKey])) { $file = $_FILES[$fileKey]; $enames = explode(".", $file["name"]); $ext = end($enames); $type = $file["type"]; $size = $file["size"]; //验证图片格式 if (!in_array($ext, $exts)) { $error = "上传图片格式错误,仅支持:" . join(",", $exts); } //验证图片类型 if (empty($error) && !in_array($type, $types)) { $error = "上传图片类型错误,仅支持:" . join(",", $types); } //验证大小 if (empty($error) && $size > $maxSize) { $error = "上传图片的大小超过:" . $maxSize . "bit"; } if (empty($error)) { $tmpName = $file["tmp_name"]; //重命名图片,随机不重复 $filename = "/uploads/pics/" . uniqid(mt_rand(), true) . "." . $ext; $filepath = APP_PATH . $filename; createFolders(APP_PATH . "/uploads/pics/"); move_uploaded_file($tmpName, $filepath); $res = array("filename" => $filename, "url" => getFullURL() . $filename); return $res; } } else { $error = "上传图片为空"; } throw new Exception($error); }
function mfXimg($file, $app, $w, $h, $path = '', $c = 0) { if (!$file) { return; } $dest = 'uploadfile/' . $app . '/' . $file; if ($w == 0 && $h == 0) { return base_url() . '/' . $dest; } $info = explode('.', $file); $name = md10($file) . '_' . $w . '_' . $h . '.' . $info[1]; if (empty($path)) { $cpath = 'cache/' . $app . '/' . $w . '/' . $name; } else { $cpath = 'cache/' . $app . '/' . $path . '/' . $w . '/' . $name; } if (!is_file($cpath)) { createFolders('cache/' . $app . '/' . $path . '/' . $w); $config['image_library'] = 'gd2'; $config['source_image'] = $dest; $config['new_image'] = $cpath; $config['create_thumb'] = FALSE; $config['maintain_ratio'] = TRUE; $config['width'] = $w; $config['height'] = $h; $ci_obj =& get_instance(); $ci_obj->load->library('image_lib'); $ci_obj->image_lib->clear(); $ci_obj->image_lib->initialize($config); $result = $ci_obj->image_lib->resize(); if (!$result) { log_message('error', '图像裁减出错-->' . $ci_obj->image_lib->display_errors()); } unset($ci_obj); } return base_url() . '/' . $cpath; }
$thelia->boot(); $faker = Faker\Factory::create(); // Intialize URL management $url = new Thelia\Tools\URL(); $con = \Propel\Runtime\Propel::getConnection(Thelia\Model\Map\ProductTableMap::DATABASE_NAME); $con->beginTransaction(); try { $stmt = $con->prepare("SET foreign_key_checks = 0"); $stmt->execute(); clearTables($con); $stmt = $con->prepare("SET foreign_key_checks = 1"); $stmt->execute(); $material = createMaterials($con); $color = createColors($con); $brands = createBrands($faker, $con); $folders = createFolders($faker, $con); $contents = createContents($faker, $folders, $con); $categories = createCategories($faker, $con); echo "creating templates\n"; $template = new \Thelia\Model\Template(); $template->setLocale('fr_FR')->setName('template de démo')->setLocale('en_US')->setName('demo template')->save($con); $at = new Thelia\Model\AttributeTemplate(); $at->setTemplate($template)->setAttribute($color)->save($con); $ft = new Thelia\Model\FeatureTemplate(); $ft->setTemplate($template)->setFeature($material)->save($con); echo "end creating templates\n"; createProduct($faker, $categories, $brands, $contents, $template, $color, $material, $con); createCustomer($faker, $con); // set some config key createConfig($faker, $folders, $contents, $con); $con->commit();
<?php defined('IN_TS') or die('Access Denied.'); switch ($ts) { case "": $userid = intval($_GET['userid']); $menu2 = intval($userid / 1000); $menu1 = intval($menu2 / 1000); $path = $menu1 . '/' . $menu2; $dest_dir = 'uploadfile/user/' . $path; createFolders($dest_dir); $file_src = "src.png"; $filename162 = $userid . ".png"; $src = base64_decode($_POST['pic']); $pic1 = base64_decode($_POST['pic1']); if ($src) { file_put_contents($file_src, $src); } file_put_contents($dest_dir . '/' . $filename162, $pic1); //更新数据库 $new['user']->update('user_info', array('userid' => $userid), array('path' => $path, 'face' => $path . '/' . $filename162)); //清除缓存文件 tsDimg($path . '/' . $filename162, 'user', '120', '120', $path); tsDimg($path . '/' . $filename162, 'user', '48', '48', $path); tsDimg($path . '/' . $filename162, 'user', '32', '32', $path); tsDimg($path . '/' . $filename162, 'user', '24', '24', $path); $rs['status'] = 1; print json_encode($rs); break; case "face": $userid = intval($_GET['userid']);
/** * Standard constructor * @param string name of the table, the data is to be stored * @param string name of the column, the data is to be stored * @param string Where-Condition to select the record that is to be updated. * @param integer ID of the content-type, i.e. plugin. */ function CISelector($table, $column, $row_identifier, $type = 0) { $this->table = $table; $this->column = $column; $this->cond = $row_identifier; $this->type = $type; $this->fk = getDBCell($table, $column, $row_identifier); global $lang, $folder, $plugin, $searchin, $pattern, $db, $specialID; // $plugin = value("plugin"); $searchin = value("searchin"); $pattern = value("pattern"); // $specialID = value("specialID"); // $folder = value("folder"); $this->add(new Label("lbl1", $lang->get("sr_selectci"), "informationheader", 2)); //$this->add(new Label("lbl", "<b>".$lang->get("selectedobject")."</b>", "informationheader")); //if ($this->fk !=0) { // $this->idlabel = new Label("lbl0", getDBCell("content", "NAME", "CID = ".$this->fk), "informationheader"); //} else { // $this->idlabel = new Label("lbl0", $lang->get("empty"), "informationheader"); //} //$this->add(&$this->idlabel); $this->add(new Label("lbl2", $lang->get("folder"), "standard")); $this->add(new Label("lbl3", $lang->get("contenttype"), "standard")); // folder dropdown. $folders[0][0] = ">"; $folders[0][1] = 0; createFolders($folders, ">", 0); $plugins = createNameValueArray("modules", "MODULE_NAME", "MODULE_ID", "1"); $this->add(new Dropdown("folder", $folders, "standard", $folder, 220, 1)); if ($this->type == 0) { $this->add(new Dropdown("plugin", $plugins, "standard", $plugin, 250, 1)); } else { $type_name = getDBCell("modules", "MODULE_NAME", "MODULE_ID = $type"); $this->add(new Label("lbl", $type_name, "standardlight", 1)); } $searchins[0][0] = $lang->get("searchin"); $searchins[0][1] = 0; $searchins[1][0] = $lang->get("name"); $searchins[1][1] = 1; $searchins[2][0] = $lang->get("keywords"); $searchins[2][1] = 2; $searchins[3][0] = $lang->get("description"); $searchins[3][1] = 3; $this->add(new Dropdown("searchin", $searchins, "standard", $searchin, 220, 1)); $this->add(new Input("pattern", $pattern, "standard", 32, "", 250)); $this->add(new Cell("clc", "standard", 1, 250)); $this->add(new ButtonInCell("search", $lang->get("search"), "standard", "SUBMIT")); global $search; $search = value("search"); if ($search != "0") { // prepare search-pattern. $ppattern = strtoupper($pattern); $ppattern = ereg_replace(" ", "%", $ppattern); $ppattern = ereg_replace("\*", "%", $ppattern); if (!isset($plugin)) $plugin = $this->type; $this->search("/", $folder, $plugin, $searchin, $ppattern); $this->add(new Label("lbl4", $lang->get("searchresults"), "standard")); $this->add(new Dropdown("CIDRES_" . $specialID, $this->results, "standard", $CID, 250, 1)); } }
function uploadSQL($file, $dir, $filename) { createFolders($dir); move_uploaded_file($file['tmp_name'], $dir . '/' . $filename); return true; }
/** * Creates a directory tree of the category-table * Recursive function. require_onces an open Database-connection! * @param array array with name-value pairs of the folders * @param string prefix, which to write in front of all foldernames. Leave blank, is internally used. * @param integer node where to start indexing * @param integer $stopnode This ID is excluded from the tree. */ function createFolders(&$folder, $prefix, $node, $stopnode="-1") { global $db; $sql = "SELECT CATEGORY_ID, CATEGORY_NAME from categories WHERE DELETED = 0 AND PARENT_CATEGORY_ID=$node AND CATEGORY_ID <> $stopnode ORDER BY CATEGORY_NAME ASC"; $query = new query($db, $sql); while ($query->getrow()) { $name = $query->field("CATEGORY_NAME"); $id = $query->field("CATEGORY_ID"); $nextId = count($folder); $nprefix = $prefix . " " . $name . " >"; if ($id != $oid) { $folder[$nextId][0] = $nprefix; $folder[$nextId][1] = $id; createFolders($folder, $nprefix, $id, $stopnode); } } $query->free(); }
mkdir('Extension', 0755, true); } if (!is_dir('Public/css')) { mkdir('Public/css', 0755, true); } if (!is_dir('Public/js')) { mkdir('Public/js', 0755, true); } if (!is_dir('Public/images')) { mkdir('Public/images', 0755, true); } if (!is_dir('Fraym')) { mkdir('Fraym', 0755, true); } } createFolders(); if (!is_file('Vendor/autoload.php') && !(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')) { echo file_get_contents('Install.tpl'); exit; } /** * Install composer */ if (!is_file('composer.phar')) { copy('http://getcomposer.org/composer.phar', 'composer.phar'); if (!is_file('composer.phar')) { $error = error_get_last(); echo json_encode(['message' => 'Downloading dependencies, this may take several minutes...', 'done' => false, 'error' => $error['message']]); } else { echo json_encode(['message' => 'Downloading dependencies, this may take several minutes...', 'done' => true, 'error' => false]); }
/** * 循环创建文件夹 * @param $dir * @return bool */ function createFolders($dir) { return is_dir($dir) or createFolders(dirname($dir)) and mkdir($dir, 0777); }
$file = ''; } if (empty($file) || !file_exists($root . $file)) { $file = '/noimage.jpg'; } echo $file; exit; $fileRes = '/resize/' . $height . '/' . $width . '/' . $type . $file; $file = $root . $file; $fileRes = $root . $fileRes; if (!file_exists($fileRes)) { require_once $root . '/SimpleImage.php'; $simpleImage = new SimpleImage(); $simpleImage->load($file); switch ($type) { case 'no': $simpleImage->square_crop($height, $width); break; case 'w': $simpleImage->fit_to_width($width); break; case 'h': $simpleImage->fit_to_height($height); break; case 's': $simpleImage->resize($height, $width); break; } createFolders($fileRes); $simpleImage->save($fileRes); }
function tsUploadPhotoUrl($photourl, $projectid, $dir) { $menu2 = intval($projectid / 1000); $menu1 = intval($menu2 / 1000); $path = $menu1 . '/' . $menu2; $dest_dir = 'uploadfile/' . $dir . '/' . $path; createFolders($dest_dir); $arrType = explode('.', strtolower($photourl)); // 转小写一下 $type = array_pop($arrType); $name = $projectid . '.' . $type; $dest = $dest_dir . '/' . $name; $img = file_get_contents($photourl); unlink($dest); file_put_contents($dest, $img); return array('path' => $path, 'url' => $path . '/' . $name, 'type' => $type); }
/** * 写出数组到文件 * @param string $file 绝对地址文件名 * @param $data Array * @return int */ public static function writeArray($file, $data) { $dir = dirname($file); is_dir($dir) or createFolders(dirname($dir)) and mkdir($dir, 0777); $data = '<?php return ' . var_export($data, TRUE) . ';'; return file_put_contents($file, $data); }
require_once $c["path"] . "api/userinterface/wizard/stcheckarchive.php"; require_once $c["path"] . "api/userinterface/wizard/stimportimages.php"; $wizard = new Wizard($lang->get("imp_impages", "Import Images")); $wizard->setTitleText($lang->get("wz_import_im_title", "This wizard is used for importing importing images to N/X. Pack the images into a zip archive. The wizard will then create the data.")); if ($wizard->firstRun) { $_SESSION["archivefolder"] = ""; } ////// STEP 1 ////// $step1 = new Step(); $step1->setTitle($lang->get("wzt_archive_file", "Select Archive")); $step1->setExplanation($lang->get("wze_archive_file", "Please select the zip-archive you want to import. The images must be into that archive in a flat structure, having no folders.")); $step1->add(new WZUploadArchive("upload")); $step2 = new STCheckArchive(); $step2->setTitle($lang->get("wzt_ach_check", "Check Archive")); $step2->setExplanation($lang->get("wze_arch_check", "Please control the result of the archive checks and press next if you want to resume.")); $step3 = new Step(); $step3->setTitle($lang->get("wzt_dest_folder", "Select destination folder")); $step3->setExplanation($lang->get("wze_dest_folder", "Please select the folder, where all the new pictures will be copied to.")); $folders = array(); createFolders($folders, ' / ', 0); $step3->add(new WZSelect('folder', $lang->get("dest_folder", "Destination folder"), $folders)); $step4 = new STImportImages(); $step4->setTitle($lang->get("wzt_imp_imag", "Importing images...")); $wizard->add($step1); $wizard->add($step2); $wizard->add($step3); $wizard->add($step4); $page->add($wizard); $page->draw(); $db->close(); echo $errors;
$userid = $new['pubs']->create('user', array('pwd' => md5($salt . $pwd), 'salt' => $salt, 'email' => $openid)); //插入ts_user_info $new['pubs']->create('user_info', array('userid' => $userid, 'username' => $arrUserInfo['screen_name'], 'email' => $openid, 'ip' => getIp(), 'addtime' => time(), 'uptime' => time())); //插入ts_user_open $new['pubs']->create('user_open', array('userid' => $userid, 'sitename' => 'weibo', 'openid' => $openid, 'access_token' => $access_token, 'uptime' => time())); //更新用户头像 if ($arrUserInfo['avatar_large']) { //1000个图片一个目录 $menu2 = intval($userid / 1000); $menu1 = intval($menu2 / 1000); $menu = $menu1 . '/' . $menu2; $photo = $userid . '.jpg'; $photos = $menu . '/' . $photo; $dir = 'uploadfile/user/' . $menu; $dfile = $dir . '/' . $photo; createFolders($dir); if (!is_file($dfile)) { $img = file_get_contents($arrUserInfo['avatar_large']); file_put_contents($dfile, $img); } $new['pubs']->update('user_info', array('userid' => $userid), array('path' => $menu, 'face' => $photos)); } //获取用户信息 $userData = $new['pubs']->find('user_info', array('userid' => $userid), 'userid,username,path,face,isadmin,signin,uptime'); //发送系统消息(恭喜注册成功) $msg_userid = '0'; $msg_touserid = $userid; $msg_content = '亲爱的微博用户 ' . $username . ' :<br />您成功加入了 ' . $TS_SITE['site_title'] . '<br />在遵守本站的规定的同时,享受您的愉快之旅吧!'; aac('message')->sendmsg($msg_userid, $msg_touserid, $msg_content); $_SESSION['tsuser'] = $userData; header("Location: " . SITE_URL);
and runs the lines after the flush server-side */ // Buffer the upcoming output ob_start(); include '../request_submitted.html'; // Get the size of the output $outputSize = ob_get_length(); // Send telling the browser to close the connection header("Content-Encoding: none\r\n"); header("Content-Length: {$outputSize}"); header("Connection: close\r\n"); // Flush all output ob_end_flush(); ob_flush(); flush(); //Creating folders and uploading files in the background createFolders($drive_service, $client, $configObj, $UsersAFSObj); uploadFiles($drive_service, $client, $configObj, $UsersAFSObj); //Get total files and folders for notification script $totalFolders = count($UsersAFSObj->folderList); $totalFiles = count($UsersAFSObj->fileList); $numFolders = $UsersAFSObj->numFoldersUploaded; $numFiles = $UsersAFSObj->numFilesUploaded; $failedFiles = $UsersAFSObj->failedFiles; $choice = 'drive'; $logline = date('Y-m-d H:i:s') . ": upload complete! \n"; fwrite($configObj->logFile, $logline); //Send user an email with the results of the transfer include '../notification_email.php'; if ($totalFolders == $numFolders && $totalFiles == $numFiles) { //Delete log file if upload was successful unlink($logfileName);