In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you the Imperial CMS function decryption field processing function of the case, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
1. Preface:
Imperial CMS provides a powerful custom field processing function, which greatly facilitates the secondary development of Imperial CMS!
Imperial CMS can set "add information processing function in the background", "modify information processing function in the background", "add information processing function in the foreground" and "modify information processing function in the foreground" when adding / modifying fields. Today we will briefly explain the format of the processing function. The specific setting location of the field processing function is shown in the following figure:
2. Basic setup steps:
1. Write processing functions
2. Copy the function to the content of e/class/userfun.php file
3. Modify the name of the field setting processing function.
Third, the format of field processing function:
The code is as follows:
Function user_FieldFun ($mid,$f,$isadd,$isq,$value,$cs) {
Return $value
}
Parameter description:
User_FieldFun: function name
$mid: system model ID
$f: field name
$isadd: add information when the value is 0; modify information when the value is 1
$isq: background processing when the value is 0; foreground processing when the value is 1
$value: original content of the field
$cs: the parameter is added to the field, and the parameter content set at the field processing function
4. Examples of field processing functions:
Example 1: automatically add the word "[EmpireCMS]" to the title
Background field function setting: user_AddTitle
The code is as follows:
Function user_AddTitle ($mid,$f,$isadd,$isq,$value,$cs) {
$value=' [EmpireCMS]'. $value
Return $value
}
Example 2: the title content consists of a combination of writer and befrom fields
Background field function setting: user_TogTitle
The title field displays the HTML code:
(note: because the title is required, it is necessary to give the initial value so that the content is not prompted to be empty)
The code is as follows:
Function user_TogTitle ($mid,$f,$isadd,$isq,$value,$cs) {
$value=$_POST ['writer']. $_ POST [' befrom']
Return $value
}
Example 3: upload pictures and automatically generate thumbnails
Background field function setting: user_TranImgAuto##170120
(note: parameter 170 in the background indicates the width of the thumbnail and 120 is the height of the thumbnail)
The upload image field displays the HTML code:
(note: the variable name uses "field name" + imgrs, which corresponds to the "$filetf" variable in the function)
The code is as follows:
Function user_TranImgAuto ($mid,$f,$isadd,$isq,$value,$cs) {
Global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$tranpicturetype,$musername
$filetf=$f.'imgrs';// variable name
If (! $_ FILES [$filetf] ['name'])
{
Return''
}
$classid= (int) $_ POST ['classid']
$id= (int) $_ POST ['id']
$filepass= (int) $_ POST ['filepass']
$filetype=GetFiletype ($_ FILES [$filetf] ['name'])
$pr=$empire- > fetch2 ("select qaddtran,qaddtransize,qaddtranimgtype from {$dbtbpre} enewspublic limit 1")
If (! $pr ['qaddtran'])
{
Printerror ("CloseQTranPic", "1)
}
If (! strstr ($pr ['qaddtranimgtype'], "|. $filetype." |))
{
Printerror ("NotQTranFiletype", "1)
}
If ($_ FILES [$filetf] ['size'] > $pr [' qaddtransize'] * 1024)
{
Printerror ("TooBigQTranFile", "1)
}
If (! strstr ($tranpicturetype,','.$filetype.','))
{
Printerror ("NotQTranFiletype", "1)
}
$tfr=DoTranFile ($_ FILES [$filetf] ['tmp_name'], $_ FILES [$filetf] [' name'], $_ FILES [$filetf] ['type'], $_ FILES [$filetf] [' size'], $classid)
If ($tfr ['tran'])
{
$csr=explode (',', $cs)
$maxwidth=$csr [0]
$maxheight=$csr [1]
$yname=$tfr ['yname']
$name=$tfr ['name']
Include_once (ECMS_PATH.'e/class/gd.php')
/ / generate thumbnails
$filer=ResizeImage ($yname,$name,$maxwidth,$maxheight,$public_r ['spickill'])
DelFiletext ($yname)
If ($filer ['file'])
{
/ / write to the database
$type=1
$filetime=date ("Y-m-d H:i:s")
$filesize=@filesize ($filer ['file'])
$filename=GetFilename (str_replace (ECMS_PATH,'',$filer ['file']))
$adduser=' [Member]'. $musername
$infoid=$isadd==1?0:$id
$empire- > query ("insert into {$dbtbpre} enewsfile (filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,fpath) values ('$filename','$filesize','$adduser','$ TF [filepath]','$filetime','$classid',' [". $f. "]" .addslink (RepPostStr ($_ post [title])). ",'$type','$infoid','$filepass','$public_ r [Fpath]');")
If ($isadd==0)
{
$tbname=$emod_r [$mid] ['tbname']
If (strstr ($emod_r [$mid] ['tbdataf'],','.
{
$ir=$empire- > fetch2 ("select stb from {$dbtbpre} ecms_". $tbname. "where id='$id'")
$ifr=$empire- > fetch2 ("select". $f. "from {$dbtbpre} ecms_". $tbname. "_ data_". $ir [STB]. "where id='$id'")
$ifval=$ifr [$f]
}
Else
{
$ir=$empire- > fetch2 ("select". $f. "from {$dbtbpre} ecms_". $tbname. "where id='$id'")
$ifval=$ir [$f]
}
If ($ifval)
{
DelYQTranFile ($classid,$id,$ifval,$f)
}
}
$value=str_replace ($tfr ['filename'], $filename,$tfr [' url'])
}
}
Else
{
$value=''
}
Return $value
}
The above is all the contents of the case of the decrypted field processing function of Imperial CMS function, thank you for your reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.