Port the Fuc 0.12.0 frontend and default-off VIP plugin. Include the previously approved password-reset token revocation. Deploy only to an independent FUC-XB test instance; no production cutover.
110 lines
10 KiB
PHP
110 lines
10 KiB
PHP
<?php
|
|
// Offline template extraction. Composer classes only; no FUC bootstrap/config/DB.
|
|
require '/Users/hellcat/Documents/GemCodes/fuc-new.loc/vendor/autoload.php';
|
|
$base='/Users/hellcat/Documents/GemCodes/fuc-new.loc';
|
|
$out=__DIR__.'/../../theme/Fuc/assets/native';
|
|
@mkdir($out,0755,true);
|
|
class ThemeFixtureUser {
|
|
public $panel_option=['themeMod'=>'light','themeLight'=>'purple','themeDark'=>'purple','menuToggle'=>'open'];
|
|
public $user_name='__NAME__', $email='__EMAIL__', $vipInfo, $total_pay='__TOTAL_PAY__', $money='__BALANCE__', $autorenew=0, $classStr='__CLASS__', $classExpireDay='__DAYS__', $class=1, $mail_level=0, $class_expire='__RESET_DATE__';
|
|
function __construct() {$this->vipInfo=(object)['name'=>'__PLAN__'];}
|
|
function isAbleToCheckin(){return false;}
|
|
function __call($name,$args){$key=strtolower($name);return match($key){'unusedtrafficpercent'=>'__REMAIN_PERCENT__','unusedtraffic'=>'__REMAIN_BYTES__','todayusedtrafficpercent'=>'__TODAY_PERCENT__','todayusedtraffic'=>'__TODAY_BYTES__','lastusedtrafficpercent'=>'__PAST_PERCENT__','lastusedtraffic'=>'__PAST_BYTES__',default=>'—'};}
|
|
}
|
|
function source($path) {
|
|
$text=file_get_contents($path);
|
|
$text=str_replace('2607:f2d8:6065:1053::a 没有被封','—(XB 未提供)',$text);
|
|
$text=preg_replace('/\?start=[A-Za-z0-9_-]+/','?start=UNAVAILABLE',$text);
|
|
$text=preg_replace('/<!--.*?-->/s','',$text);
|
|
$text=preg_replace('/<script\b[^>]*>.*?<\/script>/is','',$text);
|
|
$text=str_replace("{include file='brand/head.tpl'}",file_get_contents('/Users/hellcat/Documents/GemCodes/fuc-new.loc/resources/views/tabler/brand/head.tpl'),$text);
|
|
// XB has no automatic-renewal quote. Keep this optional source include inert.
|
|
$text=preg_replace("/^[\\t ]*\\{include file='user\\/plan\\/renewal_quote\\.tpl'\\}[\\t ]*$/m",'',$text);
|
|
$text=preg_replace('/\{include[^}]*\}/','',$text);
|
|
// Keep the data output branch, without comparing placeholder strings.
|
|
$text=preg_replace('/\{if \$user->LastusedTrafficPercent\(\) < \'1\'\}.*?\{else\}(.*?)\{\/if\}/s','$1',$text);
|
|
return $text;
|
|
}
|
|
$reference=__DIR__.'/../../codex/output/fuc-theme/reference/raw';@mkdir($reference,0755,true);
|
|
$styles=[];
|
|
function recordOriginal($name,$html){global $reference,$styles;file_put_contents("$reference/$name.html",$html);preg_match_all('/<link[^>]+href=[\'"]([^\'"]+\.css[^\'"]*)[\'"]/i',$html,$m);$styles[$name]=array_map(fn($url)=>str_starts_with($url,'https:')?'assets/cool/all.min.css':ltrim(preg_replace('/^\.\.\//','',$url),'/'),$m[1]);}
|
|
$smarty=new Smarty\Smarty();
|
|
$compile=__DIR__.'/../../codex/output/fuc-theme/reference/compile';@mkdir($compile,0755,true);
|
|
$smarty->setCompileDir($compile);
|
|
$smarty->assign('config',['appName'=>'__BRAND__','url_doc_base'=>'#/knowledge']);
|
|
$smarty->assign('user',new ThemeFixtureUser());
|
|
$smarty->assign('ann',(object)['content'=>'__PINNED__','date'=>'__PIN_DATE__']);
|
|
$smarty->assign('ann_last',(object)['content'=>'__LATEST__','date'=>'__LATEST_DATE__']);
|
|
$smarty->assign('UniversalSub','__SUB_URL__');
|
|
$smarty->assign('url_doc_base','#/knowledge');
|
|
$smarty->assign('public_setting',['enable_login_captcha'=>false,'enable_reset_password_captcha'=>false]);
|
|
foreach(['header','index'] as $file){
|
|
$text=source("$base/resources/views/tabler/user/$file.tpl");
|
|
$html=$smarty->fetch('string:'.$text);
|
|
recordOriginal($file,$html);
|
|
$dom=new DOMDocument();libxml_use_internal_errors(true);$dom->loadHTML('<?xml encoding="UTF-8">'.$html,LIBXML_NONET|LIBXML_NOERROR|LIBXML_NOWARNING);libxml_clear_errors();
|
|
$xp=new DOMXPath($dom);
|
|
if($file==='header'){
|
|
$nodes=$xp->query('//div[@id="panel-option-modal"]|//style|//nav[contains(@class,"header-navbar")]|//div[contains(concat(" ",normalize-space(@class)," ")," main-menu ")]');
|
|
$html='';foreach($nodes as $node)$html.=$dom->saveHTML($node);
|
|
}else{
|
|
$node=$xp->query('//section[@id="dashboard-analytics"]')->item(0);if(!$node)throw new Exception('missing dashboard');$html=$dom->saveHTML($node);
|
|
}
|
|
file_put_contents("$out/$file.html",$html);
|
|
echo "$file extracted\n";
|
|
}
|
|
|
|
$smarty->assign('is_login',false);
|
|
$smarty->assign('year_title','');
|
|
$smarty->assign('taocan',array_map(fn($i)=>(object)['name'=>'__PUBLIC_PLAN_'.$i.'__','price'=>'__PUBLIC_PRICE_'.$i.'__','content'=>(object)['bandwidth'=>'__PUBLIC_GB_'.$i.'__']],range(0,2)));
|
|
foreach(['home'=>'front/index.tpl','login'=>'auth/login.tpl'] as $name=>$file){
|
|
$text=source("$base/resources/views/tabler/$file");
|
|
$html=$smarty->fetch('string:'.$text);
|
|
recordOriginal($name??$file,$html);
|
|
file_put_contents("$out/$name.html",$html);
|
|
echo "$name extracted\n";
|
|
}
|
|
|
|
// Every repeated block remains original markup in an inert template for XB data binding.
|
|
class ThemeFixtureList extends ArrayObject {function isEmpty(){return false;}}
|
|
function fixture($values){return new ArrayObject($values,ArrayObject::ARRAY_AS_PROPS);}
|
|
$u=new ThemeFixtureUser();$u->vipInfo=fixture(['name'=>'__PLAN__']);$u->money_aff='__COMMISSION__';$u->gb='__GB__';$u->usdt_addr='';
|
|
$smarty->assign('user',$u);
|
|
$smarty->assign('env',['invite_rate'=>'__RATE__','aff_draw_need'=>'__WITHDRAW_MIN__','aff_reward_gb'=>'__REWARD_GB__','user_payClass'=>0]);
|
|
$product=['id'=>'__P_ID__','name'=>'__P_NAME__','name_sub'=>'','price'=>'__P_PRICE__','class_time'=>'__P_PERIOD__','time_group_str'=>'','is_huodong'=>false,'have_endtime'=>false,'have_stock'=>false,'stock'=>-1,'shengyu'=>'—','shengyu_rate'=>0,'end_time'=>0,'coupon_disable'=>0,'content'=>['bandwidth'=>'__P_GB__','ip_limit'=>'__P_IP__','speed_limit'=>'__P_SPEED__']];
|
|
$smarty->assign('products',['__CYCLE__'=>['is_huodong'=>false,'data'=>[$product]]]);
|
|
foreach(['invite_reward_rate'=>'__RATE__','aff_reward_gb'=>'__REWARD_GB__','aff_draw_need'=>'__WITHDRAW_MIN__','aff_draw_fee_rate'=>'__FEE__','invite_url'=>'__INVITE_URL__','wait_draw_have'=>false,'pageBar'=>'','sPageBar'=>''] as $k=>$v)$smarty->assign($k,$v);
|
|
$smarty->assign('ips',new ThemeFixtureList([fixture(['ip'=>'__IP__','location'=>'__LOCATION__','node_name'=>'__NODE__'])]));
|
|
$smarty->assign('logins',[fixture(['ip'=>'__IP__','datetime'=>'__DATE__','location'=>'__LOCATION__'])]);
|
|
$smarty->assign('oTicketList',[fixture(['id'=>'__T_ID__','datetime'=>'__T_DATE__','title'=>'__T_TITLE__','status'=>'__T_STATUS__','status_code'=>'open'])]);
|
|
$smarty->assign('oTicket',fixture(['id'=>'__T_ID__']));
|
|
$smarty->assign('oCommentList',[fixture(['commenter_isAdmin'=>0,'commenter_name'=>'__M_NAME__','datetime'=>'__M_DATE__','comment'=>'__M_BODY__'])]);
|
|
$smarty->assign('oNodeList',[fixture(['country_code'=>'__S_COUNTRY__','pid'=>1,'name'=>'__S_NAME__','memo_front'=>'__S_TYPE__','traffic_rate_front'=>'__S_RATE__'])]);$smarty->assign('aServerLiveIds',[1]);
|
|
$smarty->assign('anns',[fixture(['rank'=>'none','title'=>'__N_TITLE__','content'=>'__N_BODY__','date'=>'__N_DATE__'])]);$smarty->assign('aMapIcon',['none'=>'bell']);
|
|
$smarty->assign('docs',[fixture(['id'=>'__D_ID__','title'=>'__D_TITLE__','date'=>'__D_DATE__'])]);$smarty->assign('doc',fixture(['title'=>'__D_TITLE__','content'=>'__D_BODY__']));
|
|
$smarty->assign('oFaqList',[fixture(['id'=>'__D_ID__','q'=>'__D_TITLE__','r'=>'__D_BODY__'])]);
|
|
$smarty->assign('oUserPlanList',new ThemeFixtureList([['id'=>'__O_ID__','user_product_name'=>'__O_NAME__','user_price'=>'__O_PRICE__','status'=>'__O_STATUS__','created_at'=>'__O_DATE__','product_code'=>'__O_ID__']]));
|
|
$smarty->assign('money_log',[['id'=>'__L_ID__','before'=>'__L_BEFORE__','after'=>'__L_AFTER__','amount'=>'__L_AMOUNT__','remark'=>'__L_REMARK__','create_time'=>'__L_DATE__']]);
|
|
$smarty->assign('oAffMoneyLogList',new ThemeFixtureList([['id'=>'__A_ID__','invoice_id'=>'__A_ORDER__','userid'=>'__A_USER__','user_name'=>'__A_NAME__','total'=>'__A_TOTAL__','ref_get'=>'__A_AMOUNT__','datetime'=>'__A_DATE__']]));
|
|
$smarty->assign('product',fixture(['id'=>'__P_ID__','name'=>'__P_NAME__','type'=>'tabp','price'=>'__P_PRICE__','huodong'=>false,'content'=>fixture(['class_time'=>'__P_PERIOD__','bandwidth'=>'__P_GB__','speed_limit'=>'__P_SPEED__','ip_limit'=>'__P_IP__'])]));
|
|
$smarty->assign('details',['field'=>['订单号','套餐','金额','状态','创建时间','操作']]);
|
|
$smarty->assign('order',fixture(['id'=>'__O_ID__','product_type_text'=>'订阅套餐','product_name'=>'__O_NAME__','coupon'=>'__O_COUPON__','price'=>'__O_PRICE__','status'=>'__O_STATUS__','create_time'=>'__O_DATE__','pay_time'=>'__O_PAID__','update_time'=>'__O_UPDATE__','product_type'=>'tabp','content'=>fixture(['time'=>'__P_PERIOD__','class_time'=>'__P_PERIOD__','class'=>'__P_NAME__','bandwidth'=>'__P_GB__','ip_limit'=>'__P_IP__','speed_limit'=>'__P_SPEED__'])]));
|
|
$smarty->assign('invoice',fixture(['id'=>'__O_ID__','price'=>'__O_PRICE__','status'=>'__O_STATUS__','create_time'=>'__O_DATE__','pay_time'=>'__O_PAID__','update_time'=>'__O_UPDATE__','content'=>[fixture(['name'=>'__O_NAME__','price'=>'__O_PRICE__'])]]));
|
|
$pages=['register'=>'auth/register.tpl','forget'=>'password/reset.tpl','reset'=>'password/token.tpl','plans'=>'user/product.tpl','myplan'=>'user/plan.tpl','wallet'=>'user/code.tpl','invite'=>'user/invite.tpl','profile'=>'user/profile.tpl','tickets'=>'user/ticket.tpl','ticket'=>'user/ticket/detail.tpl','servers'=>'user/node.tpl','notices'=>'user/announcement.tpl','knowledge'=>'user/docs/index.tpl','article'=>'user/docs/view.tpl','faq'=>'user/faq.tpl','orders'=>'user/order/index.tpl','purchase'=>'user/order/create.tpl','checkout'=>'user/order/view.tpl','planlog'=>'user/plan/ajax_planLog.tpl','walletlog'=>'user/code/ajax_moneyLog.tpl','afflog'=>'user/invite/ajax_affMoneyLog.tpl'];
|
|
foreach($pages as $name=>$file){
|
|
$text=source("$base/resources/views/tabler/$file");
|
|
$text=preg_replace_callback('/\{foreach ([^{}]+)\}/',function($m){preg_match('/as\s+\$(\w+)(?:\s*=>\s*\$(\w+))?/',$m[1],$v);return $m[0].'<template data-repeat="'.($v[2]??$v[1]).'">';},$text);
|
|
$text=str_replace('{/foreach}','</template>{/foreach}',$text);
|
|
// CSS uses braces; Smarty auto-literal handles them unchanged.
|
|
$html=$smarty->fetch('string:'.$text);
|
|
recordOriginal($name??$file,$html);
|
|
if(str_contains($html,'Warning:'))throw new Exception("template warning: $name");
|
|
file_put_contents("$out/$name.html",$html);echo "$name extracted\n";
|
|
}
|
|
|
|
file_put_contents("$out/styles.json",json_encode($styles,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
|
|
|
|
$footer=source("$base/resources/views/tabler/user/footer.tpl");
|
|
$footer=substr($footer,0,strpos($footer,"</footer>")+9);
|
|
file_put_contents("$out/footer.html",$footer);
|