コード例 #1
0
ファイル: diff.php プロジェクト: kelsh/classic
function diff($path, $action, $title, $content)
{
    $Head = '<meta name="robots" content="noindex, nofollow" />';
    $content['PageNav']->Active("Page History");
    if (is_numeric($action[1])) {
        $pageQuery = mysql_query("SELECT `PageID`,`AccountID`,`EditTime`,`Name`,`Description`,`Title`,`Content` FROM `Wiki_Edits` WHERE `ID`='{$action['1']}' and `Archived` = 0");
        list($PageID, $AccountID, $PageEditTime, $PageName, $PageDescription, $PageTitle, $pageContent) = mysql_fetch_array($pageQuery);
        $previousQuery = mysql_query("Select `ID`, `Content` from `Wiki_Edits` where `ID` < '{$action['1']}' and `PageID`='{$PageID}' and `Archived` = 0 order by `ID` desc limit 1");
        list($previousID, $previousContent) = mysql_fetch_array($previousQuery);
        $nextQuery = mysql_query("Select `ID` from `Wiki_Edits` where `ID` > '{$action['1']}' and `PageID`='{$PageID}' and `Archived` = 0 order by `ID` limit 1");
        list($nextID) = mysql_fetch_array($nextQuery);
        if (!empty($previousID)) {
            $previousPath = FormatPath("/{$path}/?diff/{$previousID}");
            $content['Title'] = "<a href='{$previousPath}' title='Previous Revision'>⟨</a> ";
        }
        $content['Title'] .= FishFormat($PageTitle);
        if (!empty($nextID)) {
            $nextPath = FormatPath("/{$path}/?diff/{$nextID}");
            $content['Title'] .= " <a href='{$nextPath}' title='Next Revision'>⟩</a>";
        }
        $content['Body'] .= <<<JavaScript
        
        <script>
            \$(document).ready(function ()
            {
                \$('body').on('keydown', function(event)
                {
                    event.stopImmediatePropagation()
                    
                    if(event.keyCode == 37) // Previous
                        location.href = '{$previousPath}';
                    else if(event.keyCode == 39) // Next
                        location.href = '{$nextPath}';
                });
            });
        </script>
JavaScript;
        $old = explode("\n", html_entity_decode($previousContent, ENT_QUOTES));
        $new = explode("\n", html_entity_decode($pageContent, ENT_QUOTES));
        // Initialize the diff class
        $diff = new Diff($old, $new);
        require_once dirname(__FILE__) . '/../libraries/Diff/Renderer/Html/SideBySide.php';
        $renderer = new Diff_Renderer_Html_SideBySide();
        $content['Body'] .= $diff->Render($renderer);
        date_default_timezone_set('America/New_York');
        $PageEditTime = formatTime($PageEditTime);
        $content['Footer'] = "This page is an old revision made by <b><a href='/names?id={$AccountID}'>{$PageName}</a></b> on {$PageEditTime}.";
        if ($PageDescription) {
            $content['Footer'] .= "<br />'{$PageDescription}'";
        }
    }
    return array($title, $content);
}
コード例 #2
0
ファイル: view.php プロジェクト: kelsh/classic
function view($path, $action, $title, $content)
{
    $content['PageNav']->Active("View Page");
    $PageQuery = mysql_query("SELECT `ID`,`Title`,`Content`,`Edits`,`Views`,`EditTime` FROM `Wiki_Pages` WHERE `Path`='{$path}'");
    list($PageID, $PageTitle, $PageContent, $PageEdits, $pageViews, $PageEditTime) = mysql_fetch_array($PageQuery);
    $tagQuery = mysql_query("Select tags.`tag`, stats.`count`\n                                from `Wiki_Tags` as tags,\n                                     `Wiki_Tag_Statistics` as stats\n                                     \n                                where tags.`pageID` = '{$PageID}'\n                                    and stats.`tag` = tags.`tag`");
    while (list($tagName, $tagCount) = mysql_fetch_array($tagQuery)) {
        $plural = 's';
        if ($tagCount == 1) {
            $plural = '';
        }
        $tagLink = urlencode($tagName);
        $tagTitle = str_replace('-', ' ', $tagName);
        $tagLinks[] = "<a href='/?tag/{$tagLink}' title='{$tagCount} tagged page{$plural}'>{$tagTitle}</a>";
    }
    if ($tagLinks) {
        $tagLinks = implode(" | ", $tagLinks);
        $tagLinks = "<hr />Tags: {$tagLinks}";
    }
    $PageTitle = PageTitler($PageTitle);
    if (empty($PageContent)) {
        $PageContent = array("Hello friend. b{Wetfish regrets to inform you this page does not exist.}", "", "Confused? This is the {{wiki|Wetfish Wiki}}, a place anyone can edit!", "It appears you've stumbled upon a place none have yet traveled.", "Would you like to be the first? {{{$path}/?edit|All it takes is a click.}}", "", "i{But please, don't wallow.}", "i{A new page surely follows.}", "i{You have the power.}");
        $PageContent = implode("<br />", $PageContent);
    } else {
        mysql_query("Update `Wiki_Pages` set `Views` = `Views` + 1 where `ID`='{$PageID}'");
    }
    if ($_SESSION['admin']) {
        $content['ExtraNav'] = new Navigation();
        $content['ExtraNav']->Add("Archive This Page", FormatPath("/{$path}/") . "?archive");
        $content['ExtraNav']->Add("Rename This Page", FormatPath("/{$path}/") . "?rename");
    }
    $title[] = FishFormat($PageTitle, "strip");
    $content['Title'] .= FishFormat($PageTitle);
    $content['Body'] .= FishFormat($PageContent);
    if ($PageEdits) {
        $EditCount = count(explode(",", $PageEdits));
        date_default_timezone_set('America/New_York');
        $PageEditTime = formatTime($PageEditTime);
        if ($pageViews != 1) {
            $viewPlural = 's';
        }
        if ($EditCount != 1) {
            $Plural = "s";
        }
        $content['Tags'] = $tagLinks;
        $content['Footer'] = "<b>" . number_format($pageViews) . "</b> page view{$viewPlural}. <b>{$EditCount}</b> edit{$Plural} &ensp;&mdash;&ensp; Last modified <b>{$PageEditTime}</b>.";
    }
    return array($title, $content);
}
コード例 #3
0
ファイル: recent.php プロジェクト: kelsh/classic
function recent($path, $action, $title, $content)
{
    //		$Head = '<meta name="robots" content="noindex, nofollow" />';
    $content['UserNav']->Active("Recent Activity");
    if (empty($_SESSION['Recent'])) {
        $_SESSION['Recent']['Active'][0] = "All Edits";
        $_SESSION['Recent']['Active'][3] = "Descending";
        $_SESSION['Recent']['Order'] = "DESC";
    }
    $content['ExtraNav'] = new Navigation();
    $content['ExtraNav']->Add("All Edits", "?recent/all");
    $content['ExtraNav']->Add("Most Recent Edit", "?recent/unique");
    $content['ExtraNav']->Add("Ascending", "?recent/asc");
    $content['ExtraNav']->Add("Descending", "?recent/desc");
    $content['ExtraNav']->Active($_SESSION['Recent']['Active']);
    $Template['Title'] = "View:";
    $content['ExtraNav']->Template($Template);
    if (empty($action[1])) {
        $content['Title'] = "Recent Activity";
        $ActivityQuery = "SELECT {$Unique} `ID`,`PageID`,`AccountID`,`EditTime`,`Size`,`Tags`,`Name`,`Description`,`Title` FROM `Wiki_Edits` where `Archived` = 0 ORDER BY `ID` {$_SESSION['Recent']['Order']}";
        list($QueryData, $Links) = Paginate($ActivityQuery, 50, $_GET['page'], $_SERVER['QUERY_STRING']);
        $content['Body'] .= "<center class='page-navigation'>{$Links}</center>";
        $content['Body'] .= "<table width='100%' class='history'>";
        $content['Body'] .= "<tr><td><b>Revision</b></td><td><b>Size</b></td><td><b>Tags</b></td><td><b>Editor</b></td><td style='min-width:200px;'><b>Title</b></td><td><b>Description</b></td></tr>";
        if ($QueryData) {
            foreach ($QueryData as $Result) {
                list($EditID, $PageID, $AccountID, $PageTime, $PageSize, $pageTags, $PageName, $PageDescription, $PageTitle) = $Result;
                if (empty($Data[$PageID])) {
                    $PageQuery = mysql_query("SELECT `Path` FROM `Wiki_Pages` WHERE `ID`='{$PageID}'");
                    list($PagePath) = mysql_fetch_array($PageQuery);
                    $Data[$PageID] = $PagePath;
                } else {
                    $PagePath = $Data[$PageID];
                }
                $Toggle++;
                date_default_timezone_set('America/New_York');
                $minWidth = recentTime($PageTime) ? 85 : 175;
                $PageTime = formatTime($PageTime);
                if ($Toggle % 2 == 1) {
                    $Class = "class='toggle'";
                } else {
                    $Class = '';
                }
                $PageName = FishFormat($PageName, "format");
                $PageDescription = FishFormat($PageDescription, "format");
                $PageTitle = FishFormat($PageTitle, "format");
                $DiffURL = str_replace("//", "/", "/{$PagePath}/?diff/{$EditID}");
                $content['Body'] .= "<tr {$Class}><td style='min-width:{$minWidth}px;'>{$PageTime}</td><td>{$PageSize}</td><td>{$pageTags}</td><td><b><a href='/edits?name={$PageName}'>{$PageName}</a></b></td><td style='max-width:400px'><span style='float:right;'><a href='{$DiffURL}' rel='nofollow'>d</a></span><b><a href='/{$PagePath}'>{$PageTitle}</a></b></td><td class='multi-line'>{$PageDescription}</td></tr>";
            }
        }
        $content['Body'] .= "</table>";
        $content['Body'] .= "<center class='page-navigation bottom'>{$Links}</center>";
    } elseif ($action[1] == "page") {
    } else {
        switch ($action[1]) {
            case "all":
                $_SESSION['Recent']['Active'][0] = "All Edits";
                $_SESSION['Recent']['Active'][1] = "";
                $_SESSION['Recent']['View'] = "";
                break;
            case "unique":
                $_SESSION['Recent']['Active'][0] = "";
                $_SESSION['Recent']['Active'][1] = "Most Recent Edit";
                $_SESSION['Recent']['View'] = "DISTINCT";
                break;
            case "asc":
                $_SESSION['Recent']['Active'][2] = "Ascending";
                $_SESSION['Recent']['Active'][3] = "";
                $_SESSION['Recent']['Order'] = "";
                break;
            case "desc":
                $_SESSION['Recent']['Active'][2] = "";
                $_SESSION['Recent']['Active'][3] = "Descending";
                $_SESSION['Recent']['Order'] = "DESC";
                break;
        }
        $content['Body'] = "<b>Settings changed...</b> <meta http-equiv='refresh' content='2;url=" . FormatPath("/{$path}/?recent") . "'>";
    }
    return array($title, $content);
}
コード例 #4
0
ファイル: exec.iscsi.php プロジェクト: BillTheBest/1.6.x
function build()
{
    $unix = new unix();
    $sock = new sockets();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . "pid";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid)) {
        build_progress("{$GLOBALS["deflog_start"]} Already process exists {$pid}", 110);
        echo "{$GLOBALS["deflog_start"]} Already process exists {$pid}\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $year = date('Y');
    $month = date('m');
    $EnableISCSI = intval($sock->GET_INFO("EnableISCSI"));
    $dd = $unix->find_program("dd");
    if ($EnableISCSI == 0) {
        build_progress("{$GLOBALS["deflog_start"]} {service_disabled}", 110);
        return;
    }
    $sql = "SELECT * FROM iscsi_params ORDER BY ID DESC";
    $q = new mysql();
    $c = 0;
    $dd = $unix->find_program("dd");
    $results = $q->QUERY_SQL($sql, 'artica_backup');
    if (!$q->ok) {
        build_progress("{$GLOBALS["deflog_start"]} MySQL error", 110);
        echo "{$GLOBALS["deflog_start"]} {$q->mysql_error}\n";
        return;
    }
    build_progress("{$GLOBALS["deflog_start"]} {building}...", 10);
    $max = mysql_num_rows($results);
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $hostname = $ligne["hostname"];
        $artica_type = $ligne["type"];
        $tbl = explode(".", $hostname);
        echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] ressource type:{$artica_type} {$ligne["dev"]}\n";
        build_progress("{$GLOBALS["deflog_start"]} {building} {$c}/{$max} {$artica_type} {$ligne["dev"]}", 20);
        if ($artica_type == "file") {
            if (!stat_system($ligne["dev"])) {
                echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] creating file {$ligne["dev"]} {$ligne["file_size"]}Go\n";
                $countsize = $ligne["file_size"] * 1000;
                $cmd = "{$dd} if=/dev/zero of={$ligne["dev"]} bs=1M count={$countsize}";
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] {$cmd}\n";
                }
                shell_exec($cmd);
                if (!stat_system($ligne["dev"])) {
                    build_progress("{$GLOBALS["deflog_start"]} {building} {$artica_type} {$ligne["dev"]} {failed}", 20);
                    echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] failed\n";
                    continue;
                }
            }
        }
        krsort($tbl);
        $newhostname = @implode(".", $tbl);
        $Params = unserialize(base64_decode($ligne["Params"]));
        if (!isset($Params["ImmediateData"])) {
            $Params["ImmediateData"] = 1;
        }
        if (!isset($Params["MaxConnections"])) {
            $Params["MaxConnections"] = 1;
        }
        if (!isset($Params["Wthreads"])) {
            $Params["Wthreads"] = 8;
        }
        if (!isset($Params["IoType"])) {
            $Params["IoType"] = "fileio";
        }
        if (!isset($Params["mode"])) {
            $Params["mode"] = "wb";
        }
        if (!is_numeric($Params["MaxConnections"])) {
            $Params["MaxConnections"] = 1;
        }
        if (!is_numeric($Params["ImmediateData"])) {
            $Params["ImmediateData"] = 1;
        }
        if (!is_numeric($Params["Wthreads"])) {
            $Params["Wthreads"] = 8;
        }
        if ($Params["IoType"] == null) {
            $Params["IoType"] = "fileio";
        }
        if ($Params["mode"] == null) {
            $Params["mode"] = "wb";
        }
        $EnableAuth = $ligne["EnableAuth"];
        $uid = trim($ligne["uid"]);
        echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] EnableAuth={$ligne["EnableAuth"]}\n";
        echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] uid=\"{$uid}\"\n";
        echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] Folder name=\"{$ligne["shared_folder"]} / {$ligne["type"]}\"\n";
        echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] Path=\"{$ligne["dev"]}\"\n";
        if ($ligne["type"] == "file") {
            if (is_dir($ligne["dev"])) {
                $newpath = FormatPath($ligne["dev"], $ligne["shared_folder"]);
                echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] Path is a directory assume {$newpath}\n";
                $ligne["dev"] = $newpath;
                $q->QUERY_SQL("UPDATE iscsi_params SET `dev`='{$newpath}' WHERE ID='{$ligne["ID"]}'", "artica_backup");
            }
        }
        if (is_link($ligne["dev"])) {
            $ligne["dev"] = @readlink($ligne["dev"]);
        }
        if ($ligne["type"] == "file") {
            $pathFile = $ligne["dev"];
            $pathDir = dirname($ligne["dev"]);
            if (!is_dir($pathDir)) {
                @mkdir($pathDir, 0755, true);
            }
            if (!stat_system($pathFile)) {
                echo "{$GLOBALS["deflog_start"]} [{$ligne["ID"]}] {$pathFile} no such file, create it\n";
                build_progress("{$GLOBALS["deflog_start"]} {building} {$pathFile}", 20);
                $countsize = $ligne["file_size"] * 1000;
                $cmd = "{$dd} if=/dev/zero of={$ligne["dev"]} bs=1M count={$countsize}";
                echo "{$cmd}\n";
                system($cmd);
            }
        }
        if ($Params["ImmediateData"] == 1) {
            $Params["ImmediateData"] = "Yes";
        } else {
            $Params["ImmediateData"] = "No";
        }
        $f[] = "Target iqn.{$year}-{$month}.{$newhostname}:{$ligne["shared_folder"]}";
        if ($EnableAuth == 1) {
            if (strlen($uid) > 2) {
                echo "{$GLOBALS["deflog_start"]} Authentication enabled for {$ligne["dev"]} with member {$ligne["uid"]}\n";
                $user = new user($ligne["uid"]);
                if ($user->password != null) {
                    $f[] = "\tIncomingUser {$ligne["uid"]} {$user->password}";
                }
            }
        }
        $f[] = "\tLun {$c} Path={$ligne["dev"]},Type={$Params["IoType"]},IOMode={$Params["mode"]}";
        $f[] = "\tMaxConnections {$Params["MaxConnections"]}";
        $f[] = "\tImmediateData {$Params["MaxConnections"]}";
        $f[] = "\tWthreads {$Params["Wthreads"]}";
        /*$f[]="\tMaxRecvDataSegmentLength 65536";
        		$f[]="\tMaxXmitDataSegmentLength 65536";
        		$f[]="\tMaxBurstLength          1048576";
        		$f[]="\tFirstBurstLength        262144";
        		$f[]="\tMaxOutstandingR2T       1";
        		$f[]="\tHeaderDigest            None";
        		$f[]="\tDataDigest              None";
        		$f[]="\tNOPInterval             60";
        		$f[]="\tNOPTimeout              180";
        		$f[]="\tQueuedCommands          64";
        		*/
        $f[] = "";
        $c++;
    }
    @mkdir("/etc/iet", true, 0600);
    $hostname = $unix->hostname_g();
    $tbl = explode(".", $hostname);
    krsort($tbl);
    $newhostname = @implode(".", $tbl);
    $sql = "SELECT * FROM users_containers WHERE created=1 AND onerror=0 AND iscsid=1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    $count = mysql_num_rows($results);
    if ($count > 0) {
        $sock = new sockets();
        $sock->SET_INFO("EnableISCSI", 1);
    }
    build_progress("{checking_containers}", 30);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $directory = trim($ligne["directory"]);
        $ID = $ligne["container_id"];
        $container_time = $ligne["container_time"];
        if (!is_numeric($container_time)) {
            $container_time = 0;
        }
        if ($container_time == 0) {
            $container_time = time();
            $q->QUERY_SQL("UPDATE users_containers SET container_time={$container_time} WHERE container_id={$ID}", "artica_backup");
        }
        $year = date("Y", $container_time);
        $month = date("m", $container_time);
        if ($directory == null) {
            echo "{$GLOBALS["deflog_start"]} id:{$ID} No specified main directory...";
            continue;
        }
        $ContainerFullPath = $directory . "/{$ID}.disk";
        $f[] = "Target iqn.{$year}-{$month}.{$newhostname}:disk{$ID}";
        $webdav_creds = unserialize(base64_decode($ligne["webdav_creds"]));
        echo "{$GLOBALS["deflog_start"]} iqn.{$year}-{$month}.{$newhostname} {$ID}.disk LUN {$ContainerFullPath}\n";
        build_progress("iqn.{$year}-{$month}.{$newhostname} {$ID}.disk", 35);
        $f[] = "\tIncomingUser {$webdav_creds["username"]} {$webdav_creds["password"]}";
        $f[] = "\tLun {$c} Path={$ContainerFullPath},Type=fileio,IOMode=wb";
        $f[] = "\tMaxConnections 5";
        $f[] = "\tImmediateData Yes";
        $f[] = "\tWthreads 8";
        $f[] = "";
    }
    build_progress("{saving_configuration}", 40);
    echo "{$GLOBALS["deflog_start"]} ietd.conf done\n";
    @file_put_contents("/etc/iet/ietd.conf", @implode("\n", $f));
    @file_put_contents("/etc/ietd.conf", @implode("\n", $f));
    build_progress("{checking_startup_script}", 50);
    system($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.initslapd.php --iscsi");
    if ($GLOBALS["PROGRESS"]) {
        build_progress("{restarting}", 80);
        system("/etc/init.d/iscsitarget restart");
    }
    build_progress("{done}", 100);
}
コード例 #5
0
function GetHtml($add, $fields, $doall = 0)
{
    global $public_r, $class_r, $class_zr, $fun_r, $empire, $dbtbpre, $emod_r, $class_tr, $level_r, $etable_r;
    if (empty($doall)) {
        if ($add['titleurl'] || $add['checked'] == 0 || $class_r[$add[classid]][showdt] == 2 || strstr($public_r['nreinfo'], ',' . $add['classid'] . ',')) {
            return '';
        }
    }
    $mid = $class_r[$add[classid]]['modid'];
    $tbname = $class_r[$add[classid]][tbname];
    //副表
    if ($emod_r[$mid]['tbdataf'] && $emod_r[$mid]['tbdataf'] != ',') {
        $selectdataf = substr($emod_r[$mid]['tbdataf'], 1, -1);
        $addr = $empire->fetch1("select " . $selectdataf . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $add[stb] . " where id='{$add['id']}'");
        $add = array_merge($add, $addr);
    }
    $iclasspath = ReturnSaveInfoPath($add[classid], $add[id]);
    $doclasspath = ECMS_PATH . $iclasspath;
    $createinfopath = $doclasspath;
    //建立日期目录
    $newspath = '';
    if ($add[newspath]) {
        $createpath = $doclasspath . $add[newspath];
        if (!file_exists($createpath)) {
            $r[newspath] = FormatPath($add[classid], $add[newspath], 1);
        }
        $createinfopath .= $add[newspath] . '/';
        $newspath = $add[newspath] . '/';
    }
    //新建存放目录
    if ($class_r[$add[classid]][filename] == 3) {
        $createinfopath .= ReturnInfoSPath($add['filename']);
        DoMkdir($createinfopath);
        $fn3 = 1;
    }
    //存文本
    if ($emod_r[$mid]['savetxtf']) {
        $stf = $emod_r[$mid]['savetxtf'];
        if ($add[$stf]) {
            $add[$stf] = GetTxtFieldText($add[$stf]);
        }
    }
    $GLOBALS['navclassid'] = $add[classid];
    $GLOBALS['navinfor'] = $add;
    //取得内容模板
    $add[newstempid] = $add[newstempid] ? $add[newstempid] : $class_r[$add[classid]][newstempid];
    $newstemp_r = GetNewsTemp($add[newstempid]);
    $newstemptext = $newstemp_r[temptext];
    $formatdate = $newstemp_r[showdate];
    //页面
    $pagetitle = htmlspecialchars($add[title]);
    $url = ReturnClassLink($add[classid]);
    //导航
    $newstemptext = Info_ReplaceSvars($newstemptext, $url, $add[classid], $pagetitle, $add[keyboard], $pagetitle);
    //文件类型/权限
    if ($add[groupid] || $class_r[$add[classid]]['cgtoinfo']) {
        if (empty($add[newspath])) {
            $include = '';
        } else {
            $pr = explode('/', $add[newspath]);
            for ($i = 0; $i < count($pr); $i++) {
                $include .= '../';
            }
        }
        if ($fn3 == 1) {
            $include .= '../';
        }
        $pr = explode('/', $iclasspath);
        $pcount = count($pr);
        for ($i = 0; $i < $pcount - 1; $i++) {
            $include .= '../';
        }
        $include1 = $include;
        $include .= 'e/class/CheckLevel.php';
        $filetype = '.php';
        $addlevel = "<?php\r\n\t\tdefine('empirecms','wm_chief');\r\n\t\t\$check_tbname='" . $class_r[$add[classid]][tbname] . "';\r\n\t\t\$check_infoid=" . $add[id] . ";\r\n\t\t\$check_classid=" . $add[classid] . ";\r\n\t\t\$check_path=\"" . $include1 . "\";\r\n\t\trequire(\"" . $include . "\");\r\n\t\t?>";
    } else {
        $filetype = $class_r[$add[classid]][filetype];
        $addlevel = '';
    }
    //取得本目录链接
    if ($class_r[$add[classid]][classurl] && $class_r[$add[classid]][ipath] == '') {
        $dolink = $class_r[$add[classid]][classurl] . '/' . $newspath;
    } else {
        $dolink = $public_r[newsurl] . $iclasspath . $newspath;
    }
    //相关信息
    if (strstr($newstemptext, '[!--other.link--]')) {
        $keyboardtext = GetKeyboard($add[keyboard], $add[keyid], $add[classid], $add[id], $class_r[$add[classid]][link_num]);
    }
    $onclick = "<script src='" . $public_r[newsurl] . "e/public/onclick?enews=donews&classid={$add['classid']}&id=" . $add[id] . "'></script>";
    //返回替换验证字符
    $docheckrep = ReturnCheckDoRepStr();
    if ($add[newstext]) {
        if (empty($public_r['dorepword']) && $docheckrep[3]) {
            $add[newstext] = ReplaceWord($add[newstext]);
            //过滤字符
        }
        if (empty($public_r['dorepkey']) && $docheckrep[4] && !empty($add[dokey])) {
            $add[newstext] = ReplaceKey($add[newstext]);
        }
        if ($public_r['opencopytext']) {
            $add[newstext] = AddNotCopyRndStr($add[newstext]);
            //随机复制字符
        }
    }
    //分页字段
    $expage = '[!--empirenews.page--]';
    //分页符
    $pf = $emod_r[$mid]['pagef'];
    //变量
    $tempf = $emod_r[$mid]['tempf'];
    if ($pf && strstr($add[$pf], $expage)) {
        $tempf = str_replace(',' . $pf . ',', ',', $tempf);
    }
    $fr = explode(',', $tempf);
    $fcount = count($fr) - 1;
    //变量替换
    $newstempstr = $newstemptext;
    //模板
    for ($i = 1; $i < $fcount; $i++) {
        $f = $fr[$i];
        $value = $add[$f];
        if ($f == 'downpath') {
            if (strstr($newstemptext, '[!--downpath--]')) {
                $value = ReturnDownSoftHtml($add);
            }
        } elseif ($f == 'onlinepath') {
            if (strstr($newstemptext, '[!--onlinepath--]')) {
                $value = ReturnOnlinepathHtml($add);
            }
        } elseif ($f == 'morepic') {
            if (strstr($newstemptext, '[!--morepic--]')) {
                $value = ReturnMorepicpathHtml($add);
            }
        } elseif ($f == 'newstime') {
            if (strstr($newstemptext, '[!--newstime--]')) {
                $value = date($formatdate, $value);
            }
        } elseif ($f == 'befrom') {
            if ($docheckrep[1] && strstr($newstemptext, '[!--befrom--]')) {
                $value = ReplaceBefrom($value);
            }
        } elseif ($f == 'writer') {
            if ($docheckrep[2] && strstr($newstemptext, '[!--writer--]')) {
                $value = ReplaceWriter($value);
            }
        } elseif ($f == 'titlepic') {
            if (empty($value)) {
                $value = $public_r[newsurl] . 'e/data/images/notimg.gif';
            }
        } elseif ($f == 'title') {
        } else {
            if (!strstr($emod_r[$mid]['editorf'], ',' . $f . ',')) {
                if (strstr($emod_r[$mid]['tobrf'], ',' . $f . ',')) {
                    $value = nl2br($value);
                }
                if (!strstr($emod_r[$mid]['dohtmlf'], ',' . $f . ',')) {
                    $value = RepFieldtextNbsp(htmlspecialchars($value));
                }
            }
        }
        $newstempstr = str_replace('[!--' . $f . '--]', $value, $newstempstr);
    }
    //固定变量
    $newstempstr = str_replace('[!--id--]', $add[id], $newstempstr);
    $newstempstr = str_replace('[!--classid--]', $add[classid], $newstempstr);
    $newstempstr = str_replace('[!--class.name--]', $class_r[$add[classid]][classname], $newstempstr);
    $newstempstr = str_replace('[!--ttid--]', $add[ttid], $newstempstr);
    $newstempstr = str_replace('[!--tt.name--]', $class_tr[$add[ttid]][tname], $newstempstr);
    $newstempstr = str_replace('[!--onclick--]', $add[onclick], $newstempstr);
    $newstempstr = str_replace('[!--userfen--]', $add[userfen], $newstempstr);
    $newstempstr = str_replace('[!--username--]', $add[username], $newstempstr);
    //带链接的用户名
    if ($add[ismember] == 1 && $add[userid]) {
        $newstempstr = str_replace('[!--linkusername--]', "<a href='" . $public_r[newsurl] . "e/space/?userid=" . $add[userid] . "' target=_blank>" . $add[username] . "</a>", $newstempstr);
    } else {
        $newstempstr = str_replace('[!--linkusername--]', $add[username], $newstempstr);
    }
    $newstempstr = str_replace('[!--userid--]', $add[userid], $newstempstr);
    $newstempstr = str_replace('[!--other.link--]', $keyboardtext, $newstempstr);
    $newstempstr = str_replace('[!--news.url--]', $public_r[newsurl], $newstempstr);
    $newstempstr = str_replace('[!--plnum--]', $add[plnum], $newstempstr);
    $newstempstr = str_replace('[!--totaldown--]', $add[totaldown], $newstempstr);
    $newstempstr = str_replace('[!--keyboard--]', $add[keyboard], $newstempstr);
    //链接
    $titleurl = sys_ReturnBqTitleLink($add);
    $newstempstr = str_replace('[!--titleurl--]', $titleurl, $newstempstr);
    $newstempstr = str_replace('[!--page.stats--]', $onclick, $newstempstr);
    $classurl = sys_ReturnBqClassname($add, 9);
    $newstempstr = str_replace('[!--class.url--]', $classurl, $newstempstr);
    //下一篇
    if (strstr($newstemptext, '[!--info.next--]')) {
        $next_r = $empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where id>{$add['id']} and classid='{$add['classid']}' and checked=1 order by id limit 1");
        if (empty($next_r[id])) {
            $infonext = "<a href='" . $classurl . "'>" . $fun_r['HaveNoNextLink'] . "</a>";
        } else {
            //链接
            $nexttitleurl = sys_ReturnBqTitleLink($next_r);
            $infonext = "<a href='" . $nexttitleurl . "'>" . $next_r[title] . "</a>";
        }
        $newstempstr = str_replace('[!--info.next--]', $infonext, $newstempstr);
    }
    //上一篇
    if (strstr($newstemptext, '[!--info.pre--]')) {
        $next_r = $empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where id<{$add['id']} and classid='{$add['classid']}' and checked=1 order by id desc limit 1");
        if (empty($next_r[id])) {
            $infonext = "<a href='" . $classurl . "'>" . $fun_r['HaveNoNextLink'] . "</a>";
        } else {
            //链接
            $nexttitleurl = sys_ReturnBqTitleLink($next_r);
            $infonext = "<a href='" . $nexttitleurl . "'>" . $next_r[title] . "</a>";
        }
        $newstempstr = str_replace('[!--info.pre--]', $infonext, $newstempstr);
    }
    //投票
    if (strstr($newstemptext, '[!--info.vote--]')) {
        $myvotetext = sys_GetInfoVote($add[classid], $add[id]);
        $newstempstr = str_replace('[!--info.vote--]', $myvotetext, $newstempstr);
    }
    //评分
    if (strstr($newstemptext, '[!--pinfopfen--]')) {
        $pinfopfen = $add[infopfennum] ? round($add[infopfen] / $add[infopfennum]) : 0;
        $newstempstr = str_replace('[!--pinfopfen--]', $pinfopfen, $newstempstr);
        $newstempstr = str_replace('[!--infopfennum--]', $add[infopfennum], $newstempstr);
    }
    if ($pf && strstr($add[$pf], $expage)) {
        $n_r = explode($expage, $add[$pf]);
        $thispagenum = count($n_r);
        //取得分页
        $thefun = $public_r['textpagefun'] ? $public_r['textpagefun'] : 'sys_ShowTextPage';
        //下拉式分页
        if (strstr($newstemptext, '[!--title.select--]')) {
            $dotitleselect = sys_ShowTextPageSelect($thispagenum, $dolink, $add, $filetype, $n_r);
        }
        for ($j = 1; $j <= $thispagenum; $j++) {
            $string = $newstempstr;
            //模板
            $truepage = '';
            $titleselect = '';
            //下一页链接
            if ($thispagenum == $j) {
                $thisnextlink = $dolink . $add[filename] . $filetype;
            } else {
                $thisj = $j + 1;
                $thisnextlink = $dolink . $add[filename] . '_' . $thisj . $filetype;
            }
            $k = $j - 1;
            if ($j == 1) {
                $file = $doclasspath . $newspath . $add[filename] . $filetype;
                $ptitle = $add[title];
            } else {
                $file = $doclasspath . $newspath . $add[filename] . '_' . $j . $filetype;
                $ti_r = explode('[/!--empirenews.page--]', $n_r[$k]);
                if (count($ti_r) >= 2) {
                    $ptitle = $ti_r[0];
                    $n_r[$k] = $ti_r[1];
                } else {
                    $ptitle = $add[title] . '(' . $j . ')';
                }
            }
            //取得当前页
            if ($thispagenum != 1) {
                $truepage = $thefun($thispagenum, $j, $dolink, $add, $filetype, '');
                $titleselect = str_replace("?" . $j . "\">", "?" . $j . "\" selected>", $dotitleselect);
            }
            //替换变量
            $newstext = $n_r[$k];
            if (!strstr($emod_r[$mid]['editorf'], ',' . $pf . ',')) {
                if (strstr($emod_r[$mid]['tobrf'], ',' . $pf . ',')) {
                    $newstext = nl2br($newstext);
                }
                if (!strstr($emod_r[$mid]['dohtmlf'], ',' . $pf . ',')) {
                    $newstext = htmlspecialchars($newstext);
                    $newstext = RepFieldtextNbsp($newstext);
                }
            }
            $string = str_replace('[!--' . $pf . '--]', $newstext, $string);
            $string = str_replace('[!--p.title--]', $ptitle, $string);
            $string = str_replace('[!--next.page--]', $thisnextlink, $string);
            $string = str_replace('[!--page.url--]', $truepage, $string);
            $string = str_replace('[!--title.select--]', $titleselect, $string);
            //写文件
            WriteFiletext($file, $addlevel . $string);
        }
    } else {
        $file = $doclasspath . $newspath . $add[filename] . $filetype;
        $string = $newstempstr;
        //模板
        //替换变量
        $string = str_replace('[!--p.title--]', $add[title], $string);
        $string = str_replace('[!--next.page--]', '', $string);
        $string = str_replace('[!--page.url--]', '', $string);
        $string = str_replace('[!--title.select--]', '', $string);
        //写文件
        WriteFiletext($file, $addlevel . $string);
    }
    //设为已生成
    if (empty($add['havehtml'])) {
        $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " set havehtml=1 where id='{$add['id']}' limit 1");
    }
}
コード例 #6
0
ファイル: cjfun.php プロジェクト: novnan/meiju
function CjNewsIn_all($classid, $checked, $uptime, $start, $userid, $username)
{
    global $class_r, $empire, $public_r, $dbtbpre, $fun_r, $emod_r;
    $checked = (int) $checked;
    $classid = (int) $classid;
    $start = (int) $start;
    if (empty($classid)) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    //操作权限
    CheckLevel($userid, $username, $classid, "cj");
    $cr = $empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='{$classid}'");
    //副表
    $cra = $empire->fetch1("select * from {$dbtbpre}ecms_infoclass_" . $cr[tbname] . " where classid='{$classid}'");
    //组合两数组
    $cr = TogTwoArray($cr, $cra);
    //导入gd处理文件
    if ($cr['mark'] || $cr['getfirstspic']) {
        @(include_once "gd.php");
    }
    if (empty($cr[insertnum])) {
        $cr[insertnum] = 10;
    }
    $mid = $class_r[$cr[newsclassid]][modid];
    $savetxtf = $emod_r[$mid]['savetxtf'];
    $stb = $emod_r[$mid]['deftb'];
    //取得采集字段
    $record = "<!--record-->";
    $field = "<!--field--->";
    $mr = $empire->fetch1("select cj from {$dbtbpre}enewsmod where mid='" . $class_r[$cr[newsclassid]][modid] . "'");
    $cjr = explode($record, $mr[cj]);
    $ccount = count($cjr);
    $sql = $empire->query("select * from {$dbtbpre}ecms_infotmp_" . $cr[tbname] . " where classid='{$classid}' and checked=0 and id>{$start} order by id limit " . $cr[insertnum]);
    $todaytime = time();
    $filetime = $todaytime;
    $b = 0;
    while ($r = $empire->fetch($sql)) {
        $b = 1;
        $newstart = $r[id];
        $ivalue = '';
        $ifield = '';
        $dataivalue = '';
        $dataifield = '';
        $titlepicnoval = 0;
        for ($j = 0; $j < $ccount - 1; $j++) {
            $cjr1 = explode($field, $cjr[$j]);
            $dofield = $cjr1[1];
            $var = "zz_" . $dofield;
            $var1 = "z_" . $dofield;
            $var2 = "qz_" . $dofield;
            $var3 = "save_" . $dofield;
            $value = $r[$dofield];
            //自身链接
            if ($dofield == "empireselfurl") {
                $value = $r['oldurl'];
            }
            //内容
            if ($dofield == "newstext") {
                if ($cr[copyimg] || $cr[copyflash]) {
                    $GLOBALS['cjnewsurl'] = $r[oldurl];
                    $value = addslashes(CopyImg(stripSlashes($value), $cr[copyimg], $cr[copyflash], $cr[newsclassid], $cr[imgurl], $username, 0, $r['id'], $cr['mark'], $public_r['filedeftb']));
                }
                //替换关键字和字符
                $value = DoReplaceKeyAndWord($value, 1, $cr[newsclassid]);
            }
            //简介
            if ($dofield == "smalltext") {
                if (empty($value)) {
                    $value = SubSmalltextVal($r[newstext], $cr[smalltextlen]);
                } else {
                    $value = DoClearSmalltextVal($value);
                }
            }
            //图片集
            if ($dofield == "morepic") {
                if ($cr[$var3] == " checked") {
                    $msavepic = 1;
                    $r['filepass'] = $r['id'];
                    $value = LoadInSaveMorepicFile($value, $msavepic, $cr[newsclassid], 0, $r, 0, $public_r['filedeftb']);
                }
            }
            //时间
            if ($dofield == "newstime") {
                continue;
            }
            //图片标题
            if ($dofield == "titlepic" && $cr[zz_titlepicl]) {
                $cr[$var] = $cr[zz_titlepicl];
                $cr[$var1] = $cr[z_titlepicl];
                $cr[$var2] = $cr[qz_titlepicl];
                $cr[$var3] = $cr[save_titlepicl];
            }
            if ($dofield == "titlepic" && empty($value)) {
                $titlepicnoval = 1;
            }
            //是否远程保存
            if ($value && !$cr[$var1] && $cr[$var3] == " checked" && $dofield != "morepic") {
                $tranr = DoTranUrl($value, $cr[newsclassid]);
                if ($tranr[tran]) {
                    $tranr[filesize] = (int) $tranr[filesize];
                    $tranr[type] = (int) $tranr[type];
                    $r[id] = (int) $r[id];
                    //记录数据库
                    eInsertFileTable($tranr[filename], $tranr[filesize], $tranr[filepath], $username, $cr[newsclassid], '[URL]' . $tranr[filename], $tranr[type], 0, $r[id], $public_r[fpath], 0, 0, $public_r['filedeftb']);
                    $value = $tranr[url];
                }
            }
            //存放文本
            if ($savetxtf == $dofield) {
                //建立目录
                $thetxtfile = GetFileMd5();
                $truevalue = MkDirTxtFile(date("Y/md"), $thetxtfile);
                //写放文件
                EditTxtFieldText($truevalue, $value);
                $value = $truevalue;
            }
            $value = addslashes($value);
            if (strstr($emod_r[$mid]['tbdataf'], ',' . $dofield . ',')) {
                $dataifield .= "," . $dofield;
                $dataivalue .= ",'" . $value . "'";
            } else {
                $ifield .= "," . $dofield;
                $ivalue .= ",'" . $value . "'";
            }
        }
        $r[keyboard] = addslashes($r[keyboard]);
        //时间
        if ($uptime) {
            $r[newstime] = $todaytime;
            $r[truetime] = $todaytime;
        } else {
            if ($r[newstime] == "0000-00-00 00:00:00") {
                $r[newstime] = $todaytime;
            } else {
                $r[newstime] = to_time($r[newstime]);
            }
        }
        //查看目录是否存在,不存在则建立
        $newspath = FormatPath($cr[newsclassid], "", 0);
        //强制签发
        if ($class_r[$cr[newsclassid]][wfid]) {
            $checked = 0;
            $isqf = 1;
        } else {
            $checked = $checked;
            $isqf = 0;
        }
        //变量处理
        $newstempid = 0;
        $ispic = $r[titlepic] ? 1 : 0;
        //返回关键字
        $keyid = GetKeyid($r[keyboard], $cr[newsclassid], 0, $class_r[$cr[newsclassid]][link_num]);
        //索引表
        $havehtml = 0;
        $indexsql = $empire->query("insert into {$dbtbpre}ecms_" . $class_r[$cr[newsclassid]][tbname] . "_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('{$cr['newsclassid']}','{$checked}','{$r['newstime']}','{$r['truetime']}','{$r['truetime']}','{$havehtml}');");
        $id = $empire->lastid();
        $infotbr = ReturnInfoTbname($class_r[$cr[newsclassid]][tbname], $checked, $stb);
        //主表
        $isurl = $r['titleurl'] ? 1 : 0;
        $isql = $empire->query("insert into " . $infotbr['tbname'] . "(id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,ispic,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard,newstime" . $ifield . ") values('{$id}','{$cr['newsclassid']}',0,0,0,0,'{$newspath}','{$filename}','{$r['userid']}','{$r['username']}',0,0,'{$ispic}',0,'{$isqf}',0,'{$isurl}','{$r['truetime']}','{$r['truetime']}','{$havehtml}',0,0,'{$r['titlefont']}','{$r['titleurl']}','{$stb}','{$public_r['filedeftb']}','{$public_r['pldeftb']}','{$r['keyboard']}','{$r['newstime']}'" . $ivalue . ");");
        //副表
        $fisql = $empire->query("insert into " . $infotbr['datatbname'] . "(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags" . $dataifield . ") values('{$id}','{$cr['newsclassid']}','{$keyid}',1,'{$newstempid}',0,0,''" . $dataivalue . ");");
        //更新栏目信息数
        AddClassInfos($cr['newsclassid'], '+1', '+1', $checked);
        //更新新信息数
        DoUpdateAddDataNum('info', $class_r[$cr['newsclassid']]['tid'], 1);
        //签发
        if ($isqf == 1) {
            InfoInsertToWorkflow($id, $cr[newsclassid], $class_r[$cr[newsclassid]][wfid], $userid, $username);
        }
        //更新附件
        UpdateTheFile($id, $r['id'], $cr[newsclassid], $public_r['filedeftb']);
        //取第一张图片为标题图片
        $addtitlepic = "";
        if ($cr['getfirstpic'] && $titlepicnoval) {
            $firsttitlepic = GetFpicToTpic($cr[newsclassid], $id, $cr['getfirstpic'], $cr['getfirstspic'], $cr['getfirstspicw'], $cr['getfirstspich'], $public_r['filedeftb']);
            if ($firsttitlepic) {
                $addtitlepic = ",titlepic='" . addslashes($firsttitlepic) . "',ispic=1";
            }
        }
        //文件命名
        $filename = ReturnInfoFilename($cr[newsclassid], $id, $r[filenameqz]);
        //信息地址
        $updateinfourl = '';
        if (!$isurl) {
            $infourl = GotoGetTitleUrl($cr['newsclassid'], $id, $newspath, $filename, 0, $isurl, '');
            $updateinfourl = ",titleurl='{$infourl}'";
        }
        $usql = $empire->query("update " . $infotbr['tbname'] . " set filename='{$filename}'" . $updateinfourl . $addtitlepic . " where id='{$id}'");
    }
    $fm = ehtmlspecialchars($_GET['fm']);
    //全部入库完毕
    if (empty($b)) {
        //取得忧化字段
        for ($ci = 0; $ci < $ccount - 1; $ci++) {
            $cir = explode($field, $cjr[$ci]);
            $cifield = $cir[1];
            if ($cifield == "title") {
                continue;
            }
            $updatefield .= "," . $cifield . "=''";
        }
        //状态原记录
        if ($cr['delloadinfo']) {
            $del = $empire->query("delete from {$dbtbpre}ecms_infotmp_" . $cr[tbname] . " where classid='{$classid}'");
        } else {
            $del = $empire->query("update {$dbtbpre}ecms_infotmp_" . $cr[tbname] . " set checked=1,keyboard=''" . $updatefield . " where classid='{$classid}'");
        }
        if ($fm) {
            echo "<link rel=\"stylesheet\" href=\"../data/images/css.css\" type=\"text/css\"><body topmargin=0><font color=red>" . $cr[classname] . "  " . $fun_r['CjLoadInInfosSuccess'] . "</font>,  <input type=button name=button value='" . $fun_r['OnlickLoadInCj'] . "' onclick=\"window.open('CheckCj.php?classid={$classid}&from=" . ehtmlspecialchars($_GET[from]) . hReturnEcmsHashStrHref2(0) . "');\"></body>";
            exit;
        } else {
            printerror("CjLoadDbSuccess", "CheckCj.php?classid={$classid}&from=" . ehtmlspecialchars($_GET[from]) . hReturnEcmsHashStrHref2(0));
        }
    }
    echo "<b>{$cr['classname']}</b>&nbsp;&nbsp;" . $fun_r['OneCjLoadDbSuccess'] . "(ID:<font color=red><b>" . $newstart . "</b></font>)<script>self.location.href='ecmscj.php?enews=CjNewsIn_all&checked={$checked}&uptime={$uptime}&classid={$classid}&start={$newstart}&fm={$fm}&from=" . ehtmlspecialchars($_GET[from]) . hReturnEcmsHashStrHref(0) . "';</script>";
    exit;
}
コード例 #7
0
ファイル: hinfofun.php プロジェクト: novnan/meiju
function CopyNews_all($classid, $id, $to_classid, $userid, $username)
{
    global $empire, $public_r, $class_r, $dbtbpre, $emod_r;
    $classid = (int) $classid;
    $to_classid = (int) $to_classid;
    if (empty($classid) || empty($to_classid)) {
        printerror("EmptyCopyClassid", "history.go(-1)");
    }
    if (empty($class_r[$classid][islast]) || empty($class_r[$to_classid][islast])) {
        printerror("EmptyCopyClassid", "history.go(-1)");
    }
    if ($class_r[$classid][modid] != $class_r[$to_classid][modid]) {
        printerror("DefModid", "history.go(-1)");
    }
    $userid = (int) $userid;
    //验证权限
    $doselfinfo = CheckLevel($userid, $username, $classid, "news");
    //权限
    if (!$doselfinfo['domoveinfo']) {
        printerror("NotMoveInfoLevel", "history.go(-1)");
    }
    $count = count($id);
    if (empty($count)) {
        printerror("NotCopyNewsid", "history.go(-1)");
    }
    $dopubid = 0;
    $donum = 0;
    $dolog = '';
    //附加链接参数
    $addecmscheck = empty($_POST['ecmscheck']) ? '&ecmscheck=1' : '';
    for ($i = 0; $i < $count; $i++) {
        $add .= "id='" . intval($id[$i]) . "' or ";
    }
    $add = substr($add, 0, strlen($add) - 4);
    $mid = $class_r[$classid][modid];
    $tbname = $class_r[$classid][tbname];
    $stf = $emod_r[$mid]['savetxtf'];
    //查看目录是否存在,不存在则建立
    $newspath = FormatPath($to_classid, "", 0);
    $newstime = time();
    $truetime = $newstime;
    $newstempid = 0;
    $dosql = $empire->query("select id,classid,checked from {$dbtbpre}ecms_" . $tbname . "_index where " . $add);
    while ($index_r = $empire->fetch($dosql)) {
        //返回表
        $infotb = ReturnInfoMainTbname($tbname, $index_r['checked']);
        //主表
        $r = $empire->fetch1("select * from " . $infotb . " where id='{$index_r['id']}' limit 1");
        //返回表信息
        $infotbr = ReturnInfoTbname($tbname, $index_r['checked'], $r['stb']);
        //副表
        $finfor = $empire->fetch1("select " . ReturnSqlFtextF($mid) . " from " . $infotbr['datatbname'] . " where id='{$r['id']}' limit 1");
        $r = array_merge($r, $finfor);
        if ($stf) {
            $r[$stf] = GetTxtFieldText($r[$stf]);
        }
        //返回自定义字段
        $ret_r = ReturnAddF($r, $class_r[$to_classid][modid], $userid, $username, 9, 1, 0);
        if ($class_r[$to_classid][wfid]) {
            $checked = 0;
            $isqf = 1;
        } else {
            $checked = $class_r[$to_classid][checked];
            $isqf = 0;
        }
        $checked = (int) $checked;
        //索引表
        $empire->query("insert into {$dbtbpre}ecms_" . $tbname . "_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('{$to_classid}','{$checked}','{$r['newstime']}','{$truetime}','{$truetime}','{$r['havehtml']}');");
        $l_id = $empire->lastid();
        $update_infotbr = ReturnInfoTbname($tbname, $checked, $ret_r['tb']);
        //主表
        $sql = $empire->query("insert into " . $update_infotbr['tbname'] . "(id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,ispic,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard" . $ret_r[fields] . ") values('{$l_id}','{$to_classid}','{$r['ttid']}',0,0,0,'{$newspath}','{$filename}',{$userid},'{$username}',0,0,'{$r['ispic']}',0,'{$isqf}',0,'{$r['isurl']}',{$truetime},{$truetime},{$r['havehtml']},{$r['groupid']},{$r['userfen']},'{$r['titlefont']}','{$r['titleurl']}','{$ret_r['tb']}','{$public_r['filedeftb']}','{$public_r['pldeftb']}','{$r['keyboard']}'" . $ret_r[values] . ");");
        //副表
        $empire->query("insert into " . $update_infotbr['datatbname'] . "(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags" . $ret_r[datafields] . ") values('{$l_id}','{$to_classid}','{$r['keyid']}',{$r['dokey']},'" . $newstempid . "',{$r['closepl']},0,'{$r['infotags']}'" . $ret_r[datavalues] . ");");
        //签发
        if ($isqf == 1) {
            InfoInsertToWorkflow($l_id, $to_classid, $class_r[$to_classid][wfid], $userid, $username);
        }
        //文件命名
        $filename = ReturnInfoFilename($to_classid, $l_id, $r[filenameqz]);
        //信息地址
        $updateinfourl = '';
        if (!$r['isurl']) {
            $infourl = GotoGetTitleUrl($to_classid, $l_id, $newspath, $filename, $r['groupid'], $r['isurl'], $r['titleurl']);
            $updateinfourl = ",titleurl='{$infourl}'";
        }
        $usql = $empire->query("update " . $update_infotbr['tbname'] . " set filename='{$filename}'" . $updateinfourl . " where id='{$l_id}'");
        //更新栏目信息数
        AddClassInfos($to_classid, '+1', '+1', $index_r['checked']);
        //生成信息文件
        if ($checked) {
            $addr = $empire->fetch1("select * from " . $update_infotbr['tbname'] . " where id='{$l_id}'");
            GetHtml($addr['classid'], $addr['id'], $addr, 1);
        }
        $donum++;
        if ($donum == 1) {
            $dopubid = ReturnInfoPubid($r['classid'], $r['id']);
            $dolog = "classid=" . $r['classid'] . "<br>id=" . $r['id'] . "<br>title=" . $r['title'] . "<br>to_classid=" . $to_classid;
        }
    }
    //刷新列表
    ReListHtml($to_classid, 1);
    //操作日志
    if ($donum == 1) {
        insert_dolog($dolog, $dopubid);
    } else {
        insert_dolog("classid=" . $classid . "<br>classname=" . $class_r[$classid][classname] . "<br>to_classid=" . $to_classid);
    }
    printerror("CopyNewsSuccess", $_SERVER['HTTP_REFERER']);
}
コード例 #8
0
function CopyNews_all($classid, $id, $to_classid, $userid, $username)
{
    global $empire, $public_r, $class_r, $dbtbpre, $emod_r;
    $classid = (int) $classid;
    $to_classid = (int) $to_classid;
    if (empty($classid) || empty($to_classid)) {
        printerror("EmptyCopyClassid", "history.go(-1)");
    }
    if (empty($class_r[$classid][islast]) || empty($class_r[$to_classid][islast])) {
        printerror("EmptyCopyClassid", "history.go(-1)");
    }
    if ($class_r[$classid][modid] != $class_r[$to_classid][modid]) {
        printerror("DefModid", "history.go(-1)");
    }
    $userid = (int) $userid;
    //验证权限
    $doselfinfo = CheckLevel($userid, $username, $classid, "news");
    //编辑权限
    if (!$doselfinfo['doeditinfo']) {
        printerror("NotEditInfoLevel", "history.go(-1)");
    }
    $count = count($id);
    if (empty($count)) {
        printerror("NotCopyNewsid", "history.go(-1)");
    }
    for ($i = 0; $i < $count; $i++) {
        $add .= "id='" . intval($id[$i]) . "' or ";
    }
    $add = substr($add, 0, strlen($add) - 4);
    $mid = $class_r[$classid][modid];
    $tbname = $class_r[$classid][tbname];
    $stf = $emod_r[$mid]['savetxtf'];
    //查看目录是否存在,不存在则建立
    $newspath = FormatPath($to_classid, "", 0);
    $newstime = time();
    $truetime = $newstime;
    $newstempid = 0;
    $dosql = $empire->query("select * from {$dbtbpre}ecms_" . $tbname . " where " . $add);
    while ($r = $empire->fetch($dosql)) {
        //副表
        if ($emod_r[$mid]['tbdataf'] && $emod_r[$mid]['tbdataf'] != ',') {
            $selectdataf = substr($emod_r[$mid]['tbdataf'], 1, -1);
            $finfor = $empire->fetch1("select " . $selectdataf . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $r[stb] . " where id='{$r['id']}'");
            $r = array_merge($r, $finfor);
        }
        if ($stf) {
            $r[$stf] = GetTxtFieldText($r[$stf]);
        }
        //返回自定义字段
        $ret_r = ReturnAddF($r, $class_r[$to_classid][modid], $userid, $username, 9, 1, 0);
        if ($class_r[$to_classid][wfid]) {
            $checked = 0;
            $isqf = 1;
        } else {
            $checked = $class_r[$to_classid][checked];
            $isqf = 0;
        }
        $checked = (int) $checked;
        //主表
        $sql = $empire->query("insert into {$dbtbpre}ecms_" . $tbname . "(classid,onclick,newspath,keyboard,keyid,userid,username,ztid,checked,truetime,ismember,dokey,isgood,titlefont,titleurl,filename,groupid,newstempid,plnum,firsttitle,isqf,userfen,totaldown,closepl,havehtml,lastdotime,haveaddfen,infopfen,infopfennum,votenum,stb,ttid,infotags,ispic" . $ret_r[fields] . ") values({$to_classid},0,'{$newspath}','{$r['keyboard']}','{$r['keyid']}',{$userid},'{$username}','',{$checked},{$truetime},0,{$r['dokey']},0,'{$r['titlefont']}','{$r['titleurl']}','{$filename}',{$r['groupid']},'" . $newstempid . "',0,0,'{$isqf}',{$r['userfen']},0,{$r['closepl']},{$r['havehtml']},{$truetime},0,0,0,0,'{$ret_r['tb']}','{$r['ttid']}','{$r['infotags']}','{$r['ispic']}'" . $ret_r[values] . ");");
        $l_id = $empire->lastid();
        //副表
        $empire->query("insert into {$dbtbpre}ecms_" . $tbname . "_data_" . $ret_r[tb] . "(id,classid" . $ret_r[datafields] . ") values('{$l_id}','{$to_classid}'" . $ret_r[datavalues] . ");");
        //签发
        if ($isqf == 1) {
            InfoInsertToWorkflow($l_id, $to_classid, $class_r[$to_classid][wfid], $userid, $username);
        }
        //文件命名
        $filename = ReturnInfoFilename($to_classid, $l_id, $r[filenameqz]);
        $usql = $empire->query("update {$dbtbpre}ecms_" . $class_r[$to_classid][tbname] . " set filename='{$filename}' where id='{$l_id}'");
        //生成信息文件
        $addr = $empire->fetch1("select * from {$dbtbpre}ecms_" . $class_r[$to_classid][tbname] . " where id='{$l_id}'");
        GetHtml($addr, '');
    }
    //刷新列表
    ReListHtml($to_classid, 1);
    //操作日志
    insert_dolog("classid=" . $classid . "<br>classname=" . $class_r[$classid][classname]);
    printerror("CopyNewsSuccess", $_SERVER['HTTP_REFERER']);
}
コード例 #9
0
ファイル: random.php プロジェクト: kelsh/classic
function random($path, $action, $title, $content)
{
    if ($path) {
        $PageQuery = mysql_query("SELECT `ID`,`Title`,`Content`,`Edits`,`Views`,`EditTime` FROM `Wiki_Pages` WHERE `Path` = '{$path}'");
        list($PageID, $PageTitle, $PageContent, $PageEdits, $pageViews, $PageEditTime) = mysql_fetch_array($PageQuery);
        $pagePrevious = RandomRow('Wiki_Pages', 'ID');
        $pageNext = RandomRow('Wiki_Pages', 'ID');
        if ($pagePrevious) {
            $previous = $pagePrevious;
        }
        if ($pageNext) {
            $next = $pageNext;
        }
        $tagQuery = mysql_query("Select tags.`tag`, stats.`count`\n                                    from `Wiki_Tags` as tags,\n                                         `Wiki_Tag_Statistics` as stats\n                                         \n                                    where tags.`pageID` = '{$PageID}'\n                                        and stats.`tag` = tags.`tag`");
        while (list($tagName, $tagCount) = mysql_fetch_array($tagQuery)) {
            $plural = 's';
            if ($tagCount == 1) {
                $plural = '';
            }
            $tagLink = urlencode($tagName);
            $tagTitle = str_replace('-', ' ', $tagName);
            $tagLinks[] = "<a href='/?tag/{$tagLink}' title='{$tagCount} tagged page{$plural}'>{$tagTitle}</a>";
        }
        $tagLinks = implode(" | ", $tagLinks);
        if ($tagLinks) {
            $tagLinks = "<hr />Tags: {$tagLinks}";
        }
        $PageTitle = PageTitler($PageTitle);
        if (empty($PageContent)) {
            $PageContent = array("Hello friend. b{Wetfish regrets to inform you this page does not exist.}", "", "Confused? This is the {{wiki|Wetfish Wiki}}, a place anyone can edit!", "It appears you've stumbled upon a place none have yet traveled.", "Would you like to be the first? {{{$path}/?edit|All it takes is a click.}}", "", "i{But please, don't wallow.}", "i{A new page surely follows.}", "i{You have the power.}");
            $PageContent = implode("<br />", $PageContent);
        } else {
            mysql_query("Update `Wiki_Pages` set `Views` = `Views` + 1 where `ID`='{$PageID}'");
        }
        if ($previous['Path']) {
            $previous['Path'] = "/{$previous['Path']}/?random";
        } else {
            $previous['Path'] = "/?random";
        }
        if ($next['Path']) {
            $next['Path'] = "/{$next['Path']}/?random";
        } else {
            $next['Path'] = "/?random";
        }
        if ($_SESSION['admin']) {
            $content['ExtraNav'] = new Navigation();
            $content['ExtraNav']->Add("Archive This Page", FormatPath("/{$path}/") . "?archive");
            $content['ExtraNav']->Add("Rename This Page", FormatPath("/{$path}/") . "?rename");
        }
        $title[] = FishFormat($PageTitle, "strip");
        $content['Title'] .= "<a href='{$previous['Path']}' title='Previous - {$previous['Title']}'>&#8668;</a> " . FishFormat($PageTitle) . " <a href='{$next['Path']}' title='Next - {$next['Title']}'>&#8669;</a>";
        $content['Body'] .= FishFormat($PageContent);
        $content['Tags'] = $tagLinks;
        $content['Body'] .= <<<JavaScript

<script>
    \$(document).ready(function ()
    {
        \$('body').on('keydown', function(event)
        {
            event.stopImmediatePropagation()
            
            if(event.keyCode == 37) // Previous
                history.back();
            else if(event.keyCode == 39) // Next
                location.href = '{$next['Path']}';

                
//\t\t\tconsole.log(event);
        });
    });
</script>

JavaScript;
        if ($PageEdits) {
            $EditCount = count(explode(",", $PageEdits));
            date_default_timezone_set('America/New_York');
            $PageEditTime = formatTime($PageEditTime);
            if ($pageViews != 1) {
                $viewPlural = 's';
            }
            if ($EditCount != 1) {
                $Plural = "s";
            }
            $content['Tags'] = $tagLinks;
            $content['Footer'] = "<b>" . number_format($pageViews) . "</b> page view{$viewPlural}. <b>{$EditCount}</b> edit{$Plural} &ensp;&mdash;&ensp; Last modified <b>{$PageEditTime}</b>.";
            //			$content['Footer'] = "This page has been edited <b>$EditCount</b> time{$Plural}, and was last edited on $PageEditTime.";
        }
    } else {
        $Head = '<meta name="robots" content="noindex, nofollow" />';
        $Random = RandomRow('Wiki_Pages', 'ID');
        $ID = uuid();
        $randomTitles = array('Wormhole open: ', 'An adventure!', 'Welcome to', 'Internet Space Award', 'Friendship served', 'WOW!');
        $randomPhrases = array('Hold on to your hat!', 'Hold on to your butt!!', 'I love butts', 'Wet, fish', 'I LOVE ANIME!!!!!!!!', 'COOL!');
        shuffle($randomTitles);
        shuffle($randomPhrases);
        header("Location: /{$Random['Path']}/?random");
        exit;
    }
    return array($title, $content);
}
コード例 #10
0
ファイル: tag.php プロジェクト: kelsh/classic
function tag($path, $action, $title, $content)
{
    $action = implode('/', $action);
    $action = explode('/', $action, 3);
    $tag = Clean($action[1]);
    $cleanTag = ucwords(str_replace('-', ' ', $tag));
    if (isset($action[2])) {
        $path = $action[2];
    }
    $totalQuery = mysql_query("Select stats.`count`\n\t\t\t\t\t\t\t\tfrom `Wiki_Tag_Statistics` as stats\n\t\t\t\t\t\t\t\twhere stats.`tag` = '{$tag}'");
    $nextQuery = mysql_query("Select `Path`, `Title`\n\t\t\t\t\t\t\t\tfrom `Wiki_Pages`,\n\t\t\t\t\t\t\t\t\t`Wiki_Tags` as tag\n\t\t\t\t\t\t\t\twhere tag.`tag` = '{$tag}' and tag.`pageID` = `ID`\n\t\t\t\t\t\t\t\t\torder by tag.`tagID` desc limit 1");
    $previousQuery = mysql_query("Select `Path`, `Title`\n\t\t\t\t\t\t\t\tfrom `Wiki_Pages`,\n\t\t\t\t\t\t\t\t\t`Wiki_Tags` as tag\n\t\t\t\t\t\t\t\twhere tag.`tag` = '{$tag}' and tag.`pageID` = `ID`\n\t\t\t\t\t\t\t\t\torder by tag.`tagID` limit 1");
    list($tagTotal) = mysql_fetch_array($totalQuery);
    $next = mysql_fetch_array($nextQuery);
    $previous = mysql_fetch_array($previousQuery);
    if ($path or isset($action[2])) {
        $PageQuery = mysql_query("SELECT `ID`,`Title`,`Content`,`Edits`,`Views`,`EditTime`,tag.`tagID` FROM `Wiki_Pages`, `Wiki_Tags` as tag WHERE `Path` like '{$path}' and tag.`tag` = '{$tag}' and tag.`pageID` = `ID`");
        list($PageID, $PageTitle, $PageContent, $PageEdits, $pageViews, $PageEditTime, $tagID) = mysql_fetch_array($PageQuery);
        $previousQuery = mysql_query("Select `Path`, `Title`\n\t\t\t\t\t\t\t\t\t\tfrom `Wiki_Pages`,\n\t\t\t\t\t\t\t\t\t\t\t`Wiki_Tags` as tag\n\t\t\t\t\t\t\t\t\t\twhere tag.`tag` = '{$tag}' and tag.`pageID` = `ID` and tag.`tagID` >'{$tagID}'\n\t\t\t\t\t\t\t\t\t\t\torder by tag.`tagID` limit 1");
        $nextQuery = mysql_query("Select `Path`, `Title`\n\t\t\t\t\t\t\t\t\tfrom `Wiki_Pages`,\n\t\t\t\t\t\t\t\t\t\t`Wiki_Tags` as tag\n\t\t\t\t\t\t\t\t\twhere tag.`tag` = '{$tag}' and tag.`pageID` = `ID` and tag.`tagID` < '{$tagID}'\n\t\t\t\t\t\t\t\t\t\torder by tag.`tagID` desc limit 1");
        $pagePrevious = mysql_fetch_array($previousQuery);
        $pageNext = mysql_fetch_array($nextQuery);
        if ($pagePrevious) {
            $previous = $pagePrevious;
        }
        if ($pageNext) {
            $next = $pageNext;
        }
        $tagQuery = mysql_query("Select tags.`tag`, stats.`count`\n\t\t\t\t\t\t\t\t\tfrom `Wiki_Tags` as tags,\n\t\t\t\t\t\t\t\t\t\t `Wiki_Tag_Statistics` as stats\n\t\t\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\twhere tags.`pageID` = '{$PageID}'\n\t\t\t\t\t\t\t\t\t\tand stats.`tag` = tags.`tag`");
        while (list($tagName, $tagCount) = mysql_fetch_array($tagQuery)) {
            $plural = 's';
            if ($tagCount == 1) {
                $plural = '';
            }
            $tagLink = urlencode($tagName);
            $tagTitle = str_replace('-', ' ', $tagName);
            $tagLinks[] = "<a href='/?tag/{$tagLink}' title='{$tagCount} tagged page{$plural}'>{$tagTitle}</a>";
        }
        $tagLinks = implode(" | ", $tagLinks);
        if ($tagLinks) {
            $tagLinks = "<hr />Tags: {$tagLinks}";
        }
        $PageTitle = PageTitler($PageTitle);
        if (empty($PageContent)) {
            $PageContent = array("Hello friend. b{Wetfish regrets to inform you this page does not exist.}", "", "Confused? This is the {{wiki|Wetfish Wiki}}, a place anyone can edit!", "It appears you've stumbled upon a place none have yet traveled.", "Would you like to be the first? {{{$path}/?edit|All it takes is a click.}}", "", "i{But please, don't wallow.}", "i{A new page surely follows.}", "i{You have the power.}");
            $PageContent = implode("<br />", $PageContent);
        } else {
            mysql_query("Update `Wiki_Pages` set `Views` = `Views` + 1 where `ID`='{$PageID}'");
        }
        if ($_SESSION['admin']) {
            $content['ExtraNav'] = new Navigation();
            $content['ExtraNav']->Add("Archive This Page", FormatPath("/{$path}/") . "?archive");
            $content['ExtraNav']->Add("Rename This Page", FormatPath("/{$path}/") . "?rename");
        }
        if ($previous['Path']) {
            $previous['Path'] = "/{$previous['Path']}/?tag/{$tag}";
        } else {
            $previous['Path'] = "/?tag/{$tag}/";
        }
        if ($next['Path']) {
            $next['Path'] = "/{$next['Path']}/?tag/{$tag}";
        } else {
            $next['Path'] = "/?tag/{$tag}/";
        }
        $title[] = FishFormat($PageTitle, "strip");
        $content['Title'] .= "<a href='{$previous['Path']}' title='Previous - {$previous['Title']}'>⟨</a> " . FishFormat($PageTitle) . " <a href='{$next['Path']}' title='Next - {$next['Title']}'>⟩</a>";
        $content['Body'] .= FishFormat($PageContent);
        $content['Tags'] = $tagLinks;
    } else {
        mysql_query("Update `Wiki_Tag_Statistics` set `views` = `views` + 1\n\t\t\t\t\t\twhere `tag` = '{$tag}'");
        if ($previous['Path']) {
            $previous['Path'] = "/{$previous['Path']}/?tag/{$tag}";
        } else {
            $previous['Path'] = "/?tag/{$tag}/";
        }
        if ($next['Path']) {
            $next['Path'] = "/{$next['Path']}/?tag/{$tag}";
        } else {
            $next['Path'] = "/?tag/{$tag}/";
        }
        $content['Title'] = "Pages tagged: <a href='{$previous['Path']}' title='Previous - {$previous['Title']}'>⟨</a> {$cleanTag} <a href='{$next['Path']}' title='Next - {$next['Title']}'>⟩</a>";
        $pageQuery = "SELECT `ID`,`Path`,`Title`,`Content`,`Edits`, `EditTime`\n\t\t\t\t\t\tFROM `Wiki_Pages`,\n\t\t\t\t\t\t\t `Wiki_Tags` as tag\n\t\t\t\t\t\tWHERE tag.`tag` = '{$tag}' and tag.`pageID` = `ID`\n\t\t\t\t\t\torder by tag.`tagID` desc";
        list($Data, $Links) = Paginate($pageQuery, 50, $_GET['page'], $_SERVER['QUERY_STRING']);
        if ($Data) {
            $content['Body'] .= "<center class='page-navigation'>{$Links}</center>";
            foreach ($Data as $Result) {
                list($pageID, $pagePath, $pageTitle, $pageContent) = $Result;
                $tagQuery = mysql_query("Select tags.`tag`, stats.`count`\n\t\t\t\t\t\t\t\t\t\t\tfrom `Wiki_Tags` as tags,\n\t\t\t\t\t\t\t\t\t\t\t\t `Wiki_Tag_Statistics` as stats\n\t\t\t\t\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\t\t\twhere tags.`pageID` = '{$pageID}'\n\t\t\t\t\t\t\t\t\t\t\t\tand stats.`tag` = tags.`tag`");
                $tagLinks = array();
                while (list($tagName, $tagCount) = mysql_fetch_array($tagQuery)) {
                    $plural = 's';
                    if ($tagCount == 1) {
                        $plural = '';
                    }
                    $tagLink = urlencode($tagName);
                    $tagTitle = str_replace('-', ' ', $tagName);
                    $tagLinks[] = "<a href='/?tag/{$tagLink}' title='{$tagCount} tagged page{$plural}'>{$tagTitle}</a>";
                }
                $tagLinks = implode(" | ", $tagLinks);
                if ($Count % 4 == 1 or $Count % 4 == 2) {
                    $class = 'toggle';
                } else {
                    $class = '';
                }
                if ($Count % 2 == 0) {
                    $content['Body'] .= "<div class='clear'></div>";
                }
                $content['Body'] .= "<div class='{$class}' style='float:left; width:50%'><div style='padding:16px'>";
                $content['Body'] .= "<a href='/{$pagePath}/?tag/{$tag}' style='font-weight:bold'>{$pageTitle}</a><br />";
                $content['Body'] .= "Tags: {$tagLinks}";
                $content['Body'] .= "</div></div>";
                $Count++;
            }
            $content['Body'] .= "<div class='clear'></div>";
            $content['Body'] .= "<center class='page-navigation bottom'>{$Links}</center>";
        }
        if (empty($Count)) {
            $content['Body'] .= "<br /><b>Sorry friend, it appears the tag you're looking for doesn't exist.</b>";
        }
    }
    if ($tagTotal == 1) {
        $footerPlural = '';
    } else {
        $footerPlural = 's';
    }
    /*
    if($previous['Path'])
    	$previous['Path'] = "/{$previous['Path']}/?tag/$tag";
    else
    	$previous['Path'] = "/?tag/$tag/";
    
    if($next['Path'])
    	$next['Path'] = "/{$next['Path']}/?tag/$tag";
    else
    	$next['Path'] = "/?tag/$tag/";
    */
    $content['Body'] .= <<<JavaScript
\t
\t<script>
\t\t\$(document).ready(function ()
\t\t{
\t\t\t\$('body').on('keydown', function(event)
\t\t\t{
\t\t\t\t// what?

\t\t\t\tevent.stopImmediatePropagation()
\t\t\t\t
\t\t\t\tif(event.keyCode == 37) // Previous
\t\t\t\t\tlocation.href = '{$previous['Path']}';
\t\t\t\telse if(event.keyCode == 39) // Next
\t\t\t\t\tlocation.href = '{$next['Path']}';

\t\t\t\t\t
\t//\t\t\tconsole.log(event);
\t\t\t});
\t\t});
\t</script>
\t
JavaScript;
    $content['Footer'] = " <a href='{$previous['Path']}' title='Previous - {$previous['Title']}'>Previous</a> &emsp; You are browsing <b><a href='/?tag/{$tag}'>{$cleanTag}</a></b>, this tag appears on <b>{$tagTotal}</b> page{$footerPlural}. &emsp; <a href='{$next['Path']}' title='Next - {$next['Title']}'>Next</a>";
    return array($title, $content);
}
コード例 #11
0
ファイル: functions.php プロジェクト: novnan/meiju
function GetHtml($classid, $id, $add, $ecms = 0, $doall = 0)
{
    global $public_r, $class_r, $class_zr, $fun_r, $empire, $dbtbpre, $emod_r, $class_tr, $level_r, $etable_r;
    $mid = $class_r[$classid]['modid'];
    $tbname = $class_r[$classid][tbname];
    if (InfoIsInTable($tbname)) {
        return '';
    }
    if ($ecms == 0) {
        $add = $empire->fetch1("select " . ReturnSqlTextF($mid, 1) . " from {$dbtbpre}ecms_" . $tbname . " where id='{$id}' limit 1");
    }
    $add['id'] = $id;
    $add['classid'] = $classid;
    if ($add['isurl']) {
        return '';
    }
    if (empty($doall)) {
        if (!$add['stb'] || $class_r[$add[classid]][showdt] == 2 || strstr($public_r['nreinfo'], ',' . $add['classid'] . ',')) {
            return '';
        }
    }
    //副表
    $addr = $empire->fetch1("select " . ReturnSqlFtextF($mid) . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $add[stb] . " where id='{$add['id']}' limit 1");
    $add = array_merge($add, $addr);
    //路径
    $iclasspath = ReturnSaveInfoPath($add[classid], $add[id]);
    $doclasspath = eReturnTrueEcmsPath() . $iclasspath;
    //moreport
    $createinfopath = $doclasspath;
    //建立日期目录
    $newspath = '';
    if ($add[newspath]) {
        $createpath = $doclasspath . $add[newspath];
        if (!file_exists($createpath)) {
            $r[newspath] = FormatPath($add[classid], $add[newspath], 1);
        }
        $createinfopath .= $add[newspath] . '/';
        $newspath = $add[newspath] . '/';
    }
    //新建存放目录
    if ($class_r[$add[classid]][filename] == 3) {
        $createinfopath .= ReturnInfoSPath($add['filename']);
        DoMkdir($createinfopath);
        $fn3 = 1;
    }
    //存文本
    if ($emod_r[$mid]['savetxtf']) {
        $stf = $emod_r[$mid]['savetxtf'];
        if ($add[$stf]) {
            $add[$stf] = GetTxtFieldText($add[$stf]);
        }
    }
    $GLOBALS['navclassid'] = $add[classid];
    $GLOBALS['navinfor'] = $add;
    //取得内容模板
    $add[newstempid] = $add[newstempid] ? $add[newstempid] : $class_r[$add[classid]][newstempid];
    $newstemp_r = $empire->fetch1("select temptext,showdate from " . GetTemptb("enewsnewstemp") . " where tempid='{$add['newstempid']}' limit 1");
    $newstemp_r['tempid'] = $add['newstempid'];
    if ($public_r['opennotcj']) {
        $newstemp_r['temptext'] = ReturnNotcj($newstemp_r['temptext']);
    }
    $newstemptext = $newstemp_r[temptext];
    $formatdate = $newstemp_r[showdate];
    //文件类型/权限
    if ($add[groupid] || $class_r[$add[classid]]['cgtoinfo']) {
        if (empty($add[newspath])) {
            $include = '';
        } else {
            $pr = explode('/', $add[newspath]);
            for ($i = 0; $i < count($pr); $i++) {
                $include .= '../';
            }
        }
        if ($fn3 == 1) {
            $include .= '../';
        }
        $pr = explode('/', $iclasspath);
        $pcount = count($pr);
        for ($i = 0; $i < $pcount - 1; $i++) {
            $include .= '../';
        }
        $include1 = $include;
        $include .= 'e/class/CheckLevel.php';
        $filetype = '.php';
        $addlevel = "<?php\n\t\tdefine('empirecms','wm_chief');\n\t\t\$check_tbname='" . $class_r[$add[classid]][tbname] . "';\n\t\t\$check_infoid=" . $add[id] . ";\n\t\t\$check_classid=" . $add[classid] . ";\n\t\t\$check_path=\"" . $include1 . "\";\n\t\trequire(\"" . $include . "\");\n\t\t?>";
    } else {
        $filetype = $class_r[$add[classid]][filetype];
        $addlevel = '';
    }
    //取得本目录链接
    if ($class_r[$add[classid]][classurl] && $class_r[$add[classid]][ipath] == '') {
        $dolink = $class_r[$add[classid]][classurl] . '/' . $newspath;
    } else {
        $dolink = $public_r[newsurl] . $iclasspath . $newspath;
    }
    //返回替换验证字符
    $docheckrep = ReturnCheckDoRepStr();
    if ($add[newstext]) {
        if (empty($public_r['dorepword']) && $docheckrep[3]) {
            $add[newstext] = ReplaceWord($add[newstext]);
            //过滤字符
        }
        if (empty($public_r['dorepkey']) && $docheckrep[4] && !empty($add[dokey])) {
            $add[newstext] = ReplaceKey($add['newstext'], $add['classid']);
        }
        if ($public_r['opencopytext']) {
            $add[newstext] = AddNotCopyRndStr($add[newstext]);
            //随机复制字符
        }
    }
    //返回编译
    $newstemptext = GetInfoNewsBq($classid, $newstemp_r, $add, $docheckrep);
    //分页字段
    $expage = '[!--empirenews.page--]';
    //分页符
    $pf = $emod_r[$mid]['pagef'];
    //变量替换
    $newstempstr = $newstemptext;
    //模板
    //分页
    if ($pf && strstr($add[$pf], $expage)) {
        $n_r = explode($expage, $add[$pf]);
        $thispagenum = count($n_r);
        //取得分页
        $thefun = $public_r['textpagefun'] ? $public_r['textpagefun'] : 'sys_ShowTextPage';
        //下拉式分页
        if (strstr($newstemptext, '[!--title.select--]')) {
            $dotitleselect = sys_ShowTextPageSelect($thispagenum, $dolink, $add, $filetype, $n_r);
        }
        for ($j = 1; $j <= $thispagenum; $j++) {
            $string = $newstempstr;
            //模板
            $truepage = '';
            $titleselect = '';
            //下一页链接
            if ($thispagenum == $j) {
                $thisnextlink = $dolink . $add[filename] . $filetype;
            } else {
                $thisj = $j + 1;
                $thisnextlink = $dolink . $add[filename] . '_' . $thisj . $filetype;
            }
            $k = $j - 1;
            if ($j == 1) {
                $file = $doclasspath . $newspath . $add[filename] . $filetype;
                $ptitle = $add[title];
            } else {
                $file = $doclasspath . $newspath . $add[filename] . '_' . $j . $filetype;
                $ti_r = explode('[/!--empirenews.page--]', $n_r[$k]);
                if (count($ti_r) >= 2) {
                    $ptitle = $ti_r[0];
                    $n_r[$k] = $ti_r[1];
                } else {
                    $ptitle = $add[title] . '(' . $j . ')';
                }
            }
            //取得当前页
            if ($thispagenum != 1) {
                $truepage = $thefun($thispagenum, $j, $dolink, $add, $filetype, '');
                $titleselect = str_replace("?" . $j . "\">", "?" . $j . "\" selected>", $dotitleselect);
            }
            //替换变量
            $newstext = $n_r[$k];
            if (!strstr($emod_r[$mid]['editorf'], ',' . $pf . ',')) {
                if (strstr($emod_r[$mid]['tobrf'], ',' . $pf . ',')) {
                    $newstext = nl2br($newstext);
                }
                if (!strstr($emod_r[$mid]['dohtmlf'], ',' . $pf . ',')) {
                    $newstext = ehtmlspecialchars($newstext);
                    $newstext = RepFieldtextNbsp($newstext);
                }
            }
            $string = str_replace('[!--' . $pf . '--]', $newstext, $string);
            $string = str_replace('[!--p.title--]', strip_tags($ptitle), $string);
            $string = str_replace('[!--next.page--]', $thisnextlink, $string);
            $string = str_replace('[!--page.url--]', $truepage, $string);
            $string = str_replace('[!--title.select--]', $titleselect, $string);
            //写文件
            WriteFiletext($file, $addlevel . $string);
        }
    } else {
        $file = $doclasspath . $newspath . $add[filename] . $filetype;
        $string = $newstempstr;
        //模板
        //替换变量
        $string = str_replace('[!--p.title--]', $add[title], $string);
        $string = str_replace('[!--next.page--]', '', $string);
        $string = str_replace('[!--page.url--]', '', $string);
        $string = str_replace('[!--title.select--]', '', $string);
        //写文件
        WriteFiletext($file, $addlevel . $string);
    }
    //设为已生成
    if (empty($doall) && empty($add['havehtml'])) {
        $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . "_index set havehtml=1 where id='{$add['id']}' limit 1");
        $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " set havehtml=1 where id='{$add['id']}' limit 1");
    }
}
コード例 #12
0
ファイル: history.php プロジェクト: kelsh/classic
function history($path, $action, $title, $content)
{
    $Head = '<meta name="robots" content="noindex, nofollow" />';
    $content['PageNav']->Active("Page History");
    $pageQuery = mysql_query("Select `ID` from `Wiki_Pages` where `Path`='{$path}'");
    list($pageID) = mysql_fetch_array($pageQuery);
    $totalQuery = mysql_query("Select `ID`\n\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `Archived` = 0");
    $nextQuery = mysql_query("Select `ID`, `Title`\n\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `Archived` = 0\n\t\t\t\t\t\t\t\torder by `ID` desc limit 1");
    $previousQuery = mysql_query("Select `ID`, `Title`\n\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `Archived` = 0\n\t\t\t\t\t\t\t\torder by `ID` limit 1");
    $totalEdits = mysql_num_rows($totalQuery);
    $next = mysql_fetch_array($nextQuery);
    $previous = mysql_fetch_array($previousQuery);
    if (is_numeric($action[1])) {
        $PreviousQuery = mysql_query("Select `Content` from `Wiki_Edits` where `ID` < '{$action['1']}' and `Archived` = 0 order by `ID` desc limit 1");
        list($PreviousContent) = mysql_fetch_array($PreviousQuery);
        $PageQuery = mysql_query("SELECT `AccountID`,`EditTime`,`Name`,`Description`,`Title`,`Content` FROM `Wiki_Edits` WHERE `ID`='{$action['1']}' and `Archived` = 0");
        list($AccountID, $PageEditTime, $PageName, $PageDescription, $PageTitle, $PageContent) = mysql_fetch_array($PageQuery);
        $previousQuery = mysql_query("Select `ID`, `Title`\n\t\t\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `ID` > '{$action['1']}' and `Archived` = 0\n\t\t\t\t\t\t\t\t\t\t\torder by `ID` limit 1");
        $nextQuery = mysql_query("Select `ID`, `Title`\n\t\t\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `ID` < '{$action['1']}' and `Archived` = 0\n\t\t\t\t\t\t\t\t\t\t\torder by `ID` desc limit 1");
        $pagePrevious = mysql_fetch_array($previousQuery);
        $pageNext = mysql_fetch_array($nextQuery);
        if ($pagePrevious) {
            $previous = $pagePrevious;
        }
        if ($pageNext) {
            $next = $pageNext;
        }
        $content['ExtraNav'] = new Navigation();
        $content['ExtraNav']->Add("View Source", FormatPath("/{$path}/") . "?source/{$action['1']}");
        $content['ExtraNav']->Add("View Difference", FormatPath("/{$path}/") . "?diff/{$action['1']}");
        if ($_SESSION['Verified'] == 1) {
            $content['ExtraNav']->Add("Revert Page", FormatPath("/{$path}/") . "?revert/{$action['1']}");
        }
        if ($_SESSION['admin']) {
            $content['ExtraNav']->Add("Archive This Edit", FormatPath("/{$path}/") . "?archive/{$action['1']}");
        }
        $title[] = FishFormat($PageTitle, "strip");
        $PageContent = FishFormat($PageContent);
        $previousPath = FormatPath("/{$path}/?history/{$previous['ID']}");
        $nextPath = FormatPath("/{$path}/?history/{$next['ID']}");
        $content['Title'] .= "<a href='{$previousPath}' title='Previous - {$previous['Title']}'>⟨</a> " . FishFormat($PageTitle) . " <a href='{$nextPath}' title='Next - {$next['Title']}'>⟩</a>";
        $content['Body'] .= $PageContent;
        date_default_timezone_set('America/New_York');
        //			$PageEditTime = date("F j\, Y G:i:s", $PageEditTime)." EST";
        $PageEditTime = formatTime($PageEditTime);
        $content['Footer'] = "This page is an old revision made by <b><a href='/names?id={$AccountID}'>{$PageName}</a></b> on {$PageEditTime}.";
        if ($PageDescription) {
            $content['Footer'] .= "<br />'{$PageDescription}'";
        }
    } else {
        $previousPath = FormatPath("/{$path}/?history/{$previous['ID']}");
        $nextPath = FormatPath("/{$path}/?history/{$next['ID']}");
        $content['Title'] = "<a href='{$previousPath}' title='Previous - {$previous['Title']}'>⟨</a> Page History <a href='{$nextPath}' title='Next - {$next['Title']}'>⟩</a>";
        $PageQuery = mysql_query("SELECT `ID` FROM `Wiki_Pages` WHERE `Path`='{$path}'");
        list($PageID) = mysql_fetch_array($PageQuery);
        $HistoryQuery = "SELECT `ID`,`AccountID`,`EditTime`,`Size`,`Tags`,`Name`,`Description`,`Title` FROM `Wiki_Edits` WHERE `PageID`='{$PageID}' and `Archived` = 0 ORDER BY `ID` DESC";
        $request = parse_url($_SERVER['REQUEST_URI']);
        list($Data, $Links) = Paginate($HistoryQuery, 50, $_GET['page'], $request['query']);
        if ($_SESSION['admin']) {
            $content['ExtraNav'] = new Navigation();
            $content['ExtraNav']->Add("Archive All Edits", FormatPath("/{$path}/") . "?archive");
        }
        $content['Body'] .= "<hr /><center>{$Links}</center><hr />";
        $content['Body'] .= "<table width='100%' class='history'>";
        $content['Body'] .= "<tr><td><b>Revision</b></td><td><b>Size</b></td><td><b>Tags</b></td><td><b>Editor</b></td><td><b>Title</b></td><td><b>Description</b></td></tr>";
        foreach ($Data as $Result) {
            list($HistoryID, $AccountID, $HistoryTime, $HistorySize, $historyTags, $HistoryName, $HistoryDescription, $HistoryTitle) = $Result;
            $Toggle++;
            date_default_timezone_set('America/New_York');
            $minWidth = recentTime($HistoryTime) ? 85 : 175;
            $HistoryTime = formatTime($HistoryTime);
            if ($Toggle % 2 == 1) {
                $Class = "class='toggle'";
            } else {
                $Class = '';
            }
            $HistoryName = FishFormat($HistoryName, "format");
            $HistoryDescription = FishFormat($HistoryDescription, "format");
            $HistoryTitle = FishFormat($HistoryTitle, "format");
            $HistoryURL = str_replace("//", "/", "/{$path}/?history/{$HistoryID}");
            $DiffURL = str_replace("//", "/", "/{$path}/?diff/{$HistoryID}");
            $content['Body'] .= "<tr {$Class}><td style='min-width:{$minWidth};'>{$HistoryTime}</td><td>{$HistorySize}</td><td>{$historyTags}</td><td><b><a href='/edits?name={$HistoryName}'>{$HistoryName}</a></b></td><td style='max-width:400px;'><span style='float:right;'><a href='{$DiffURL}' rel='nofollow'>d</a></span><b><a href='{$HistoryURL}' rel='nofollow'>{$HistoryTitle}</a></b></td><td>{$HistoryDescription}</td></tr>";
        }
        $content['Body'] .= "</table>";
        $content['Body'] .= "<hr /><center>{$Links}</center>";
    }
    $content['Body'] .= <<<JavaScript
\t
\t<script>
\t\t\$(document).ready(function ()
\t\t{
\t\t\t\$('body').on('keydown', function(event)
\t\t\t{
\t\t\t\tevent.stopImmediatePropagation()
\t\t\t\t
\t\t\t\tif(event.keyCode == 37) // Previous
\t\t\t\t\tlocation.href = '{$previousPath}';
\t\t\t\telse if(event.keyCode == 39) // Next
\t\t\t\t\tlocation.href = '{$nextPath}';

\t\t\t\t\t
\t//\t\t\tconsole.log(event);
\t\t\t});
\t\t});
\t</script>
\t
JavaScript;
    return array($title, $content);
}