Ejemplo n.º 1
0
function typeoffile($file)
{
    if (file_type($file, "jpg|jpeg|png|gif")) {
        return "img";
    } else {
        if (file_type($file, "html|htm")) {
            return "html";
        } else {
            if (file_type($file, "doc")) {
                return "doc";
            } else {
                if (file_type($file, "pdf")) {
                    return "pdf";
                } else {
                    if (file_type($file, "chm")) {
                        return "chm";
                    } else {
                        if (file_type($file, "zip|gz|rar")) {
                            return "zip";
                        } else {
                            return "file";
                        }
                    }
                }
            }
        }
    }
}
function git_commitdiff($projectroot, $project, $hash, $hash_parent)
{
    global $tpl;
    $cachekey = sha1($project) . "|" . $hash . "|" . $hash_parent;
    $git = new Git($projectroot . $project);
    $hash = sha1_bin($hash);
    if (isset($hash_parent)) {
        $hash_parent = sha1_bin($hash_parent);
    }
    if (!$tpl->is_cached('commitdiff.tpl', $cachekey)) {
        $co = git_read_commit($git, $hash);
        $ad = date_str($co['author_epoch']);
        $tpl->assign('committer', $co['committer']);
        $tpl->assign('rfc2822', $ad['rfc2822']);
        if (!isset($hash_parent) && isset($co['parent'])) {
            $hash_parent = sha1_bin($co['parent']);
        }
        $a_tree = isset($hash_parent) ? $git->getObject($hash_parent)->getTree() : array();
        $b_tree = $git->getObject(sha1_bin($co['tree']));
        $difftree = GitTree::diffTree($a_tree, $b_tree);
        $tpl->assign("hash", sha1_hex($hash));
        $tpl->assign("tree", $co['tree']);
        $tpl->assign("hashparent", sha1_hex($hash_parent));
        $tpl->assign("title", $co['title']);
        $refs = read_info_ref($git);
        if (isset($refs[$hash])) {
            $tpl->assign("commitref", $refs[$hash]);
        }
        $tpl->assign("comment", $co['comment']);
        $difftreelines = array();
        $status_map = array(GitTree::TREEDIFF_ADDED => "A", GitTree::TREEDIFF_REMOVED => "D", GitTree::TREEDIFF_CHANGED => "M");
        foreach ($difftree as $file => $diff) {
            $difftreeline = array();
            $difftreeline["from_mode"] = decoct($diff->old_mode);
            $difftreeline["to_mode"] = decoct($diff->new_mode);
            $difftreeline["from_id"] = sha1_hex($diff->old_obj);
            $difftreeline["to_id"] = sha1_hex($diff->new_obj);
            $difftreeline["status"] = $status_map[$diff->status];
            $difftreeline["file"] = $file;
            $difftreeline["md5"] = md5($file);
            $difftreeline["from_type"] = file_type($difftreeline["from_mode"]);
            $difftreeline["to_type"] = file_type($difftreeline["to_mode"]);
            if ($diff->status == GitTree::TREEDIFF_ADDED) {
                $difftreeline['diffout'] = explode("\n", git_diff($git, null, "/dev/null", $diff->new_obj, "b/" . $file));
            } else {
                if ($diff->status == GitTree::TREEDIFF_REMOVED) {
                    $difftreeline['diffout'] = explode("\n", git_diff($git, $diff->old_obj, "a/" . $file, null, "/dev/null"));
                } else {
                    if ($diff->status == GitTree::TREEDIFF_CHANGED && $diff->old_obj != $diff->new_obj) {
                        $difftreeline['diffout'] = explode("\n", git_diff($git, $diff->old_obj, "a/" . $file, $diff->new_obj, "b/" . $file));
                    }
                }
            }
            $difftreelines[] = $difftreeline;
        }
        $tpl->assign("difftreelines", $difftreelines);
    }
    $tpl->display('commitdiff.tpl', $cachekey);
}
Ejemplo n.º 3
0
function in_blacklist_file($item)
{
    global $whitelist_fileext;
    $item = strtolower($item);
    $ext = file_type($item);
    if (in_array($ext, $whitelist_fileext) === true) {
        return false;
    }
    return true;
}
Ejemplo n.º 4
0
function git_commitdiff($projectroot, $project, $hash, $hash_parent)
{
    global $tpl;
    $cachekey = sha1($project) . "|" . $hash . "|" . $hash_parent;
    if (!$tpl->is_cached('commitdiff.tpl', $cachekey)) {
        $ret = prep_tmpdir();
        if ($ret !== TRUE) {
            echo $ret;
            return;
        }
        $co = git_read_commit($projectroot . $project, $hash);
        if (!isset($hash_parent)) {
            $hash_parent = $co['parent'];
        }
        $diffout = git_diff_tree($projectroot . $project, $hash_parent . " " . $hash);
        $difftree = explode("\n", $diffout);
        $refs = read_info_ref($projectroot . $project);
        $tpl->assign("hash", $hash);
        $tpl->assign("tree", $co['tree']);
        $tpl->assign("hashparent", $hash_parent);
        $tpl->assign("title", $co['title']);
        if (isset($refs[$co['id']])) {
            $tpl->assign("commitref", $refs[$co['id']]);
        }
        $tpl->assign("comment", $co['comment']);
        $difftreelines = array();
        foreach ($difftree as $i => $line) {
            if (preg_match("/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)\$/", $line, $regs)) {
                $difftreeline = array();
                $difftreeline["from_mode"] = $regs[1];
                $difftreeline["to_mode"] = $regs[2];
                $difftreeline["from_id"] = $regs[3];
                $difftreeline["to_id"] = $regs[4];
                $difftreeline["status"] = $regs[5];
                $difftreeline["file"] = $regs[6];
                $difftreeline["from_type"] = file_type($regs[1]);
                $difftreeline["to_type"] = file_type($regs[2]);
                if ($regs[5] == "A") {
                    $difftreeline['diffout'] = explode("\n", git_diff($projectroot . $project, null, "/dev/null", $regs[4], "b/" . $regs[6]));
                } else {
                    if ($regs[5] == "D") {
                        $difftreeline['diffout'] = explode("\n", git_diff($projectroot . $project, $regs[3], "a/" . $regs[6], null, "/dev/null"));
                    } else {
                        if ($regs[5] == "M" && $regs[3] != $regs[4]) {
                            $difftreeline['diffout'] = explode("\n", git_diff($projectroot . $project, $regs[3], "a/" . $regs[6], $regs[4], "b/" . $regs[6]));
                        }
                    }
                }
                $difftreelines[] = $difftreeline;
            }
        }
        $tpl->assign("difftreelines", $difftreelines);
    }
    $tpl->display('commitdiff.tpl', $cachekey);
}
 function list_files()
 {
     $path = "images/";
     $file_types = array('jpeg', 'jpg', 'ico', 'png', 'gif', 'bmp');
     $p = opendir($path);
     while (false !== ($filename = readdir($p))) {
         $files[] = $filename;
     }
     sort($files);
     foreach ($files as $file) {
         $extension = file_type($file);
         if ($file != '.' && $file != '..' && array_search($extension, $file_types)) {
             $file_count++;
             echo '<a href="' . $path . $file . '"><img src="' . $path . $file . '"></a> <br/>';
         }
     }
 }
