예제 #1
0
function page()
{
    for ($i = 0; $i < 1000; $i++) {
        $a = new Post();
        $a->CateID = 0;
        $a->AuthorID = 1;
        $a->Tag = '';
        $a->Status = ZC_POST_STATUS_PUBLIC;
        $a->Type = ZC_POST_TYPE_PAGE;
        $a->Alias = '';
        $a->IsTop = false;
        $a->IsLock = false;
        $a->Title = getRandStr(mt_rand(6, 10));
        $a->Intro = '';
        $a->Content = getRandStr(mt_rand(200, 300)) . GetGuid() . '<br/>' . GetGuid();
        $a->IP = GetGuestIP();
        $a->PostTime = time();
        $a->CommNums = 0;
        $a->ViewNums = 0;
        $a->Template = '';
        $a->Meta = '';
        $a->Save();
    }
}
예제 #2
0
파일: post.php 프로젝트: greenanu/phpsimpl
if ($_POST['submit_button'] == 'Save Draft and Continue Editing' || $_POST['submit_button'] == 'Save' || $_POST['submit_button'] == 'Save and Publish') {
    $redirect = true;
    // Get all the Form Data
    $myPost->SetValues($_POST);
    switch ($_POST['submit_button']) {
        case 'Save Draft and Continue Editing':
            $myPost->SetValue('status', 'Draft');
            $redirect = false;
            break;
        case 'Save and Publish':
            $myPost->SetValue('status', 'Published');
        default:
            break;
    }
    // Save the info to the DB if there is no errors
    if ($myPost->Save()) {
        // Sync in the Tags
        $myPostTag = new PostTag();
        $myPostTag->SetValue('post_id', $myPost->GetPrimary());
        $myPostTag->Sync($myPost->GetValue('tags'));
        SetAlert('Post Information Saved.', 'success');
        // Redirect if needed
        if ($redirect) {
            header('location:posts.php');
            die;
        }
    }
}
// If Deleting the Page
if ($_POST['submit_button'] == 'Delete') {
    // Get all the form data
function processPosts($counter = 0)
{
    global $USER, $STATS;
    while (isset($_POST["p_p" . $counter])) {
        if (STATS_ACTIVE) {
            $STATS->ProcessAction(ST_ACTION_EXTERNAL_POST);
        }
        $id = md5($USER->Browsers[0]->SystemId . AJAXDecode($_POST[POST_EXTERN_CHAT_ID]) . AJAXDecode($_POST["p_i" . $counter]));
        $post = new Post($id, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->InternalUser->SystemId, AJAXDecode($_POST["p_p" . $counter]), time(), $USER->Browsers[0]->ChatId);
        if (isset($_POST["p_pt" . $counter])) {
            $post->Translation = AJAXDecode($_POST["p_pt" . $counter]);
            $post->TranslationISO = AJAXDecode($_POST["p_ptiso" . $counter]);
        }
        $post->Save();
        $USER->AddFunctionCall("lz_chat_release_post('" . AJAXDecode($_POST["p_i" . $counter]) . "');", false);
        $counter++;
    }
    $counter = 0;
    while (isset($_POST["pr_i" . $counter])) {
        markPostReceived(AJAXDecode($_POST["pr_i" . $counter]));
        $USER->AddFunctionCall("lz_chat_message_set_received('" . AJAXDecode($_POST["pr_i" . $counter]) . "');", false);
        $counter++;
    }
}
 function ProcessPosts()
 {
     global $USER;
     $pc = 0;
     if (!empty($USER->Browsers[0]->QueuedPosts)) {
         if (!$USER->Browsers[0]->Waiting) {
             while (!empty($_GET["mi" . $pc])) {
                 $pc++;
             }
             foreach ($USER->Browsers[0]->QueuedPosts as $id => $postar) {
                 $_GET["mp" . $pc] = $postar[0];
                 $_GET["mrid" . $pc] = $_GET["mi" . $pc] = Encoding::Base64UrlEncode($id);
                 $_GET["mc" . $pc++] = Encoding::Base64UrlEncode($postar[1]);
                 DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `id`='" . DBManager::RealEscape($id) . "' LIMIT 1;");
             }
             $pc = 0;
             $USER->Browsers[0]->QueuedPosts = array();
         }
     }
     $this->OverlayHTML = "";
     if (!empty($_GET["mi" . $pc]) || $USER->Browsers[0]->Waiting || !empty($USER->Browsers[0]->InitChatWith) || !empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Received && $USER->Browsers[0]->Forward->Processed) {
         if ($USER->Browsers[0]->Waiting && $this->Botmode && !empty($USER->Browsers[0]->QueuedPosts)) {
             $USER->Browsers[0]->QueuedPosts = array();
         } else {
             if (!Visitor::$OpenChatExternal) {
                 $this->Init();
             }
         }
         if (!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Received && $USER->Browsers[0]->Forward->Processed) {
             $USER->Browsers[0]->Forward->Save(true, true);
             Visitor::$IsActiveOverlayChat = !$USER->Browsers[0]->Declined;
         }
     }
     if (!empty($USER->Browsers[0]->ChatId)) {
         $USER->AddFunctionCall("lz_chat_id='" . $USER->Browsers[0]->ChatId . "';", false);
     }
     $USER->Browsers[0]->VisitId = $USER->VisitId;
     while (!empty($_GET["mi" . $pc])) {
         $id = Communication::ReadParameter("mrid" . $pc, md5($USER->Browsers[0]->SystemId . $USER->Browsers[0]->ChatId . $_GET["mi" . $pc]));
         $senderName = !empty($USER->Browsers[0]->UserData->Fullname) ? $USER->Browsers[0]->UserData->Fullname : LocalizationManager::$TranslationStrings["client_guest"] . " " . Visitor::GetNoName($USER->UserId . Communication::GetIP());
         $post = new Post($id, $USER->Browsers[0]->SystemId, "", Encoding::Base64UrlDecode($_GET["mp" . $pc]), Communication::ReadParameter("mc" . $pc, time()), $USER->Browsers[0]->ChatId, $senderName);
         $post->BrowserId = VisitorMonitoring::$Browser->BrowserId;
         if (!empty($_GET["mpti" . $pc])) {
             $post->Translation = Encoding::Base64UrlDecode($_GET["mpt" . $pc]);
             $post->TranslationISO = Encoding::Base64UrlDecode($_GET["mpti" . $pc]);
         }
         $saved = false;
         if (!$USER->Browsers[0]->Waiting) {
             foreach (Server::$Groups as $groupid => $group) {
                 if ($group->IsDynamic && $USER->Browsers[0]->Status == CHAT_STATUS_ACTIVE && isset($group->Members[$USER->Browsers[0]->SystemId])) {
                     foreach ($group->Members as $member => $persistent) {
                         if ($member != $USER->Browsers[0]->SystemId) {
                             if (!empty(Server::$Operators[$member])) {
                                 processPost($id, $post, $member, $pc, $groupid, $USER->Browsers[0]->ChatId);
                             } else {
                                 processPost($id, $post, $member, $pc, $groupid, CacheManager::GetValueBySystemId($member, "chat_id", ""));
                             }
                             $saved = true;
                         }
                     }
                     $pGroup = $group;
                 }
             }
             foreach ($USER->Browsers[0]->Members as $systemid => $member) {
                 if (!empty($member->Declined)) {
                     continue;
                 }
                 if (!empty(Server::$Operators[$systemid]) && !empty($pGroup) && isset($pGroup->Members[$systemid])) {
                     continue;
                 }
                 if (!(!empty($pGroup) && !empty(Server::$Operators[$systemid]))) {
                     $saved = processPost($id, $post, $systemid, $pc, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId, Server::$Operators[$systemid]->IsBot);
                 }
             }
             if (!empty($USER->Browsers[0]->OperatorId) && (Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot || $USER->Browsers[0]->Status == CHAT_STATUS_ACTIVE)) {
                 $rpost = new Post($id = getId(32), Server::$Operators[$USER->Browsers[0]->OperatorId]->SystemId, $USER->Browsers[0]->SystemId, $answer = Server::$Operators[$USER->Browsers[0]->OperatorId]->GetAutoReplies($post->Text . " " . $post->Translation, $USER->Browsers[0]), time(), $USER->Browsers[0]->ChatId, Server::$Operators[$USER->Browsers[0]->OperatorId]->Fullname);
                 if (!empty($answer)) {
                     if (Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot) {
                         sleep(1);
                         $USER->AddFunctionCall("lz_chat_input_bot_state(true,false);", false);
                     }
                     $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                     $rpost->Save();
                     $saved = true;
                     foreach ($USER->Browsers[0]->Members as $opsysid => $member) {
                         if ($opsysid != Server::$Operators[$USER->Browsers[0]->OperatorId]->SystemId || !Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot) {
                             $rpost = new Post($id, Server::$Operators[$USER->Browsers[0]->OperatorId]->SystemId, $opsysid, $answer, time(), $USER->Browsers[0]->ChatId, Server::$Operators[$opsysid]->Fullname);
                             $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                             $rpost->Save();
                         }
                     }
                 }
             }
             if ($saved) {
                 $USER->AddFunctionCall("lz_chat_release_post('" . Encoding::Base64UrlDecode($_GET["mi" . $pc]) . "');", false);
             }
         } else {
             processPost($id, $post, "", $pc, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId, false);
             $USER->Browsers[0]->QueuedPosts[$id] = array(0 => $_GET["mp" . $pc], 1 => time(), 2 => VisitorMonitoring::$Browser->BrowserId);
             $USER->AddFunctionCall("lz_chat_release_post('" . Encoding::Base64UrlDecode($_GET["mi" . $pc]) . "');", false);
         }
         $pc++;
     }
     if (!empty($USER->Browsers[0]->OperatorId) && empty($pc) && !Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot) {
         $autoReply = Server::$Operators[$USER->Browsers[0]->OperatorId]->GetAutoReplies("", $USER->Browsers[0]);
         if (!empty($autoReply)) {
             ChatAutoReply::SendAutoReply($autoReply, $USER, $USER->Browsers[0]->OperatorId);
         }
     }
 }
예제 #5
0
<?php

include_once "../includes/header.inc.php";
$REQUIRED_USER_LEVEL = "LoggedVerified";
//NIVEL DE USUARIO MINIMO REQUERIDO
include_once "../includes/needLogIn.inc.php";
require_once "../Classes/Post.class.php";
if (isset($PARAMS['id'])) {
    $post = new Post();
    $post->id = $PARAMS['id'];
    $post->Find();
    if ($post->variables && !$post->delete_date && $post->username == $_SESSION['username']) {
        $post->delete_date = date("Ymd");
        $post->Save();
        echo json_encode(array("status" => "OK"));
    } else {
        echo json_encode(array("status" => "unknowPost"));
    }
} else {
    echo json_encode(array("status" => "wrongData"));
}
 static function SendAutoReply($_reply, $_user, $_sender)
 {
     $arpost = new Post($id = getId(32), Server::$Operators[$_user->Browsers[0]->OperatorId]->SystemId, $_user->Browsers[0]->SystemId, $_reply, time(), $_user->Browsers[0]->ChatId, Server::$Operators[$_user->Browsers[0]->OperatorId]->Fullname);
     $arpost->ReceiverOriginal = $arpost->ReceiverGroup = $_user->Browsers[0]->SystemId;
     $arpost->Save();
     foreach ($_user->Browsers[0]->Members as $opsysid => $member) {
         $rpost = new Post($id, Server::$Operators[$_user->Browsers[0]->OperatorId]->SystemId, $opsysid, $_reply, time(), $_user->Browsers[0]->ChatId, $_sender->Fullname);
         $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $_user->Browsers[0]->SystemId;
         $rpost->Save();
     }
 }
function processPosts()
{
    global $INTERNAL, $GROUPS, $VISITOR, $CONFIG, $STATS;
    $time = time();
    $count = -1;
    while (isset($_POST[POST_INTERN_PROCESS_POSTS . "_va" . ++$count])) {
        $post = slashesStrip($_POST[POST_INTERN_PROCESS_POSTS . "_va" . $count]);
        if ($_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count] == GROUP_EVERYONE_INTERN || isset($GROUPS[$_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count]])) {
            foreach ($INTERNAL as $internal) {
                if ($internal->SystemId != CALLER_SYSTEM_ID) {
                    if ($_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count] == GROUP_EVERYONE_INTERN || in_array($_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count], $internal->Groups)) {
                        if ($internal->Status != USER_STATUS_OFFLINE || !empty($CONFIG["gl_ogcm"])) {
                            $npost = new Post(getId(32), CALLER_SYSTEM_ID, $internal->SystemId, $post, $time, "");
                            $npost->Translation = $_POST[POST_INTERN_PROCESS_POSTS . "_vd" . $count];
                            $npost->TranslationISO = $_POST[POST_INTERN_PROCESS_POSTS . "_ve" . $count];
                            $npost->Persistent = true;
                            if ($_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count] == GROUP_EVERYONE_INTERN || in_array($_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count], $INTERNAL[CALLER_SYSTEM_ID]->Groups)) {
                                $npost->ReceiverGroup = $_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count];
                            }
                            $npost->Save();
                        }
                    }
                }
            }
        } else {
            if ($_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count] == GROUP_EVERYONE_EXTERN) {
                foreach ($INTERNAL[CALLER_SYSTEM_ID]->ExternalChats as $chat) {
                    $npost = new Post(getId(32), CALLER_SYSTEM_ID, $chat->SystemId, $post, $time, "");
                    $npost->Translation = $_POST[POST_INTERN_PROCESS_POSTS . "_vd" . $count];
                    $npost->TranslationISO = $_POST[POST_INTERN_PROCESS_POSTS . "_ve" . $count];
                    $npost->Save();
                }
            } else {
                if (!isset($INTERNAL[$_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count]])) {
                    if (STATS_ACTIVE) {
                        $STATS->ProcessAction(ST_ACTION_INTERNAL_POST);
                    }
                    if (isset($INTERNAL[CALLER_SYSTEM_ID]->ExternalChats[$_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count]])) {
                        $npost = new Post($_POST[POST_INTERN_PROCESS_POSTS . "_vc" . $count], CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count], $post, $time, $INTERNAL[CALLER_SYSTEM_ID]->ExternalChats[$_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count]]->ChatId);
                    } else {
                        continue;
                    }
                } else {
                    $npost = new Post($_POST[POST_INTERN_PROCESS_POSTS . "_vc" . $count], CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count], $post, $time, "");
                }
                $npost->Persistent = isset($INTERNAL[$_POST[POST_INTERN_PROCESS_POSTS . "_vb" . $count]]);
                $npost->Translation = $_POST[POST_INTERN_PROCESS_POSTS . "_vd" . $count];
                $npost->TranslationISO = $_POST[POST_INTERN_PROCESS_POSTS . "_ve" . $count];
                $npost->Save();
            }
        }
    }
}
예제 #8
0
파일: index.php 프로젝트: ijustyce/zblogphp
function InsertInfo()
{
    global $zbp;
    $zbp->guid = GetGuid();
    $mem = new Member();
    $guid = GetGuid();
    $mem->Guid = $guid;
    $mem->Level = 1;
    $mem->Name = GetVars('username', 'POST');
    $mem->Password = Member::GetPassWordByGuid(GetVars('password', 'POST'), $guid);
    $mem->IP = GetGuestIP();
    $mem->PostTime = time();
    $mem->Save();
    $cate = new Category();
    $cate->Name = $zbp->lang['msg']['uncategory'];
    $cate->Alias = 'uncategorized';
    $cate->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_navbar'];
    $t->FileName = "navbar";
    $t->Source = "system";
    $t->SidebarID = 0;
    $t->Content = '<li id="nvabar-item-index"><a href="{#ZC_BLOG_HOST#}">' . $zbp->lang['zb_install']['index'] . '</a></li><li id="navbar-page-2"><a href="{#ZC_BLOG_HOST#}?id=2">' . $zbp->lang['zb_install']['guestbook'] . '</a></li>';
    $t->HtmlID = "divNavBar";
    $t->Type = "ul";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['calendar'];
    $t->FileName = "calendar";
    $t->Source = "system";
    $t->SidebarID = 1;
    $t->Content = "";
    $t->HtmlID = "divCalendar";
    $t->Type = "div";
    $t->IsHideTitle = true;
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['control_panel'];
    $t->FileName = "controlpanel";
    $t->Source = "system";
    $t->SidebarID = 1;
    $t->Content = '<span class="cp-hello">' . $zbp->lang['zb_install']['wellcome'] . '</span><br/><span class="cp-login"><a href="{#ZC_BLOG_HOST#}zb_system/cmd.php?act=login">' . $zbp->lang['msg']['admin_login'] . '</a></span>&nbsp;&nbsp;<span class="cp-vrs"><a href="{#ZC_BLOG_HOST#}zb_system/cmd.php?act=misc&amp;type=vrs">' . $zbp->lang['msg']['view_rights'] . '</a></span>';
    $t->HtmlID = "divContorPanel";
    $t->Type = "div";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_catalog'];
    $t->FileName = "catalog";
    $t->Source = "system";
    $t->SidebarID = 1;
    $t->Content = "";
    $t->HtmlID = "divCatalog";
    $t->Type = "ul";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['search'];
    $t->FileName = "searchpanel";
    $t->Source = "system";
    $t->SidebarID = 1;
    $t->Content = '<form name="search" method="post" action="{#ZC_BLOG_HOST#}zb_system/cmd.php?act=search"><input type="text" name="q" size="11" /> <input type="submit" value="' . $zbp->lang['msg']['search'] . '" /></form>';
    $t->HtmlID = "divSearchPanel";
    $t->Type = "div";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_comments'];
    $t->FileName = "comments";
    $t->Source = "system";
    $t->SidebarID = 1;
    $t->Content = "";
    $t->HtmlID = "divComments";
    $t->Type = "ul";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_archives'];
    $t->FileName = "archives";
    $t->Source = "system";
    $t->SidebarID = 1;
    $t->Content = "";
    $t->HtmlID = "divArchives";
    $t->Type = "ul";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_statistics'];
    $t->FileName = "statistics";
    $t->Source = "system";
    $t->SidebarID = 0;
    $t->Content = "";
    $t->HtmlID = "divStatistics";
    $t->Type = "ul";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_favorite'];
    $t->FileName = "favorite";
    $t->Source = "system";
    $t->SidebarID = 1;
    $t->Content = '<li><a href="http://bbs.zblogcn.com/" target="_blank">ZBlogger社区</a></li><li><a href="http://app.zblogcn.com/" target="_blank">Z-Blog应用中心</a></li><li><a href="http://weibo.com/zblogcn" target="_blank">Z-Blog新浪官微</a></li><li><a href="http://t.qq.com/zblogcn" target="_blank">Z-Blog腾讯官微</a></li>';
    $t->HtmlID = "divFavorites";
    $t->Type = "ul";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_link'];
    $t->FileName = "link";
    $t->Source = "system";
    $t->SidebarID = 1;
    $t->Content = '<li><a href="http://www.dbshost.cn/" target="_blank" title="独立博客服务 Z-Blog官方主机">DBS主机</a></li>';
    $t->HtmlID = "divLinkage";
    $t->Type = "ul";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_misc'];
    $t->FileName = "misc";
    $t->Source = "system";
    $t->SidebarID = 1;
    $t->Content = '<li><a href="http://www.zblogcn.com/" target="_blank"><img src="{#ZC_BLOG_HOST#}zb_system/image/logo/zblog.gif" height="31" width="88" alt="RainbowSoft Studio Z-Blog" /></a></li><li><a href="{#ZC_BLOG_HOST#}feed.php" target="_blank"><img src="{#ZC_BLOG_HOST#}zb_system/image/logo/rss.png" height="31" width="88" alt="订阅本站的 RSS 2.0 新闻聚合" /></a></li>';
    $t->HtmlID = "divMisc";
    $t->Type = "ul";
    $t->IsHideTitle = true;
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_authors'];
    $t->FileName = "authors";
    $t->Source = "system";
    $t->SidebarID = 0;
    $t->Content = "";
    $t->HtmlID = "divAuthors";
    $t->Type = "ul";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_previous'];
    $t->FileName = "previous";
    $t->Source = "system";
    $t->SidebarID = 0;
    $t->Content = "";
    $t->HtmlID = "divPrevious";
    $t->Type = "ul";
    $t->Save();
    $t = new Module();
    $t->Name = $zbp->lang['msg']['module_tags'];
    $t->FileName = "tags";
    $t->Source = "system";
    $t->SidebarID = 0;
    $t->Content = "";
    $t->HtmlID = "divTags";
    $t->Type = "ul";
    $t->Save();
    $a = new Post();
    $a->CateID = 1;
    $a->AuthorID = 1;
    $a->Tag = '';
    $a->Status = ZC_POST_STATUS_PUBLIC;
    $a->Type = ZC_POST_TYPE_ARTICLE;
    $a->Alias = '';
    $a->IsTop = false;
    $a->IsLock = false;
    $a->Title = $zbp->lang['zb_install']['hello_zblog'];
    $a->Intro = $zbp->lang['zb_install']['hello_zblog_content'];
    $a->Content = $zbp->lang['zb_install']['hello_zblog_content'];
    $a->IP = GetGuestIP();
    $a->PostTime = time();
    $a->CommNums = 0;
    $a->ViewNums = 0;
    $a->Template = '';
    $a->Meta = '';
    $a->Save();
    $a = new Post();
    $a->CateID = 0;
    $a->AuthorID = 1;
    $a->Tag = '';
    $a->Status = ZC_POST_STATUS_PUBLIC;
    $a->Type = ZC_POST_TYPE_PAGE;
    $a->Alias = '';
    $a->IsTop = false;
    $a->IsLock = false;
    $a->Title = $zbp->lang['zb_install']['guestbook'];
    $a->Intro = '';
    $a->Content = $zbp->lang['zb_install']['guestbook_content'];
    $a->IP = GetGuestIP();
    $a->PostTime = time();
    $a->CommNums = 0;
    $a->ViewNums = 0;
    $a->Template = '';
    $a->Meta = '';
    $a->Save();
    echo $zbp->lang['zb_install']['create_datainfo'] . "<br/>";
}
function processPostForExternal($rec, $recgroup, $post, $time, $count, $_group = false)
{
    global $INTERNAL, $GROUPS, $STATS;
    if (STATS_ACTIVE) {
        $STATS->ProcessAction(ST_ACTION_INTERNAL_POST);
    }
    if (!empty($INTERNAL[CALLER_SYSTEM_ID]->ExternalChats[$rec]) && $_group) {
        $INTERNAL[CALLER_SYSTEM_ID]->ExternalChats[$rec]->Load();
        $INTERNAL[CALLER_SYSTEM_ID]->ExternalChats[$rec]->Members[$rec] = true;
        $chatId = $INTERNAL[CALLER_SYSTEM_ID]->ExternalChats[$rec]->ChatId;
        $receiverlist = $INTERNAL[CALLER_SYSTEM_ID]->ExternalChats[$rec]->Members;
    } else {
        $chatId = getValueBySystemId($rec, "chat_id", "");
        $receiverlist = array($rec => $rec);
    }
    $npost = new Post(getId(32), CALLER_SYSTEM_ID, "", $post, $time, $chatId, $INTERNAL[CALLER_SYSTEM_ID]->Fullname);
    foreach ($receiverlist as $systemid => $member) {
        if ($systemid == CALLER_SYSTEM_ID || !empty($member->Declined)) {
            continue;
        }
        if (!empty($INTERNAL[$systemid]) && !empty($GROUPS[$recgroup]->Members[$systemid])) {
            continue;
        }
        $npost->Receiver = $systemid;
        $npost->Persistent = false;
        $npost->Translation = $_POST[POST_INTERN_PROCESS_POSTS . "_vd" . $count];
        $npost->TranslationISO = $_POST[POST_INTERN_PROCESS_POSTS . "_ve" . $count];
        $npost->ReceiverGroup = $recgroup;
        $npost->ReceiverOriginal = $rec;
        $npost->Save();
        $INTERNAL[CALLER_SYSTEM_ID]->SetRepostTime($npost->ReceiverGroup, $npost->Created);
    }
}
 function RepostChatHistory($_caller, $_chatId, $_internalSystemId, $_from = 0, $_last = 0, $_receiverGroup = "", $_targetChatId = "", $_targetReceiverGroup = "", $_external = false, $_botonly = false, $_externalSelf = true)
 {
     global $INTERNAL;
     if (empty($_receiverGroup)) {
         $_receiverGroup = $this->SystemId;
     }
     if (!empty($INTERNAL[$_internalSystemId]->Reposts[$this->SystemId])) {
         $_from = $INTERNAL[$_internalSystemId]->Reposts[$this->SystemId];
     }
     if (empty($_targetChatId)) {
         $cidcrit = !empty($_chatId) ? " `chat_id` != '" . DBManager::RealEscape($_chatId) . "' AND" : "";
     } else {
         $cidcrit = !empty($_chatId) ? " `chat_id` = '" . DBManager::RealEscape($_chatId) . "' AND" : "";
     }
     $reccrit = $_external ? "" : " AND `received`=1";
     $result = queryDB(true, $d = "SELECT * FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE" . $cidcrit . " `repost`=0" . $reccrit . " AND `receiver_group`='" . DBManager::RealEscape($_receiverGroup) . "' AND `time`>" . $_from . " GROUP BY `id`;");
     if ($result) {
         while ($row = DBManager::FetchArray($result)) {
             if ($_botonly) {
                 if (!(isset($INTERNAL[$row["receiver_original"]]) && $INTERNAL[$row["receiver_original"]]->IsBot) && !(isset($INTERNAL[$row["sender"]]) && $INTERNAL[$row["sender"]]->IsBot)) {
                     continue;
                 }
             }
             $post = new Post(getId(32), $row["sender"], $_internalSystemId, $row["text"], $row["time"], empty($_targetChatId) ? $row["chat_id"] : $_targetChatId, $row["sender_name"]);
             $post->Translation = $row["translation"];
             $post->ReceiverOriginal = $row["receiver_original"];
             $post->TranslationISO = $row["translation_iso"];
             $post->ReceiverGroup = empty($_targetReceiverGroup) ? $row["receiver_group"] : $_targetReceiverGroup;
             $post->Repost = true;
             $post->Save(array(0 => $row["micro"], 1 => $row["time"]));
             $_last = max($_last, $row["time"]);
             if ($_external && $_externalSelf) {
                 $post->Id = getId(32);
                 $post->Receiver = $_targetReceiverGroup;
                 $post->Save(array(0 => $row["micro"], 1 => $row["time"]));
             }
         }
     }
     $INTERNAL[$_internalSystemId]->Reposts[$this->SystemId] = max($_last, $_from);
 }
