Hongmu Notes
Home Program Notes EmpireCMS uses PHP to directly submit data for updating articles.
Program Notes Empire cms Language Notes PHP

EmpireCMS uses PHP to directly submit data for updating articles.

EmpireCMS uses PHP to directly submit data for updating articles.

Submitted code:

While I had some free time, I took the time to thoroughly study the "Locomotive" module and integrated it with Empire CMS, resulting in the following code. Developers familiar with PHP are welcome to modify this code; the code below is merely a simple submission example – the data needs to be configured manually!

<?php
$url = "http://www.4s5.cn/e/admin/123.php"; // 替换为实际的接收数据的URL,你的火车头接口

// 要提交的数据
$postData = array(
    "enews" => "AddNews", // 操作类型
    "classid" => "1", // 类别ID
    "bclassid" => "0", // 父类别ID
    "id" => "0", // 文章ID
    "filepass" => "[Timestamp:时间]", // 文件密码
    "username" => "admin1", // 用户名
    "oldfilename" => "", // 旧文件名
    "oldgroupid" => "", // 旧用户组ID
    "oldchecked" => "1", // 旧审核状态
    "newstext_url" => "", // 新闻链接
    "ecmsfrom" => "", // 来源
    "ecmsnfrom" => "1", // 是否显示来源
    "fstb" => "", // 标题加粗
    "oldttid" => "", // 旧标题分类ID
    "ecmscheck" => "0", // 是否审核
    "ztids" => "", // 所属专题ID
    "zcids" => "", // 所属专栏ID
    "oldztids" => "", // 旧所属专题ID
    "oldzcids" => "", // 旧所属专栏ID
    "havetmpic" => "0", // 是否有临时图片
    "title" => "", // 标题
    "titlecolor" => "", // 标题颜色
    "ftitle" => "", // 副标题
    "checked" => "1", // 审核状态
    "isgood" => "0", // 是否推荐
    "firsttitle" => "0", // 是否头条
    "keyboard" => "", // 关键词
    "titleurl" => "", // 标题链接
    "newstime" => "2023-11-22 17:56:36", // 发布时间
    "titlepic" => "", // 缩略图
    "smalltext" => "", // 简介
    "writer" => "", // 作者
    "w_id" => "", // 作者ID
    "befrom" => "", // 资讯来源
    "befrom_id" => "选择信息来源", // 资讯来源ID
    "newstext" => "", // 正文内容
    "dokey" => "1", // 是否生成关键词
    "qz_url" => "", // 网址前缀
    "autosize" => "5000", // 自动提取摘要字数
    "getfirsttitlepic" => "", // 是否获取第一个标题图片
    "getfirsttitlespicw" => "105", // 获取第一个标题图片宽度
    "getfirsttitlespich" => "118", // 获取第一个标题图片高度
    "istop" => "0", // 是否置顶
    "newstempid" => "1", // 内容模板ID
    "groupid" => "0", // 用户组ID
    "userfen" => "0", // 用户积分
    "onclick" => "62", // 点击数
    "totaldown" => "0", // 下载数
    "newspath" => "", // 存放目录
    "filename" => "", // 文件名
    "infotags" => "", // 信息标签
    "oldinfotags" => "", // 旧信息标签
    "info_diyotherlink" => "0", // 是否自定义相关链接
    "info_keyid" => "", // 相关信息关联ID
    "info_infouptime" => "2023-11-22 17:56:36", // 信息发布时间
    "info_infodowntime" => "", // 信息下架时间
    "vote_title" => "", // 投票标题
    "vote_name" => ["", "", "", "", "", "", "", ""], // 投票选项名称
    "vote_num" => ["0", "0", "0", "0", "0", "0", "0", "0"], // 投票选项初始票数
    "v_vote_num" => "1", // 投票选项总数
    "v_editnum" => "8", // 可编辑的投票选项数
    "vote_class" => "0", // 投票类型
    "dovote_ip" => "0", // 投票限制方式
    "vote_olddotime" => "0000-00-00", // 投票开始时间
    "vote_dotime" => "0000-00-00", // 投票结束时间
    "vote_width" => "500", // 投票宽度
    "vote_height" => "300", // 投票高度
    "vote_tempid" => "1", // 投票模板ID
    "addnews" => "提交" // 提交操作标识
);

