Home > Backend Development > PHP Tutorial > Create coupon code with PHP/THINKPHP

Create coupon code with PHP/THINKPHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:08:00
Original
1905 people have browsed it

<code><span><span><?php</span><span>namespace</span><span>Addons</span>\<span>Coupon</span>\<span>Controller</span>;
<span>use</span><span>Home</span>\<span>Controller</span>\<span>AddonsController</span>;

<span><span>class</span><span>WapController</span><span>extends</span><span>AddonsController</span>{</span><span>protected</span><span>$model</span>;
    <span>public</span><span><span>function</span><span>__construct</span><span>()</span> {</span><span>$GLOBALS</span> [<span>'is_wap'</span>] = <span>true</span>;

        <span>parent</span>::__construct ();
        <span>$uid</span>= get_uid_by_openid();
        <span>$this</span>->model = getModelByName (<span>'coupon'</span>);
        <span>$this</span>->model || <span>$this</span>->error ( <span>'model is not found!'</span> );
    }

    <span>/*
     * Create coupon code
     * 
     *<span> @param</span>  $namespace string
     *<span> @return</span> $guid string 
     *<span> @author</span> sun
     */</span><span>private</span><span><span>function</span><span>create_guid</span><span>(<span>$namespace</span> = <span>''</span>)</span> {</span><span>static</span><span>$guid</span> = <span>''</span>;
        <span>$uid</span> = uniqid(<span>""</span>, <span>true</span>);
        <span>$data</span> = <span>$namespace</span>;
        <span>$data</span> .= <span>$_SERVER</span>[<span>'REQUEST_TIME'</span>];
        <span>$data</span> .= <span>$_SERVER</span>[<span>'HTTP_USER_AGENT'</span>];
        <span>$data</span> .= <span>$_SERVER</span>[<span>'LOCAL_ADDR'</span>];
        <span>$data</span> .= <span>$_SERVER</span>[<span>'LOCAL_PORT'</span>];
        <span>$data</span> .= <span>$_SERVER</span>[<span>'REMOTE_ADDR'</span>];
        <span>$data</span> .= <span>$_SERVER</span>[<span>'REMOTE_PORT'</span>];
        <span>$hash</span> = strtoupper(hash(<span>'ripemd128'</span>, <span>$uid</span> . <span>$guid</span> . md5(<span>$data</span>)));
        <span>// test str combination</span><span>$guid</span> =
        substr(<span>$hash</span>, <span>0</span>, <span>6</span>) .
        <span>'-'</span> .
        substr(<span>$hash</span>, <span>8</span>, <span>4</span>) .
        <span>'-'</span> .
        substr(<span>$hash</span>, <span>12</span>, <span>4</span>) .
        <span>'-'</span> .
        substr(<span>$hash</span>, <span>16</span>, <span>4</span>) .
        <span>'-'</span> .
        substr(<span>$hash</span>, <span>20</span>, <span>8</span>);
        <span>return</span><span>$guid</span>;
    }

}


<span>// end</span></span></span></code>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces how to create coupon codes with PHP/THINKPHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template