[PHP] 博客blog cms内容管理系统nucleus →→→→→进入此内容的聊天室

来自 , 2019-07-03, 写在 PHP, 查看 146 次.
URL http://www.code666.cn/view/ad82140c
  1. =========================================================
  2.  
  3. 安装:
  4.  
  5. =========================================================
  6.  
  7.  
  8. 1. 解压缩文件包
  9.  
  10. 将文件包中的所有文件解压缩到你电脑上的某个目录中。保证解压缩后的文件目录结构保持不变。解压缩完成后,你将得到如下的目录结构(* 代表该目录下包含文件):
  11. /*                           (系统主文件目录)
  12. /nucleus/*                   (管理主文件目录)
  13. /nucleus/javascript/*        (javascript帮助代码目录)
  14. /nucleus/libs/*              (Nucleus核心库文件目录)
  15. /nucleus/language/*          (语言包文件目录)
  16. /nucleus/plugins/*           (插件目录)
  17. /nucleus/xmlrpc/*            (XML-RPC接口目录)
  18. /nucleus/documentation/*     (文档 + 管理帮助目录)
  19. /nucleus/styles/*            (文档 + 管理帮助风格目录)
  20. /nucleus/forms/*             (表单式样目录)
  21. /extra/*                     (其他, e.g. needed files to enable fancy URLs)
  22. /skins/*                     (皮肤目录[导入的皮肤也存放于此])
  23. /media/*                     (媒体文件目录[空的])
  24.  
  25.  
  26.  
  27.  
  28. 2. 上传文件到服务器
  29.  
  30. 上传所有的文件到服务器,保证所有的php文件都是在ASCII模式下进行传输。如果用其他模式传输,程序运行将会出错。
  31. 可选项:
  32. 为了使你的安装更简单,你最好将 config.php 的文件属性改为 666 。这样的话,安装脚本就能够自动将系统的配置保存在其中。否则,你只能手动配置。(如何更改文件属性)
  33. 如果你想使用文件上传功能,你必须将 /media/ 目录设置为可写(777)属性(777)。(如何更改文件属性)
  34. 如果你想使用 SkinFiles 插件编辑皮肤文件,你需要将 /skins/ 目录下的所有文件设置成 666 属性。如果你想创建新的皮肤文件,就必须设置目录为 777 属性。
  35.  
  36.  
  37.  
  38.  
  39. 3. 运行install.php
  40.  
  41. 用你的浏览器打开下面的地址,将 yoursite和yourpath 的内容改成你的服务器对应的内容。
  42. http://www.yoursite.com/yourpath/install.php
  43.  
  44. 该安装脚本将会提示你输入一些信息并完成大部分的安装工作。当安装成功以后,install.php 将会给你进一步的提示(你仍需要手工删除一些文件)。
  45. 注意: 当你在浏览器打开 install.php 后,出现 "If you see this text in your browser..." 这样的文字,或者提示你下载 install.php,说明你的服务器不支持PHP,安装将无法进行。
  46.  
  47.  
  48.  
  49.  
  50. 4. 完成
  51.  
  52. 安装完成后你就可以访问你的网站并进行管理了。更多安装问题请到HEXU查询。
  53.  
  54.  
  55. <?php
  56.  
  57. class ACTION
  58. {
  59.         function ACTION()
  60.         {
  61.        
  62.         }
  63.        
  64.         function doAction($action)
  65.         {
  66.                 switch($action) {
  67.                         case 'addcomment':
  68.                                 return $this->addComment();
  69.                                 break;
  70.                         case 'sendmessage':
  71.                                 return $this->sendMessage();
  72.                                 break;
  73.                         case 'createaccount':
  74.                                 return $this->createAccount();
  75.                                 break;         
  76.                         case 'forgotpassword':
  77.                                 return $this->forgotPassword();
  78.                                 break;
  79.                         case 'votepositive':
  80.                                 return $this->doKarma('pos');
  81.                                 break;
  82.                         case 'votenegative':
  83.                                 return $this->doKarma('neg');
  84.                                 break;
  85.                         case 'plugin':
  86.                                 return $this->callPlugin();
  87.                                 break;
  88.                         default:
  89.                                 doError(_ERROR_BADACTION);
  90.                 }
  91.         }
  92.        
  93.         function addComment() {
  94.                 global $CONF, $errormessage, $manager;
  95.  
  96.                 $post['itemid'] =       intPostVar('itemid');
  97.                 $post['user'] =         postVar('user');
  98.                 $post['userid'] =       postVar('userid');
  99.                 $post['body'] =         postVar('body');
  100.  
  101.                 // set cookies when required
  102.                 $remember = intPostVar('remember');
  103.                 if ($remember == 1) {
  104.                         $lifetime = time()+2592000;
  105.                         setcookie($CONF['CookiePrefix'] . 'comment_user',$post['user'],$lifetime,'/','',0);
  106.                         setcookie($CONF['CookiePrefix'] . 'comment_userid', $post['userid'],$lifetime,'/','',0);
  107.                 }
  108.  
  109.                 $comments = new COMMENTS($post['itemid']);
  110.  
  111.                 $blogid = getBlogIDFromItemID($post['itemid']);
  112.                 $this->checkban($blogid);
  113.                 $blog =& $manager->getBlog($blogid);
  114.  
  115.                 // note: PreAddComment and PostAddComment gets called somewhere inside addComment
  116.                 $errormessage = $comments->addComment($blog->getCorrectTime(),$post);
  117.  
  118.                 if ($errormessage == '1') {            
  119.                         // redirect when adding comments succeeded
  120.                         if (postVar('url')) {
  121.                                 redirect(postVar('url'));
  122.                         } else {
  123.                                 $url = $CONF['IndexURL'] . createItemLink($post['itemid']);
  124.                                 redirect($url);
  125.                         }
  126.                 } else {
  127.                         // else, show error message using default skin for blog
  128.                         return array(
  129.                                 'message' => $errormessage,
  130.                                 'skinid' => $blog->getDefaultSkin()
  131.                         );
  132.                 }
  133.                
  134.                 exit;
  135.         }
  136.  
  137.         // Sends a message from the current member to the member given as argument
  138.         function sendMessage() {
  139.                 global $CONF, $member;
  140.  
  141.                 $error = $this->validateMessage();
  142.                 if ($error != '')
  143.                         return array('message' => $error);
  144.  
  145.                 if (!$member->isLoggedIn()) {
  146.                         $fromMail = postVar('frommail');
  147.                         $fromName = _MMAIL_FROMANON;
  148.                 } else {
  149.                         $fromMail = $member->getEmail();
  150.                         $fromName = $member->getDisplayName();
  151.                 }
  152.  
  153.                 $tomem = new MEMBER();
  154.                 $tomem->readFromId(postVar('memberid'));
  155.  
  156.                 $message  = _MMAIL_MSG . ' ' . $fromName . "\n"
  157.                           . '(' . _MMAIL_FROMNUC. ' ' . $CONF['IndexURL'] .") \n\n"
  158.                           . _MMAIL_MAIL . " \n\n"
  159.                           . postVar('message');
  160.                 $message .= getMailFooter();
  161.  
  162.                 $title = _MMAIL_TITLE . ' ' . $fromName;
  163.                 mail($tomem->getEmail(), $title, $message, 'From: '. $fromMail);
  164.  
  165.                 if (postVar('url')) {
  166.                         redirect(postVar('url'));
  167.                 } else {
  168.                         $CONF['MemberURL'] = $CONF['IndexURL'];
  169.                         if ($CONF['URLMode'] == 'pathinfo')
  170.                         {
  171.                                 $url = createLink('member', array('memberid' => $tomem->getID(), 'name' => $tomem->getDisplayName()));
  172.                         }
  173.                         else
  174.                         {
  175.                                 $url = $CONF['IndexURL'] . createMemberLink($tomem->getID());
  176.                         }
  177.                         redirect($url);
  178.                 }
  179.                
  180.                 exit;
  181.  
  182.         }
  183.        
  184.         function validateMessage() {
  185.                 global $CONF, $member, $manager;
  186.  
  187.                 if (!$CONF['AllowMemberMail'])
  188.                         return _ERROR_MEMBERMAILDISABLED;
  189.  
  190.                 if (!$member->isLoggedIn() && !$CONF['NonmemberMail'])
  191.                         return _ERROR_DISALLOWED;
  192.  
  193.                 if (!$member->isLoggedIn() && (!isValidMailAddress(postVar('frommail'))))
  194.                         return _ERROR_BADMAILADDRESS;
  195.                        
  196.                 // let plugins do verification (any plugin which thinks the comment is invalid
  197.                 // can change 'error' to something other than '')
  198.                 $result = '';
  199.                 $manager->notify('ValidateForm', array('type' => 'membermail', 'error' => &$result));
  200.                
  201.                 return $result;
  202.                
  203.         }
  204.  
  205.         // creates a new user account
  206.         function createAccount() {
  207.                 global $CONF, $manager;
  208.  
  209.                 if (!$CONF['AllowMemberCreate'])
  210.                         doError(_ERROR_MEMBERCREATEDISABLED);
  211.  
  212.                 // even though the member can not log in, set some random initial password. One never knows.
  213.                 srand((double)microtime()*1000000);
  214.                 $initialPwd = md5(uniqid(rand(), true));
  215.  
  216.                 // create member (non admin/can not login/no notes/random string as password)
  217.                 $r = MEMBER::create(postVar('name'), postVar('realname'), $initialPwd, postVar('email'), postVar('url'), 0, 0, '');
  218.                
  219.                 if ($r != 1)
  220.                         doError($r);
  221.                        
  222.                 // send message containing password.
  223.                 $newmem = new MEMBER();
  224.                 $newmem->readFromName(postVar('name'));
  225.                 $newmem->sendActivationLink('register');
  226.  
  227.                 $manager->notify('PostRegister',array('member' => &$newmem));          
  228.  
  229.                 if (postVar('desturl')) {
  230.                         redirect(postVar('desturl'));
  231.                 } else {
  232.                         echo _MSG_ACTIVATION_SENT;
  233.                 }
  234.                
  235.                 exit;
  236.         }
  237.  
  238.         // sends a new password
  239.         function forgotPassword() {
  240.                 $membername = trim(postVar('name'));
  241.  
  242.                 if (!MEMBER::exists($membername))
  243.                         doError(_ERROR_NOSUCHMEMBER);
  244.                 $mem = MEMBER::createFromName($membername);
  245.  
  246.                 if (!$mem->canLogin())
  247.                         doError(_ERROR_NOLOGON_NOACTIVATE);
  248.  
  249.                 // check if e-mail address is correct
  250.                 if (!($mem->getEmail() == postVar('email')))
  251.                         doError(_ERROR_INCORRECTEMAIL);
  252.  
  253.                 // send activation link
  254.                 $mem->sendActivationLink('forgot');
  255.  
  256.                 if (postVar('url')) {
  257.                         redirect(postVar('url'));
  258.                 } else {
  259.                         echo _MSG_ACTIVATION_SENT;
  260.                 }
  261.                
  262.                 exit;
  263.         }
  264.  
  265.         // handle karma votes
  266.         function doKarma($type) {
  267.                 global $itemid, $member, $CONF, $manager;
  268.  
  269.                 // check if itemid exists
  270.                 if (!$manager->existsItem($itemid,0,0))
  271.                         doError(_ERROR_NOSUCHITEM);
  272.  
  273.                 $blogid = getBlogIDFromItemID($itemid);
  274.                 $this->checkban($blogid);      
  275.  
  276.                 $karma =& $manager->getKarma($itemid);
  277.  
  278.                 // check if not already voted
  279.                 if (!$karma->isVoteAllowed(serverVar('REMOTE_ADDR')))
  280.                         doError(_ERROR_VOTEDBEFORE);           
  281.  
  282.                 // check if item does allow voting
  283.                 $item =& $manager->getItem($itemid,0,0);
  284.                 if ($item['closed'])
  285.                         doError(_ERROR_ITEMCLOSED);
  286.  
  287.                 switch($type) {
  288.                         case 'pos':
  289.                                 $karma->votePositive();
  290.                                 break;
  291.                         case 'neg':
  292.                                 $karma->voteNegative();
  293.                                 break;
  294.                 }
  295.  
  296.                 $blogid = getBlogIDFromItemID($itemid);
  297.                 $blog =& $manager->getBlog($blogid);
  298.  
  299.                 // send email to notification address, if any
  300.                 if ($blog->getNotifyAddress() && $blog->notifyOnVote()) {
  301.  
  302.                         $mailto_msg = _NOTIFY_KV_MSG . ' ' . $itemid . "\n";
  303.                         $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n";
  304.                         if ($member->isLoggedIn()) {
  305.                                 $mailto_msg .= _NOTIFY_MEMBER . ' ' . $member->getDisplayName() . ' (ID=' . $member->getID() . ")\n";
  306.                         }
  307.                         $mailto_msg .= _NOTIFY_IP . ' ' . serverVar('REMOTE_ADDR') . "\n";
  308.                         $mailto_msg .= _NOTIFY_HOST . ' ' .  gethostbyaddr(serverVar('REMOTE_ADDR'))  . "\n";
  309.                         $mailto_msg .= _NOTIFY_VOTE . "\n " . $type . "\n";
  310.                         $mailto_msg .= getMailFooter();
  311.  
  312.                         $mailto_title = _NOTIFY_KV_TITLE . ' ' . strip_tags($item['title']) . ' (' . $itemid . ')';
  313.  
  314.                         $frommail = $member->getNotifyFromMailAddress();
  315.  
  316.                         $notify = new NOTIFICATION($blog->getNotifyAddress());
  317.                         $notify->notify($mailto_title, $mailto_msg , $frommail);
  318.                 }
  319.  
  320.  
  321.                 $refererUrl = serverVar('HTTP_REFERER');
  322.                 if ($refererUrl)
  323.                         $url = $refererUrl;
  324.                 else
  325.                         $url = $CONF['IndexURL'] . 'index.php?itemid=' . $itemid;
  326.  
  327.                 redirect($url);
  328.                 exit;
  329.         }
  330.  
  331.         /**
  332.           * Calls a plugin action
  333.           */
  334.         function callPlugin() {
  335.                 global $manager;
  336.  
  337.                 $pluginName = 'NP_' . requestVar('name');
  338.                 $actionType = requestVar('type');
  339.  
  340.                 // 1: check if plugin is installed
  341.                 if (!$manager->pluginInstalled($pluginName))
  342.                         doError(_ERROR_NOSUCHPLUGIN);
  343.  
  344.                 // 2: call plugin
  345.                 $pluginObject =& $manager->getPlugin($pluginName);
  346.                 if ($pluginObject)
  347.                         $error = $pluginObject->doAction($actionType);
  348.                 else
  349.                         $error = 'Could not load plugin (see actionlog)';
  350.  
  351.                 // doAction returns error when:
  352.                 // - an error occurred (duh)
  353.                 // - no actions are allowed (doAction is not implemented)
  354.                 if ($error)
  355.                         doError($error);
  356.                        
  357.                 exit;
  358.  
  359.         }
  360.  
  361.         function checkban($blogid) {
  362.                 // check if banned
  363.                 $ban = BAN::isBanned($blogid, serverVar('REMOTE_ADDR'));
  364.                 if ($ban != 0) {
  365.                         doError(_ERROR_BANNED1 . $ban->iprange . _ERROR_BANNED2 . $ban->message . _ERROR_BANNED3);
  366.                 }
  367.  
  368.         }
  369.  
  370.  
  371. }
  372.  
  373. ?>

回复 "博客blog cms内容管理系统nucleus"

这儿你可以回复上面这条便签

captcha