// 转换为字符串格式
$postDataStr = http_build_query($postData);

// 初始化 CURL
$ch = curl_init();

// 设置 CURL 参数
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postDataStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// 执行 CURL 请求
$response = curl_exec($ch);

// 检查请求是否成功
if ($response === false) {
    echo "CURL Error: " . curl_error($ch);
} else {
    echo "Response: " . $response;
}

// 关闭 CURL
curl_close($ch);
?>

Interface Code:

This is the PHP file for integrating Trainhead with Empire CMS (published without requiring login); simply upload it to your `admin` directory. For example:e/admin/

<?php

/********密码验证***********/
$password='9999999';				                   //这个密码是登陆验证用的.您需要在模块里设置和这里一样的密码....注意一定需要修改.
if($password!=$_GET['pw']) exit('验证密码错误');   //安全检测,密码不符则退出

/****以下代码非专业人员不建议修改***************/
define('EmpireCMSAdmin','1');
require("../class/connect.php");
require("../class/db_sql.php");
require("../class/functions.php");
require LoadLang("pub/fun.php");
require("../class/delpath.php");
require("../class/copypath.php");
require("../class/t_functions.php");
require("../data/dbcache/class.php");
require("../data/dbcache/MemberLevel.php");

//获取分类列表
foreach($class_r as $kv)
{
	if($kv['modid']=='1')
	{
		$cates[]=array('cname'=>$kv['classname'],'cid'=>$kv['classid'],'pid'=>$kv['bclassid']);
	}
}

if(empty($_POST))
{
	//这里刷新列表
	echo "<select name='list'>";
	echo maketree($cates,0,'');
	echo '</select>';
	exit();
}

foreach($_POST as $k=>$v){
    if(strpos($v,'[db:') !== false){
        $_POST[$k] = '';
    }
}
$link=db_connect();
$empire=new mysqlquery();
//验证用户
$loginin=$_POST['username'];
$lur=$empire->fetch1("select * from {$dbtbpre}enewsuser limit 1");
if(!$lur) exit('不存在的用户名'.$loginin);

$loginin = $lur['username'];
$logininid=$lur['userid'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];

$incftp=0;
if($public_r['phpmode'])
{
	include("../class/ftp.php");
	$incftp=1;
}
require("../class/hinfofun.php");
$navtheid=(int)$_POST['filepass'];
AddNews($_POST,$logininid,$loginin);

db_close();
$empire=null;

/***生成目录的一个遍历算法***/
function maketree($ar,$id,$pre)
{
	$ids='';
	foreach($ar as $k=>$v){
		$pid=$v['pid'];
		$cname=$v['cname'];
		$cid=$v['cid'];
		if($pid==$id)
		{
			$ids.="<option value='$cid'>{$pre}{$cname}</option>";
			foreach($ar as $kk=>$vv)
			{
				$pp=$vv['pid'];
				if($pp==$cid)
				{ 
					$ids.=maketree($ar,$cid,$pre."&nbsp;&nbsp;");
					break;
				}
			}
		}
	}
	return $ids;
}
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

After clicking to submit the form in Empire CMS, use js to combine the URL and redirect it

After clicking to submit the form in Empire CMS, use js to combine the URL and redirect it Program Notes Empire cms Language Notes JavaScript

Many times, the search link is too long and carries many parameters. We want to make pseudo-static modifications and also hope that the link can be accessed a second time. Original html code: 🔒 Hidden content: You can view it after logging in &lt;form class="form-search" id="q-form" method="get"&gt; &lt;div class="input-…
👁 302
sqlite database online php read operation view, pbootcms database online view

sqlite database online php read operation view, pbootcms database online view Program Notes PbootCms Language Notes PHP

When using pbootcms, a database is often used, but the database of pb is a .db file, so it is very troublesome. There is no ready-made visualization page to view the database, so a php visualization page for php online viewing is developed here. This will be much more convenient. How to use? In the folder of the db file, create a php, put the following code in it, modify your database name, and then access p...
👁 167
PHP ob function record

PHP ob function record Language Notes PHP

Usage of the following three functions ob_get_contents(); ob_end_clean(); ob_start(); You can use these functions to buffer local files and execute local script code. Use ob_start() to save the output code into the buffer, and the page will not be displayed; then use ob_get_contents to get the data in the buffer. o…
👁 141
PHP preg

