Пример #1
0
 function makedir($path)
 {
     if (!file_exists($path)) {
         makedir(dirname($path));
         return mkdir($path, 0777);
     }
 }
Пример #2
0
 /**
 * 读模板页进行替换后写入到cache页里
 *
 * @param string $tplfile
 *        	:模板源文件地址
 * @param string $objfile
 *        	:模板cache文件地址
 * @return string
 */
 function complie($tplfile, $objfile)
 {
     $template = "<?php defined('IN_TS') or die('Access Denied.'); ?>";
     $template .= file_get_contents($tplfile);
     $template = $this->parse($template);
     makedir(dirname($objfile));
     isWriteFile($objfile, $template, $mod = 'w', TRUE);
 }
Пример #3
0
function makedir($dir, $mod = 0777, $mkindex = true)
{
    if (!is_dir($dir)) {
        makedir(dirname($dir), $mod, $mkindex);
        @mkdir($dir, $mod);
        @chmod($dir, 0777);
        if (!empty($mkindex)) {
            @touch($dir . '/index.htm');
            @chmod($dir . '/index.htm', 0777);
        }
    }
    return true;
}
Пример #4
0
function log_search()
{
    global $Paths;
    $search_str = trim($_POST['search'] . " " . $_GET['q']);
    // is there anything to save?
    if ('' != $search_str) {
        // set path
        $log_path = $Paths['pivot_path'] . 'db/';
        // is there an old to load?
        if (file_exists($log_path . 'log_search.php')) {
            // file exists - load if writable
            if (is_writable($log_path . 'log_search.php')) {
                $log_search_array = load_serialize($log_path . 'log_search.php');
                $log_exists = TRUE;
            }
        }
        // just in case
        if (!is_array($log_search_array)) {
            $log_search_array = array();
        }
        // add to the log
        $log_search_array[$search_str]++;
        if (isset($log_exists) && TRUE == $log_exists) {
            // easy route - now serialize and save
            save_serialize($log_path . 'log_search.php', $log_search_array);
        } else {
            // else attempt to make it - suppress errors
            @makedir($log_path, 0700);
            @touch($log_path . 'log_search.php');
            @chmod($log_path . 'log_search.php', 0777);
            // final check
            if (is_writable($log_path . 'log_search.php')) {
                save_serialize($log_path . 'log_search.php', $log_search_array);
            }
        }
    }
}
Пример #5
0
Файл: nav.php Проект: rmaine/GIT
function makedir($path, $backOut)
{
    echo "<ul>\n";
    $files = scandir($path);
    foreach ($files as $key => $value) {
        $alias = explode("~", $value);
        $alias = array_pop($alias);
        $alias = str_replace("&", "&amp;", $alias);
        $alias = str_replace("-", " ", $alias);
        $isMe = $value;
        $value = str_replace("&", "%26", $value);
        if ($value != "." && $value != ".." && $value != "images" && substr($value, 0, 1) != "_" && substr($value, -3) != "php") {
            $pos = strrpos($_SERVER["PHP_SELF"], $value);
            echo "<li>";
            if (basename(realpath(".")) == $isMe) {
                echo "<span class=\"currentPage\">{$alias}</span>";
                $backOut = "yup";
                //break 1;
            } else {
                echo "<a href=\"{$path}{$value}\">{$alias}</a>";
                $backOut = "nope";
            }
            if ($pos === false) {
                echo "</li>\n";
            } else {
                $path = explode("/", $path);
                array_pop($path);
                array_pop($path);
                $path = implode("/", $path) . "/";
                makedir($path, $backOut);
                $path = $path . "../";
                echo "</ul>\n";
                echo "</li>\n";
            }
        }
    }
}
Пример #6
0
    {
        $p = $this->db->query($sql);
        $p->setFetchMode(PDO::FETCH_ASSOC);
        $result = $p->fetchAll();
        return $result;
    }
    /**
     * 返回一行数据
     * @param 
     */
    protected function FetRow($sql)
    {
        $p = $this->db->query($sql);
        $p->setFetchMode(PDO::FETCH_ASSOC);
        $result = $p->fetchAll();
        return $result[0];
    }
}
$m = new Loginlog();
function makedir($m, $sdate, $edate)
{
    $sdate = strtotime($sdate);
    $edate = strtotime($edate);
    while ($sdate <= $edate) {
        $date = date('Y-m-d', $sdate);
        $m->executeall($date);
        $sdate = strtotime('+1 day', $sdate);
    }
}
makedir($m, '2015-02-01', '2015-11-02');
Пример #7
0
				`task_id`,
				`time`,
				`file`
				) values (NULL, ?, ?, ?, ?);';
        $sql->prepare($query);
        $sql->bind_param('iiis', $user_id, $task_id, $time, $file);
        $sql->execute();
        $grading_id = $mysqli->insert_id;
        $user = user($user_id);
        $task = task($task_id);
        //CREATE THIS RESULT DIRECTORY
        if ($config['mode'] != 'online') {
            $parent_dir = 'graded/' . D('y-w-d', time(0));
            makedir($parent_dir);
            $thisDir = $parent_dir . '/' . $user['user'] . '-' . $task['name_short'] . '-' . D('H:M:S', time(0));
            makedir($thisDir);
            cp('upload/' . $file, $thisDir . '/' . $file);
        }
        //COMPILE
        $name = compile($file);
        $message = message();
        $text = '';
        $score = 0;
        $timeused = 0;
        if (file_exists('compiled/' . $name . '.out')) {
            // COMPILE SUCCESS
            //GRADE
            if ($task['success']) {
                $script = 'ev/' . $task['name_short'] . '/script.php';
                if (!file_exists($script)) {
                    error('Script file not found! ' . $script);
 function generate_thumb($thumb_size = '0')
 {
     global $config_vars;
     if (!is_file($this->file)) {
         return;
     }
     // if $thumb_size is not set == 0 then set it from the config vars
     if ($thumb_size == '0') {
         $thumb_size = $config_vars['thumb_size'];
     }
     $new_size = $this->calc_new_size($thumb_size);
     $thumbfile = $this->get_thumbfile();
     if ($new_size['type'] == 1) {
         $src_img = imagecreatefromgif($this->file);
     }
     if ($new_size['type'] == 2) {
         $src_img = imagecreatefromjpeg($this->file);
     }
     if ($new_size['type'] == 3) {
         $src_img = imagecreatefrompng($this->file);
     }
     $dst_img = imagecreate($new_size['width'], $new_size['height']);
     imagejpeg($dst_img, $thumbfile, 75);
     $dst_img = imagecreatefromjpeg($thumbfile);
     imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_size['width'], $new_size['height'], imagesx($src_img), imagesy($src_img));
     if (!is_dir(dirname($thumbfile))) {
         makedir(dirname($thumbfile));
     }
     imagejpeg($dst_img, $thumbfile, 75);
     // 75 == quality
     ImageDestroy($src_img);
     ImageDestroy($dst_img);
 }
Пример #9
0
function makelog($logdir, $log)
{
    makedir($logdir);
    $logfile = $logdir . date("Y-m-d") . ".log";
    $fp = fopen($logfile, "a");
    if ($fp) {
        fputs($fp, $log);
    }
    fclose($fp);
    return TRUE;
}
Пример #10
0
 public function views($aid)
 {
     $aid = intval($aid);
     if ($aid < 1) {
         header('HTTP/1.1 301 Moved Permanently');
         header('Location: /');
         exit;
     }
     $data = $this->emulemodel->getEmuleTopicByAid($aid, 0, $this->userInfo['uid'], $this->userInfo['isadmin'], 0);
     if (empty($data)) {
         header('Location: ' . $this->url404);
         exit;
     }
     $cid = $data['info']['cid'] ? $data['info']['cid'] : 0;
     $this->checkAge($this->viewData['channel'][$cid]['isadult'], $goReferer = '/maindex/views/' . $aid);
     $_key = 'view_rightHot' . $cid;
     $viewHot = $this->mem->get($_key);
     if (!$viewHot) {
         $viewHot = $this->emulemodel->getArticleListByCid($cid, 2, 2, 18);
         $this->mem->set($_key, $viewHot, self::$ttl['12h']);
     }
     $data['info']['intro'] = preg_replace(array('#[a-z]+://[a-z0-9]+\\.[a-z0-9-_/\\.]+#is', '#[a-z0-9]+\\.[a-z0-9-_/\\.]+#is'), array('', ''), $data['info']['intro']);
     // seo setting
     $kw = $this->viewData['channel'][$cid]['name'];
     $title = $data['info']['name'];
     $keywords = sprintf('%s,%s在线观看,%s全集,%s%s,%s下载,%s主题曲,%s剧情,%s演员表', $title, $title, $title, $kw, $title, $title, $title, $title, $title);
     $seo_description = strip_tags($data['info']['intro']);
     $seo_description = preg_replace('#\\s+#Uis', '', $seo_description);
     $seo_description = mb_substr($seo_description, 0, 250);
     $isCollect = $this->emulemodel->getUserIscollect($this->userInfo['uid'], $data['info']['id']);
     $this->assign(array('isCollect' => $isCollect, 'verifycode' => $verifycode, 'seo_title' => $title, 'seo_keywords' => $keywords, 'cid' => $cid, 'cpid' => $cpid, 'info' => $data['info'], 'aid' => $aid, 'seo_description' => $seo_description, 'videovols' => $data['vols'], 'viewHot' => $viewHot));
     #echo "<pre>";var_dump($this->viewData);exit;
     if (!$this->robot && self::$static_html) {
         $this->viewData['userInfo'] = array('uid' => 0);
         $this->view('index_view');
         $cache_file = CACHEDIR . $aid % 10 . '/views_' . $aid . '.html';
         $cache_dir = dirname($cache_file);
         makedir($cache_dir, 0777);
         $output = $this->output->get_output();
         file_put_contents($cache_file, $output);
         @chmod($cache_file, 0777);
         die($output);
     }
     $this->view('index_view');
 }
Пример #11
0
function ensure_writable_dir($dir)
{
    /*returns:
    	 	0 if $dir exists and is writeable
    		1 if $dir could be created writeable
    		2 if $dir does exists but is not writeable
    		3 if $dir could be created but is not writeable
    		4 if $dir does not exists and could not be created
    		
    	 
    	*/
    if (is_dir("./" . $dir)) {
        if (check_writeable($dir)) {
            return 0;
        } else {
            return 2;
        }
    } else {
        if (@makedir($dir)) {
            // dir created
            if (check_writeable($dir)) {
                return 1;
            } else {
                return 3;
            }
        } else {
            // dir not creatable
            return 4;
        }
    }
}
Пример #12
0
/**
 * Recursively creates chmodded directories.
 *
 * NB! Directories are created with permission 777 - worldwriteable -
 * unless you have added a line 'chmod_dir|XYZ' to pv_cfg_settings.php.
 *
 * @param string $name
 */
function makedir($name)
{
    global $Cfg;
    // if it exists, just return.
    if (file_exists($name)) {
        return;
    }
    // if more than one level, try parent first..
    if (dirname($name) != ".") {
        makedir(dirname($name));
    }
    // use permission if set in pv_cfg_settings.php
    if (isset($Cfg['chmod_dir'])) {
        $mode = '0' . $Cfg['chmod_dir'];
    } else {
        $mode = '0777';
    }
    $mode_dec = octdec($mode);
    $oldumask = umask(0);
    @mkdir($name, $mode_dec);
    @chmod($name, $mode_dec);
    umask($oldumask);
}
Пример #13
0
 /**
  * 生成缩略图的方法
  * @param  strint	原图地址       
  * @return array	返回成功或错误信息
  * 返回值为数组各字段含义,error:是否出错,1出错,0正常,errorcode:报错代码,path:缩略图片路径
  */
 public function createthumb($thumb_src_image)
 {
     global $_M;
     $thumb_src_image = path_absolute($thumb_src_image);
     if ($this->thumb_save_type == 1) {
         $thumb_savepath = dirname($thumb_src_image) . '/' . $this->thumb_savepath;
     }
     if ($this->thumb_save_type == 2) {
         $thumb_savepath = dirname($thumb_src_image) . '/';
     }
     if ($this->thumb_save_type == 3) {
         $thumb_savepath = $this->thumb_savepath;
     }
     if (stristr(PHP_OS, "WIN")) {
         $thumb_src_image = @iconv("utf-8", "GBK", $thumb_src_image);
     }
     if (!file_exists($thumb_src_image) || is_dir($thumb_src_image)) {
         return $this->error($_M['word']['batchtips30']);
     }
     $this->thumb_width = $this->thumb_width ? $this->thumb_width : 100;
     $this->thumb_height = $this->thumb_height ? $this->thumb_height : 100;
     $gd = $this->gd_version();
     //检查原始是否文件存在并且得到原图信息
     $org_info = @getimagesize($thumb_src_image);
     //返回图片大小
     if ($org_info[mime] == 'image/bmp') {
         //bmp图无法压缩
         return $this->error($_M['word']['upfileFail5']);
     }
     if (!$this->check_img_function($org_info[2])) {
         return $this->error($_M['word']['upfileFail6']);
     }
     $img_org = $this->img_resource($thumb_src_image, $org_info[2]);
     //原始图像和缩略图尺寸对比
     $scale_org = $org_info[0] / $org_info[1];
     $scale_tumnb = $this->thumb_width / $this->thumb_height;
     //处理缩略图宽度和高度为0的情况,背景和缩略图一样大
     if ($this->thumb_width == 0) {
         $this->thumb_width = $this->thumb_height * $scale_org;
     }
     if ($this->thumb_height == 0) {
         $this->thumb_height = $this->thumb_width / $scale_org;
     }
     //创建缩略图
     if ($gd == 2) {
         //创建一张缩略图(黑色)
         $img_thumb = imagecreatetruecolor($this->thumb_width, $this->thumb_height);
     } else {
         $img_thumb = imagecreate($this->thumb_width, $this->thumb_height);
     }
     //缩略图背景颜色
     if (empty($this->thumb_bgcolor)) {
         $this->thumb_bgcolor = "#FFFFFF";
     }
     $this->thumb_bgcolor = trim($this->thumb_bgcolor, "#");
     sscanf($this->thumb_bgcolor, "%2x%2x%2x", $red, $green, $blue);
     $clr = imagecolorallocate($img_thumb, $red, $green, $blue);
     imagefilledrectangle($img_thumb, 0, 0, $this->thumb_width, $this->thumb_height, $clr);
     //创建背景色,默认为白色
     switch ($this->thumb_kind) {
         case 1:
             $dst_x = 0;
             $dst_y = 0;
             $lessen_width = $this->thumb_width;
             $lessen_height = $this->thumb_height;
             $scr_x = 0;
             $scr_y = 0;
             $scr_w = $org_info[0];
             $scr_h = $org_info[1];
             break;
         case 2:
             if ($org_info[0] / $this->thumb_width > $org_info[1] / $this->thumb_height) {
                 //上下留白
                 $lessen_width = $this->thumb_width;
                 $lessen_height = $this->thumb_width / $scale_org;
             } else {
                 //左右留白
                 $lessen_width = $this->thumb_height * $scale_org;
                 $lessen_height = $this->thumb_height;
             }
             $dst_x = ($this->thumb_width - $lessen_width) / 2;
             $dst_y = ($this->thumb_height - $lessen_height) / 2;
             $scr_x = 0;
             $scr_y = 0;
             $scr_w = $org_info[0];
             $scr_h = $org_info[1];
             break;
         case 3:
             $dst_x = 0;
             $dst_y = 0;
             $lessen_width = $this->thumb_width;
             $lessen_height = $this->thumb_height;
             if ($org_info[0] / $this->thumb_width > $org_info[1] / $this->thumb_height) {
                 //上下留白,截左右
                 $scr_w = $org_info[1] * $scale_tumnb;
                 $scr_h = $org_info[1];
             } else {
                 //左右留白,截上下
                 $scr_w = $org_info[0];
                 $scr_h = $org_info[0] / $scale_tumnb;
             }
             $scr_x = ($org_info[0] - $scr_w) / 2;
             $scr_y = ($org_info[1] - $scr_h) / 2;
             break;
     }
     //放大原始图片
     if ($gd == 2) {
         imagecopyresampled($img_thumb, $img_org, $dst_x, $dst_y, $scr_x, $scr_y, $lessen_width, $lessen_height, $scr_w, $scr_h);
     } else {
         imagecopyresized($img_thumb, $img_org, $dst_x, $dst_y, $scr_x, $scr_y, $lessen_width, $lessen_height, $scr_w, $scr_h);
     }
     if (!makedir($thumb_savepath)) {
         return $this->error($_M['word']['upfileFail4']);
     }
     $thumbname = $thumb_savepath . basename($thumb_src_image);
     //Create
     switch ($org_info[mime]) {
         case 'image/gif':
             if (function_exists('imagegif')) {
                 $re = imagegif($img_thumb, $thumbname);
             } else {
                 return $this->error($_M['word']['upfileFail9']);
             }
             break;
         case 'image/pjpeg':
         case 'image/jpeg':
             if (function_exists('imagejpeg')) {
                 $re = imagejpeg($img_thumb, $thumbname, 100);
             } else {
                 return $this->error($_M['word']['upfileFail10']);
             }
             break;
         case 'image/x-png':
         case 'image/png':
             if (function_exists('imagejpeg')) {
                 $re = imagepng($img_thumb, $thumbname);
             } else {
                 return $this->error($_M['word']['upfileFail11']);
             }
             break;
         default:
             return $this->error($_M['word']['upfileFail7']);
     }
     if (!$re) {
         return $this->error($_M['word']['upfileFail8']);
     }
     if (stristr(PHP_OS, "WIN")) {
         $thumbname = @iconv("GBK", "utf-8", $thumbname);
     }
     $thumbname = '../' . str_replace(PATH_WEB, '', $thumbname);
     imagedestroy($img_thumb);
     imagedestroy($img_org);
     return $this->sucess($thumbname);
 }
Пример #14
0
}
// check if user is allowed to add content
if (check_cat_action_allowed($category->get_catgroup_id(), $userdata['user_id'], 'content_add')) {
    $smarty->assign('allow_content_add', true);
    // get catgroups where add_to_group is allowed
    $add_to_contentgroups = get_contentgroups_data_where_perm('id,name', 'add_to_group');
    $smarty->assign('add_to_contentgroups', $add_to_contentgroups);
    if (isset($HTTP_POST_VARS['newcontent'])) {
        $objtyp = $filetypes[getext($HTTP_POST_FILES['new_content_file']['name'])];
        if (isset($objtyp)) {
            add_content($HTTP_POST_FILES['new_content_file']['name'], $HTTP_POST_FILES['new_content_file']['tmp_name'], $HTTP_POST_VARS['new_content_name'], $HTTP_GET_VARS['cat_id'], $HTTP_POST_VARS['new_content_place_in_cat'], $HTTP_POST_VARS['new_content_group']);
        } elseif (eregi("zip\$", $HTTP_POST_FILES['new_content_file']['name'])) {
            // its a zip file
            $zip = new PclZip($HTTP_POST_FILES['new_content_file']['tmp_name']);
            $folder = $config_vars['default_upload_dir'] . "/zip_" . $userdata['username'];
            makedir($folder);
            $zip->extract(PCLZIP_OPT_PATH, $folder);
            add_dir_parsed($folder, $HTTP_POST_VARS['new_content_group'], $HTTP_GET_VARS['cat_id']);
            // remove directory;
            unlink($folder . "/index.html");
            rmdir($folder);
        }
    }
}
if (intval($HTTP_SESSION_VARS['first_content']) == '') {
    $HTTP_SESSION_VARS['first_content'] = 0;
}
if (!isset($HTTP_GET_VARS['content_per_page'])) {
    if (!isset($HTTP_SESSION_VARS['content_per_page'])) {
        $content_per_page = $userdata['content_per_page'];
        $HTTP_SESSION_VARS['content_per_page'] = $content_per_page;
Пример #15
0
/** 
 * Grabs the data that was parsed from a Podcast
 *
 * @author Ross Carlson
 * @since 11/02/2005
 * @param $item An array with all the values to grab
 * @param $folder The subfolder to store the file in
 * @return boolean true|false
 *
 **/
function getPodcastData($item, $folder)
{
    global $include_path, $podcast_folder;
    if ($item['file'] == "") {
        return false;
    }
    $be = new jzBackend();
    $display = new jzDisplay();
    // Let's clean the new folder name
    $folder = trim(cleanFileName($folder));
    // Let's grab the file and save it to disk
    $ext = substr($item['file'], strlen($item['file']) - 3, 3);
    $track = trim(cleanFileName($item['title'] . "." . $ext));
    if (substr($podcast_folder, 0, 1) != "/") {
        $dir = str_replace("\\", "/", getcwd()) . "/" . $podcast_folder . "/" . $folder;
    } else {
        $dir = $podcast_folder . "/" . $folder;
    }
    $track = $dir . "/" . $track;
    // Now let's create the directory we need
    makedir($dir);
    // Now let's see if the file already exists
    if (!is_file($track)) {
        ?>
			<script language="javascript">
				t.innerHTML = '<?php 
        echo word("Downloading") . ": " . $display->returnShortName($item['title'], 45);
        ?>
';									
				-->
			</SCRIPT>
			<?php 
        flushdisplay();
        // Now let's grab the file and write it out
        $fName = str_replace("&amp;", "&", $item['file']);
        $data = file_get_contents($fName);
        $handle = fopen($track, "w");
        fwrite($handle, $data);
        fclose($handle);
        ?>
			<script language="javascript">
				t.innerHTML = '<?php 
        echo word("Download Complete!");
        ?>
';									
				-->
			</SCRIPT>
			<?php 
        flushdisplay();
    } else {
        ?>
			<script language="javascript">
				t.innerHTML = '<?php 
        echo word("Exists - moving to next track...");
        ?>
';									
				-->
			</SCRIPT>
			<?php 
        flushdisplay();
    }
    return $track;
}
Пример #16
0
 /** 
  * 打水印的方法
  * @param  string $water_scr_image	原图路径
  * @return array			        返回成功信息		
  * 返回值为数组各字段含义,error:是否出错,1出错,0正常,errorcode:报错代码,path:水印图片路径
  */
 public function create($water_scr_image)
 {
     global $_M;
     $water_scr_image = path_absolute($water_scr_image);
     if (!file_exists($water_scr_image) || is_dir($water_scr_image)) {
         return $this->error($_M['word']['batchtips30']);
     }
     if ($this->is_watermark != 1) {
         return $this->sucess(path_relative($water_scr_image));
     }
     if ($this->water_save_type == 1) {
         $save_path_water = dirname($water_scr_image) . '/' . $this->water_savepath;
     }
     if ($this->water_save_type == 2) {
         $save_path_water = dirname($water_scr_image) . '/';
     }
     if ($this->water_save_type == 3) {
         $save_path_water = $this->water_savepath;
     }
     if (stristr(PHP_OS, "WIN")) {
         $water_scr_image = @iconv("utf-8", "GBK", $water_scr_image);
         $this->water_image_name = @iconv("utf-8", "GBK", $this->water_image_name);
     }
     if (!file_exists($water_scr_image) || is_dir($water_scr_image)) {
         return $this->error($_M['word']['batchtips30']);
     }
     $src_image_type = $this->get_type($water_scr_image);
     $src_image = $this->createImage($src_image_type, $water_scr_image);
     if (!$src_image) {
         return;
     }
     $src_image_w = ImageSX($src_image);
     $src_image_h = ImageSY($src_image);
     if ($this->water_mark_type == 'img') {
         $this->water_image_name = strtolower(trim($this->water_image_name));
         $met_image_type = $this->get_type($this->water_image_name);
         $met_image = $this->createImage($met_image_type, $this->water_image_name);
         $met_image_w = ImageSX($met_image);
         $met_image_h = ImageSY($met_image);
         $temp_met_image = $this->getPos($src_image_w, $src_image_h, $this->water_pos, $met_image);
         $met_image_x = $temp_met_image["dest_x"];
         $met_image_y = $temp_met_image["dest_y"];
         if ($this->get_type($this->water_image_name) == 'png') {
             imagecopy($src_image, $met_image, $met_image_x, $met_image_y, 0, 0, $met_image_w, $met_image_h);
         } else {
             imagecopymerge($src_image, $met_image, $met_image_x, $met_image_y, 0, 0, $met_image_w, $met_image_h, $this->met_image_transition);
         }
     }
     if ($this->water_mark_type == 'text') {
         $temp_water_text = $this->getPos($src_image_w, $src_image_h, $this->water_pos);
         $water_text_x = $temp_water_text["dest_x"];
         $water_text_y = $temp_water_text["dest_y"];
         if (preg_match("/([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])/i", $this->water_text_color, $color)) {
             $red = hexdec($color[1]);
             $green = hexdec($color[2]);
             $blue = hexdec($color[3]);
             $water_text_color = imagecolorallocate($src_image, $red, $green, $blue);
         } else {
             $water_text_color = imagecolorallocate($src_image, 255, 255, 255);
         }
         imagettftext($src_image, $this->water_text_size, $this->water_text_angle, $water_text_x, $water_text_y, $water_text_color, $this->water_text_font, $this->water_text);
     }
     makedir($save_path_water);
     $save_file = $save_path_water . basename($water_scr_image);
     if ($save_path_water) {
         switch ($this->get_type($save_path_water)) {
             case 'gif':
                 $src_img = ImagePNG($src_image, $save_file);
                 break;
             case 'jpeg':
                 $src_img = ImageJPEG($src_image, $save_file, $this->jpeg_quality);
                 break;
             case 'png':
                 $src_img = ImagePNG($src_image, $save_file);
                 break;
             default:
                 $src_img = ImageJPEG($src_image, $save_file, $this->jpeg_quality);
                 break;
         }
     } else {
         if ($src_image_type = "jpg") {
             $src_image_type = "jpeg";
         }
         header("Content-type: image/{$src_image_type}");
         switch ($src_image_type) {
             case 'gif':
                 $src_img = ImagePNG($src_image);
                 break;
             case 'jpg':
                 $src_img = ImageJPEG($src_image, "", $this->jpeg_quality);
                 break;
             case 'png':
                 $src_img = ImagePNG($src_image);
                 break;
             default:
                 $src_img = ImageJPEG($src_image, "", $this->jpeg_quality);
                 break;
         }
     }
     imagedestroy($src_image);
     if (stristr(PHP_OS, "WIN")) {
         $water_scr_image = @iconv("GBK", "utf-8", $water_scr_image);
         $this->water_image_name = @iconv("GBK", "utf-8", $this->water_image_name);
         $save_file = @iconv("GBK", "utf-8", $save_file);
     }
     return $this->sucess(path_relative($save_file));
 }
Пример #17
0
/**
 * 生成zip压缩文件
 * @param string  $dir			要压缩的文件
 * @param string  $destination	压缩后的文件名(必须指定zip后缀)
 * @param boolean $overwrite	是否覆盖已有的文件(true:覆盖已有文件,false:不覆盖已有文件)默认覆盖
 * @return					    压缩失败返回false
 */
function zipfile($dir, $destination = '', $overwrite = true)
{
    makedir($dir);
    $dir = path_absolute($dir);
    if ($destination == '') {
        $destination = str_replace('.' . getfileable($dir), '', $dir) . '.zip';
    }
    $destination = path_absolute($destination);
    if (is_strinclude($destination, '.zip') === false) {
        return false;
    }
    @clearstatcache();
    if (file_exists($destination) && $overwrite == false) {
        return false;
    } else {
        if (file_exists($destination)) {
            unlink($destination);
        }
        fclose(fopen($destination, 'w'));
        $z = new PclZip($destination);
        $v_list = $z->create($dir);
        if ($v_list == 0) {
            return false;
        } else {
            return true;
        }
    }
}
Пример #18
0
 /** 
  * 上传方法
  * @param array $form 上传空间名,也就是input,file上传控件的name字段值
  */
 public function upload($form = '')
 {
     global $_M;
     if (is_array($form)) {
         $filear = $form;
     } else {
         $filear = $_FILES[$form];
     }
     if (!$filear) {
         foreach ($_FILES as $key => $val) {
             $filear = $_FILES[$key];
             break;
         }
     }
     //是否能正常上传
     if (!is_array($filear)) {
         $filear['error'] = 4;
     }
     if ($filear['error'] != 0) {
         $errors = array(0 => $_M['word']['upfileOver4'], 1 => $_M['word']['upfileOver'], 2 => $_M['word']['upfileOver1'], 3 => $_M['word']['upfileOver2'], 4 => $_M['word']['upfileOver3'], 6 => $_M['word']['upfileOver5'], 7 => $_M['word']['upfileOver5']);
         $error_info[] = $errors[$filear['error']] ? $errors[$filear['error']] : $errors[0];
         return $this->error($errors[$filear['error']]);
     }
     //文件大小是否正确
     if ($filear["size"] > $this->maxsize || $filear["size"] > $_M['config']['met_file_maxsize'] * 1048576) {
         return $this->error("{$_M['word']['upfileFile']}" . $filear["name"] . " {$_M['word']['upfileMax']} {$_M['word']['upfileTip1']}");
     }
     //文件后缀是否为合法后缀
     $this->getext($filear["name"]);
     //获取允许的后缀
     if (strtolower($this->ext) == 'php' || strtolower($this->ext) == 'aspx' || strtolower($this->ext) == 'asp' || strtolower($this->ext) == 'jsp' || strtolower($this->ext) == 'js' || strtolower($this->ext) == 'asa') {
         return $this->error($this->ext . " {$_M['word']['upfileTip3']}");
     }
     if ($_M['config']['met_file_format']) {
         if ($_M['config']['met_file_format'] != "" && !in_array(strtolower($this->ext), explode('|', strtolower($_M['config']['met_file_format']))) && $filear) {
             return $this->error($this->ext . " {$_M['word']['upfileTip3']}");
         }
     } else {
         return $this->error($this->ext . " {$_M['word']['upfileTip3']}");
     }
     if ($this->format) {
         if ($this->format != "" && !in_array(strtolower($this->ext), explode('|', strtolower($this->format))) && $filear) {
             return $this->error($this->ext . " {$_M['word']['upfileTip3']}");
         }
     }
     //文件名重命名
     $this->set_savename($filear["name"], $this->is_rename);
     //新建保存文件
     if (stripos($this->savepath, PATH_WEB . 'upload/') !== 0) {
         return $this->error($_M['word']['upfileFail2']);
     }
     if (!makedir($this->savepath)) {
         return $this->error($_M['word']['upfileFail2']);
     }
     //复制文件
     $upfileok = 0;
     $file_tmp = $filear["tmp_name"];
     $file_name = $this->savepath . $this->savename;
     if (stristr(PHP_OS, "WIN")) {
         $file_name = @iconv("utf-8", "GBK", $file_name);
     }
     if (function_exists("move_uploaded_file")) {
         if (move_uploaded_file($file_tmp, $file_name)) {
             $upfileok = 1;
         } else {
             if (copy($file_tmp, $file_name)) {
                 $upfileok = 1;
             }
         }
     } elseif (copy($file_tmp, $file_name)) {
         $upfileok = 1;
     }
     if (!$upfileok) {
         if (file_put_contents($this->savepath . 'test.txt', 'metinfo')) {
             $_M['word']['upfileOver4'] = $_M['word']['upfileOver5'];
         }
         unlink($this->savepath . 'test.txt');
         $errors = array(0 => $_M['word']['upfileOver4'], 1 => $_M['word']['upfileOver'], 2 => $_M['word']['upfileOver1'], 3 => $_M['word']['upfileOver2'], 4 => $_M['word']['upfileOver3'], 6 => $_M['word']['upfileOver5'], 7 => $_M['word']['upfileOver5']);
         $filear['error'] = $filear['error'] ? $filear['error'] : 0;
         return $this->error($errors[$filear['error']]);
     } else {
         @unlink($filear['tmp_name']);
         //Delete temporary files
     }
     $back = '../' . str_replace(PATH_WEB, '', $this->savepath) . $this->savename;
     return $this->sucess($back);
 }
Пример #19
0
 /**
  * Saves the current entry - flat file implementation.
  *
  * Returns true if successfully saved. Current implementation
  * seems to return true no matter what...
  *
  * @param boolean $update_index Whether to update the date index.
  * @return boolean
  */
 function save_entry($update_index = TRUE)
 {
     $filename = $this->set_filename();
     unset($this->entry['commnames']);
     unset($this->entry['commcount']);
     unset($this->entry['commcount_str']);
     unset($this->entry['tracknames']);
     unset($this->entry['trackcount']);
     unset($this->entry['trackcount_str']);
     unset($this->entry['filename']);
     makedir(dirname($filename));
     save_serialize($filename, $this->entry);
     debug("Save entry '" . $this->entry['title'] . "' (" . $this->entry['code'] . ")");
     $this->update_index();
     $this->write_entry_index();
     if ($update_index) {
         $this->write_date_index();
     }
     return TRUE;
 }
Пример #20
0
makedir("merges/winrt");
makedir("platforms/android");
makedir("platforms/android/res/drawable");
makedir("platforms/android/res/drawable-hdpi");
makedir("platforms/android/res/drawable-ldpi");
makedir("platforms/android/res/drawable-mdpi");
makedir("platforms/android/res/drawable-xhdpi");
makedir("platforms/android/res/drawable-xxhdpi");
makedir("platforms/ios");
makedir("platforms/ios/MonacaApp/Resources/icons");
makedir("platforms/ios/MonacaApp/Resources/splash");
makedir("platforms/winrt");
makedir("platforms/firefoxos");
makedir("platforms/winrt");
makedir("plugins");
makedir("www");
// コピー
chdir($curdir);
$copy = ["project_info.json" => ".monaca/project_info.json", "android/res/" => "platforms/android/res/", "assets/android/AndroidManifest.xml" => "platforms/android/AndroidManifest.xml", "assets/android/config.xml" => "platforms/android/config.xml", "assets/android/splash_default.png" => "platforms/android/splash_default.png", "assets/iOS/config.xml" => "platforms/ios/config.xml", "assets/iOS/MonacaSkeleton-Info.plist" => "platforms/ios/MonacaApp-Info.plist", "assets/www/" => "www/", "iOS/MonacaSkeleton/Icon*" => "platforms/ios/MonacaApp/Resources/icons/", "iOS/MonacaSkeleton/Default*" => "platforms/ios/MonacaApp/Resources/splash/", "winrt/*.png" => "platforms/winrt/"];
foreach ($copy as $from => $to) {
    $command = "rsync -a {$curdir}/{$from} {$newdir}/{$to} 2>&1";
    #echo $command . "\n";
    passthru($command);
}
exec("mv {$curdir} {$curdir}_old");
exec("mv {$newdir} {$curdir}");
function makedir($dir)
{
    echo "Mkdir {$dir}\n";
    @mkdir($dir, 0777, true);
}
Пример #21
0
function checkfile($path, $move) {
 global $dirs;
 global $current_dir;
 global $current_dest;
 global $acc;
 global $ignores;
 global $files_copied;

 foreach($ignores as $ptn) {
  if (preg_match("/".$ptn."/is", $path)) return;
 }

 $tmdiff=0;

 if (!$current_dest) {
  $dest=$dirs[$current_dir];
 } else {
  $dest=$current_dest;
 }

 $path=str_replace('NET:', '//', $path);
 $current_dir=str_replace('NET:', '//', $current_dir);

 $mtime=filemtime($path);

 $dest=str_replace('NET:', '//', $dest);
 $dest=str_replace($current_dir, $dest, $path);
 $dest_path=str_replace(basename($dest), '', $dest);

  $new_dest_path=preparePathTime($dest_path, $mtime);
  $dest=str_replace($dest_path, $new_dest_path, $dest);
  $dest_path=$new_dest_path;


 if (!is_dir2($dest_path)) {
  //echo "\n\n make dir: $dest_path \n\n";
  if (!makedir($dest_path)) return 0;
 }

 if (!file_exists($dest)) {
  echo $path." -> ".$dest." (new)\n";
  copyFile($path, $dest);
 } else {
  $dest_size=filesize($dest);
  $src_size=filesize($path);
  $tmdiff=filemtime($path)-filemtime($dest);
  if ($tmdiff>$acc || ($dest_size==0 && $src_size!=0)) { 
   $status="updated $tmdiff";
   echo $path." -> ".$dest." (updated ".round($tmdiff/60/60, 1)." h)\n";
   copyFile($path, $dest);
  } else {
   //echo $path." -> ".$dest." (OK ".round($tmdiff/60/60, 1)." h)\n";
   $fs=filesize($path);
   if ($fs>(2*1024*1024)) {
    $k=basename($path).'_'.$fs;
    //$files_copied[$k]=$dest;
   }
  }
 }

 if ($move) {
  unlink($path);
 }


}
Пример #22
0
/**
 * 创建目录
 * @param unknown $dir
 * @return boolean
 */
function makedir($dir)
{
    return is_dir($dir) or makedir(dirname($dir)) and mkdir($dir, 0777);
}
Пример #23
0
function createsyms_rec(&$srcdir, &$dstdir, $path)
{
    global $silent;
    global $verbose;
    global $OK;
    global $FAILED;
    global $COLS;
    $dh = @opendir($path);
    while ($file = @readdir($dh)) {
        if ($file != "." && $file != "..") {
            $f = $path . $file;
            if (is_file($f)) {
                /* do not link backupfiles */
                if (!preg_match('/^.*~$/i', $f)) {
                    $targetpath = $dstdir . substr($path, strlen($srcdir));
                    $target = $targetpath . $file;
                    if (!file_exists($targetpath)) {
                        makedir($targetpath);
                    }
                    if (@is_link($target)) {
                        unlink($target);
                    }
                    $symError = "";
                    if (!is_file($target)) {
                        ob_start();
                        $symResult = symlink($f, $target);
                        if (!$symResult) {
                            $symError = str_replace("\n", "", ob_get_contents());
                        }
                        ob_end_clean();
                        if ($symResult) {
                            if ($verbose) {
                                echo str_pad("Creating link: " . basename($target), $COLS) . $OK . "\n";
                            }
                        } else {
                            if (!$silent) {
                                echo str_pad("Creating link: " . substr($path, strlen($srcdir)) . basename($target), $COLS) . $FAILED;
                                echo " ({$symError})\n";
                            }
                        }
                    } else {
                        if (!$silent) {
                            echo str_pad("Creating link: " . substr($path, strlen($srcdir)) . basename($target), $COLS) . $FAILED;
                            echo " (File already exists)\n";
                        }
                    }
                }
            } else {
                if (is_dir($f)) {
                    /* skip CVS directories */
                    if ($file != "CVS" && $file != ".svn" && $file != ".git") {
                        $targetpath = $dstdir . substr("{$path}{$file}/", strlen($srcdir));
                        makedir($targetpath);
                        createsyms_rec($srcdir, $dstdir, "{$f}/");
                    }
                }
            }
        }
    }
    @closedir($dh);
}
Пример #24
0
/**
 * The screen that's shown when we rebuild the search index.
 *
 */
function build_search()
{
    global $Cfg, $filtered_words, $Pivot_Vars;
    PageHeader(lang('adminbar', 'buildsearchindex'), 1);
    PageAnkeiler(lang('adminbar', 'buildsearchindex') . ' &raquo; ' . lang('adminbar', 'buildsearchindex_title'));
    /* JM - Bob said was 300, and was lowered to 200 because of a user
    			with large entries going over PHP's 8Mb variables limit... wow!
    			Is there a more elegant/flexible solution? he asks.
    	*/
    // initialise the threshold.. Initially it's set to 10 * the rebuild_threshold,
    // roughly assuming we index 10 entries per second.
    if (isset($Cfg['rebuild_threshold']) && $Cfg['rebuild_threshold'] > 4) {
        $chunksize = 10 * $Cfg['rebuild_threshold'];
    } else {
        $chunksize = 280;
    }
    @set_time_limit(0);
    echo "<p><strong>" . lang('adminbar', 'buildsearchindex_start') . "</strong><br /><br />\n";
    flush();
    makedir("db/search");
    include_once "modules/module_search.php";
    $start = isset($Pivot_Vars['start']) ? $Pivot_Vars['start'] : 0;
    $stop = $start + $chunksize;
    $time = isset($Pivot_Vars['time']) ? $Pivot_Vars['time'] : 0;
    if ($start == 0) {
        clear_index();
    }
    $continue = start_index($start, $stop, $time);
    write_index(FALSE);
    $time = isset($Pivot_Vars['time']) ? $Pivot_Vars['time'] : 0;
    $time += timetaken('int');
    if ($continue) {
        $myurl = sprintf("index.php?session=%s&menu=admin&func=admin&do=build_search&start=%s&time=%s", $Pivot_Vars['session'], $stop, $time);
        printf('<script> self.location = "%s"; </script>', $myurl);
        //printf('<a href="%s">%s</a>',$myurl,$myurl);
    } else {
        echo "<br /><br />\n\n<p><b>" . str_replace("%num%", $time, lang('adminbar', 'buildindex_finished')) . "</b><br /><br /></p>\n";
    }
    // stuff stops here..
    PageFooter();
}
Пример #25
0
<?php

$tbkey_debug = false;
include_once "../../pv_core.php";
$keydir = $Paths["pivot_path"] . "db/tbkeys/";
$tburl = $Paths["host"] . $Paths["pivot_url"] . "tb.php?tb_id=" . $_GET["id"] . "&amp;key=";
if (!strstr($_SERVER["HTTP_REFERER"], $_SERVER["SERVER_NAME"])) {
    // Creating a bogus key
    $tbkey = md5(microtime());
    debug("hardened trackbacks: illegal request - creating bogus key");
} else {
    makedir($keydir);
    $tbkey = md5($Cfg['server_spam_key'] . $_SERVER["REMOTE_ADDR"] . $_GET["id"] . time());
    if (!touch($keydir . $tbkey)) {
        debug("hardened trackbacks: directory {$keydir} isn't writable - can't create key");
    } else {
        chmod_file($keydir . $tbkey);
    }
}
// Getting the time offset between the web and file server (if there is any)
$offset = timediffwebfile($tbkey_debug);
// delete keys older than 15 minutes
$nNow = time();
$handle = opendir($keydir);
while (false !== ($file = readdir($handle))) {
    $filepath = $keydir . $file;
    if (!is_dir($filepath) && $file != "index.html") {
        $Diff = $nNow - filectime($filepath);
        if ($Diff > 60 * 15 + $offset && $tbkey_debug != true) {
            unlink($filepath);
        }
Пример #26
0
function makedir($strFilePath, $arrDir = array(), $num = 0)
{
    //传入文件路径
    $arrDir[$num] = dirname($strFilePath);
    if (file_exists($arrDir[$num])) {
        for ($i = $num - 1; $i >= 0; $i--) {
            !file_exists($arrDir[$i]) && @mkdir($arrDir[$i], 0755);
        }
        return true;
    }
    return makedir($arrDir[$num], $arrDir, ++$num);
}
Пример #27
0
/**
 * Generates the footer for the XML feeds and saves to file.
 *
 * @uses feedtemplate loads the footer template for XML feeds.
 */
function finish_rss()
{
    global $rss, $rss_items, $atom, $atom_items, $Weblogs, $Current_weblog, $VerboseGenerate, $Cfg;
    //write out the rss
    if ($Weblogs[$Current_weblog]['rss_filename'] != "") {
        krsort($rss_items);
        // If the undocumented 'limit_feed_items' option is set, we slice the items to
        // a difined number, effectively limiting the maximum length of the feed
        if (isset($Cfg['limit_feed_items']) && $Cfg['limit_feed_items'] > 0) {
            $rss_items = array_slice($rss_items, 0, intval($Cfg['limit_feed_items']));
        }
        foreach ($rss_items as $item) {
            $rss .= $item;
        }
        $rss .= feedtemplate('feed_rss_template.xml', 'footer');
        $filename = $Weblogs[$Current_weblog]['rss_path'] . $Weblogs[$Current_weblog]['rss_filename'];
        debug("Write RSS: {$filename}");
        //make sure the directory exists
        makedir($Weblogs[$Current_weblog]['rss_path']);
        write_file($filename, $rss);
    }
    //write out the atom feed
    if ($Weblogs[$Current_weblog]['atom_filename'] != "") {
        krsort($atom_items);
        // If the undocumented 'limit_feed_items' option is set, we slice the items to
        // a difined number, effectively limiting the maximum length of the feed
        if (isset($Cfg['limit_feed_items']) && $Cfg['limit_feed_items'] > 0) {
            $atom_items = array_slice($atom_items, 0, intval($Cfg['limit_feed_items']));
        }
        foreach ($atom_items as $item) {
            $atom .= $item;
        }
        $atom .= feedtemplate('feed_atom_template.xml', 'footer');
        $filename = $Weblogs[$Current_weblog]['rss_path'] . $Weblogs[$Current_weblog]['atom_filename'];
        debug("Write Atom: {$filename}");
        write_file($filename, $atom);
    }
}
Пример #28
0
function makedir($name)
{
    // if it exists, just return.
    if (file_exists($name)) {
        return;
    }
    // if more than one level, try parent first..
    if (dirname($name) != ".") {
        makedir(dirname($name));
    }
    $oldumask = umask(0);
    @mkdir($name, 0777);
    @chmod($name, 0777);
    umask($oldumask);
}
Пример #29
0
    exit;
}
if (isset($_GET["squidstats-test-nas"])) {
    squidstats_tests_nas();
    exit;
}
if (isset($_GET["execute-debian-mirror-rsync"])) {
    debian_mirror_execute_rsync();
    exit;
}
if (isset($_GET["recompile-postfix"])) {
    recompile_postfix();
    exit;
}
if (isset($_GET["makedir"])) {
    makedir();
    exit;
}
if (isset($_GET["restart-arp-daemon"])) {
    restart_arpd();
    exit;
}
if (isset($_GET["restart-phpfpm"])) {
    restart_phpfpm();
    exit;
}
if (isset($_GET["restart-vnstat"])) {
    restart_vnstat();
    exit;
}
if (isset($_GET["restart-winbindd"])) {
Пример #30
0
				p = document.getElementById("pbar");
				p.innerHTML = '<?php 
    echo "<br><br><center><img src={$include_path}style/images/progress-bar.gif><br>" . word("Please wait") . "...</center>";
    ?>
';									
				-->
			</SCRIPT>
			<?php 
    if (stristr($image, "http://")) {
        if (substr($podcast_folder, 0, 1) != "/") {
            $dir = str_replace("\\", "/", getcwd()) . "/" . $podcast_folder . "/" . $title;
        } else {
            $dir = $podcast_folder . "/" . $title;
        }
        // Now let's create the directory we need
        makedir($dir);
        $imgFile = $dir . "/" . $title . ".jpg";
        $iData = file_get_contents($image);
        $handle = fopen($imgFile, "w");
        fwrite($handle, $iData);
        fclose($handle);
    }
    // Now let's create the node in the backend and assign it some values
    $newNode = new jzMediaNode($node->getPath("string") . "/" . $_POST['edit_podcast_path']);
    $newNode->addDescription($desc);
    $newNode->addMainArt($imgFile);
    // Now let's loop and look at each enclosure
    $i = 1;
    foreach ($retArray as $item) {
        // Let's grab it
        $track = getPodcastData($item, $title);