function processPosts($counter = 0)
{
    global $USER, $STATS, $GROUPS, $INTERNAL, $LZLANG;
    while (isset($_POST["p_p" . $counter])) {
        if (STATS_ACTIVE) {
            $STATS->ProcessAction(ST_ACTION_EXTERNAL_POST);
        }
        $id = md5($USER->Browsers[0]->SystemId . base64UrlDecode($_POST[POST_EXTERN_CHAT_ID]) . base64UrlDecode($_POST["p_i" . $counter]));
        $senderName = !empty($USER->Browsers[0]->Fullname) ? $USER->Browsers[0]->Fullname : $LZLANG["client_guest"] . " " . getNoName($USER->UserId . getIP());
        $post = new Post($id, $USER->Browsers[0]->SystemId, "", base64UrlDecode($_POST["p_p" . $counter]), time(), $USER->Browsers[0]->ChatId, $senderName);
        foreach ($GROUPS as $groupid => $group) {
            if ($group->IsDynamic && !empty($group->Members[$USER->Browsers[0]->SystemId])) {
                foreach ($group->Members as $member => $persistent) {
                    if ($member != $USER->Browsers[0]->SystemId) {
                        if (!empty($INTERNAL[$member])) {
                            processPost($id, $post, $member, $counter, $groupid, $USER->Browsers[0]->ChatId);
                        } else {
                            processPost($id, $post, $member, $counter, $groupid, getValueBySystemId($member, "chat_id", ""));
                        }
                    }
                }
                $pGroup = $group;
            }
        }
        foreach ($USER->Browsers[0]->Members as $systemid => $member) {
            if (!empty($member->Declined)) {
                continue;
            }
            if (!empty($INTERNAL[$systemid]) && !empty($pGroup->Members[$systemid])) {
                continue;
            }
            if (!(!empty($pGroup) && !empty($INTERNAL[$systemid]))) {
                processPost($id, $post, $systemid, $counter, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId);
            }
        }
        $autoReply = $USER->Browsers[0]->InternalUser->GetAutoReplies($post->Text, $USER->Browsers[0]);
        if (!empty($autoReply)) {
            $arpost = new Post($id = getId(32), $USER->Browsers[0]->InternalUser->SystemId, $USER->Browsers[0]->SystemId, $autoReply, time(), $USER->Browsers[0]->ChatId, $USER->Browsers[0]->InternalUser->Fullname);
            $arpost->ReceiverOriginal = $arpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
            $arpost->Save();
            foreach ($USER->Browsers[0]->Members as $opsysid => $member) {
                $rpost = new Post($id, $USER->Browsers[0]->InternalUser->SystemId, $opsysid, $autoReply, time(), $USER->Browsers[0]->ChatId, $INTERNAL[$systemid]->Fullname);
                $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                $rpost->Save();
            }
        }
        $USER->AddFunctionCall("lz_chat_release_post('" . base64UrlDecode($_POST["p_i" . $counter]) . "');", false);
        $counter++;
    }
    $counter = 0;
    while (isset($_POST["pr_i" . $counter])) {
        $post = new Post(base64UrlDecode($_POST["pr_i" . $counter]), "", "", "", "", "", "");
        $post->MarkReceived($USER->Browsers[0]->SystemId);
        $USER->AddFunctionCall("lz_chat_message_set_received('" . base64UrlDecode($_POST["pr_i" . $counter]) . "');", false);
        $counter++;
    }
}
예제 #12
0
function processPosts($counter = 0)
{
    global $USER;
    while (isset($_POST["p_p" . $counter])) {
        $id = md5($USER->Browsers[0]->SystemId . $_POST[POST_EXTERN_CHAT_ID] . $_POST["p_i" . $counter]);
        $post = new Post($id, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->Chat->InternalUser->SystemId, AJAXDecode($_POST["p_p" . $counter]), time());
        $post->Save();
        $USER->AddFunctionCall("lz_chat_release_post('" . $_POST["p_i" . $counter] . "');", false);
        $counter++;
    }
    $counter = 0;
    while (isset($_POST["pr_i" . $counter])) {
        markPostReceived($_POST["pr_i" . $counter]);
        $USER->AddFunctionCall("lz_chat_message_set_received('" . $_POST["pr_i" . $counter] . "');", false);
        $counter++;
    }
}
예제 #13
0
             }
         }
         if (!empty($USER->Browsers[0]->InternalUser) && ($USER->Browsers[0]->InternalUser->IsBot || $USER->Browsers[0]->Status == CHAT_STATUS_ACTIVE)) {
             $rpost = new Post($id = getId(32), $USER->Browsers[0]->InternalUser->SystemId, $USER->Browsers[0]->SystemId, $answer = $USER->Browsers[0]->InternalUser->GetAutoReplies($post->Text . " " . $post->Translation, $USER->Browsers[0]), time(), $USER->Browsers[0]->ChatId, $USER->Browsers[0]->InternalUser->Fullname);
             if (!empty($answer)) {
                 if ($USER->Browsers[0]->InternalUser->IsBot) {
                     $USER->AddFunctionCall("lz_chat_input_bot_state(true,false);", false);
                 }
                 $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                 $rpost->Save();
                 $saved = true;
                 foreach ($USER->Browsers[0]->Members as $opsysid => $member) {
                     if ($opsysid != $USER->Browsers[0]->InternalUser->SystemId || !$USER->Browsers[0]->InternalUser->IsBot) {
                         $rpost = new Post($id, $USER->Browsers[0]->InternalUser->SystemId, $opsysid, $answer, time(), $USER->Browsers[0]->ChatId, $INTERNAL[$systemid]->Fullname);
                         $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                         $rpost->Save();
                     }
                 }
             }
         }
         if ($saved) {
             $USER->AddFunctionCall("lz_chat_release_post('" . base64UrlDecode($_GET["mi" . $pc]) . "');", false);
         }
     } else {
         processPost($id, $post, "", $pc, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId, false);
         $USER->Browsers[0]->QueuedPosts[$id] = array(0 => $_GET["mp" . $pc], 1 => time(), 2 => $BROWSER->BrowserId);
         $USER->AddFunctionCall("lz_chat_release_post('" . base64UrlDecode($_GET["mi" . $pc]) . "');", false);
     }
     $pc++;
 }
 $startTime = 0;
