Example #1
0
 function cleanAlbum($obj)
 {
     global $albumcount;
     $subalbum = $obj->name;
     $file = basename($subalbum);
     $seoname = seoFriendly($file);
     if ($seoname != $file) {
         $newname = dirname($subalbum);
         if (empty($newname) || $newname == '.') {
             $newname = $seoname;
         } else {
             $newname .= '/' . $seoname;
         }
         if ($e = $obj->rename($newname)) {
             $error = getE($e, $subalbum, $newname);
             printf(gettext('<em>%1$s</em> rename to <em>%2$s</em> failed: %3$s'), $subalbum, $newname, $error);
             echo "<br />\n";
         } else {
             $obj->save();
             clearstatcache();
             printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $subalbum, $newname);
             echo "<br />\n";
             $albumcount++;
             $obj = newAlbum($newname);
         }
     }
     if (!$obj->isDynamic()) {
         checkFolder($obj);
     }
 }
Example #2
0
 function cleanAlbum($obj)
 {
     global $albumcount;
     $subalbum = $obj->name;
     $file = basename($subalbum);
     $seoname = seoFriendly($file);
     $album_cleaned = false;
     if ($seoname != $file) {
         $newname = dirname($subalbum);
         if (empty($newname) || $newname == '.') {
             $newname = $seoname;
         } else {
             $newname .= '/' . $seoname;
         }
         if ($e = $obj->rename($newname)) {
             $error = getE($e, $subalbum, $newname);
             printf(gettext('<em>%1$s</em> rename to <em>%2$s</em> failed: %3$s'), $subalbum, $newname, $error);
             echo "<br />\n";
         } else {
             $obj->save();
             clearstatcache();
             printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $subalbum, $newname);
             echo "<br />\n";
             $albumcount++;
             $obj = newAlbum($newname);
             zpFunctions::removeDir(SERVERCACHE . '/' . $subalbum);
             if (extensionEnabled('static_html_cache')) {
                 Gallery::clearCache(SERVERPATH . '/' . STATIC_CACHE_FOLDER);
             }
             $album_cleaned = true;
         }
     }
     if (!$obj->isDynamic()) {
         checkFolder($obj, $album_cleaned);
     }
 }
Example #3
0
function apiMoveLab($lab, $path)
{
    $rc = checkFolder(BASE_LAB . $path);
    if ($rc === 2) {
        // Folder is not valid
        $output['code'] = 400;
        $output['status'] = 'fail';
        $output['message'] = $GLOBALS['messages'][60009];
        return $output;
    } else {
        if ($rc === 1) {
            // Folder does not exist
            $output['code'] = 404;
            $output['status'] = 'fail';
            $output['message'] = $GLOBALS['messages'][60008];
            return $output;
        }
    }
    if (is_file(BASE_LAB . $path . '/' . $lab->getFilename())) {
        $output['code'] = 400;
        $output['status'] = 'fail';
        $output['message'] = $GLOBALS['messages'][60016];
        return $output;
    }
    if (rename($lab->getPath() . '/' . $lab->getFilename(), BASE_LAB . $path . '/' . $lab->getFilename())) {
        $output['code'] = 200;
        $output['status'] = 'success';
        $output['message'] = $GLOBALS['messages'][60035];
    } else {
        $output['code'] = 400;
        $output['status'] = 'fail';
        $output['message'] = $GLOBALS['messages'][60034];
        error_log('ERROR: ' . $GLOBALS['messages'][60034]);
    }
    return $output;
}
Example #4
0
    $cookie = $app->getCookie('unetlab_session');
    $app->deleteCookie('unetlab_session');
    $output = apiLogout($db, $cookie);
    $app->response->setStatus($output['code']);
    $app->response->setBody(json_encode($output));
});
$app->get('/api/auth', function () use($app, $db) {
    list($user, $tenant, $output) = apiAuthorization($db, $app->getCookie('unetlab_session'));
    if ($user === False) {
        // Set 401 not 412 for this page only -> used to refresh after a logout
        $output['code'] = 401;
        $app->response->setStatus($output['code']);
        $app->response->setBody(json_encode($output));
        return;
    }
    if (checkFolder(BASE_LAB . $user['folder']) !== 0) {
        // User has an invalid last viewed folder
        $user['folder'] = '/';
    }
    $output['code'] = 200;
    $output['status'] = 'success';
    $output['message'] = $GLOBALS['messages']['90002'];
    $output['data'] = $user;
    $app->response->setStatus($output['code']);
    $app->response->setBody(json_encode($output));
});
/*
* TODO
$app -> put('/api/auth', function() use ($app, $db) {
	// Set tenant
	// TODO should be used by admin user on single-user mode only
Example #5
0
/**
 * Function to get all folders from a path.
 *
 * @param   string     $path            Path
 * @return  Array                       List of folders (JSend data)
 */
