Weiphp Scratch Card Controller code

Source: Internet
Author: User
Tags string format

1<?PHP2 3 namespace Addons\scratch\controller;4 5  UseHome\controller\addonscontroller;6 7 classScratchcontrollerextendsAddonscontroller {8     functionEdit () {//How to edit a scratch card9         $id= I (' id ');//gets the ID of the pass parameterTen         $model=$this->getmodel ();//get the model array One          A         if(Is_post) {//If there is a post to do the following processing -             $Model= D (Parse_name (Get_table_name ($model[' ID ']), 1));//get table name and swap strings - //Get field information for the model the             $Model=$this->checkattr ($Model,$model[' ID ']);//Convert string Format -             if($Model->create () &&$Model->save ()) {//If the data is created and saved successfully -                 $this->_savekeyword ($model,$id);//Save Keywords -                  +                 $this->success (' Save ').$model[' title ']. Success ', U (' lists?model= '.$model[' Name ']) );//show success and go jump -}Else { +                 $this->error ($Model->geterror ());//otherwise output error A             } at}Else { -             $fields= Get_model_attribute ($model[' ID ']);//Get property information and cache -              - //Get Data -             $data= M (Get_table_name ($model[' ID ']) )->find ($id ); -             $data||$this->error (' data does not exist! ‘ );//If there is no data, throw an error in              -         $token= Get_token ();//Get token to //Verify token value +         if(isset($data[' token ']) &&$token!=$data[' token '] &&defined(' Addon_public_path ' )) { -             $this->error (' Illegal access! ‘ ); the         }             *              $             $this->assign (' Fields ',$fields );Panax Notoginseng             $this->assign (' Data ',$data ); -             $this->meta_title = ' edit '.$model[' title '];//Set String the              +             $this-_deal_data (); A              the             $this-display (); +         } -     } $     functionAdd () {//New Method $         $model=$this->getmodel ();//Get model Values -         if(Is_post) {//Verify the Pass parameter -             $Model= D (Parse_name (Get_table_name ($model[' ID ']), 1));//get table name and swap strings the //Get field information for the model -             $Model=$this->checkattr ($Model,$model[' ID ']);//Validation StringWuyi             if($Model->create () &&$id=$Model->add ()) {//If you create a save successfully the                 $this->_savekeyword ($model,$id);//Save Keywords -                  Wu                 $this->success (' Add '.$model[' title ']. Success ', U (' lists?model= '.$model[' Name ']) );//show success and go jump -}Else { About                 $this->error ($Model->geterror ());//otherwise the error $             } -}Else { -             $fields= Get_model_attribute ($model[' ID ']);//or get the ID information in the model and cache -              A             $this->assign (' Fields ',$fields);//Pass the reference +             $this->meta_title = ' new '.$model[' title '];//Set String the              -             $this->_deal_data ();//working with public data $              the             $this-display (); the         } the     } the      -     //Add or edit the public part in     function_deal_data () { the         //Set Array the         $normal _tips=Plugin Scenario restriction parameter Description: format: [plugin name: id], such as <br/> About [Poll: 10], which indicates that the vote for ID 10 has been completed. Can receive <br/> the [voting: *] means that you can collect <br/> if you vote the [Micro-survey: 15], the completion of the study ID 15 will be able to receive <br/> the[Micro-exam: 10], the completion of the exam ID 10 will be able to receive <br/> '; +         $this->assign (' Normal_tips ',$normal _tips);//Pass the parameter to the template -     } the     functionPreview () {//Preview MethodBayi         $this->show ();//Call Display method display the     } the     functionShow () {//Display Method -         $id=$map[' target_id '] = I (' id ');//set the target_id value in the map and give it to the ID -          the         $data= M (' scratch ')->find ($id);//look up the ID in the database and give it to the data the         $this->assign (' Data ',$data);//Pass value to template display the //dump ($data); the          - //Awards the         $map[' addon '] = ' Scratch ';//Assign Value the         $prizes= M (' Prize ')->where ($map)->select ();//Check Table the         $this->assign (' prizes ',$prizes);//Pass value to template display94          the //Lottery record the         $all _prizes= M (' Sn_code ')->where ($map)->order (' id desc ')Select (); the         //dump ($all _prizes);98         foreach($all _prizes  as $all) {//Loop Array Feedback information About             if($all[' prize_id '] > 0) { -                 $has[$all[' prize_id '] + = 1;//the number of times each award has been101                 $new _prizes[] =$all;//Latest winning record102                 $all[' uid '] = =$this->mid &&$my _prizes[] =$all;//my winning record.103}Else {104                 $no _count+ = 1;//no number of winners the             }106             107             //record the number of times I have drawn a lottery108             $all[' uid '] = =$this->mid &&$my _count+ = 1;109         } the         111         $this->assign (' new_prizes ',$new _prizes);//submit to Template display the         $this->assign (' my_prizes ',$my _prizes);//submit to Template display

Weiphp Scratch Card Controller code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.