Greeting
[ class tree: Greeting ] [ index: Greeting ] [ all elements ]

example

  1. <?php 
  2. /**
  3.  * File contain example with text
  4.  *
  5.  * @package     Greeting
  6.  * @version     1.1
  7.  * @copyright     Copyright (C)2006 Todor Iliev <todor.iliev@viplord.com> . All rights reserved.
  8.  * @license     http://www.gnu.org/copyleft/gpl.html GNU Public License
  9.  * @filesource
  10.  */
  11.  
  12. /**
  13.  *     LICENSE
  14.  *     This program is free software; you can redistribute it and/or
  15.  *     modify it under the terms of the GNU General Public License (GPL)
  16.  *     as published by the Free Software Foundation; either version 2
  17.  *     of the License, or (at your option) any later version.
  18.  *    This program is distributed in the hope that it will be useful,
  19.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  *    GNU General Public License for more details.
  22.  *    To read the license please visit http://www.gnu.org/copyleft/gpl.html
  23.  *    ----------------------------------------------------------------------
  24.  *    Original Author of file:
  25.  *    Purpose of file:
  26.  *    ----------------------------------------------------------------------
  27.  *     Tested with IE 6,IE 7, Netscape 7, Opera 9, Firefox 2.0
  28.  *     This is free software. Use at your own risk.
  29.  */
  30. $safe_op    =    (!empty($_REQUEST['op'])) $_REQUEST['op''' ;
  31.         
  32. if(!empty($safe_op)) {
  33.     $color         =     array('red','blue','green','white','gray','purple','black','yellow');
  34.     $font        =    array('Arial','Balthazar','Chicago','Garamond','Georgia','Times New Roman','Victorian LET','Rage Italic LET');
  35.     $size        =    array('xx-small','x-small','small','medium','large','x-large','xx-large');
  36.     $style        =    array('bold','italic','underline');
  37.     $position    =    array('left','center','right');
  38.     $gc            =    array('1.png','2.png','3.png');    
  39.     
  40. }    
  41.             
  42. ?>
  43. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  44. <html xmlns="http://www.w3.org/1999/xhtml">
  45. <head>
  46. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  47. <title>Greeting cards</title>
  48. <link href="css/mainstyle.css" rel="stylesheet" type="text/css" />
  49. </head>
  50.  
  51. <body>
  52. <?php if(strcmp($safe_op,'send'== 0?>
  53. <?php 
  54.       require('class.php4.greeting.php');
  55. //    require('class.php5.greeting.php');      
  56.  
  57.       /**
  58.        * Greeting cards url path
  59.        * @var string 
  60.        */
  61.       $gc_url_path    =    '[Your Images URL_PATH]';
  62.       
  63.       /**
  64.        * Initialize variables
  65.        */
  66.       settype($_POST['color'],'integer');
  67.       settype($_POST['text_color'],'integer');
  68.       settype($_POST['font'],'integer');
  69.       settype($_POST['size'],'string');
  70.       settype($_POST['style'],'integer');
  71.       settype($_POST['position'],'integer');
  72.       settype($_POST['text'],'string');
  73.       settype($_POST['op'],'string');
  74.       settype($_POST['gc'],'integer');
  75.       settype($_POST['from_name'],'string');
  76.       settype($_POST['from_mail'],'string');
  77.       settype($_POST['to_mail'],'string');
  78.       
  79.       /**
  80.        * Random file name
  81.        * @var string 
  82.        */
  83.       $random_file_name md5(time());
  84.  
  85.       /**
  86.        * Add text in creeting card
  87.        * @var string 
  88.        */
  89.       $add_txt 'You have greeting on this address [URL path]/'  's_greeting/' $random_file_name '.html';
  90.       
  91.       /**
  92.        * Mail subject
  93.        * @var string 
  94.        */
  95.       $subject 'Greeting card from ' $_POST['from_name'];
  96.       
  97.       /**
  98.        * Create greeting object
  99.        * @var object 
  100.        */
  101.       $greeting new Greeting($gc_url_path $gc[$_POST['gc']])
  102.       
  103.       /**
  104.        * Initialize greeting object attributes
  105.        */
  106.       
  107.       /**
  108.        * Background color
  109.        * @var string 
  110.        */
  111.       $greeting->mBg                =    (!empty($_POST['color'])) $color[$_POST['color']] $color[3];
  112.       
  113.       /**
  114.        * Text color
  115.        * @var string 
  116.        */
  117.       $greeting->mTextColor         =     (!empty($_POST['text_color'])) $color[$_POST['text_color']] $color[6];
  118.       
  119.       /**
  120.        * Text font
  121.        * @var string 
  122.        */
  123.       $greeting->mTextFont        =    (!empty($_POST['font'])) $font[$_POST['font']] $font[0];
  124.       
  125.       /**
  126.        * Text size
  127.        * @var mixed 
  128.        */
  129.       $greeting->mTextSize        =    (!empty($_POST['size'])) $size[$_POST['size']] $size[0];
  130.       
  131.       /**
  132.        * Text style
  133.        * @var string 
  134.        */
  135.       $greeting->mTextStyle        =    (!empty($_POST['style'])) $style[$_POST['style']] $style[0];
  136.       
  137.       /**
  138.        * Text position
  139.        * @var string 
  140.        */
  141.       $greeting->mTextPos            =    (!empty($_POST['position'])) $position[$_POST['position']] $position[0];
  142.       
  143.       /**
  144.        * Greeting text
  145.        * @var mixed 
  146.        */
  147.       $greeting->mText            =    htmlspecialchars($_POST['text']);
  148.       
  149.       /**
  150.        * Sender name
  151.        * @var string 
  152.        */
  153.       $greeting->mSendFromName    =    $_POST['from_name'];
  154.       
  155.       /**
  156.        * Sender mail address
  157.        * @var string 
  158.        */
  159.       $greeting->mSendFromMail    =    $_POST['from_mail'];
  160.       
  161.       /**
  162.        * Addressee
  163.        * @var string 
  164.        */
  165.       $greeting->mSendToMail        =    $_POST['to_mail'];
  166.       
  167.       /**
  168.        * Mail subject
  169.        * @var mixed 
  170.        */
  171.       $greeting->mSubject            =    $subject;
  172.       
  173.       /**
  174.        * Type on greeting card (html or text)
  175.        * @var string 
  176.        */
  177.       $greeting->mType            =    'text';
  178.     
  179.       // Create greeting file
  180.      if (!$handle fopen('s_greeting/' $random_file_name '.html',"a")) {
  181.           echo "Cannot open file ('s_greeting/' . $random_file_name . '.html')";
  182.         exit;
  183.        }
  184.                
  185.        if (fwrite($handle$greeting->GetCard()) === FALSE{
  186.         echo "Cannot write to file ('s_greeting/' . $random_file_name . '.html')";
  187.         exit;
  188.     }
  189.        fclose($handle);
  190.    
  191.        // Send mail to recipient
  192.        /**
  193.        * Add text in greeting card
  194.        * @var mixed 
  195.        */
  196.       $greeting->mAddTxt            =    $add_txt;
  197.       
  198.     if(empty($greeting->mError)) {
  199.           
  200.           if($greeting->SendCard(=== true{
  201.             echo 'Your greeting card sended successful.';
  202.             else {
  203.                 $greeting->ShowErrors();
  204.             }//    if($greeting->SendCard() === true) {
  205.         
  206.           else {
  207.             $greeting->ShowErrors();
  208.         }//    if(empty($greeting->mError)) {
  209. ?>
  210.  
  211. <?php elseif(strcmp($safe_op,'options'== 0?>
  212. <form id="gc_form" name="gc_form" method="post" action="<?php echo $_SERVER['PHP_SELF'?>">
  213.   <table width="100%" border="0" cellspacing="0" cellpadding="0">
  214.     <tr>
  215.       <td colspan="4"><h3>Background color </h3></td>
  216.     </tr>
  217.     <tr>
  218.       <td id="red"><input name="color" type="radio" value="0" accesskey="r" tabindex="1" id="rb1" />
  219.       <label for="rb1">Red</label></td>
  220.       <td id="blue"><input name="color" type="radio" value="1" accesskey="u" tabindex="2" id="rb2" />
  221.       <label for="rb2">Blue</label></td>
  222.       <td id="green"><input name="color" type="radio" value="2" accesskey="g" tabindex="3" id="rb3" />
  223.       <label for="rb3">Green</label></td>
  224.       <td id="white"><input name="color" type="radio" value="3" accesskey="w" tabindex="4" id="rb4" />
  225.       <label for="rb4">White</label></td>
  226.     </tr>
  227.     <tr>
  228.       <td id="gray"><input name="color" type="radio" value="4" accesskey="y" tabindex="5" id="rb5" />
  229.       <label for="rb5">Gray</label></td>
  230.       <td id="purple"><input name="color" type="radio" value="5" accesskey="p" tabindex="6" id="rb6"/>
  231.       <label for="rb6">Purple</label></td>
  232.       <td id="black"><input name="color" type="radio" value="6" accesskey="b" tabindex="7" id="rb7" />
  233.       <label for="rb7">Black</label></td>
  234.       <td id="yellow"><input name="color" type="radio" value="7" accesskey="y" tabindex="8" id="rb8" />
  235.       <label for="rb8">Yellow</label></td>
  236.     </tr>
  237.     <tr>
  238.       <td colspan="4"><h3>Text color </h3></td>
  239.     </tr>
  240.     <tr>
  241.       <td id="red"><input name="text_color" type="radio" value="0" accesskey="r" tabindex="1" id="rb9" />
  242.           <label for="rb9">Red</label></td>
  243.       <td id="blue"><input name="text_color" type="radio" value="1" accesskey="u" tabindex="2" id="rb10" />
  244.           <label for="rb10">Blue</label></td>
  245.       <td id="green"><input name="text_color" type="radio" value="2" accesskey="g" tabindex="3" id="rb11" />
  246.           <label for="rb11">Green</label></td>
  247.       <td id="white"><input name="text_color" type="radio" value="3" accesskey="w" tabindex="4" id="rb12" />
  248.           <label for="rb12">White</label></td>
  249.     </tr>
  250.     <tr>
  251.       <td id="gray"><input name="text_color" type="radio" value="4" accesskey="y" tabindex="5" id="rb13" />
  252.           <label for="rb13">Gray</label></td>
  253.       <td id="purple"><input name="text_color" type="radio" value="5" accesskey="p" tabindex="6" id="rb14"/>
  254.           <label for="rb14">Purple</label></td>
  255.       <td id="black"><input name="text_color" type="radio" value="6" accesskey="b" tabindex="7" id="rb15" />
  256.           <label for="rb15">Black</label></td>
  257.       <td id="yellow"><input name="text_color" type="radio" value="7" accesskey="y" tabindex="8" id="rb16" />
  258.           <label for="rb16">Yellow</label></td>
  259.     </tr>
  260.     
  261.     <tr>
  262.       <td colspan="4"><h3>Text font </h3></td>
  263.     </tr>
  264.     <tr>
  265.       <td id="f1"><input name="font" type="radio" value="0" accesskey="a" tabindex="9" id="rb17" />
  266.       <label for="rb17">Arial</label></td>
  267.       <td id="f2"><input name="font" type="radio" value="1" accesskey="z" tabindex="10" id="rb18" />
  268.       <label for="rb18">Balthazar</label></td>
  269.       <td id="f3"><input name="font" type="radio" value="2" accesskey="c" tabindex="11" id="rb19" />
  270.       <label for="rb19">Chicago</label></td>
  271.       <td id="f4"><input name="font" type="radio" value="3" accesskey="m" tabindex="12" id="rb20" />
  272.       <label for="rb20">Garamond</label></td>
  273.     </tr>
  274.     <tr>
  275.       <td id="f5"><input name="font" type="radio" value="4" accesskey="i" tabindex="13" id="rb21" />
  276.       <label for="rb21">Georgia</label></td>
  277.       <td id="f6"><input name="font" type="radio" value="5" accesskey="t" tabindex="14" id="rb22" />
  278.       <label for="rb22">Times New Roman</label></td>
  279.       <td id="f7"><input name="font" type="radio" value="6" accesskey="v" tabindex="15" id="rb23" />
  280.       <label for="rb23">Victorian LET</label></td>
  281.       <td id="f8"><input name="font" type="radio" value="7" accesskey="e" tabindex="16" id="rb24" />
  282.       <label for="rb24">Rage Italic LET</label></td>
  283.     </tr>
  284.     <tr>
  285.       <td colspan="4"><h3>Text size </h3></td>
  286.     </tr>
  287.     <tr>
  288.       <td id="s1"><input name="size" type="radio" value="0" accesskey="1" tabindex="17" id="rb25" />
  289.       <label for="rb25">xx-small</label></td>
  290.       <td id="s2"><input name="size" type="radio" value="1" accesskey="2" tabindex="18" id="rb26" />
  291.       <label for="rb26">x-small</label></td>
  292.       <td id="s3"><input name="size" type="radio" value="2" accesskey="3" tabindex="19" id="rb27" />
  293.       <label for="rb27">small</label></td>
  294.       <td id="s4"><input name="size" type="radio" value="3" accesskey="4" tabindex="20" id="rb28" />
  295.       <label for="rb28">medium</label></td>
  296.     </tr>
  297.     <tr>
  298.       <td id="s5"><input name="size" type="radio" value="4" accesskey="5" tabindex="21" id="rb29" />
  299.       <label for="rb29">large</label></td>
  300.       <td id="s6"><input name="size" type="radio" value="5" accesskey="6" tabindex="22" id="rb30" />
  301.       <label for="rb30">x-large</label></td>
  302.       <td id="s7"><input name="size" type="radio" value="6" accesskey="7" tabindex="23" id="rb31" />
  303.       <label for="rb31">xx-large</label></td>
  304.       <td>&nbsp;</td>
  305.     </tr>
  306.     <tr>
  307.       <td colspan="4"><h3>Text style </h3></td>
  308.     </tr>
  309.     <tr>
  310.       <td id="st1"><input name="style" type="radio" value="0" accesskey="d" tabindex="24" id="rb32" />
  311.       <label for="rb32">Bold</label></td>
  312.       <td id="st2"><input name="style" type="radio" value="1" accesskey="t" tabindex="25" id="rb33" />
  313.       <label for="rb33">italic</label></td>
  314.       <td id="st3"><input name="style" type="radio" value="2" accesskey="n" tabindex="26" id="rb34" />
  315.       <label for="rb34">underline</label></td>
  316.       <td>&nbsp;</td>
  317.     </tr>
  318.     <tr>
  319.       <td colspan="4"><h3>Text position </h3></td>
  320.     </tr>
  321.     <tr>
  322.       <td id="p1"><input name="position" type="radio" value="2" accesskey="f" tabindex="26" id="rb35" />
  323.       <label for="rb35">left</label></td>
  324.       <td id="p2">&nbsp;</td>
  325.       <td><input name="position" type="radio" value="1" accesskey="c" tabindex="27" id="rb36" />
  326.           <label for="rb36">center</label></td>
  327.       <td><input name="position" type="radio" value="0" accesskey="h" tabindex="28" id="rb37" />
  328.           <label for="rb37">right</label></td>
  329.     </tr>
  330.     <tr>
  331.       <td colspan="4"><h3>Text</h3></td>
  332.     </tr>
  333.     <tr>
  334.       <td colspan="4" class="p"><label for="text" class="hide">Text</label>
  335.       <textarea name="text" cols="64" rows="10" id="text" accesskey="x" tabindex="29"></textarea>
  336.       <input name="op" type="hidden" id="op" value="send" />
  337.       <input name="gc" type="hidden" id="gc" value="<?php echo $_GET['gc']?>" /></td>
  338.     </tr>
  339.     <tr>
  340.       <td colspan="4" class="p"><label for="from"></label>
  341.         <label for="from_name">Your name</label>
  342.       <input type="text" name="from_name" id="from_name" />        
  343.       <label for="label">&nbsp;</label>
  344.       <label for="from_mail">Your mail</label>
  345.       <input type="text" name="from_mail" id="from_mail" /></td>
  346.     </tr>
  347.     <tr>
  348.       <td colspan="4" class="p"><label for="to_mail">To mail</label>
  349.       <input type="text" name="to_mail" id="to_mail" /></td>
  350.     </tr>
  351.     <tr>
  352.       <td colspan="4" class="p"><label for="Submit" class="hide">Send greeting card</label>
  353.       <input type="submit" name="Submit" value="Send greeting card" accesskey="s" tabindex="30" id="Submit" /></td>
  354.     </tr>
  355.   </table>
  356. </form>
  357.  
  358. <?php else?>
  359. <p align="center"><a href="<?php echo $_SERVER['PHP_SELF''?op=options&gc=0'?>"><img src="images/small_1.png" alt="greeting card 1" width="128" height="96" border="0" /></a>&nbsp;<a href="<?php echo $_SERVER['PHP_SELF''?op=options&gc=1'?>"><img src="images/small_2.png" alt="greeting card 2" width="120" height="81" border="0" /></a>&nbsp;<a href="<?php echo $_SERVER['PHP_SELF''?op=options&gc=2'?>"><img src="images/small_3.png" alt="greeting card 3" width="120" height="81" border="0" /></a></p>
  360. <p>
  361.   <?php endif?>
  362. </p>
  363. </body>
  364. </html>

Documentation generated on Mon, 18 Dec 2006 00:26:05 +0200 by phpDocumentor 1.3.1