function appendPosts()
{
    global $INTERNAL, $GROUPS, $VISITOR, $CONFIG;
    $posts = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_POSTS . "_va"]));
    $receivers = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_POSTS . "_vb"]));
    $postids = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_POSTS . "_vc"]));
    $time = time();
    foreach ($posts as $key => $post) {
        if ($receivers[$key] == GROUP_EVERYONE_INTERN || isset($GROUPS[$receivers[$key]])) {
            foreach ($INTERNAL as $internal) {
                if ($internal->SystemId != CALLER_SYSTEM_ID) {
                    if ($receivers[$key] == GROUP_EVERYONE_INTERN || in_array($receivers[$key], $internal->Groups)) {
                        if ($internal->Status != USER_STATUS_OFFLINE || !isnull($CONFIG["gl_ogcm"])) {
                            $npost = new Post(getId(32), CALLER_SYSTEM_ID, $internal->SystemId, $posts[$key], $time);
                            $npost->Persistent = true;
                            if ($receivers[$key] == GROUP_EVERYONE_INTERN || in_array($receivers[$key], $INTERNAL[CALLER_SYSTEM_ID]->Groups)) {
                                $npost->ReceiverGroup = $receivers[$key];
                            }
                            $npost->Save();
                        }
                    }
                }
            }
        } else {
            if ($receivers[$key] == GROUP_EVERYONE_EXTERN) {
                foreach ($INTERNAL[CALLER_SYSTEM_ID]->ExternalChats as $chat) {
                    $npost = new Post(getId(32), CALLER_SYSTEM_ID, $chat->ExternalUser->SystemId, $posts[$key], $time);
                    $npost->Save();
                }
            } else {
                $npost = new Post($postids[$key], CALLER_SYSTEM_ID, $receivers[$key], $posts[$key], $time);
                $npost->Persistent = isset($INTERNAL[$receivers[$key]]);
                $npost->Save();
                if (!$npost->Persistent) {
                    archiveExternalChat($npost);
                }
            }
        }
    }
}
예제 #15
0
파일: save.php 프로젝트: leloulight/didapi
<?php