Ejemplo n.º 6
0
 function filedesc($fname = '')
 {
     global $streamtypes;
     if (strlen($fname) > 0) {
         $this->fid = file_type($fname);
     } else {
         $this->fid = -1;
     }
     $this->extension = '';
     $this->found = false;
     $this->mime = 0;
     $this->gid = 0;
     $this->m3u = 0;
     $this->view = 0;
     $this->logaccess = 0;
     if ($this->fid != -1) {
         $this->found = true;
         $this->extension = $streamtypes[$this->fid][0];
         $this->mime = $streamtypes[$this->fid][1];
         $this->m3u = $streamtypes[$this->fid][2];
         $this->gid = $streamtypes[$this->fid][3];
         $this->view = $streamtypes[$this->fid][4];
         $this->logaccess = $streamtypes[$this->fid][5];
     }
 }
Ejemplo n.º 7
0
// Подключение к базе данных;
include $_SERVER['DOCUMENT_ROOT'] . '/systems/connect.php';
if (isset($_GET['banner_id'])) {
    // Загрузка выбранного баннера;
    $sql = "CALL banner(NULL, '" . $_GET['banner_id'] . "');";
    if ($banner = $db->row($sql)) {
        // Вывод файла;
        die($banner['file']);
    }
} else {
    // Загрузка следующего баннера;
    $sql = "CALL banner('" . $club['id'] . "', NULL);";
    if ($banner = $db->row($sql)) {
        // Определение типа файла;
        $banner['type'] = file_type($banner['file'], true);
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="rus" lang="rus" style="overflow: hidden;">
 <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv="Refresh" content="3600" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <script type="text/javascript" src="/systems/jquery/jquery.js"></script>
  <script type="text/javascript">
  $(document).ready(function() {
    $("#shadow").css("opacity", "0");
  });
Ejemplo n.º 8
0
<?php

include '../../include.php';
if ($posting) {
    if ($_GET['doc_id'] == 'new') {
        $_GET['doc_id'] = false;
    }
    if ($uploading) {
        $_POST['extension'] = file_type($_FILES['content']['name']);
        $_POST['content'] = file_get_uploaded('content');
    }
    $id = db_save('dl_docs', @$_GET['doc_id']);
    db_checkboxes('categories', 'dl_docs_to_categories', 'doc_id', 'category_id', $id);
    url_drop('id');
} elseif (url_action('delete')) {
    db_delete('dl_docs');
    url_drop('id,action');
}
echo drawTop();
if (!empty($_GET['doc_id'])) {
    if ($_GET['doc_id'] == 'new') {
        $_GET['doc_id'] = false;
    }
    $f = new form('dl_docs', @$_GET['doc_id'], ($_GET['doc_id'] ? 'Edit' : 'Add') . ' Document');
    $f->set_title_prefix($page['breadcrumbs']);
    $f->set_field(array('name' => 'title', 'label' => getString('title'), 'type' => 'text'));
    $f->unset_fields('extension');
    $f->set_field(array('name' => 'content', 'label' => getString('file'), 'type' => 'file', 'additional' => getString('upload_max') . file_get_max()));
    $f->set_field(array('name' => 'categories', 'label' => getString('categories'), 'type' => 'checkboxes', 'options_table' => 'dl_categories', 'option_title' => 'title', 'linking_table' => 'dl_docs_to_categories', 'object_id' => 'doc_id', 'option_id' => 'category_id'));
    echo $f->draw();
} else {
Ejemplo n.º 9
0
    }
}
if (!$contents) {
    exit('<div class="error_msg">' . $lang_check_cantLocate . '</div>');
}
if (ob_get_level() == 0) {
    ob_start();
}
foreach ($contents as $value) {
    if (in_array($value, $garbage)) {
        continue;
    }
    $dirPath = str_replace($prefix, '', $value);
    $onlyFileName = strrchr($value, '/');
    $file_date = date("m/d/Y H:i:s", filectime($value));
    $file_type = file_type($onlyFileName);
    $clean_title = clean_title($onlyFileName);
    $datafile = $prefix . 'data' . $onlyFileName . '.txt';
    if (file_exists($datafile)) {
        continue;
    }
    debugWrite('[DEBUG] <b>Name:</b>' . $clean_title . ' <b>File:</b>' . $onlyFileName . ' <b>Type:</b>' . $file_type);
    if ($settings_data['imdb_mode'] == 'false') {
        touch($datafile);
        continue;
    }
    debugWrite(' [' . $lang_check_debugCreateFile . ']<BR>');
    $fh = fopen($datafile, 'a') or die($lang_check_notWritable);
    $movieArray = $imdb->getMovieInfo($clean_title, 2);
    $genres = implode(',', $movieArray['genres']);
    $stringData = $file_date . PHP_EOL . $movieArray['title'] . PHP_EOL . $file_type . PHP_EOL . $movieArray['title_id'] . PHP_EOL . $genres . PHP_EOL . $movieArray['rating'] . PHP_EOL . $dirPath . PHP_EOL . $movieArray['movie_rating'] . PHP_EOL . $movieArray['plot'];
Ejemplo n.º 10
0
function thumb_crop($filename, $desired_width, $desired_height, $bordersize, $position)
{
    // Get new dimensions
    $type = file_type($filename);
    list($width, $height) = getimagesize($filename);
    if ($desired_width / $desired_height > $width / $height) {
        $new_width = $desired_width;
        $new_height = $height * ($desired_width / $width);
    } else {
        $new_width = $width * ($desired_height / $height);
        $new_height = $desired_height;
    }
    // Resize
    $image_p = imagecreatetruecolor($new_width, $new_height);
    $image_f = imagecreatetruecolor($desired_width, $desired_height);
    $image = createImage($filename);
    if ($type == 'image/gif' or $type == 'image/png') {
        imagecolortransparent($image_p, imagecolorallocatealpha($image_p, 0, 0, 0, 127));
        imagealphablending($image_p, false);
        imagesavealpha($image_p, true);
        imagecolortransparent($image_f, imagecolorallocatealpha($image_f, 0, 0, 0, 127));
        imagealphablending($image_f, false);
        imagesavealpha($image_f, true);
    }
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
    // Adjust position
    switch ($position) {
        case "topleft":
            $x = $bordersize;
            $y = $bordersize;
            break;
        case "topright":
            $x = $new_width - $desired_width + $bordersize;
            $y = $bordersize;
            break;
        case "bottomleft":
            $x = $bordersize;
            $y = $new_height - $desired_height + $bordersize;
            break;
        case "bottomright":
            $x = $new_width - $desired_width + $bordersize;
            $y = $new_height - $desired_height + $bordersize;
            break;
        case "center":
            $x = ($new_width - $desired_width) / 2 + $bordersize;
            $y = ($new_height - $desired_height) / 2 + $bordersize;
            break;
    }
    // Resample with 1px border
    imagecopyresampled($image_f, $image_p, $bordersize, $bordersize, $x, $y, $desired_width - 2 * $bordersize, $desired_height - 2 * $bordersize, $desired_width - 2 * $bordersize, $desired_height - 2 * $bordersize);
    return $image_f;
}
Ejemplo n.º 11
0
function git_commit($projectroot, $project, $hash)
{
    global $tpl;
    $cachekey = sha1($project) . "|" . $hash;
    if (!$tpl->is_cached('commit.tpl', $cachekey)) {
        $co = git_read_commit($projectroot . $project, $hash);
        $ad = date_str($co['author_epoch'], $co['author_tz']);
        $cd = date_str($co['committer_epoch'], $co['committer_tz']);
        if (isset($co['parent'])) {
            $root = "";
            $parent = $co['parent'];
        } else {
            $root = "--root";
            $parent = "";
        }
        $diffout = git_diff_tree($projectroot . $project, $root . " " . $parent . " " . $hash, TRUE);
        $difftree = explode("\n", $diffout);
        $tpl->assign("hash", $hash);
        $tpl->assign("tree", $co['tree']);
        if (isset($co['parent'])) {
            $tpl->assign("parent", $co['parent']);
        }
        $tpl->assign("title", $co['title']);
        $refs = read_info_ref($projectroot . $project);
        if (isset($refs[$co['id']])) {
            $tpl->assign("commitref", $refs[$co['id']]);
        }
        $tpl->assign("author", $co['author']);
        $tpl->assign("adrfc2822", $ad['rfc2822']);
        $tpl->assign("adhourlocal", $ad['hour_local']);
        $tpl->assign("adminutelocal", $ad['minute_local']);
        $tpl->assign("adtzlocal", $ad['tz_local']);
        $tpl->assign("committer", $co['committer']);
        $tpl->assign("cdrfc2822", $cd['rfc2822']);
        $tpl->assign("cdhourlocal", $cd['hour_local']);
        $tpl->assign("cdminutelocal", $cd['minute_local']);
        $tpl->assign("cdtzlocal", $cd['tz_local']);
        $tpl->assign("id", $co['id']);
        $tpl->assign("repository", preg_replace('/^([a-zA-Z0-9\\-\\_]+).git$/', '$1', $project));
        $tpl->assign("parents", $co['parents']);
        $tpl->assign("comment", $co['comment']);
        $tpl->assign("difftreesize", count($difftree) + 1);
        $difftreelines = array();
        foreach ($difftree as $i => $line) {
            if (preg_match("/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)\$/", $line, $regs)) {
                $difftreeline = array();
                $difftreeline["from_mode"] = $regs[1];
                $difftreeline["to_mode"] = $regs[2];
                $difftreeline["from_mode_cut"] = substr($regs[1], -4);
                $difftreeline["to_mode_cut"] = substr($regs[2], -4);
                $difftreeline["from_id"] = $regs[3];
                $difftreeline["to_id"] = $regs[4];
                $difftreeline["status"] = $regs[5];
                $difftreeline["similarity"] = ltrim($regs[6], "0");
                $difftreeline["file"] = $regs[7];
                $difftreeline["from_file"] = strtok($regs[7], "\t");
                $difftreeline["from_filetype"] = file_type($regs[1]);
                $difftreeline["to_file"] = strtok("\t");
                $difftreeline["to_filetype"] = file_type($regs[2]);
                if ((octdec($regs[2]) & 0x8000) == 0x8000) {
                    $difftreeline["isreg"] = TRUE;
                }
                $modestr = "";
                if ((octdec($regs[1]) & 0x17000) != (octdec($regs[2]) & 0x17000)) {
                    $modestr .= " from " . file_type($regs[1]) . " to " . file_type($regs[2]);
                }
                if ((octdec($regs[1]) & 0777) != (octdec($regs[2]) & 0777)) {
                    if (octdec($regs[1]) & 0x8000 && octdec($regs[2]) & 0x8000) {
                        $modestr .= " mode: " . (octdec($regs[1]) & 0777) . "->" . (octdec($regs[2]) & 0777);
                    } else {
                        if (octdec($regs[2]) & 0x8000) {
                            $modestr .= " mode: " . (octdec($regs[2]) & 0777);
                        }
                    }
                }
                $difftreeline["modechange"] = $modestr;
                $simmodechg = "";
                if ($regs[1] != $regs[2]) {
                    $simmodechg .= ", mode: " . (octdec($regs[2]) & 0777);
                }
                $difftreeline["simmodechg"] = $simmodechg;
                $difftreelines[] = $difftreeline;
            }
        }
        $tpl->assign("difftreelines", $difftreelines);
    }
    $tpl->display('commit.tpl', $cachekey);
}
Ejemplo n.º 12
0
if(isset($_GET["filemd5"])){FILE_MD5();exit;}
if(isset($_GET["read-file"])){ReadFromfile();exit;}



if(isset($_GET["lvs-all"])){LVM_lVS_INFO_ALL();exit;}
if(isset($_GET["lv-resize-add"])){LVM_LV_ADDSIZE();exit;}
if(isset($_GET["lv-resize-red"])){LVM_LV_DELSIZE();exit;}
if(isset($_GET["disk-ismounted"])){disk_ismounted();exit;}
if(isset($_GET["disks-quotas-list"])){disks_quotas_list();exit;}
if(isset($_GET["dfmoinshdev"])){disks_dfmoinshdev();exit;}



if(isset($_GET["filesize"])){file_size();exit;}
if(isset($_GET["filetype"])){file_type();exit;}
if(isset($_GET["mime-type"])){mime_type();exit;}

if(isset($_GET["sync-remote-smtp-artica"])){postfix_sync_artica();exit;}

//etc/hosts
if(isset($_GET["etc-hosts-open"])){etc_hosts_open();exit;}
if(isset($_GET["etc-hosts-add"])){etc_hosts_add();exit;}
if(isset($_GET["etc-hosts-del"])){etc_hosts_del();exit;}
if(isset($_GET["etc-hosts-del-by-values"])){etc_hosts_del_by_values();exit;}



if(isset($_GET["full-hostname"])){hostname_full();exit;}

//computers
Ejemplo n.º 13
0
    exit;
}
if (isset($_GET["lv-resize-red"])) {
    LVM_LV_DELSIZE();
    exit;
}
if (isset($_GET["disk-ismounted"])) {
    disk_ismounted();
    exit;
}
if (isset($_GET["filesize"])) {
    file_size();
    exit;
}
if (isset($_GET["filetype"])) {
    file_type();
    exit;
}
if (isset($_GET["mime-type"])) {
    mime_type();
    exit;
}
if (isset($_GET["sync-remote-smtp-artica"])) {
    postfix_sync_artica();
    exit;
}
//etc/hosts
if (isset($_GET["etc-hosts-open"])) {
    etc_hosts_open();
    exit;
}
Ejemplo n.º 14
0
function material_photo_upload()
{
    global $_MooClass, $dbTablePre, $userid, $user, $pic_size_arr, $user_arr, $memcached;
    $and_uuid = isset($_GET['uuid']) ? $_GET['uuid'] : '';
    $uid = $_GET['uid'] = isset($_GET['uid']) ? $_GET['uid'] : '';
    if ($uid) {
        $userid = $mem_uid = $memcached->get('uid_' . $uid);
    }
    $checkuuid = check_uuid($and_uuid, $userid);
    if (!$checkuuid) {
        $error = "uuid_error";
        echo return_data($error, false);
        exit;
    }
    $user_arr = $user = MooMembersData($userid);
    $user_rank_id = get_userrank($userid);
    if (MOOPHP_ALLOW_FASTDB) {
        $usercer = MooFastdbGet('certification', 'uid', $userid);
    } else {
        $usercer = $_MooClass['MooMySQL']->getOne("SELECT * FROM {$dbTablePre}certification WHERE uid='{$userid}' LIMIT 1 ", true);
    }
    if ($_POST['isupload'] == '1') {
        //note 设定用户id
        $memberid = $userid;
        //note 设定用户上传图片大小限制 最小10240字节 = 10k 最大419430字节 = 400K
        $minfilesize = 20480;
        $maxfilesize = 1024000;
        $filesize = $_FILES['userfile']['size'];
        if ($filesize > $maxfilesize) {
            $notice = "请上传小于1000KB的照片。";
            echo return_data($notice);
            exit;
        }
        if ($filesize < $minfilesize) {
            $notice = "请上传大于20KB的照片。";
            echo return_data($notice);
            exit;
        }
        //note 判断文件类型
        $flag = '';
        $true_type = file_type($_FILES['userfile']['tmp_name']);
        $extname = strtolower(substr($_FILES['userfile']['name'], strrpos($_FILES['userfile']['name'], '.') + 1));
        $images = array('/jpg/', '/jpeg/', '/gif/', '/png/', '/JPG/', '/JPEG/', '/GIF/', '/PNG/');
        if (in_array('/' . $extname . '/', $images)) {
            foreach ($images as $v) {
                //note http://ask.wangmeng.cn/question/76
                if (preg_match($v, $_FILES['userfile']['type']) && ('image/' . $true_type == $_FILES['userfile']['type'] || 'image/p' . $true_type == $_FILES['userfile']['type'] || 'image/x-' . $true_type == $_FILES['userfile']['type'])) {
                    $file_content = file_get_contents($_FILES['userfile']['tmp_name']);
                    $low_file_content = strtolower($file_content);
                    $pos = strpos($low_file_content, '<?php');
                    if ($pos) {
                        $notice = "照片中含有不安全信息请重新上传";
                        echo return_data($notice);
                        exit;
                    } else {
                        $flag = 1;
                    }
                }
            }
        }
        //echo $true_type,'_',$flag,'_',$_FILES['userfile']['type'];exit;
        if ($flag != 1) {
            $notice = "请上传JPEG,JPG,PNG或GIF格式";
            echo return_data($notice);
            exit;
        }
        //note 设定该用户最多上传20张图片(形象照除外)
        $maxuploadnum = 20;
        //note 查询出来的总数
        $query = $_MooClass['MooMySQL']->getOne("select count(1) as num from `{$dbTablePre}pic` where `uid` = '{$memberid}' AND `isimage` = '0'", true);
        $total = $query['num'];
        //note 还可以上传多少张
        $leave_num = $maxuploadnum - $total;
        if ($leave_num <= 0) {
            $notice = '您已经有' . $maxuploadnum . '张照片了,';
            if ($user_arr['mainimg']) {
                $notice .= '不可以再上传了。';
            } else {
                $notice .= '请在相册中选一张作为形象照。';
            }
            echo return_data($notice);
            exit;
        }
        //note 设定相册名
        $album = '';
        //note 设定全局路径
        $orgin = "orgin";
        //note 原图文件夹名
        $thumb_path = PIC_PATH;
        //图片路径
        $timestat = time();
        $thumb_datedir = date("Y", $timestat) . "/" . date("m", $timestat) . "/" . date("d", $timestat);
        //原图路径
        $main_img_path = $thumb_path . "/" . $thumb_datedir . "/" . $orgin . "/";
        //note 调用文件操作类库,建立无限级目录
        $mkdirs = MooAutoLoad('MooFiles');
        !is_dir($main_img_path) && $mkdirs->fileMake($main_img_path, 0777);
        //note 上传到指定目录(原图),并且获得上传后的文件描述
        $upload = MooAutoLoad('MooUpload');
        $upload->config(array('targetDir' => $main_img_path, 'saveType' => '0'));
        $files = $upload->saveFiles('userfile');
        //note 获得图片路径和缩略图的路径
        $imgurl = $files[0]['path'] . $files[0]['name'] . "." . $files[0]['extension'];
        if ($files[0]['extension'] == 'gif') {
            $output = imagecreatefromgif($imgurl);
            imagegif($output, $imgurl, 100);
            imagedestroy($output);
        }
        $imgurl2 = $files[0]['path'] . $files[0]['name'] . "_nowater." . $files[0]['extension'];
        @copy($imgurl, $imgurl2);
        //拷贝一张无水印图片(用于形象照)
        $pic_name = $files[0]['name'] . "." . $files[0]['extension'];
        $pic_name2 = $files[0]['name'] . "_nowater." . $files[0]['extension'];
        $first = new Imagick($imgurl);
        //写入水印
        $second = new Imagick('public/system/images/logo_original.png');
        //$second->setImageOpacity (0.4);//设置透明度
        $dw = new ImagickDraw();
        $dw->setGravity(Imagick::GRAVITY_SOUTHEAST);
        //设置位置
        //$dw->setGravity(Imagick::GRAVITY_SOUTH);//设置位置
        $dw->composite($second->getImageCompose(), 0, 0, 50, 0, $second);
        $first->drawImage($dw);
        $first->writeImage($imgurl);
        //将第一张图片的大小控制成我们需要的大小
        list($width, $height) = getimagesize($imgurl);
        $d = $width / $height;
        $off_wh = off_WH($width, $height);
        $new_width = $off_wh['width'];
        $new_height = $off_wh['height'];
        unset($off_wh);
        $big_path = $files[0]['path'];
        $big_name = $files[0]['name'] . '.' . $files[0]['extension'];
        $image = MooAutoLoad('MooImage');
        $image->config(array('thumbDir' => $big_path, 'thumbStatus' => '1', 'saveType' => '0', 'thumbName' => $pic_name, 'waterMarkMinWidth' => '41', 'waterMarkMinHeight' => '57', 'waterMarkStatus' => 9));
        $image->thumb($new_width, $new_height, $imgurl);
        $image->waterMark();
        //note 缩略无水印图片
        $image->config(array('thumbDir' => $big_path, 'thumbStatus' => '1', 'saveType' => '0', 'thumbName' => $pic_name2, 'waterMarkMinWidth' => '41', 'waterMarkMinHeight' => '57', 'waterMarkStatus' => 9));
        $image->thumb($new_width, $new_height, $imgurl2);
        $image->waterMark();
        $thumb1_width = $pic_size_arr["1"]["width"];
        $thumb1_height = $pic_size_arr["1"]["height"];
        $thumb2_width = $pic_size_arr["2"]["width"];
        $thumb2_height = $pic_size_arr["2"]["height"];
        $thumb3_width = $pic_size_arr["3"]["width"];
        $thumb3_height = $pic_size_arr["3"]["height"];
        //note 生成日期目录
        $thumb1_path = $thumb_path . "/" . $thumb_datedir . "/" . $thumb1_width . "_" . $thumb1_height . "/";
        $thumb2_path = $thumb_path . "/" . $thumb_datedir . "/" . $thumb2_width . "_" . $thumb2_height . "/";
        $thumb3_path = $thumb_path . "/" . $thumb_datedir . "/" . $thumb3_width . "_" . $thumb3_height . "/";
        !is_dir($thumb1_path) && $mkdirs->fileMake($thumb1_path, 0777);
        !is_dir($thumb2_path) && $mkdirs->fileMake($thumb2_path, 0777);
        !is_dir($thumb3_path) && $mkdirs->fileMake($thumb3_path, 0777);
        //note 缩略图文件名
        $thumb_filename = md5($files[0]['name']) . "." . $files[0]['extension'];
        $c = 41 / 57;
        if ($d > $c) {
            $thumb1_width = 41;
            $b = $width / $thumb1_width;
            $thumb1_height = $height / $b;
        } else {
            $thumb1_height = 57;
            $b = $height / $thumb1_height;
            $thumb1_width = $width / $b;
        }
        $image->config(array('thumbDir' => $thumb1_path, 'thumbStatus' => '1', 'saveType' => '0', 'thumbName' => $thumb_filename, 'waterMarkMinWidth' => '41', 'waterMarkMinHeight' => '57', 'waterMarkStatus' => 9));
        $image->thumb($thumb1_width, $thumb1_height, $imgurl);
        $image->waterMark();
        $c = 139 / 189;
        if ($d > $c) {
            $thumb2_width = 139;
            $b = $width / $thumb2_width;
            $thumb2_height = $height / $b;
        } else {
            $thumb2_height = 189;
            $b = $height / $thumb2_height;
            $thumb2_width = $width / $b;
        }
        $image->config(array('thumbDir' => $thumb2_path, 'thumbStatus' => '1', 'saveType' => '0', 'thumbName' => $thumb_filename, 'waterMarkMinWidth' => '139', 'waterMarkMinHeight' => '189', 'waterMarkStatus' => 9));
        $image->thumb($thumb2_width, $thumb2_height, $imgurl);
        $image->waterMark();
        $c = 171 / 244;
        if ($d > $c) {
            $thumb3_width = 171;
            $b = $width / $thumb3_width;
            $thumb3_height = $height / $b;
        } else {
            $thumb3_height = 244;
            $b = $height / $thumb3_height;
            $thumb3_width = $width / $b;
        }
        $image->config(array('thumbDir' => $thumb3_path, 'thumbStatus' => '1', 'saveType' => '0', 'thumbName' => $thumb_filename, 'waterMarkMinWidth' => '171', 'waterMarkMinHeight' => '244', 'waterMarkStatus' => 9));
        $image->thumb($thumb3_width, $thumb3_height, $imgurl);
        $image->waterMark();
        //note 设定是否是形象照 1为形象照,0为普通照
        $isimage = (int) $_POST['isimage'];
        $updatetime = time();
        if ($isimage === 1) {
            $_MooClass['MooMySQL']->query("update `{$dbTablePre}members_base` set `mainimg`='{$imgurl}',`pic_date` = '{$thumb_datedir}',`pic_name` = '{$pic_name}' where `uid` = '{$memberid}'");
            $_MooClass['MooMySQL']->query("update `{$dbTablePre}members_search` set images_ischeck='2'  where `uid` = '{$memberid}'");
            if (MOOPHP_ALLOW_FASTDB) {
                $image_arr = array();
                $image_arr['mainimg'] = $imgurl;
                $image_arr['pic_date'] = $thumb_datedir;
                $image_arr['pic_name'] = $pic_name;
                $members_search['images_ischeck'] = '2';
                MooFastdbUpdate('members_base', 'uid', $memberid, $image_arr);
                MooFastdbUpdate('members_search', 'uid', $memberid, $members_search);
            }
            searchApi("members_man members_women")->updateAttr(array('images_ischeck'), array($memberid => array(0)));
            UpdateMembersSNS($userid, '修改了形象照');
        }
        //note 写入相册表
        $isimage = 0;
        //web_members.mainimg == web_pic.imgurl 即形象照
        $_MooClass['MooMySQL']->query("insert into `{$dbTablePre}pic` set `uid` = '{$memberid}',`isimage` = '{$isimage}',`album` = '{$album}',`imgurl` = '{$imgurl}',`pic_date` = '{$thumb_datedir}',`pic_name` = '{$pic_name}'");
        //提交会员动态makui
        UpdateMembersSNS($userid, '修改了相册');
        $notice = "成功";
        echo return_data($notice);
        exit;
    } else {
        $user1 = $user_arr;
    }
}
Ejemplo n.º 15
0
function image_resize($file, $width, $height = false)
{
    // Создание изображения на основе исходного файла;
    if (!file_exists($file)) {
        return false;
    }
    // Проверка расширения;
    if (in_array(file_type($file), array('jpg', 'jpeg'))) {
        $source = imagecreatefromjpeg($file);
    } elseif (in_array(file_type($file), array('png'))) {
        $source = imagecreatefrompng($file);
    } elseif (in_array(file_type($file), array('gif'))) {
        $source = imagecreatefromgif($file);
    } else {
        return false;
    }
    // Опеределение размеров изображения;
    $source_w = imagesx($source);
    $source_h = imagesy($source);
    if ($source_w <= $width and $source_h <= $height) {
        return false;
    }
    // Вычисление масштаба;
    $r = $height ? min($source_w / $width, $source_h / $height) : $source_w / $width;
    // Вычисление пропорций;
    $image_w = round($source_w / $r);
    $image_h = round($source_h / $r);
    // Создание пустой картинки;
    $image = imagecreatetruecolor($width, $height);
    imagefill($image, 0, 0, imagecolorallocate($image, 255, 255, 255));
    // Масштабирование изображения;
    imagecopyresampled($image, $source, 0, 0, 0, 0, $image_w, $image_h, $source_w, $source_h);
    // Вывод результата;
    //ob_start();
    imagejpeg($image, $file);
    //$content = ob_get_clean();
    // Удаление переменных;
    imagedestroy($image);
    imagedestroy($source);
    //return $content;
}
Ejemplo n.º 16
0
function step2()
{
    global $_MooClass, $dbTablePre, $userid, $timestamp;
    global $user_arr;
    $story2 = MooGetGPC('story2', 'string');
    $pics = MooGetGPC('pics', 'string');
    $insert_id = MooGetGPC('tid', 'integer');
    if ($story2 || $pics) {
        $title = safeFilter(MooGetGPC('subject', 'string'));
        $content = safeFilter(MooGetGPC('content', 'string'));
        $insert_id = MooGetGPC('tid', 'integer');
        $img_title = safeFilter(MooGetGPC('imgTitle', 'string'));
    }
    if ($story2 && $insert_id) {
        $storycontent = isset($_COOKIE['storycontent']) ? $_COOKIE['storycontent'] : '';
        $md5content = md5($title . $content);
        if ($md5content != $storycontent) {
            $_MooClass['MooMySQL']->query("UPDATE {$dbTablePre}story SET title = '{$title}',content = '{$content}',submit_date = '{$timestamp}', syscheck = '0' WHERE sid = '{$insert_id}'");
            $lsql = "UPDATE {$dbTablePre}story SET title = '{$title}',content = '{$content}', syscheck = '0' WHERE sid = '{$insert_id}'";
        }
        //提示消息
        MooMessage("您的爱情故事已上传成功,感谢您和我们分享您的幸福。", "index.php?n=story", '05');
        //note 上传相册中的照片的时候
    } elseif ($pics && $insert_id) {
        $album = $_MooClass['MooMySQL']->getAll("SELECT count(1) as count FROM {$dbTablePre}story_pic WHERE uid = '{$userid}'", 0, 0, 0, true);
        //note 如果上传照片超过30个图片,不允许上传
        if (isset($album['count']) && $album['count'] > '30') {
            MooMessage("您上传的图片已满30张!不可以在上传新的图片了", "index.php?n=story", '03');
        }
        //note 判断上传的文件类型
        $flag = '';
        $images = array('jpg', 'jpeg', 'gif', 'png', 'bmp');
        $maxfilesize = 1024 * 1024;
        $filesize = $_FILES['pic']['size'];
        $true_type = file_type($_FILES['pic']['tmp_name']);
        $extname = strtolower(substr($_FILES['pic']['name'], strrpos($_FILES['pic']['name'], '.') + 1));
        $_FILES['pic']['type'] = strtolower($_FILES['pic']['type']);
        if (in_array($true_type, $images) && in_array($extname, $images)) {
            foreach ($images as $v) {
                if ('image/' . $true_type == $_FILES['pic']['type'] || 'image/p' . $true_type == $_FILES['pic']['type'] || 'image/x-' . $true_type == $_FILES['pic']['type']) {
                    //过滤图片信息
                    $file_content = file_get_contents($_FILES['pic']['tmp_name']);
                    $low_file_content = strtolower($file_content);
                    $pos = strpos($low_file_content, '<?php');
                    if ($pos) {
                        $notice = "照片中含有不安全信息请重新上传";
                        MooMessage($notice, 'index.php?n=story&h=upload');
                        exit;
                    } else {
                        $flag = 1;
                    }
                }
            }
        }
        if ($flag != 1) {
            $notice = "照片必须为BMP,JPG,PNG或GIF格式";
            MooMessage($notice, 'index.php?n=story&h=step1');
            exit;
        }
        if ($filesize > $maxfilesize) {
            $notice = "上传图片大小不得超过1M";
            MooMessage($notice, 'index.php?n=story&h=step1');
            exit;
        }
        //note 上传到指定目录,并且获得上传后的文件描述
        $upload = MooAutoLoad('MooUpload');
        $upload->config(array('targetDir' => STORY_IMG_PATH, 'saveType' => '0'));
        $files = $upload->saveFiles('pic');
        $story_picname = $files[0]['name'] . "." . $files[0]['extension'];
        $_MooClass['MooMySQL']->query("UPDATE {$dbTablePre}story SET title = '{$title}',content = '{$content}',submit_date = '{$timestamp}' WHERE sid = '{$insert_id}'");
        $album = $_MooClass['MooMySQL']->getAll("SELECT * FROM {$dbTablePre}story_pic WHERE uid = '{$userid}' order by submit_date desc");
        if ($story_picname) {
            $_MooClass['MooMySQL']->query("INSERT INTO {$dbTablePre}story_pic (img,sid,uid,submit_date,title) values ('{$story_picname}','{$insert_id}','{$userid}','{$timestamp}','{$img_title}')");
            $mid = $_MooClass['MooMySQL']->insertId();
            $album[] = array('img' => $story_picname, 'sid' => $insert_id, 'uid' => $userid, 'submit_date' => $timestamp, 'title' => $img_title, 'mid' => $mid);
        }
        $prompt = '<script>alert("上传成功,您可以继续上传");location.href="index.php?n=story&h=step2#1"</script>';
    }
    //note 查询出相册
    $love_story = $_MooClass['MooMySQL']->getOne("SELECT * FROM {$dbTablePre}story WHERE uid = '{$userid}'");
    $insert_id = $love_story['sid'];
    include MooTemplate('public/story_upload2', 'module');
}
Ejemplo n.º 17
0
?>
    <?php 
if (!empty($_GET['rfile']) && empty($_GET['sfile']) && empty($_GET['path'])) {
    ?>
        <form action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
" method='POST'>
        <input type="hidden" name='rfile' value='<?php 
    echo $_GET['rfile'];
    ?>
'/>
         
        <input type="submit" value="SAVE EDIT" name="EDITFILE"/><br>
        <textarea id='highlightit' style='height:700px;width:700px;' class='<?php 
    echo 'brush:' . file_type($_GET['rfile']);
    ?>
' name="textforEdit">
            <?php 
    fetch_file($_GET['rfile']);
    ?>
             
        </textarea><br>
         
        <input type="submit" value="SAVE EDIT" name="EDITFILE"/>
        </form>
    <?php 
}
?>
    <?php 
if (!empty($_POST['EDITFILE']) && !empty($_POST['textforEdit']) && !empty($_POST['rfile'])) {
Ejemplo n.º 18
0
<embed src="<?php 
            echo $videoURL;
            ?>
" width="750" height="750"></embed>
<!-- Embeded End -->

<!-- HTML5 Start -->
<?php 
        } else {
            if ($settings_data['player_type'] == 'html5') {
                ?>
<video controls width="750" height="750" src="<?php 
                echo $videoURL;
                ?>
" type="<?php 
                echo file_type($videoURL);
                ?>
">
Your browser does not support HTML5 video.
</video>
<!-- HTML5 End -->

<!-- Flash Start -->
<?php 
            } else {
                if ($settings_data['player_type'] == 'flash') {
                    ?>
<object type="application/x-shockwave-flash" data="<?php 
                    echo $videoURL;
                    ?>
" width="750" height="750">
Ejemplo n.º 19
0
<?php

// Подключение к базе данных;
include $_SERVER['DOCUMENT_ROOT'] . '/systems/connect.php';
// Авторизация пользователя;
if ($_COOKIE['in_name'] and $_COOKIE['in_password']) {
    // Загрузка данных пользователя;
    $sql = "SELECT `id`, `name` FROM `users` WHERE `name`='" . $_COOKIE['in_name'] . "' AND `password`='" . $_COOKIE['in_password'] . "' AND `status`='1' LIMIT 1";
    if ($user = $db->row($sql)) {
        // Имя файла;
        $filename = '/files/uploads/' . time() . '.' . file_type($_FILES['image']['tmp_name']);
        // Загрузка фотографии;
        if ($_FILES['image']) {
            if (move_uploaded_file($_FILES['image']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . $filename)) {
                // Сжатие фотографии;
                image_resize($_SERVER['DOCUMENT_ROOT'] . $filename, 640, 480);
                // Вывод имени файла;
                die($filename);
            }
        }
    }
}
Ejemplo n.º 20
0
 if (!$_FILES['fileData1']['tmp_name']) {
     MooMessage("请上传证件!", "index.php?n=myaccount&h=convinceindex", "03");
 }
 $field_arr = array(1 => 'identity', 2 => 'marriage', 3 => 'education', 4 => 'occupation', 5 => 'salary', 6 => 'house');
 $phototype = MooGetGPC('phototype', 'integer');
 if (!$usercer) {
     $insertsqlarr = array('uid' => $uid);
     inserttable('certification', $insertsqlarr);
 } else {
     if ($usercer[$field_arr[$phototype]] != '' && $usercer[$field_arr[$phototype] . '_check'] == 3) {
         MooMessage("您已经上传过此类证件!", "index.php?n=myaccount&h=convinceindex", "03");
     }
 }
 //note 判断上传的文件类型
 $flag = '';
 $true_type = file_type($_FILES['fileData1']['tmp_name']);
 $extname = strtolower(substr($_FILES['fileData1']['name'], strrpos($_FILES['fileData1']['name'], '.') + 1));
 $images = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'JPG', 'JPEG', 'GIF', 'PNG', 'BMP');
 $img_type = explode('/', $_FILES['fileData1']['type']);
 //foreach($images as $v) {
 //if(eregi($v,$_FILES['fileData1']['type'])
 if (in_array($img_type[1], $images) && in_array($extname, $images) && ('image/' . $true_type == $_FILES['fileData1']['type'] || 'image/p' . $true_type == $_FILES['fileData1']['type'] || 'image/x-' . $true_type == $_FILES['fileData1']['type'])) {
     $flag = 1;
     //break;
 }
 //}
 if ($flag != 1) {
     $notice = "照片必须为BMP,JPG,PNG或GIF格式";
     MooMessage($notice, 'index.php?n=myaccount&h=convinceindex', "02");
     exit;
 }