function apiGetFolders($path)
{
    $rc = checkFolder(BASE_LAB . $path);
    if ($rc === 2) {
        // Folder is not valid
        $output['code'] = 400;
        $output['status'] = 'fail';
        $output['message'] = $GLOBALS['messages'][60009];
        return $output;
    } else {
        if ($rc === 1) {
            // Folder does not exist
            $output['code'] = 404;
            $output['status'] = 'fail';
            $output['message'] = $GLOBALS['messages'][60008];
            return $output;
        }
    }
    // Listing content
    $folders = array();
    $labs = array();
    if ($path != '/') {
        // Adding '..' folder
        $folders[] = array('name' => '..', 'path' => dirname($path));
    }
    // Scanning directory
    foreach (scandir(BASE_LAB . $path) as $element) {
        if (!in_array($element, array('.', '..'))) {
            if (is_dir(BASE_LAB . $path . '/' . $element)) {
                if ($path == '/') {
                    $folders[] = array('name' => $element, 'path' => '/' . $element);
                } else {
                    $folders[] = array('name' => $element, 'path' => $path . '/' . $element);
                }
                continue;
            }
            if (is_file(BASE_LAB . $path . '/' . $element) && preg_match('/^.+\\.unl$/', $element)) {
                if ($path == '/') {
                    $labs[] = array('file' => $element, 'path' => '/' . $element);
                } else {
                    $labs[] = array('file' => $element, 'path' => $path . '/' . $element);
                }
                continue;
            }
        }
    }
    // Sorting
    usort($folders, function ($a, $b) {
        return strnatcasecmp($a['name'], $b['name']);
    });
    usort($labs, function ($a, $b) {
        return strnatcasecmp($a['file'], $b['file']);
    });
    // Printing info
    $output['code'] = 200;
    $output['status'] = 'success';
    $output['message'] = $GLOBALS['messages'][60007];
    $output['data'] = array('folders' => $folders, 'labs' => $labs);
    return $output;
}
Example #6
0
function checkFolder($folder)
{
    global $albums, $gallery, $count, $albumcount;
    $files = scandir(ALBUM_FOLDER_SERVERPATH . '/' . $folder);
    $display = true;
    if (!empty($folder)) {
        $album = new Album($gallery, filesystemToInternal($folder));
    }
    foreach ($files as $file) {
        $file = str_replace('\\', '/', $file);
        $key = str_replace(SERVERPATH . '/', '', $folder . '/' . $file);
        if (is_dir(ALBUM_FOLDER_SERVERPATH . $folder . '/' . $file) && $file != '..' && $file != '.') {
            if (empty($folder)) {
                $albumname = $file;
            } else {
                $albumname = $folder . '/' . $file;
            }
            checkFolder($albumname);
        } else {
            if (is_valid_image($file) || is_valid_other_type($file)) {
                $filename = internalToFilesystem($file);
                $seoname = seoFriendly($filename);
                if ($seoname != $filename) {
                    $old = filesystemToInternal($file);
                    $image = newImage($album, $old);
                    if (!($e = $image->rename($seoname))) {
                        if ($display) {
                            echo '<p>' . filesystemToInternal($folder) . "</p>\n";
                            $display = false;
                        }
                        echo '&nbsp;&nbsp;';
                        printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $old, $seoname);
                        echo "<br />\n";
                        $count++;
                        ?>
						<script type="text/javascript">
						<!--
							imagecount = <?php 
                        echo $count;
                        ?>
;
						//-->
						</script>
						<?php 
                    }
                }
            }
        }
    }
    if (!empty($folder)) {
        $albumname = internalToFilesystem($folder);
        $file = basename($albumname);
        $seoname = seoFriendly($file);
        if ($seoname != $file) {
            $newname = dirname($albumname);
            if (empty($newname) || $newname == '.') {
                $newname = $seoname;
            } else {
                $newname .= '/' . $seoname;
            }
            if (!$album->rename($newname)) {
                printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $albumname, $newname);
                echo "<br />\n";
                $albumcount++;
                ?>
				<script type="text/javascript">
				<!--
					albumcount = <?php 
                echo $albumcount;
                ?>
;
				//-->
				</script>
				<?php 
            }
        }
    }
}
function checkGroup($group)
{
    global $readClient, $writeClient;
    global $oldPath;
    global $newSite;
    global $dryrun;
    global $verbose;
    global $checked;
    global $exit_on_error;
    $type = "group";
    if (isset($checked["{$type}.{$group}"])) {
        return;
    } else {
        $checked["{$type}.{$group}"] = 1;
    }
    if ($verbose > 2) {
        echo "Checking {$type} " . getName($group) . "...\n";
    }
    $ident->id = getName($group);
    $ident->type = strtolower($type);
    $writeClient->read($ident);
    if (!$writeClient->success) {
        $ident->id = $group;
        $readClient->read($ident);
        if (!$readClient->success) {
            echo "Failed reading: " . $group . "\n";
            echo cleanup($readClient->response);
            if ($exit_on_error) {
                cleanexit();
            } else {
                return;
            }
        }
        $asset = $readClient->asset;
        $asset->{$type}->groupName = getName($group);
        #
        # only keep members with accounts in new environment
        #
        global $host, $host2;
        if ($host != $host2 && isset($asset->{$type}->users)) {
            $users = preg_split('/;/', $asset->{$type}->users);
            $newusers = array();
            foreach ($users as &$user) {
                $ident->id = $user;
                $ident->type = 'user';
                $writeClient->read($ident);
                if ($writeClient->success) {
                    array_push($newusers, $user);
                } else {
                    if ($verbose > 1) {
                        echo "*** Skipping user {$user}\n";
                    }
                }
            }
            $asset->{$type}->users = join(';', $newusers);
        }
        removeIds($asset->{$type});
        if (want($asset->{$type}->groupAssetFactoryContainerPath, 'assetFactoryContainer')) {
            checkContainer($asset->{$type}->groupAssetFactoryContainerId, $asset->{$type}->groupAssetFactoryContainerPath, 'assetFactoryContainer');
        } else {
            if ($verbose > 1) {
                echo "*** Adjusting groupAssetFactoryContainerPath in {$type} {$group}\n";
            }
            $asset->{$type}->groupAssetFactoryContainerPath = null;
        }
        if (isset($asset->{$type}->groupStartingPagePath)) {
            if (want($asset->{$type}->groupStartingPagePath, 'page')) {
                checkAsset($asset->id, $asset->{$type}->groupStartingPagePath, 'page');
                $asset->{$type}->groupStartingPagePath = getPath($asset->{$type}->groupStartingPagePath);
            } else {
                if ($verbose > 1) {
                    echo "*** Adjusting groupStartingPagePath in {$type} {$group}\n";
                }
                $asset->{$type}->groupStartingPagePath = null;
            }
        }
        if (isset($asset->{$type}->groupBaseFolderPath)) {
            if (want($asset->{$type}->groupBaseFolderPath, 'folder')) {
                checkFolder($asset->{$type}->{$groupBaseFolderId}, $asset->{$type}->groupBaseFolderPath);
                $asset->{$type}->groupBaseFolderPath = getPath($asset->{$type}->groupBaseFolderPath);
            } else {
                if ($verbose > 1) {
                    echo "*** Adjusting groupBaseFolderPath in {$type} {$group}\n";
                }
                $asset->{$type}->groupBaseFolderPath = null;
            }
        }
        if ($verbose) {
            echo "Creating: {$type} " . getName($group) . "\n";
        }
        if (!$dryrun) {
            $writeClient->create($asset);
            if (!$writeClient->success) {
                if (!preg_match('/already exists/', $writeClient->message)) {
                    echo "\nFailed: {$type} " . getName($group) . "\n";
                    print_r($asset);
                    echo cleanup($writeClient->response);
                    if ($exit_on_error) {
                        cleanexit();
                    } else {
                        return;
                    }
                }
            }
        }
    }
}
Example #8
0
function resetAccessData_temp()
{
    handlePower('恢复模板数据');
    //管理权限处理
    $GLOBALS['conn='] = OpenConn();
    $splStr = '';
    $i = '';
    $s = '';
    $columnname = '';
    $title = '';
    $nCount = '';
    $webdataDir = '';
    $webdataDir = @$_REQUEST['webdataDir'];
    if ($webdataDir != '') {
        if (checkFolder($webdataDir) == false) {
            eerr('网站数据目录不存在,恢复默认数据未成功', $webdataDir);
        }
    } else {
        $webdataDir = '/Data/WebData/';
    }
    aspEcho('提示', '恢复数据完成');
    rw('<hr><a href=\'../index.php\' target=\'_blank\'>进入首页</a> | <a href="?" target=\'_blank\'>进入后台</a>');
    $content = '';
    $filePath = '';
    $parentid = '';
    $author = '';
    $adddatetime = '';
    $fileName = '';
    $bodycontent = '';
    $webtitle = '';
    $webkeywords = '';
    $webdescription = '';
    $sortrank = '';
    $labletitle = '';
    $target = '';
    $websitebottom = '';
    $webTemplate = '';
    $webimages = '';
    $webcss = '';
    $webjs = '';
    $flags = '';
    $websiteurl = '';
    $splxx = '';
    $columntype = '';
    $relatedtags = '';
    $npagesize = '';
    $customaurl = '';
    $nofollow = '';
    $templatepath = '';
    $isthrough = '';
    $titlecolor = '';
    $showreason = '';
    $ncomputersearch = '';
    $nmobliesearch = '';
    $ncountsearch = '';
    $ndegree = '';
    //竞价表
    $displaytitle = '';
    $aboutcontent = '';
    $isonhtml = '';
    //单页表
    $columnenname = '';
    //导航表
    $smallimage = '';
    $bigImage = '';
    $bannerimage = '';
    //文章表
    $httpurl = '';
    $price = '';
    $morepageurl = '';
    $charset = '';
    $thispage = '';
    $countpage = '';
    $bigClassName = '';
    $startStr = '';
    $endStr = '';
    $startaddstr = '';
    $endaddstr = '';
    $sType = '';
    $saction = '';
    $fieldName = '';
    $fieldcheck = '';
    //网站配置
    $content = GetFText($webdataDir . '/website.txt');
    //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
    if (inStr($content, vbCrlf()) == false) {
        $content = replace($content, chr(10), vbCrlf());
    }
    if ($content != '') {
        $webtitle = newGetStrCut($content, 'webtitle');
        $webkeywords = newGetStrCut($content, 'webkeywords');
        $webdescription = newGetStrCut($content, 'webdescription');
        $websitebottom = newGetStrCut($content, 'websitebottom');
        $webTemplate = newGetStrCut($content, 'webtemplate');
        $webimages = newGetStrCut($content, 'webimages');
        $webcss = newGetStrCut($content, 'webcss');
        $webjs = newGetStrCut($content, 'webjs');
        $flags = newGetStrCut($content, 'flags');
        $websiteurl = newGetStrCut($content, 'websiteurl');
        if (getRecordCount($GLOBALS['db_PREFIX'] . 'website', '') == 0) {
            connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'website(webtitle) values(\'测试\')');
        }
        connexecute('update ' . $GLOBALS['db_PREFIX'] . 'website  set webtitle=\'' . $webtitle . '\',webkeywords=\'' . $webkeywords . '\',webdescription=\'' . $webdescription . '\',websitebottom=\'' . $websitebottom . '\',webtemplate=\'' . $webTemplate . '\',webimages=\'' . $webimages . '\',webcss=\'' . $webcss . '\',webjs=\'' . $webjs . '\',flags=\'' . $flags . '\',websiteurl=\'' . $websiteurl . '\'');
    }
    //导航
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'webcolumn');
    $content = getDirTxtList($webdataDir . '/webcolumn/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('导航', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【webtitle】') > 0) {
                    $s = $s . vbCrlf();
                    $webtitle = newGetStrCut($s, 'webtitle');
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $webdescription = newGetStrCut($s, 'webdescription');
                    $customaurl = newGetStrCut($s, 'customaurl');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    $fileName = newGetStrCut($s, 'filename');
                    $columnname = newGetStrCut($s, 'columnname');
                    $columnenname = newGetStrCut($s, 'columnenname');
                    $columntype = newGetStrCut($s, 'columntype');
                    $flags = newGetStrCut($s, 'flags');
                    $parentid = newGetStrCut($s, 'parentid');
                    $parentid = phpTrim(getColumnId($parentid));
                    //可根据栏目名称找到对应ID   不存在为-1
                    //call echo("parentid",parentid)
                    $labletitle = newGetStrCut($s, 'labletitle');
                    //每页显示条数
                    $npagesize = newGetStrCut($s, 'npagesize');
                    if ($npagesize == '') {
                        $npagesize = 10;
                    }
                    //默认分页数为10条
                    $target = newGetStrCut($s, 'target');
                    $smallimage = newGetStrCut($s, 'smallimage');
                    $bigImage = newGetStrCut($s, 'bigImage');
                    $bannerimage = newGetStrCut($s, 'bannerimage');
                    $templatepath = newGetStrCut($s, 'templatepath');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $bodycontent = contentTranscoding($bodycontent);
                    //是否启用生成html
                    $isonhtml = newGetStrCut($s, 'isonhtml');
                    if ($isonhtml == '0' || lCase($isonhtml) == 'false') {
                        $isonhtml = 0;
                    } else {
                        $isonhtml = 1;
                    }
                    //是否为nofollow
                    $nofollow = newGetStrCut($s, 'nofollow');
                    if ($nofollow == '1' || lCase($nofollow) == 'true') {
                        $nofollow = 1;
                    } else {
                        $nofollow = 0;
                    }
                    //call echo(columnname,nofollow)
                    $aboutcontent = newGetStrCut($s, 'aboutcontent');
                    $aboutcontent = contentTranscoding($aboutcontent);
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $bodycontent = contentTranscoding($bodycontent);
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'webcolumn (webtitle,webkeywords,webdescription,columnname,columnenname,columntype,sortrank,filename,customaurl,flags,parentid,labletitle,aboutcontent,bodycontent,npagesize,isonhtml,nofollow,target,smallimage,bigImage,bannerimage,templatepath) values(\'' . $webtitle . '\',\'' . $webkeywords . '\',\'' . $webdescription . '\',\'' . $columnname . '\',\'' . $columnenname . '\',\'' . $columntype . '\',' . $sortrank . ',\'' . $fileName . '\',\'' . $customaurl . '\',\'' . $flags . '\',' . $parentid . ',\'' . $labletitle . '\',\'' . $aboutcontent . '\',\'' . $bodycontent . '\',' . $npagesize . ',' . $isonhtml . ',' . $nofollow . ',\'' . $target . '\',\'' . $smallimage . '\',\'' . $bigImage . '\',\'' . $bannerimage . '\',\'' . $templatepath . '\')');
                }
            }
        }
    }
    //文章
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'articledetail');
    $content = getDirAllFileList($webdataDir . '/articledetail/', 'txt');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('文章', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【title】') > 0) {
                    $s = $s . vbCrlf();
                    $parentid = newGetStrCut($s, 'parentid');
                    $parentid = getColumnId($parentid);
                    $title = newGetStrCut($s, 'title');
                    $titlecolor = newGetStrCut($s, 'titlecolor');
                    $webtitle = newGetStrCut($s, 'webtitle');
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $webdescription = newGetStrCut($s, 'webdescription');
                    $author = newGetStrCut($s, 'author');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $fileName = newGetStrCut($s, 'filename');
                    $templatepath = newGetStrCut($s, 'templatepath');
                    $flags = newGetStrCut($s, 'flags');
                    $relatedtags = newGetStrCut($s, 'relatedtags');
                    $customaurl = newGetStrCut($s, 'customaurl');
                    $target = newGetStrCut($s, 'target');
                    $smallimage = newGetStrCut($s, 'smallimage');
                    $bigImage = newGetStrCut($s, 'bigImage');
                    $bannerimage = newGetStrCut($s, 'bannerimage');
                    $labletitle = newGetStrCut($s, 'labletitle');
                    $aboutcontent = newGetStrCut($s, 'aboutcontent');
                    $aboutcontent = contentTranscoding($aboutcontent);
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $bodycontent = contentTranscoding($bodycontent);
                    //是否启用生成html
                    $isonhtml = newGetStrCut($s, 'isonhtml');
                    if ($isonhtml == '0' || lCase($isonhtml) == 'false') {
                        $isonhtml = 0;
                    } else {
                        $isonhtml = 1;
                    }
                    //是否为nofollow
                    $nofollow = newGetStrCut($s, 'nofollow');
                    if ($nofollow == '1' || lCase($nofollow) == 'true') {
                        $nofollow = 1;
                    } else {
                        $nofollow = 0;
                    }
                    //价格
                    $price = getDianNumb(newGetStrCut($s, 'price'));
                    if ($price == '') {
                        $price = 0;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'articledetail (parentid,title,titlecolor,webtitle,webkeywords,webdescription,author,sortrank,adddatetime,filename,flags,relatedtags,aboutcontent,bodycontent,updatetime,isonhtml,customaurl,nofollow,target,smallimage,bigImage,bannerimage,templatepath,labletitle,price) values(' . $parentid . ',\'' . $title . '\',\'' . $titlecolor . '\',\'' . $webtitle . '\',\'' . $webkeywords . '\',\'' . $webdescription . '\',\'' . $author . '\',' . $sortrank . ',\'' . $adddatetime . '\',\'' . $fileName . '\',\'' . $flags . '\',\'' . $relatedtags . '\',\'' . $aboutcontent . '\',\'' . $bodycontent . '\',\'' . now() . '\',' . $isonhtml . ',\'' . $customaurl . '\',' . $nofollow . ',\'' . $target . '\',\'' . $smallimage . '\',\'' . $bigImage . '\',\'' . $bannerimage . '\',\'' . $templatepath . '\',\'' . $labletitle . '\',' . $price . ')');
                }
            }
        }
    }
    //单页
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'OnePage');
    $content = getDirTxtList($webdataDir . '/OnePage/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('单页', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【webkeywords】') > 0) {
                    $s = $s . vbCrlf();
                    $title = newGetStrCut($s, 'title');
                    $displaytitle = newGetStrCut($s, 'displaytitle');
                    $webtitle = newGetStrCut($s, 'webtitle');
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $webdescription = newGetStrCut($s, 'webdescription');
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $fileName = newGetStrCut($s, 'filename');
                    $aboutcontent = newGetStrCut($s, 'aboutcontent');
                    $aboutcontent = contentTranscoding($aboutcontent);
                    $target = newGetStrCut($s, 'target');
                    $templatepath = newGetStrCut($s, 'templatepath');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $bodycontent = contentTranscoding($bodycontent);
                    //是否启用生成html
                    $isonhtml = newGetStrCut($s, 'isonhtml');
                    if ($isonhtml == '0' || lCase($isonhtml) == 'false') {
                        $isonhtml = 0;
                    } else {
                        $isonhtml = 1;
                    }
                    //是否为nofollow
                    $nofollow = newGetStrCut($s, 'nofollow');
                    if ($nofollow == '1' || lCase($nofollow) == 'true') {
                        $nofollow = 1;
                    } else {
                        $nofollow = 0;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'onepage (title,displaytitle,webtitle,webkeywords,webdescription,adddatetime,filename,isonhtml,aboutcontent,bodycontent,nofollow,target,templatepath) values(\'' . $title . '\',\'' . $displaytitle . '\',\'' . $webtitle . '\',\'' . $webkeywords . '\',\'' . $webdescription . '\',\'' . $adddatetime . '\',\'' . $fileName . '\',' . $isonhtml . ',\'' . $aboutcontent . '\',\'' . $bodycontent . '\',' . $nofollow . ',\'' . $target . '\',\'' . $templatepath . '\')');
                }
            }
        }
    }
    //竞价
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'Bidding');
    $content = getDirTxtList($webdataDir . '/Bidding/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('竞价', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【webkeywords】') > 0) {
                    $s = $s . vbCrlf();
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $showreason = newGetStrCut($s, 'showreason');
                    $ncomputersearch = newGetStrCut($s, 'ncomputersearch');
                    $nmobliesearch = newGetStrCut($s, 'nmobliesearch');
                    $ncountsearch = newGetStrCut($s, 'ncountsearch');
                    $ndegree = newGetStrCut($s, 'ndegree');
                    $ndegree = getNumber($ndegree);
                    if ($ndegree == '') {
                        $ndegree = 0;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'Bidding (webkeywords,showreason,ncomputersearch,nmobliesearch,ndegree) values(\'' . $webkeywords . '\',\'' . $showreason . '\',' . $ncomputersearch . ',' . $nmobliesearch . ',' . $ndegree . ')');
                }
            }
        }
    }
    //搜索统计
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'SearchStat');
    $content = getDirTxtList($webdataDir . '/SearchStat/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('搜索统计', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【title】') > 0) {
                    $s = $s . vbCrlf();
                    $title = newGetStrCut($s, 'title');
                    $webtitle = newGetStrCut($s, 'webtitle');
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $webdescription = newGetStrCut($s, 'webdescription');
                    $customaurl = newGetStrCut($s, 'customaurl');
                    $target = newGetStrCut($s, 'target');
                    $isthrough = newGetStrCut($s, 'isthrough');
                    if ($isthrough == '0' || lCase($isthrough) == 'false') {
                        $isthrough = 0;
                    } else {
                        $isthrough = 1;
                    }
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    //是否启用生成html
                    $isonhtml = newGetStrCut($s, 'isonhtml');
                    if ($isonhtml == '0' || lCase($isonhtml) == 'false') {
                        $isonhtml = 0;
                    } else {
                        $isonhtml = 1;
                    }
                    //是否为nofollow
                    $nofollow = newGetStrCut($s, 'nofollow');
                    if ($nofollow == '1' || lCase($nofollow) == 'true') {
                        $nofollow = 1;
                    } else {
                        $nofollow = 0;
                    }
                    //call echo("title",title)
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'SearchStat (title,webtitle,webkeywords,webdescription,customaurl,target,isthrough,sortrank,isonhtml,nofollow) values(\'' . $title . '\',\'' . $webtitle . '\',\'' . $webkeywords . '\',\'' . $webdescription . '\',\'' . $customaurl . '\',\'' . $target . '\',' . $isthrough . ',' . $sortrank . ',' . $isonhtml . ',' . $nofollow . ')');
                }
            }
        }
    }
    $itemid = '';
    $userName = '';
    $ip = '';
    $reply = '';
    $tableName = '';
    //评论
    //评论
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'TableComment');
    $content = getDirTxtList($webdataDir . '/TableComment/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('评论', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【title】') > 0) {
                    $s = $s . vbCrlf();
                    $tableName = newGetStrCut($s, 'tablename');
                    $title = newGetStrCut($s, 'title');
                    $itemid = getArticleId(newGetStrCut($s, 'itemid'));
                    if ($itemid == '') {
                        $itemid = 0;
                    }
                    //call echo("itemID",itemID)
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $userName = newGetStrCut($s, 'username');
                    $ip = newGetStrCut($s, 'ip');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $reply = newGetStrCut($s, 'reply');
                    $isthrough = newGetStrCut($s, 'isthrough');
                    if ($isthrough == '0' || lCase($isthrough) == 'false') {
                        $isthrough = 0;
                    } else {
                        $isthrough = 1;
                    }
                    //call echo("title",title)
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'TableComment (tablename,title,itemid,adddatetime,username,ip,bodycontent,reply,isthrough) values(\'' . $tableName . '\',\'' . $title . '\',' . $itemid . ',\'' . $adddatetime . '\',\'' . $userName . '\',\'' . $ip . '\',\'' . $bodycontent . '\',\'' . $reply . '\',' . $isthrough . ')');
                }
            }
        }
    }
    //友情链接
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'FriendLink');
    $content = getDirTxtList($webdataDir . '/FriendLink/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('评论', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【title】') > 0) {
                    $s = $s . vbCrlf();
                    $title = newGetStrCut($s, 'title');
                    $httpurl = newGetStrCut($s, 'httpurl');
                    $smallimage = newGetStrCut($s, 'smallimage');
                    $flags = newGetStrCut($s, 'flags');
                    $target = newGetStrCut($s, 'target');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '0' || lCase($sortrank) == 'false') {
                        $sortrank = 0;
                    } else {
                        $sortrank = 1;
                    }
                    $isthrough = newGetStrCut($s, 'isthrough');
                    if ($isthrough == '0' || lCase($isthrough) == 'false') {
                        $isthrough = 0;
                    } else {
                        $isthrough = 1;
                    }
                    //call echo("title",title)
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'FriendLink (title,httpurl,smallimage,flags,sortrank,isthrough,target) values(\'' . $title . '\',\'' . $httpurl . '\',\'' . $smallimage . '\',\'' . $flags . '\',' . $sortrank . ',' . $isthrough . ',\'' . $target . '\')');
                }
            }
        }
    }
    //留言
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'GuestBook');
    $content = getDirTxtList($webdataDir . '/GuestBook/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('留言', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【adddatetime】') > 0) {
                    $s = $s . vbCrlf();
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $reply = newGetStrCut($s, 'reply');
                    $isthrough = newGetStrCut($s, 'isthrough');
                    if ($isthrough == '0' || lCase($isthrough) == 'false') {
                        $isthrough = 0;
                    } else {
                        $isthrough = 1;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'GuestBook (adddatetime,bodycontent,reply,isthrough) values(\'' . $adddatetime . '\',\'' . $bodycontent . '\',\'' . $reply . '\',' . $isthrough . ')');
                }
            }
        }
    }
    //采集网站
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'CaiWeb');
    $content = getDirTxtList($webdataDir . '/CaiWeb/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('采集网站', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【bigclassname】') > 0) {
                    $s = $s . vbCrlf();
                    $bigClassName = newGetStrCut($s, 'bigclassname');
                    $httpurl = newGetStrCut($s, 'httpurl');
                    $morepageurl = newGetStrCut($s, 'morepageurl');
                    $charset = newGetStrCut($s, 'charset');
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    $thispage = newGetStrCut($s, 'thispage');
                    if ($thispage == '') {
                        $thispage = 0;
                    }
                    $countpage = newGetStrCut($s, 'countpage');
                    if ($countpage == '') {
                        $thispage = 0;
                    }
                    $columnname = newGetStrCut($s, 'columnname');
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'CaiWeb (adddatetime,bodycontent,httpurl,morepageurl,charset,sortrank,thispage,countpage,bigclassname,columnname) values(\'' . $adddatetime . '\',\'' . $bodycontent . '\',\'' . $httpurl . '\',\'' . $morepageurl . '\',\'' . $charset . '\',' . $sortrank . ',' . $thispage . ',' . $countpage . ',\'' . $bigClassName . '\',\'' . $columnname . '\')');
                }
            }
        }
    }
    //采集配置
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'CaiConfig');
    $content = getDirTxtList($webdataDir . '/CaiConfig/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('采集配置', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【bigclassname】') > 0) {
                    $s = $s . vbCrlf();
                    $bigClassName = newGetStrCut($s, 'bigclassname');
                    $sType = newGetStrCut($s, 'stype');
                    $startStr = newGetStrCut($s, 'startstr');
                    $endStr = newGetStrCut($s, 'endstr');
                    $startaddstr = newGetStrCut($s, 'startaddstr');
                    $endaddstr = newGetStrCut($s, 'endaddstr');
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    $saction = newGetStrCut($s, 'saction');
                    $isthrough = newGetStrCut($s, 'isthrough');
                    $isthrough = IIF($isthrough == '0' || lCase($isthrough) == 'false', 0, 1);
                    $fieldName = newGetStrCut($s, 'fieldname');
                    $fieldcheck = newGetStrCut($s, 'fieldcheck');
                    if ($fieldcheck == '') {
                        $fieldcheck = 0;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'CaiConfig (adddatetime,sortrank,bigclassname,stype,startstr,endstr,startaddstr,endaddstr,saction,isthrough,fieldname,fieldcheck) values(\'' . $adddatetime . '\',' . $sortrank . ',\'' . $bigClassName . '\',\'' . $sType . '\',\'' . $startStr . '\',\'' . $endStr . '\',\'' . $startaddstr . '\',\'' . $endaddstr . '\',\'' . $saction . '\',' . $isthrough . ',\'' . $fieldName . '\',' . $fieldcheck . ')');
                }
            }
        }
    }
    writeSystemLog('', '恢复默认数据' . $GLOBALS['db_PREFIX']);
    //系统日志
}
Example #9
0
function getFileFolderList($folderPath, $c = '', $action = '|处理文件#|处理文件夹|文件名称|文件夹名称|循环文件夹|', $fileTypeList = '|*|')
{
    $folderPath = handlePath($folderPath);
    //文件夹为假退出 加了这个判断尽然把HTTP 错误 500.0 - Internal Server Error  报错给解决了 小云你牛 20160719home
    if (checkFolder($folderPath) == false) {
        return $c;
    }
    $fso = @opendir($folderPath);
    if ($fso) {
        while (($file = readdir($fso)) !== false) {
            if ($file != '.' && $file != '..') {
                $ffPath = $folderPath . "\\" . $file;
                //为文件夹
                if (is_dir($ffPath)) {
                    if (strstr('|' . $action . '|', '|处理文件夹|')) {
                        if (strstr('|' . $action . '|', '|文件夹名称|')) {
                            $s = $file;
                        } else {
                            $s = handlePath($ffPath);
                        }
                        $c = $c . $s . vbCrlf();
                    }
                    if (strstr('|' . $action . '|', '|循环文件夹|')) {
                        //aspecho('$ffPath',$ffPath);
                        $tempC = getFileFolderList($ffPath, "", $action, $fileTypeList);
                        if ($tempC != '') {
                            $tempC = $tempC . vbCrlf();
                        }
                        $c = $c . $tempC;
                    }
                } elseif (strstr('|' . $action . '|', '|处理文件|')) {
                    $fileType = strtolower(substr(strrchr($file, '.'), 1));
                    if (strstr('|' . $action . '|', '|文件名称|')) {
                        $s = $file;
                    } elseif (strstr('|' . $action . '|', '|文件类型|')) {
                        $s = $fileType;
                    } else {
                        $s = handlePath($ffPath);
                    }
                    if (strstr('|' . $fileTypeList . '|', '|' . $fileType . '|') || strstr('|' . $fileTypeList . '|', '|*|')) {
                        $c = $c . $s . vbCrlf();
                    }
                }
            }
        }
        closedir($fso);
    }
    if ($c != '') {
        $c = substr($c, 0, strlen($c) - 2);
    }
    return $c;
}