include_once '../../globals.php';
$response = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // if form has been posted process data
    $postdata = file_get_contents("php://input");
    $request = json_decode($postdata);
    $content = $request->content;
    $title = $request->title;
    $request->date = date("Y-m-d H:i:s");
    $request->user_id = $_SESSION['user_id'];
    $post = new Post();
    $success = $post->Save($request);
    echo $success;
    echo $success == true ? 'Votre article a bien été sauvegardé' : 'Il y a eu une erreur lors de la sauvegarde de votre article';
}
?>

예제 #16
0
 public function Run()
 {
     echo $this->Title('Posts');
     $total_new = 0;
     $total_found = 0;
     $total_ignored = 0;
     // Lets not bother with spammers
     $skipauthors = array();
     $query = 'SELECT "authorid",COUNT(*) AS "total",SUM("hidden") AS "hidden" FROM "posts" GROUP BY "authorid" ';
     $rs = static::$conn->Execute($query);
     while ($row = $rs->Fetch()) {
         // Total posts equals hidden posts
         if ($row['total'] == $row['hidden'] && $row['hidden'] > self::SPAM_POST_THRESHOLD) {
             $skipauthors[$row['authorid']] = $row['authorid'];
         }
     }
     // Process new articles by author - each author gets 30 seconds so that spam can't hold up useful posts
     $authors = array();
     $query = 'SELECT "articles"."authorid","authors"."name" FROM "articles" ' . 'LEFT JOIN "authors" ON ("authors"."id" = "articles"."authorid") ' . 'WHERE ("articles"."postid" = 0) AND ("articles"."created" > ?) ' . (count($skipauthors) > 0 ? 'AND ("articles"."authorid" NOT IN (' . implode(',', $skipauthors) . ')) ' : '') . 'GROUP BY "articles"."authorid" ' . 'ORDER BY RAND() ';
     // Ensures that if a single author still holds up script too long, next time luck might change
     $rs = static::$conn->Execute($query, time() - self::MATCH_RECENT);
     while ($row = $rs->Fetch()) {
         $authors[$row['authorid']] = $row['name'];
     }
     foreach ($authors as $author_id => $author_name) {
         try {
             // Begin transaction
             static::$conn->BeginTransaction();
             $start = GetMicroTime();
             echo '<p><i>Processing articles posted by <b>' . SafeHTML($author_name) . '</b></i><br />';
             $count = 0;
             $new = 0;
             $found = 0;
             $ignored = 0;
             $skip = array();
             while (GetMicroTime() - $start < self::TIME_LIMIT) {
                 // Get article not yet associated with a post
                 $query = 'SELECT "id","authorid","subject","post_date" FROM "articles" ' . 'WHERE ("postid" = 0) AND ("authorid" = ?) AND ("created" > ?) ' . (count($skip) > 0 ? 'AND ("id" > ' . intval(end($skip)) . ') ' : '') . 'ORDER BY "id" ASC LIMIT 0,1';
                 $rs = static::$conn->Execute($query, $author_id, time() - self::MATCH_RECENT);
                 $row = $rs->Fetch();
                 // Abort if no more articles
                 if (!$row) {
                     break;
                 }
                 // Reset
                 $this->sql = $row['subject'];
                 $this->sql_alt = $row['subject'];
                 $this->parts = null;
                 $this->pos = null;
                 // Create Queries
                 $this->CreateQueries();
                 echo SafeHTML($row['subject']) . ' - ';
                 $strategy = $this->DetermineStrategy($row);
                 // If first pass failed, try a second time
                 if ($strategy == self::STRATEGY_IGNORE) {
                     $strategy = $this->SecondPass($row);
                 }
                 // Skip ignored
                 if ($strategy == self::STRATEGY_IGNORE) {
                     $ignored++;
                     $skip[$row['id']] = $row['id'];
                     echo ' - <i><b style="color:#990000">Ignored</b></i><br />';
                     continue;
                 }
                 // Find existing post (if any)
                 $query = 'SELECT "postid" FROM "articles" WHERE ("postid" != 0) AND ("subject" LIKE ?) AND ("authorid" = ?) AND ("post_date" > ?) AND ("post_date" < ?) LIMIT 0,1';
                 $rs = static::$conn->Execute($query, $strategy == self::STRATEGY_PRIMARY ? $this->sql : $this->sql_alt, $row['authorid'], $row['post_date'] - self::MATCH_RANGE, $row['post_date'] + self::MATCH_RANGE);
                 $match = $rs->Fetch();
                 if ($match) {
                     $found++;
                     $post = Post::FindByID($match['postid']);
                     echo ' - <i><b style="color:#000099">Found</b></i><br />';
                 } else {
                     $new++;
                     $post = new Post();
                     // We need the post ID so save first
                     $post->Save();
                     echo ' - <i><b style="color:#009900">New</b></i><br />';
                 }
                 // Update articles
                 $query = 'UPDATE "articles" SET "postid" = ?  WHERE ("postid" = 0) AND ("subject" LIKE ?) AND ("authorid" = ?) AND ("post_date" > ?) AND ("post_date" < ?)';
                 static::$conn->Execute($query, $post->id, $strategy == self::STRATEGY_PRIMARY ? $this->sql : $this->sql_alt, $row['authorid'], $row['post_date'] - self::MATCH_RANGE, $row['post_date'] + self::MATCH_RANGE);
                 // Queue post recalculation + post group update (initializes all missing fields for new posts too)
                 Post::Queue($post->id);
                 // Sleep for 0.1 seconds to give database time to process
                 usleep(100000);
                 if ($count > self::ARTICLE_LIMIT) {
                     break;
                 }
                 $count++;
             }
             // Update all posts in one go (in case one post was updated more than once)
             $posts = Post::Update();
             // Commit transaction
             static::$conn->Commit();
         } catch (Exception $e) {
             // Rollback on error
             static::$conn->Rollback();
             throw $e;
         }
         echo '<b>' . $new . '</b> posts added, <b>' . $found . '</b> posts updated, <b>' . $ignored . '</b> posts ignored (<b>' . number_format(GetMicroTime() - $start, 2) . '</b> seconds)</p>';
         $total_new += $new;
         $total_found += $found;
         $total_ignored += $ignored;
         // Abort if processing all authors takes to much time
         if (GetMicroTime() - $this->time['start'] > self::MAX_TIME_LIMIT) {
             break;
         }
     }
     echo '<p><i>Total <b>' . $total_new . '</b> posts added, <b>' . $total_found . '</b> posts updated, <b>' . $total_ignored . '</b> posts ignored</i></p>';
     // Detect spam
     $this->DetectSpam();
     // Update last 1000 number of posts that are marked hidden yet are still being listed (=BAD!)
     $query = 'SELECT "id" FROM "posts" LEFT JOIN "postcat" ON ("postcat"."postid" = "posts"."id") ' . 'WHERE ("postcat"."postid" IS NOT NULL) ' . 'AND ("posts"."hidden" = 1) ' . 'ORDER BY "posts"."id" DESC ' . 'LIMIT 0,1000 ';
     $rs = static::$conn->Execute($query);
     while ($row = $rs->Fetch()) {
         $post = Post::Find($row['id']);
         $post->Save();
     }
     // Update last 100 number of posts that are not being listed even though they're not marked hidden (ie: they were still incomplete when last time encountered)
     $query = 'SELECT "id" FROM "posts" LEFT JOIN "postcat" ON ("postcat"."postid" = "posts"."id") ' . 'WHERE ("postcat"."postid" IS NULL) ' . 'AND ("posts"."hidden" = 0) ' . 'AND ("posts"."post_date" < ' . (time() - 600) . ') ' . 'AND ("posts"."files" > 1) ' . 'AND ("posts"."files" < ' . self::MAX_POST_FILES_LIMIT . ') ' . 'AND ("posts"."size" >= 1048576) ' . 'ORDER BY "posts"."post_date" DESC ' . 'LIMIT 0,100 ';
     $rs = static::$conn->Execute($query);
     while ($row = $rs->Fetch()) {
         $post = Post::Find($row['id']);
         $post->Save();
     }
     // Update last 100 number of posts that have been last updated longest time ago
     $rs = static::$conn->Execute('SELECT "id" FROM "posts" ORDER BY "updated" ASC LIMIT 0,100 ');
     while ($row = $rs->Fetch()) {
         $post = Post::Find($row['id']);
         $post->Save();
     }
     PostCat::Update();
 }