PHP preg Language Notes PHP

The preg_match_all function is used to perform a global regular expression match. preg_match_all() Syntax int preg_match_all ( string $pattern , string $subject [, array &$matches [, int $flags = PREG…
👁 169
Detailed explanation of PHP ternary operator and if

Detailed explanation of PHP ternary operator and if Language Notes PHP

Ternary operator condition ? Result 1 : Result 2 Explanation: The position in front of the question mark is the condition for judgment. If the condition is met, the result is 1, and if it is not met, the result is 2. This article compares and explains the ternary operator and if...else... in detail. I hope it will be helpful to everyone. Today when I was revising my paper online, I encountered a statement that I couldn’t understand: $if_summary = $row['IF_SUMMARY']=…
👁 189

Recommended reading

(PC + WAP) marketing environmental protection shell powder ecological coating pbootcms website template cyan paint coating website source code download 0716

(PC + WAP) marketing environmental protection shell powder ecological coating pbootcms website template cyan paint coating website source code download 0716 Practical Collection pbootcms Template

A PbootCMS marketing website template for environmental protection shell powder ecological coating and paint and coating industry, using cyan style, support PC and WAP end. The design style is fresh and environmentally friendly, and can display ecological coating products and coating engineering cases. Help paint enterprises to promote green building materials online, to attract more home decoration and engineering customers. Template display, installation instructions website background: / admin.php Account: admin password: ad...
👁 38
Brand Strategy and Design Agency – General Website Template 0180

Brand Strategy and Design Agency – General Website Template 0180 Practical Collection Yiyou template

An eYouCMS template designed for general-purpose websites intended for brand strategy and design agencies. Its creative and professional design style effectively showcases brand strategy projects, design case studies, creative concepts, and service offerings. This template helps brand strategy firms demonstrate their professional expertise online and attract corporate clients. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for eYouCMS | eYou...
👁 46
Empire CMS source mall virtual supply software download adaptive response mobile phone HTML5 whole station template 052

Empire CMS source mall virtual supply software download adaptive response mobile phone HTML5 whole station template 052 Practical Collection empire template

The entire site is produced using the latest Empire CMS core, making it safe, efficient and operational! The template does not have too many fancy styles and functions, and everything is optimized for the operation of individual webmasters. The webmaster has good resources at hand and can start operations immediately using this entire site template. The entire site adapts to mobile devices such as mobile phones and tablets! A certain fish sells for 800, which is actually copied from someone else’s zblog... Preview image and unzip password 🔒 Hidden content: Check the download page after commenting...
👁 758
Responsive Youth Growth Training Camp Training Website Template 0838

Responsive Youth Growth Training Camp Training Website Template 0838 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for youth development camps and the training industry. Its vibrant and educational design effectively showcases camp curricula, camp environments, faculty expertise, and student growth success stories. It helps quality-oriented education institutions attract parents and young participants online. Template Demo | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS...
👁 62
(PC + WAP) Green Landscape Nursery Seedling Website Template – Download PbootCMS Website Source Code for Agricultural and Forestry Seedling Websites – 0086

(PC + WAP) Green Landscape Nursery Seedling Website Template – Download PbootCMS Website Source Code for Agricultural and Forestry Seedling Websites – 0086 Practical Collection pbootcms Template

This PbootCMS template is ideal for the green landscaping, nursery stock, and agricultural/forestry cultivation industries, and is compatible with both PC and WAP devices. Its natural and fresh design style effectively showcases nursery products, cultivation bases, and landscaping project examples. It is an excellent choice for landscaping companies or nursery stock cultivation bases looking to establish a branded official website or expand their sales channels. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin
👁 38
(Independent mobile version) blue marketing network company mobile website template general enterprise website wap website source code 0717

(Independent mobile version) blue marketing network company mobile website template general enterprise website wap website source code 0717 Practical Collection pbootcms Template

This independent mobile version of the blue marketing network company template, is PbootCMS to build the general enterprise WAP website quality choice. The design style is modern and simple, suitable for IT, network technology companies to display services and cases. It helps enterprises to build a professional brand image on the mobile terminal and attract potential customers. Template display, installation instructions Website background: / admin.php account: admin password: admin decompression password: w...
👁 51