<?Phpnamespace Addons\card\controller; //thinkphp the namespace definition, and the namespace definition must be written before all PHP code, otherwise an error will occur UseAddons\card\controller\basecontroller;//represents the introduction of the Addons\card\controller\basecontroller namespace for easy direct useclassCardcontrollerextendsBasecontroller {//inherit the base controller in the corresponding directory of the namespace Basecontroller functionConfig () {//Defining Configuration Functions $normal _tips= ' After the configuration is saved, in the reply: Membership card, you can see the effect. ‘;//defines the value of the string variable normal_tips $this->assign (' Normal_tips ',$normal _tips);//the value of the normal_tips to the front-end output variable $this->getmodel ();//Use the Getmodel function under the parent class if(Is_post) {//To see if there are post parameters if($_post[' Config '] [' background '] = = 11) {//determine if there is a value in the two-dimensional array that the post passed in background equals one $_post[' Config '] [' background_custom '] = Get_cover_url ($_post[' Config '] [' BG ']);//assigning Background_custom to a two-dimensional array using the Get_cover_url method } $flag= D (' common/addonconfig ')->set (_addons, I (' config '));//instantiate the common group Addonconfig model Call set method return value to $flag if($flag!==false) {//If there is a return value, the save is successful $this->success (' Save Success ', Cookie (' __forward__ ') ) ); } Else{//If there is no return value, throw an error, save failed $this->error (' Save failed ' ); } } $map[' name '] = _addons;//set the value of name under array map to the plug-in identity name $addon= M (' Addons ')->where ($map)->find ();//instantiate the Addons model and submit the data from the database for the current plug-in name to the array addon if(!$addon)//If addon is empty, the plug-in is installed $this->error (' Plugin not installed ' ); $addon _class= Get_addon_class ($addon[' name ']);//gets the class name of the plug-in class given to $addon_class $data=New $addon _class();//instantiating a plug-in class $addon[' addon_path '] =$data->addon_path;//assigning values to Addon_path in an array $addon $addon[' custom_config '] =$data->custom_config;//assigning values to Custom_config in an array $addon $db _config= D (' common/addonconfig ')->get (_addons);//instantiate the Addonconfig class under Common, get the plug-in configuration and give it to $db_config $addon[' config '] =include $data->config_file;//assigning a config value to the array $addon if($db _config) {//if $db_config is not empty, loop the array foreach($addon[' Config '] as $key=$value ) { if($value[' type ']! = ' Group ') { !isset($db _config[$key] ) ||$addon[' Config '] [$key] [' value '] =$db _config[$key]; } Else { foreach($value[' Options '] as $gourp=$options ) { foreach($options[' Options '] as $gkey=$value ) { !isset($db _config[$key] ) ||$addon[' Config '] [$key] [' Options '] [$gourp] [' Options '] [$gkey] [' value '] =$db _config[$gkey]; } } } } } $this->assign (' Data ',$addon);//passing values to the front-end template $this->display ();//Show Templates } functionShow () {//defining the Show method $TPL= ' show ';//Set Variable $TPL value to String ' Show ' $map[' uid '] =$this->mid;//assigning values to $map [' uid '] $info= M (' Card_member ')->where ($map)->find ();//Get Info/dump ($info); Dump (M (' Card_member ')->getlastsql ()); if($info) {//if $info is not empty, the value is dropped to the show template display $TPL= ' Show_card '; $this->assign (' Info ',$info ); } $this->display ($TPL);//Adjust Show Template display } //Introduction to use functionIntroduction () {//Define Introduction Functions $this-display (); } //Applicable stores functionStorelist () {//define applicable store functions $this-display (); } //fill in the Membership card information functionWritecardinfo () {//define the method of filling in the membership card information $map[' uid '] =$this->mid;//Set UID $info= M (' Card_member ')->where ($map)->find ();//Check the Card_member table for the corresponding UID of the information given to $info if(Is_post) {//To see if there are post parameters $data[' username '] = I (' Post.username ');//Pass the username value of post to the $data array . $data[' phone '] = I (' Post.phone ');//Pass the phone value of post to the $data array. if($info) { $res= M (' Card_member ')->where ($map)->save ($data);//update data for the corresponding UID entry in the Card_member table}Else { $config= Getaddonconfig (' Card ');//get the Card plugin configuration information $map _token[' token '] = Get_token ();//get token to be given to token under Map_token array $data[' number '] = M (' Card_member ')->where ($map _token)->getfield ("Max (number) as number");//Check the table Card_member, get the corresponding card number if(Empty($data[' Number '] )) { $data[' number '] =$config[' Length ']; } Else { $data[' number '] + = 1; } $data[' uid '] =$map 2[' id '] =$this->mid;//Associate User Identities $data[' cTime '] = Time();//Get current Time $data[' token '] = Get_token ();//Get token $res= M (' Card_member ')->add ($data);//Save DataM (' Follow ')->where ($map 2)->setfield (' Status ', 3 ); //Add pointsAdd_credit (' Card_bind ' ); } redirect (Addons_url (' Card://card/showcard '));//jump to the card's preview screen } $this->assign (' Info ',$info);//Distributing info information to front-end templates $this->display (' Write_cardinfo ');//Invoke Template } functionindex () {$this-display (); } //bind entity Membership card functionBindcard () {$this->display (' Bind_card ' ); } //points functionscore () {$this-display (); } //Redeem functionExchange () {$this-display (); } //Discount Coupon functionticket () {$this-display (); } //after collection functionShowcard () {$map[' uid '] =$this-mid; $info= M (' Card_member ')->where ($map),find (); $this->assign (' Info ',$info ); $this->display (' Show_card ' ); }}
Weiphp Membership card Plug-in Cardcontroller controller code information