Files
OMS/app/base/lib/application/tips.php
2025-12-28 23:13:25 +08:00

54 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
class base_application_tips{
static function tip_apps(){
$apps = array();
$lang = kernel::get_lang();
if ($handle = opendir(APP_DIR)) {
while (false !== ($file = readdir($handle))) {
if($file[0]!='.' && is_dir(APP_DIR.'/'.$file) && file_exists(APP_DIR.'/'.$file.'/lang/'.$lang.'/tips.txt')){
$apps[] = $file;
}
if(defined('CUSTOM_CORE_DIR') && $file[0]!='.' && is_dir(CUSTOM_CORE_DIR.'/'.$file) && file_exists(CUSTOM_CORE_DIR.'/'.$file.'/lang/'.$lang.'/tips.txt')){
$apps[] = $file;
}
}
closedir($handle);
}
return $apps;
}
static function tips_item_by_app($app_id){
$lang = kernel::get_lang();
$tips = array();
foreach(file(APP_DIR.'/'.$app_id.'/lang/'.$lang.'/tips.txt') as $tip){
$tip = trim($tip);
if($tip){
$tips[] = $tip;
}
}
return $tips;
}
static function tip(){
$apps = self::tip_apps();
if(empty($apps)) return '';
$key = array_rand($apps);
$app_id = $apps[$key];
if(empty($app_id)) return '';
$tips = self::tips_item_by_app($app_id);
$key = array_rand($tips);
return $tips[$key];
}
}