Hongmu Notes
Home Language Notes EmpireCMS "Locomotive" – No-Login PHP API Code (Automatic Categorization)
Language Notes PHP

EmpireCMS "Locomotive" – No-Login PHP API Code (Automatic Categorization)

EmpireCMS "Locomotive" – No-Login PHP API Code (Automatic Categorization)
<?php

/********密码验证***********/
$password='123456';				                   //这个密码是登陆验证用的.您需要在模块里设置和这里一样的密码....注意一定需要修改.
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();
}

$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;
}

If you scrape another website, you could end up with thousands of pages!

We have created the same sections as the competing website!

How can automatic classification be implemented?

Add the following code to the above snippet:

 隐藏内容:评论后查看
if($_POST['classnames']){
    //分析栏目
    foreach ($cates as $v){
        if($_POST['classnames'] === $v['cname']){
            $_POST['classid'] = $v['cid'];
        }
    }
}

Then, add the following to the Train Engine release module:

 

20240416164457954-图片

This allows you to automatically categorize content by scraping sections from external websites!

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

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

Author homepage View home page →

Related articles

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
PHP cast type

PHP cast type Language Notes PHP PHP collection PHP and mysql

Get the data type 1. If you want to check the value and type of an expression, use var_dump(). 2. If you just want to get an easy-to-read type expression for debugging, use gettype(). 3. To check a certain type, do not use gettype(), but use the is_type() function. Converting Strings to Numbers When a string is evaluated as a number, the result is determined according to the following rules...
👁 232

Recommended reading

China–UK Foreign Trade Industrial Equipment Website Template 1077

China–UK Foreign Trade Industrial Equipment Website Template 1077 Practical Collection Yiyou template

An EyouCMS website template designed specifically for the Chinese and British foreign trade and industrial equipment sectors. Its professional, international design style effectively showcases industrial equipment products, technical specifications, export advantages, and global market presence, helping industrial equipment enterprises promote their brands in international markets. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (...
👁 51
Responsive web design and promotion website template – 0377

Responsive web design and promotion website template – 0377 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for the website development, design, marketing, and SEO optimization industry. Its modern, tech-driven design style makes it perfect for showcasing website development projects, design works, marketing strategies, and SEO optimization services. It helps digital marketing agencies attract corporate clients online. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 40
(Adaptive mobile version) Responsive tea ceremony article-based website PBootCMS template; Download source code for news and knowledge-based websites – 0872

(Adaptive mobile version) Responsive tea ceremony article-based website PBootCMS template; Download source code for news and knowledge-based websites – 0872 Practical Collection pbootcms Template

A responsive PbootCMS website template combining tea ceremony and news/knowledge content, compatible with both PC and WAP devices. Its classical and elegant design makes it ideal for sharing tea culture, tea ceremony knowledge, and industry news. This template helps tea brands or tea culture enthusiasts promote the aesthetics of the tea ceremony online. Template Preview | Installation Instructions | Website Admin Panel: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn
👁 60
(Adaptive mobile version) PBootCMS template – IT network website development company; Download source code for corporate website – 0204

(Adaptive mobile version) PBootCMS template – IT network website development company; Download source code for corporate website – 0204 Practical Collection pbootcms Template

An adaptive mobile-friendly PbootCMS website template designed for IT and web development companies – ideal for showcasing services and case studies in digital marketing and website development. It helps online businesses attract corporate clients and enhance their brand influence. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 59
Responsive外贸 enterprise website template – 1078

Responsive外贸 enterprise website template – 1078 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for foreign trade enterprises, featuring a professional international design style that effectively showcases their export products, export business operations, global market presence, and corporate strength. It helps foreign trade companies present their brands online and expand their international customer base. Template Display / Installation Instructions: Website Backend: /login.php; Username: admin; Password: admin. Related Articles: Summary of Common Installation Issues for EyouCMS; EyouCMS (Eyou...
👁 30
Responsive home appliance and kitchen/bathroom appliance website template – 0378

Responsive home appliance and kitchen/bathroom appliance website template – 0378 Practical Collection Yiyou template

An eyouCMS responsive website template designed for the household appliances and kitchen/bathroom appliance industry. Its modern and practical design is ideal for showcasing home appliance products, kitchen and bathroom appliances, brand identity, and new product launches. This template helps appliance brands showcase their products online and attract home consumers. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for YououCMS | Youou...
👁 38