示例#1
1
function processImage($uploadDir, $filename)
{
    $uploadedFile = combine($uploadDir, $filename);
    //save exif data
    $message = "File uploaded.";
    $exif = getImageMetadata($uploadedFile);
    $dateTaken = getExifDateTaken($uploadedFile, $exif);
    if (!$dateTaken) {
        $dateTaken = getDateFromFilename($filename);
    }
    if (!$dateTaken) {
        $dateTaken = getFileDate($uploadedFile);
    }
    $exif["dateTaken"] = $dateTaken;
    $description = arrayGetCoalesce($exif, "ImageDescription", "IPTC.Caption");
    $description = trim($description);
    writeCsvFile("{$uploadedFile}.txt", $exif);
    writeTextFile("{$uploadedFile}.js", jsValue($exif));
    //resize images and keep hd version
    $sizes = getConfig("thumbnails.sizes");
    $resized = resizeMultiple($uploadDir, $filename, $sizes);
    $keep = getConfig("thumbnails.keep");
    if ($keep) {
        moveFile("{$uploadDir}/.{$keep}", $filename, $uploadDir);
        deleteDir("{$uploadDir}/.{$keep}");
        unset($resized[$keep]);
    }
    if ($dateTaken) {
        setFileDate($uploadedFile, $dateTaken);
    }
    $vars = get_defined_vars();
    $result = array();
    $exif["meal"] = selectMeal($dateTaken);
    $result["_exif"] = $exif;
    $result["success"] = true;
    return addVarsToArray($result, "filename filesize mimeType dateTaken description", $vars);
}
function updataKml($kmls, $starttime, $file = '', $source = 1, $topic)
{
    //访问API
    $kmlUpdateApi = getConfig('kmlUpdateApi');
    $unique = unique_arr($kmls);
    //去重
    //print_r($unique);exit;
    $soadata = formatApiData($unique);
    //去重
    $returnData = curlPost($kmlUpdateApi, array('data' => $soadata));
    logs($returnData, 1, 'consumer', $topic);
    print_r($returnData);
    exit;
    //logs(' Access :'.$kmlUpdateApi, 1, 'consumer',$topic);
    //logs(' Params is:'.json_encode($data), 1, 'consumer',$topic);
    //logs(' Return is:'.$returnData, 1, 'consumer',$topic);
    $cachePath = getconfig('kmlCachePath');
    $cacheBack = getconfig('kmlCacheBak');
    //验证还回结果
    $objs = json_decode($returnData);
    if (empty($returnData) || $objs->status != 0 || empty($objs->data)) {
        if ($source == 2) {
            $dir = $cacheBack . '/' . date('Y-m-d') . '/' . $topic;
            mkFolder($dir);
            $toPath = $dir . '/' . basename($file);
            moveFile($file, $toPath);
            logs(date('H:i:s') . ' API error:' . $objs->msg . '; file:' . $file . ' has move to ' . $toPath, 1, 'consumer', $topic);
        } else {
            if ($objs->status < 3) {
                $cacheTopicPath = $cachePath . '/' . $topic;
                mkFolder($cacheTopicPath);
                $filename = basename($file);
                $source = $cacheTopicPath . '/' . $filename;
                file_put_contents($source, $data);
                logs(date('H:i:s') . ' API error:' . $objs->msg . '; file:' . $file . ' has backup to ' . $source, 1, 'consumer', $topic);
            } else {
                $backFile = $cacheBack . '/' . basename($file);
                moveFile($file, $backFile);
                logs(date('H:i:s') . ' API error:' . $objs->msg . '; file ' . basename($file) . 'has move to ' . $backFile, 1, 'consumer', $topic);
            }
        }
    }
    if ($source == 2) {
        if (file_exists($file)) {
            unlink($file);
        }
    }
    $arr = object2Array($objs);
    $returnKml = $arr['data'];
    $insertNum = 0;
    if ($source == 1) {
        $insertNum = addKml($returnKml, $kmls, $topic);
    }
    logs('kafka num:' . count($kmls) . ',send data num:' . count($unique) . ', API return:' . count($returnKml) . ',insertNum:' . $insertNum . ',Time: ' . getTime($starttime), 1, 'consumer', $topic);
    $kmls = '';
}
 public function update()
 {
     $upload_list = $this->uploadImages();
     if ($upload_list) {
         foreach ($upload_list as $upload_item) {
             if ($upload_item['key'] == "SITE_LOGO") {
                 $site_logo = $upload_item['recpath'] . $upload_item['savename'];
                 $site_logo = moveFile($site_logo, './logo.gif');
             }
             if ($upload_item['key'] == "WATER_IMAGE") {
                 $water_image = $upload_item['recpath'] . $upload_item['savename'];
             }
             if ($upload_item['key'] == "FOOT_LOGO") {
                 $foot_logo = $upload_item['recpath'] . $upload_item['savename'];
                 $foot_logo = moveFile($foot_logo, './foot_logo.gif');
             }
             if ($upload_item['key'] == "LINK_LOGO") {
                 $link_logo = $upload_item['recpath'] . $upload_item['savename'];
                 $link_logo = moveFile($link_logo, './link_logo.gif');
             }
         }
     }
     $list = D('SysConf')->where("status=1")->findAll();
     foreach ($list as $k => $v) {
         $v['val'] = isset($_REQUEST[$v['name']]) ? $_REQUEST[$v['name']] : $v['val'];
         if ($v['name'] == "SITE_LOGO" && !empty($site_logo)) {
             if ($site_logo != $v['val']) {
                 @unlink(FANWE_ROOT . $v['val']);
                 $v['val'] = $site_logo;
             }
         }
         if ($v['name'] == "WATER_IMAGE" && !empty($water_image)) {
             if ($water_image != $v['val']) {
                 @unlink(FANWE_ROOT . $v['val']);
                 $v['val'] = $water_image;
             }
         }
         if ($v['name'] == "FOOT_LOGO" && !empty($foot_logo)) {
             if ($foot_logo != $v['val']) {
                 @unlink(FANWE_ROOT . $v['val']);
                 $v['val'] = $foot_logo;
             }
         }
         if ($v['name'] == "LINK_LOGO" && !empty($link_logo)) {
             if ($link_logo != $v['val']) {
                 @unlink(FANWE_ROOT . $v['val']);
                 $v['val'] = $link_logo;
             }
         }
         D('SysConf')->save($v);
     }
     $this->saveLog(1);
     $this->success(L('EDIT_SUCCESS'));
 }
