Hongmu Notes
Home Program Notes Empire cms php calls random lines in text
Program Notes Empire cms

Empire cms php calls random lines in text

Empire cms php calls random lines in text

function rand_txt($filename = "hot", $type = 1){
    if(!file_exists(ECMS_PATH."d/{$filename}.txt")){
        return "请检查网站根目录下/d/{$filename}.txt文件是否存在。";
        exit;
    }
    $file=@file_get_contents(ECMS_PATH."d/{$filename}.txt");
    $ci = explode("\n",$file);
    if(empty($ci)){
        return "请检查网站根目录下/d/{$filename}.txt文件是否存在内容。";        
    }
    if($type == 2){
        $filecache = ECMS_PATH."d/json/".md5('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']).".json";
        if(!file_exists($filecache)){ 
          @mkdir(ECMS_PATH."d/json",0777); 
          @chmod(ECMS_PATH."d/json",0777); 
          $row = mt_rand(0,count($ci)-1);
          file_put_contents($filecache,$row);
          return $ci[$row];
        }else{
           $row = file_get_contents($filecache);
           return $ci[$row];
        }
    }
    return $ci[mt_rand(0,count($ci)-1)];
}

Empire cms php calls random lines in text

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

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

Author homepage View home page →

Related articles

Empire CMS database statement & SQL statement format

Empire CMS database statement & SQL statement format Program Notes Empire cms

Introduction to Imperial CMS extended SQL program writing, basic examples of Imperial CMS database statements & SQL statement formats: Note: The following examples are based on placing PHP files in the system root directory. Example 1: Connect to MYSQL program. (a.php)<?php require('e/class/connect.php'); //Introduce database configuration files and public function files requ…
👁 353
Empire CMS obtains the system COOKIE variable function getcvar()

Empire CMS obtains the system COOKIE variable function getcvar() Program Notes Empire cms

Get the system COOKIE variable function syntax: getcvar($var,$ecms) Description: $var: is the variable name $ecms: 0 is to set the foreground COOKIE variable, 1 is to set the background COOKIE variable. This parameter can be omitted and defaults to 0. Usage example: getcvar('mlusername'), get the user name of the front-end login member getcvar('loginu...
👁 296
Empire CMS smart label call field collection

Empire CMS smart label call field collection Program Notes Empire cms

Collect and classify all fields that support smart tag calls into Empire CMS smart tags: [e:loop={column ID/topic ID, number of items displayed, operation type, only display pictures with titles, additional SQL conditions, display sorting}] Template code content [/e:loop] Calling time: <?=date('m-d',$bqr[newstime])?> <?=dat…
👁 3749

Recommended reading

Responsive exercise bike and fitness bicycle website template 0467

Responsive exercise bike and fitness bicycle website template 0467 Practical Collection Yiyou template

An eyouCMS responsive website template designed for the sports bike, fitness, and bicycle industries. Its dynamic, sports-oriented design is ideal for showcasing bicycle products, fitness equipment, sports gear, and brand stories. It helps bike and sports brand owners effectively present their products online and attract cycling enthusiasts. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Common Questions About Installing EasyCMS...
👁 35
Responsive New Energy & Clean Energy Company Website Template 0468

Responsive New Energy & Clean Energy Company Website Template 0468 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for new energy and clean energy companies. Its modern, eco-friendly design effectively showcases new energy projects, clean energy products, technological R&D capabilities, and corporate strength. It helps new energy enterprises present their brands online and attract investment and partnerships. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS...
👁 38
Responsive branded women's fashion website template – 0469

Responsive branded women's fashion website template – 0469 Practical Collection Yiyou template

An eyouCMS responsive website template designed specifically for the branded women's fashion industry. Its stylish, high-end design is ideal for showcasing women's clothing products, brand identity, new product launches, and franchise opportunities. This template helps women's fashion brands attract consumers and distributors online while enhancing their brand awareness. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for YouyouCMS...
👁 29
Resource website typecho001 template

Resource website typecho001 template Program Notes Typecho

typecho001 template template please do not modify the folder name of this template. The folder name is: typecho001 1.4 Fix the js output problem on the article page 1.3 Fix the error prompt when the plug-in is not installed Optimize the list page code output 1.2 Fix the comment function and add a custom homepage title 1.1 Fix the comment reply asymmetry function Add a separate title setting function on the homepage Add the website favicon.ico icon Add one...
👁 199
Responsive Coffee, Milk Tea & Dessert Website Template – 0470

Responsive Coffee, Milk Tea & Dessert Website Template – 0470 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for the coffee, milk tea, and dessert industries. Its stylish and cozy design effectively showcases coffee beverages, milk tea and dessert products, brand stories, and store branding – helping coffee and milk tea brands attract customers and franchisees online. Template Preview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (E...
👁 36
Modification of typecho paging style

Modification of typecho paging style Program Notes Typecho

Sir, times have changed! Typecho is currently the most perfect solution, because Baidu can only see the code of fixed thinking. The actual generated HTML code is breathtakingly clean and fully customized, including adding classes to the li element, adding classes to the a element, adding classes to the previous page and next page, and removing the li tags that come with typecho to express more. I can even add some text to the content inside...
👁 517