示例#4
0
     $path_source = "files/" . $fileDetail->fil_project[0] . "/" . $fileDetail->fil_name[0];
     $path_destination = "files/" . $fileDetail->fil_project[0] . "/{$changename}";
 }
 if ($allowPhp == "false") {
     $send = "";
     if ($_FILES['upload']['name'] != "" && ($extension == "php" || $extension == "php3" || $extension == "phtml")) {
         $error4 .= $strings["no_php"] . "<br/>";
         $send = "false";
     }
 }
 if ($_FILES['upload']['name'] != "" && $_FILES['upload']['size'] < $maxFileSize && $_FILES['upload']['size'] != 0 && $send != "false") {
     $docopy = "true";
 }
 if ($docopy == "true") {
     //Copy old file with a new file name
     moveFile($path_source, $path_destination);
     //Set variables from original files details.
     $copy_project = $fileDetail->fil_project[0];
     $copy_task = $fileDetail->fil_task[0];
     $copy_date = $fileDetail->fil_date[0];
     $copy_size = $fileDetail->fil_size[0];
     $copy_extension = $fileDetail->fil_extension[0];
     $copy_comments = $fileDetail->fil_comments[0];
     $copy_upload = $fileDetail->fil_upload[0];
     $copy_pusblished = $fileDetail->fil_published[0];
     $copy_vc_parent = $fileDetail->fil_vc_parent[0];
     $copy_id = $fileDetail->fil_id[0];
     $copy_vc_version = $fileDetail->fil_vc_version[0];
     //Insert a new row for the copied file
     $comments = convertData($comments);
     $tmpquery = "INSERT INTO " . $tableCollab["files"] . "(owner,project,task,name,date,size,extension,comments,upload,published,status,vc_status,vc_version,vc_parent,phase) VALUES('{$idSession}','{$copy_project}','{$copy_task}','{$changename}','{$copy_date}','{$copy_size}','{$copy_extension}','{$copy_comments}','{$copy_upload}','0','2','3','{$copy_vc_version}','{$copy_id}','0')";
function backFile($f)
{
    $fileArr = explode('/', $f);
    $filename = $fileArr[count($fileArr) - 1];
    //$path = getconfig('kmlBakPath').'/'.date('Y-m-d'));
    //mkFolder($path);
    $path = getconfig('kmlBakPath');
    if (file_exists($f)) {
        //       moveFile($f, $path.'/'.$filename);
        $kmlBakPath = '/home/webdata/htdocs/data/feiniu/snd/NEW_KML_BACKUP/' . date('Y-m-d');
        mkFolder($kmlBakPath);
        moveFile($f, $kmlBakPath . '/' . $filename);
        logs("success move to " . $kmlBakPath);
    }
    logs("success move to bakkup");
}
示例#6
0
function signUp($user)
{
    $user = validateFixProfile($user);
    if (is_string($user)) {
        # error msg: invalid info
        return $user;
    }
    if (userExists($user["email"])) {
        return ACCOUNT_ALREADY_EXISTS_ERR;
    }
    $user["password"] = trim($user["password"]);
    $checkPassword = checkPassword($user["password"], $user["confirm_password"]);
    if (is_string($checkPassword)) {
        return $checkPassword;
    }
    $account_type = $user["account_type"];
    if ($account_type !== "Tutor" && $account_type !== "Student") {
        return INVALID_ACCOUNT_TYPE_ERR;
    }
    $gender = $user["gender"];
    if ($gender !== "Male" && $gender !== "Female") {
        return INVALID_GENDER_ERR;
    }
    if (is_uploaded_file($_FILES["profile_pic"]["tmp_name"]) && isValidImg("profile_pic") !== true) {
        return INVALID_IMG_ERR;
    }
    $user_id = insertUser($user);
    if (isNum($user_id)) {
        insertInto($account_type, $user_id);
        if (file_exists($_FILES["profile_pic"]["tmp_name"])) {
            $path = getProfilePicPath($user_id);
            moveFile("profile_pic", getTempPath($user_id), $path);
            changeProfilePic($user_id, $path);
        }
        # else {
        #    changeProfilePic($user_id, DEFAULT_PROFILE_PIC);
        # }
        $u = getFullUserById($user_id);
        if (sendActivationMail($u["email"], $user_id, $u["activation_code"])) {
            return true;
        } else {
            return " Account successfully created but could not send you a verification email. Please request another one. ";
        }
    } else {
        return UNKNOWN_ERR . RETRY_MSG;
    }
}
示例#7
0
            createNewFile();
            break;
        case "createDir":
            createDir();
            break;
        case "renameFile":
            renameFile();
            break;
        case "removeFile":
            removeFile();
            break;
        case "duplicateFile":
            duplicateFile();
            break;
        case "moveFile":
            moveFile();
            break;
        case 'uploadFile':
            uploadFile();
            break;
        case 'checkForExistentFile':
            checkForExistentFile();
            break;
        case 'downloadFile':
            downloadFile();
            break;
    }
}
if (isset($_GET['action'])) {
    if (!isUserLogged()) {
        exit;
示例#8
0
function copyHtmlToWeb()
{
    $webDir = '';
    $toWebDir = '';
    $toFilePath = '';
    $filePath = '';
    $fileName = '';
    $fileList = '';
    $splStr = '';
    $content = '';
    $s = '';
    $s1 = '';
    $c = '';
    $webImages = '';
    $webCss = '';
    $webJs = '';
    $splJs = '';
    $webFolderName = '';
    $jsFileList = '';
    $setFileCode = '';
    $nErrLevel = '';
    $jsFilePath = '';
    $url = '';
    $setFileCode = @$_REQUEST['setcode'];
    //设置文件保存编码
    handlePower('复制生成HTML页面');
    //管理权限处理
    writeSystemLog('', '复制生成HTML页面');
    //系统日志
    $webFolderName = $GLOBALS['cfg_webTemplate'];
    if (left($webFolderName, 1) == '/') {
        $webFolderName = mid($webFolderName, 2, -1);
    }
    if (right($webFolderName, 1) == '/') {
        $webFolderName = mid($webFolderName, 1, len($webFolderName) - 1);
    }
    if (inStr($webFolderName, '/') > 0) {
        $webFolderName = mid($webFolderName, inStr($webFolderName, '/') + 1, -1);
    }
    $webDir = '/htmladmin/' . $webFolderName . '/';
    $toWebDir = '/htmlw' . 'eb/viewweb/';
    CreateDirFolder($toWebDir);
    $toWebDir = $toWebDir . pinYin2($webFolderName) . '/';
    deleteFolder($toWebDir);
    //删除
    CreateFolder('/htmlweb/web');
    //创建文件夹 防止web文件夹不存在20160504
    deleteFolder($webDir);
    CreateDirFolder($webDir);
    $webImages = $webDir . 'Images/';
    $webCss = $webDir . 'Css/';
    $webJs = $webDir . 'Js/';
    copyFolder($GLOBALS['cfg_webImages'], $webImages);
    copyFolder($GLOBALS['cfg_webCss'], $webCss);
    CreateFolder($webJs);
    //创建Js文件夹
    //处理Js文件夹
    $splJs = aspSplit(getDirJsList($webJs), vbCrlf());
    foreach ($splJs as $key => $filePath) {
        if ($filePath != '') {
            $toFilePath = $webJs . getFileName($filePath);
            aspEcho('js', $filePath);
            moveFile($filePath, $toFilePath);
        }
    }
    //处理Css文件夹
    $splStr = aspSplit(getDirCssList($webCss), vbCrlf());
    foreach ($splStr as $key => $filePath) {
        if ($filePath != '') {
            $content = getFText($filePath);
            $content = replace($content, $GLOBALS['cfg_webImages'], '../images/');
            $content = deleteCssNote($content);
            $content = PHPTrim($content);
            //设置为utf-8编码 20160527
            if (lCase($setFileCode) == 'utf-8') {
                $content = replace($content, 'gb2312', 'utf-8');
            }
            WriteToFile($filePath, $content, $setFileCode);
            aspEcho('css', $GLOBALS['cfg_webImages']);
        }
    }
    //复制栏目HTML
    $GLOBALS['isMakeHtml'] = true;
    $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'webcolumn where isonhtml=true');
    while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) {
        $GLOBALS['glb_filePath'] = replace(getColumnUrl($rss['columnname'], 'name'), $GLOBALS['cfg_webSiteUrl'] . '/', '');
        if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') {
            $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
        }
        if (right($GLOBALS['glb_filePath'], 5) == '.html') {
            if (right($GLOBALS['glb_filePath'], 11) == '/index.html') {
                $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf();
            } else {
                $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList;
            }
            $fileName = replace($GLOBALS['glb_filePath'], '/', '_');
            $toFilePath = $webDir . $fileName;
            copyFile($GLOBALS['glb_filePath'], $toFilePath);
            aspEcho('导航', $GLOBALS['glb_filePath']);
        }
    }
    //复制文章HTML
    $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'articledetail where isonhtml=true');
    while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) {
        $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/detail/detail' . $rss['id']);
        $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', '');
        if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') {
            $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
        }
        if (right($GLOBALS['glb_filePath'], 5) == '.html') {
            if (right($GLOBALS['glb_filePath'], 11) == '/index.html') {
                $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf();
            } else {
                $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList;
            }
            $fileName = replace($GLOBALS['glb_filePath'], '/', '_');
            $toFilePath = $webDir . $fileName;
            copyFile($GLOBALS['glb_filePath'], $toFilePath);
            aspEcho('文章' . $rss['title'], $GLOBALS['glb_filePath']);
        }
    }
    //复制单面HTML
    $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'onepage where isonhtml=true');
    while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) {
        $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/page/page' . $rss['id']);
        $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', '');
        if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') {
            $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
        }
        if (right($GLOBALS['glb_filePath'], 5) == '.html') {
            if (right($GLOBALS['glb_filePath'], 11) == '/index.html') {
                $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf();
            } else {
                $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList;
            }
            $fileName = replace($GLOBALS['glb_filePath'], '/', '_');
            $toFilePath = $webDir . $fileName;
            copyFile($GLOBALS['glb_filePath'], $toFilePath);
            aspEcho('单页' . $rss['title'], $GLOBALS['glb_filePath']);
        }
    }
    //批量处理html文件列表
    //call echo(cfg_webSiteUrl,cfg_webTemplate)
    //call rwend(fileList)
    $sourceUrl = '';
    $replaceUrl = '';
    $splStr = aspSplit($fileList, vbCrlf());
    foreach ($splStr as $key => $filePath) {
        if ($filePath != '') {
            $filePath = $webDir . replace($filePath, '/', '_');
            aspEcho('filePath', $filePath);
            $content = getFText($filePath);
            foreach ($splStr as $key => $s) {
                $s1 = $s;
                if (right($s1, 11) == '/index.html') {
                    $s1 = left($s1, len($s1) - 11) . '/';
                }
                $sourceUrl = $GLOBALS['cfg_webSiteUrl'] . $s1;
                $replaceUrl = $GLOBALS['cfg_webSiteUrl'] . replace($s, '/', '_');
                //Call echo(sourceUrl, replaceUrl) 							'屏蔽  否则大量显示20160613
                $content = replace($content, $sourceUrl, $replaceUrl);
            }
            $content = replace($content, $GLOBALS['cfg_webSiteUrl'], '');
            //删除网址
            $content = replace($content, $GLOBALS['cfg_webTemplate'] . '/', '');
            //删除模板路径 记
            //content=nullLinkAddDefaultName(content)
            foreach ($splJs as $key => $s) {
                if ($s != '') {
                    $fileName = getFileName($s);
                    $content = replace($content, 'Images/' . $fileName, 'js/' . $fileName);
                }
            }
            if (inStr($content, '/Jquery/Jquery.Min.js') > 0) {
                $content = replace($content, '/Jquery/Jquery.Min.js', 'js/Jquery.Min.js');
                copyFile('/Jquery/Jquery.Min.js', $webJs . '/Jquery.Min.js');
            }
            $content = replace($content, '<a href="" ', '<a href="index.html" ');
            //让首页加index.html
            createFileGBK($filePath, $content);
        }
    }
    //把复制网站夹下的images/文件夹下的js移到js/文件夹下  20160315
    $htmlFileList = '';
    $splHtmlFile = '';
    $splJsFile = '';
    $htmlFilePath = '';
    $jsFileName = '';
    $jsFileList = getDirJsNameList($webImages);
    $htmlFileList = getDirHtmlList($webDir);
    $splHtmlFile = aspSplit($htmlFileList, vbCrlf());
    $splJsFile = aspSplit($jsFileList, vbCrlf());
    foreach ($splHtmlFile as $key => $htmlFilePath) {
        $content = getFText($htmlFilePath);
        foreach ($splJsFile as $key => $jsFileName) {
            $content = regExp_Replace($content, 'Images/' . $jsFileName, 'js/' . $jsFileName);
        }
        $nErrLevel = 0;
        $content = handleHtmlFormatting($content, false, $nErrLevel, '|删除空行|');
        //|删除空行|
        $content = handleCloseHtml($content, true, '');
        //闭合标签
        $nErrLevel = checkHtmlFormatting($content);
        if (checkHtmlFormatting($content) == false) {
            echoRed($htmlFilePath . '(格式化错误)', $nErrLevel);
            //注意
        }
        //设置为utf-8编码
        if (lCase($setFileCode) == 'utf-8') {
            $content = replace($content, '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />', '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
        }
        $content = PHPTrim($content);
        WriteToFile($htmlFilePath, $content, $setFileCode);
    }
    //images下js移动到js下
    foreach ($splJsFile as $key => $jsFileName) {
        $jsFilePath = $webImages . $jsFileName;
        $content = getFText($jsFilePath);
        $content = PHPTrim($content);
        WriteToFile($webJs . $jsFileName, $content, $setFileCode);
        DeleteFile($jsFilePath);
    }
    copyFolder($webDir, $toWebDir);
    //使htmlWeb文件夹用php压缩
    if (@$_REQUEST['isMakeZip'] == '1') {
        makeHtmlWebToZip($webDir);
    }
    //使网站用xml打包20160612
    if (@$_REQUEST['isMakeXml'] == '1') {
        makeHtmlWebToXmlZip('/htmladmin/', $webFolderName);
    }
    //浏览地址
    $url = 'http://10.10.10.57/' . $toWebDir;
    aspEcho('浏览', '<a href=\'' . $url . '\' target=\'_blank\'>' . $url . '</a>');
}
示例#9
0
        return _filemanager_filenotuploaded;
    }
    move_uploaded_file($_FILES['uploadFile']['tmp_name'], $newFile);
    chmod($newFile, 0666);
    $clear_upload = true;
    return false;
}
if (isset($_REQUEST['action'])) {
    if ('delete' == $_REQUEST['action']) {
        $err = deleteFile();
    }
    if ('rename' == $_REQUEST['action']) {
        $err = renameFile();
    }
    if ('move' == $_REQUEST['action']) {
        $err = moveFile();
    }
    if ('createFolder' == $_REQUEST['action']) {
        $err = createFolder();
    }
}
if (isset($_FILES['uploadFile']) && is_array($_FILES['uploadFile'])) {
    $err = uploadFile();
}
function parse_size($size)
{
    if ($size < 1024) {
        return $size . ' bytes';
    } else {
        if ($size >= 1024 && $size < 1024 * 1024) {
            return sprintf('%01.2f', $size / 1024.0) . ' KB';
示例#10
0
 function processAttachments()
 {
     if (!isset($_POST['MAX_FILE_SIZE'])) {
         $_POST['MAX_FILE_SIZE'] = getConfig("MAX_UPLOAD_FILE_SIZE");
     }
     if (!isset($_POST['IF_FILE_EXISTS'])) {
         $_POST['IF_FILE_EXISTS'] = "replace";
     }
     if (!isset($_POST['FILE_ACTION'])) {
         $_POST['FILE_ACTION'] = "create";
     }
     if (!isset($_POST['TEXT_EXTRACTION'])) {
         $_POST['TEXT_EXTRACTION'] = "true";
     }
     if (!isset($_POST['forTable']) || !isset($_POST['forIDVal'])) {
         echo "<script>parent.uploadComplete('Error In File Attachments!');</script>";
         return false;
     }
     $forTable = $_POST['forTable'];
     $forIDVal = $_POST['forIDVal'];
     if (isset($_POST['forIDCol'])) {
         $forIDCol = $_POST['forIDCol'];
     } else {
         $forIDCol = "id";
     }
     $errors = array();
     $values = array();
     foreach ($_FILES as $a => $b) {
         $values[$a] = array();
         $src = "";
         if (is_array($_POST[$a]) && count($_POST[$a]) > 0) {
             $src = $_POST[$a][0];
         } else {
             $src = $_POST[$a];
         }
         if (is_array($b['name'])) {
             foreach ($b['name'] as $c => $d) {
                 $file = array("name" => $b['name'][$c], "type" => $b['type'][$c], "tmp_name" => $b['tmp_name'][$c], "error" => $b['error'][$c], "size" => $b['size'][$c], "src" => $src);
                 if (strlen($file['name']) == 0 && $file['size'] == 0 && strlen($file['tmp_name'])) {
                     $values[$a] = null;
                     continue;
                 }
                 $lnk = moveFile($file);
                 if (is_array($lnk)) {
                     if (isset($lnk['Error'])) {
                         $errors[$a . "." . $c] = $lnk;
                     }
                 } else {
                     array_push($values[$a], $lnk);
                 }
             }
         } else {
             $file = $b;
             if (strlen($file['name']) == 0 && $file['size'] == 0 && strlen($file['tmp_name'])) {
                 $values[$a] = null;
                 continue;
             }
             $file["src"] = $src;
             $lnk = moveFile($file);
             if (is_array($lnk)) {
                 if (isset($lnk['Error'])) {
                     $errors[$a . "." . $b['name']] = $lnk;
                 }
             } else {
                 array_push($values[$a], $lnk);
             }
         }
     }
     foreach ($values as $a => $b) {
         if ($b != null) {
             $values[$a] = implode(",", $b);
             $values[$a] = "{$a}='{$values[$a]}'";
         } else {
             unset($values[$a]);
         }
     }
     $values = implode(", ", $values);
     if (strpos("#" . $forTable, $GLOBALS["DBCONFIG"]["DB_SYSTEM"]) == 1) {
         $sysDb = true;
     } else {
         $sysDb = false;
     }
     $sqlUpdate = "UPDATE {$forTable} SET {$values} WHERE {$forIDCol}='{$forIDVal}'";
     //echo $sqlUpdate;
     _dbQuery($sqlUpdate, $sysDb);
     //$cnt=_db($sysDb)->affected_rows();
     $cnt = count($errors);
     //if(count($errors)>0) {printArray($errors);}
     if ($cnt > 0) {
         $tms = "Failed To Attach {$cnt} Documents.";
     } else {
         $tms = "";
     }
     echo "<script>parent.uploadComplete('{$tms}');</script>";
 }
示例#11
0
 function unzipConversionResults($sourceZipPath, $previewDirectory)
 {
     chmod($previewDirectory, 0700);
     $destinationZipPath = $previewDirectory . DIRECTORY_SEPARATOR . basename($sourceZipPath);
     $this->destinationZip = $destinationZipPath;
     if (!moveFile($sourceZipPath, $destinationZipPath)) {
         webServiceError('&error-webpage-unable-to-move;', 500, array('source' => $sourceZipPath, 'destination' => $destinationZipPath));
     }
     chmod($destinationZipPath, 0666);
     include_once dirname(__FILE__) . '/lib/pclzip-2-6/pclzip.lib.php';
     $archive = new PclZip($destinationZipPath);
     if (($archivedFiles = $archive->listContent()) == 0) {
         webServiceError('&error-webpage-unzipping-files;', 500, array('errorMessage' => $archive->errorInfo(true)));
     }
     foreach ($archivedFiles as $archivedFile) {
         $extractedFileMetaData = $archive->extractByIndex($archivedFile['index'], PCLZIP_OPT_PATH, $previewDirectory);
         $extractedFileMetaData = $extractedFileMetaData[0];
         $extractedDestinationPath = substr($extractedFileMetaData['filename'], 2);
         if (file_exists($extractedDestinationPath) && !chmod($extractedDestinationPath, 0700)) {
             webServiceError('&error-webpage-unzipping-files;', 500, array('errorMessage' => $extractedDestinationPath));
         }
     }
     return $this->destinationZip;
 }
示例#12
0
文件: lib.php 项目: Nolfneo/docvert
function processConversion($files, $converter, $pipeline, $autoPipeline, $afterConversion, $setupOpenOfficeOrg, $outputZip, $justShowPreviewDirectory = null)
{
    $forcedPipeline = getGlobalConfigItem('forcePipeline');
    if ($forcedPipeline != null) {
        $pipeline = 'fake:' . $forcedPipeline;
    }
    ensureClientType();
    if (thereWasAFileGiven($files, $pipeline) || $justShowPreviewDirectory) {
        $returnZipPath = null;
        $previewDirectory = null;
        if (!$justShowPreviewDirectory) {
            $previewDirectory = getTemporaryDirectoryInsideDirectory(getWritableDirectory(), 'preview');
            $temporaryDirectory = getTemporaryDirectory();
            $pipelineToRunOnDocuments = substringAfter($pipeline, ':');
            foreach ($files as $file) {
                if ($file['size'] != 0) {
                    $documentPath = moveUploadToConversionDirectory($file, $temporaryDirectory);
                    $oasisOpenDocumentPath = '';
                    if (!isAnOasisOpenDocument($file)) {
                        $oasisOpenDocumentPath = makeOasisOpenDocument($documentPath, $converter);
                        silentlyUnlink($documentPath);
                    } else {
                        $oasisOpenDocumentPath = $documentPath;
                    }
                    if ($pipelineToRunOnDocuments != "none") {
                        extractUsefulOasisOpenDocumentFiles($oasisOpenDocumentPath);
                        silentlyUnlink($oasisOpenDocumentPath);
                        $oasisOpenDocumentContentPath = dirname($oasisOpenDocumentPath) . DIRECTORY_SEPARATOR . 'docvert-content.xml';
                        applyPipeline($oasisOpenDocumentContentPath, $pipelineToRunOnDocuments, $autoPipeline, $previewDirectory);
                        silentlyUnlink($oasisOpenDocumentContentPath);
                    }
                }
            }
            $returnZipPath = zipAndDeleteTemporaryFiles($temporaryDirectory);
            if ($afterConversion == 'preview') {
                include_once dirname(__FILE__) . '/webpage.php';
                $themes = new Themes();
                //$returnZipPath = $themes->unzipConversionResults($returnZipPath, $previewDirectory); //WTF
            }
        } else {
            $previewDirectory = getWritableDirectory() . $justShowPreviewDirectory;
            $zipsInPreviewDirectory = glob($previewDirectory . DIRECTORY_SEPARATOR . '*.zip');
            if (count($zipsInPreviewDirectory) != 1) {
                $errorData = array('zipsInPreviewDirectory' => count($zipsInPreviewDirectory), 'previewDirectory' => $previewDirectory);
                webServiceError('&docvert-internal-error-no-zip-file;', 500, $errorData);
            }
            $returnZipPath = $zipsInPreviewDirectory[0];
        }
        if ($afterConversion == 'preview') {
            include_once dirname(__FILE__) . '/webpage.php';
            $themes = new Themes();
            $themes->previewConversionResults($returnZipPath, $previewDirectory);
        } elseif ($afterConversion == 'saveZip') {
            if (DOCVERT_CLIENT_TYPE == 'command line') {
                moveFile($returnZipPath, $outputZip);
                print 'Ok! File saved to ' . $outputZip . "\n";
                deleteDirectoryRecursively($temporaryDirectory);
                die;
            } else {
                webServiceError('&error-after-conversion-flag;');
            }
        } elseif ($afterConversion == 'downloadZip') {
            //TODO: different versions of IE want different "content disposition" header syntaxes
            //perhaps we could detect versions of IE and serve up what they need? Will need quite a bit of research.
            header('Content-Type: application/x-zip-compressed');
            header('Content-disposition: attachment; filename=' . basename($returnZipPath));
            $zipContents = file_get_contents($returnZipPath);
            print $zipContents;
            flush();
            silentlyUnlink($returnZipPath);
            deleteDirectoryRecursively($temporaryDirectory);
            die;
        } else {
            webServiceError('&error-unsupported-after-conversion;', 500, array('after-conversion' => revealXml($afterConversion)));
        }
    } elseif ($setupOpenOfficeOrg) {
        setupOpenOfficeOrg();
    } else {
        /* TODO: so there's been no upload and what do we do?
         * I suppose an http status code would be appropriate.
         *     http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
         * The 4xx series are for user error, which seems appropriate.
         * ...but none of them seem quite appropriate for a casual
         * "you didn't give me files" response.
         * They talk about malformed requests.
         *
         * So I'm doing a "400 Bad Request" in the meantime.
         */
        webServiceError('&error-no-files-uploaded;', '400 Bad Request');
    }
}
示例#13
0
    } else {
        return false;
    }
}
//begin by converting any non utf8 character to uft8 chracter and removing any bad characters
$lstrFile = makeValidFileName($_FILES['upload']['name']);
//determine whether the file extension is valid
if (validExtension($lstrFile)) {
    //get the user's assets folder path
    $lobjPath = getUserPath();
    //if no errors (first element is boolean determining whether there is a error
    if ($lobjPath[0]) {
        //second element is user assets folder path
        $lstrPath = $lobjPath[1];
        //move uploaded file to user assets folder path and store url of uploaded to temp string
        if ($lstrTemp = moveFile($lstrPath . DIRECTORY_SEPARATOR . $lstrFile)) {
            //if no error, store as url
            $lstrUrl = getUserURL() . "/" . $lstrFile;
        } else {
            //create error message
            $lstrMessage = _('Could not upload file to user\\\'s assets folder.');
        }
    } else {
        //create error message
        $lstrMessage = _($lobjPath[1]);
    }
    //move from temp to permanent if not error return url using $BasePath from config and smile
} else {
    //create error message
    $lstrMessage = _('The extension is not supported.');
}
示例#14
0
     listTevents($_GET['id'], $_GET['fid'], $_GET['tab']);
     break;
 case 'getCustomTermin':
     getCustomTermin($_GET['id'], $_GET['tab'], $_GET['day'], $_GET['month'], $_GET['year']);
     break;
 case 'showDir':
     showDir($_GET['id'], $_GET['dir']);
     break;
 case 'showFile':
     showFile($_GET['pfad'], $_GET['file']);
     break;
 case 'lockFile':
     lockFile($_GET['file'], $_GET['pfad'], $_GET['id']);
     break;
 case 'moveFile':
     moveFile($_GET['file'], $_GET['pfadleft']);
     break;
 case 'saveAttribut':
     saveAttribut($_GET['name'], $_GET['oldname'], $_GET['pfad'], $_GET['komment'], $_GET['id']);
     break;
 case 'newDir':
     newDir($_GET['pfad'], $_GET['newdir']);
     break;
 case 'delFile':
     delFile($_GET['id'], $_GET['pfad'], $_GET['file']);
     break;
 case 'usermail':
     getUsermail($_GET['uid']);
     break;
 default:
     echo "nicht erlaubt";
 }
 output("Backup location:" . $backup_path . "\n");
 // Applications list
 $root_applications = scandir("/Applications");
 array_unshift($root_applications, "Root apps:");
 $home_applications = scandir(getAbsolutePath("~/Applications"));
 array_unshift($home_applications, "Home apps:");
 file_put_contents($backup_path . "/Applications.txt", implode("\n", array_merge($root_applications, $home_applications)));
 output("Created applications list\n");
 // Macports list
 $port_output = shell_exec("sudo port installed requested" . " 2>&1");
 file_put_contents($backup_path . "/Macports.txt", $port_output);
 output("Created Macports list\n");
 // MySQL
 command("php " . $_SERVER["HOME"] . "/" . dirname($_SERVER["PHP_SELF"]) . "/mysql_dump_all.php mysqldump", true, false);
 moveFile("~/mysqldump.sql", $backup_path . "/mysqldump.sql");
 // config files
 copyFile("~/.bash_profile", $backup_path . "/bash_profile");
 copyFile("~/.gitconfig", $backup_path . "/gitconfig");
 copyFile("~/.gitignore_global", $backup_path . "/gitignore_global");
 copyFile("~/.tm_properties", $backup_path . "/tm_properties");
 copyFile("/etc/hosts", $backup_path . "/hosts");
 copyFolder("~/Sites/apache/", $backup_path . "/Sites/apache/");
 copyFolder("~/Desktop/", $backup_path . "/Desktop/");
 copyFolder("~/Pictures/", $backup_path . "/Pictures/");
 copyFolder("~/Documents/", $backup_path . "/Documents/");
 copyFolder("~/Library/Keychains/", $backup_path . "/Library/Keychains/");
 copyFolder("~/Library/Preferences/", $backup_path . "/Library/Preferences/");
 copyFolder("~/Library/Fonts/", $backup_path . "/Library/Fonts/");
 copyFolder("~/Library/Application Support/Firefox/", $backup_path . "/Library/Application Support/Firefox");
 copyFolder("~/Library/Application Support/Sequel Pro/", $backup_path . "/Library/Application Support/Sequel Pro/");