[ PHPXref.com ] [ Generated: Sun Jul 20 17:05:41 2008 ] [ Coppermine 1.4.5 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> ecard.php (source)

   1  <?php
   2  /*************************

   3    Coppermine Photo Gallery

   4    ************************

   5    Copyright (c) 2003-2006 Coppermine Dev Team

   6    v1.1 originally written by Gregory DEMAR

   7  

   8    This program is free software; you can redistribute it and/or modify

   9    it under the terms of the GNU General Public License as published by

  10    the Free Software Foundation; either version 2 of the License, or

  11    (at your option) any later version.

  12    ********************************************

  13    Coppermine version: 1.4.5

  14    $Source: /cvsroot/coppermine/stable/ecard.php,v $

  15    $Revision: 1.21 $

  16    $Author: gaugau $

  17    $Date: 2006/03/02 08:17:40 $

  18  **********************************************/
  19  
  20  define('IN_COPPERMINE', true);
  21  define('ECARDS_PHP', true);
  22  
  23  require ('include/init.inc.php');
  24  require ('include/smilies.inc.php');
  25  require ('include/mailer.inc.php');
  26  
  27  if (!USER_CAN_SEND_ECARDS) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
  28  
  29  //print_r(get_defined_constants());

  30  
  31  function get_post_var($name, $default = '')
  32  {
  33  
  34      return isset($_POST[$name]) ? $_POST[$name] : $default;
  35  }
  36  
  37  $pid = (int)$_GET['pid'];
  38  $album = $_GET['album'];
  39  $pos = (int)$_GET['pos'];
  40  
  41  $sender_name = get_post_var('sender_name', USER_NAME ? USER_NAME : (isset($USER['name']) ? $USER['name'] : ''));
  42  if (defined('UDB_INTEGRATION')AND USER_ID) $USER_DATA = array_merge($USER_DATA,$cpg_udb->get_user_infos(USER_ID));
  43  if ($USER_DATA['user_email']){
  44  $sender_email = $USER_DATA['user_email'];
  45  $sender_box = $sender_email;
  46  } else {
  47  $sender_email = get_post_var('sender_email',$USER['email'] ? $USER['email'] : '');
  48  $sender_box = "<input type=\"text\" class=\"textinput\" value=\"$sender_email\" name=\"sender_email\" style=\"width: 100%;\" />";
  49  }
  50  $recipient_name = get_post_var('recipient_name');
  51  $recipient_email = get_post_var('recipient_email');
  52  $greetings = get_post_var('greetings');
  53  $message = get_post_var('message');
  54  $sender_email_warning = '';
  55  $recipient_email_warning = '';
  56  // Get picture thumbnail url

  57  $result = cpg_db_query("SELECT * from {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid' $ALBUM_SET");
  58  if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
  59  $row = mysql_fetch_array($result);
  60  $thumb_pic_url = get_pic_url($row, 'thumb');
  61  
  62  $pic_title = $row['title'];
  63  $pic_caption = bb_decode($row['caption']);
  64  
  65  if (!is_image($row['filename'])) cpg_die(ERROR, $lang_ecard_php['error_not_image'], __FILE__, __LINE__);
  66  
  67  // Check supplied email address

  68  $valid_email_pattern = "^[_\.0-9a-z\-]+@([0-9a-z][0-9a-z-]*\.)+[a-z]{2,6}$";
  69  $valid_sender_email = eregi($valid_email_pattern, $sender_email);
  70  $valid_recipient_email = eregi($valid_email_pattern, $recipient_email);
  71  $invalid_email = '<font size="1">' . $lang_ecard_php['invalid_email'] . ' (' . $recipient_email . ')</font>';
  72  if (!$valid_sender_email && count($_POST) > 0) $sender_email_warning = $invalid_email;
  73  if (!$valid_recipient_email && count($_POST) > 0) $recipient_email_warning = $invalid_email;
  74  
  75  pageheader($lang_ecard_php['title']);
  76  
  77  if (isset($_POST['submit'])) {
  78  
  79  // Create and send the e-card

  80  if (count($_POST) > 0 && $valid_sender_email && $valid_recipient_email) {
  81      $gallery_url_prefix = $CONFIG['ecards_more_pic_target']. (substr($CONFIG['ecards_more_pic_target'], -1) == '/' ? '' : '/');
  82      if ($CONFIG['make_intermediate'] && max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width']) {
  83          $n_picname = get_pic_url($row, 'normal');
  84      } else {
  85          $n_picname = get_pic_url($row, 'fullsize');
  86      }
  87  
  88      if (!stristr($n_picname, 'http:')) $n_picname = $gallery_url_prefix . $n_picname;
  89  
  90      $msg_content = process_smilies($message, $gallery_url_prefix);
  91  
  92      $data = array('rn' => $_POST['recipient_name'],
  93          'sn' => $_POST['sender_name'],
  94          'se' => $sender_email,
  95          'p' => $n_picname,
  96          'g' => $greetings,
  97          'm' => $message,
  98          'pid' => $pid,
  99          'pt' => $pic_title,
 100          'pc' => $pic_caption,
 101          );
 102  
 103      $encoded_data = urlencode(base64_encode(serialize($data)));
 104  
 105      $params = array('{LANG_DIR}' => $lang_text_dir,
 106          '{TITLE}' => sprintf($lang_ecard_php['ecard_title'], $sender_name),
 107          '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
 108          '{VIEW_ECARD_TGT}' => "{$gallery_url_prefix}displayecard.php?data=$encoded_data",
 109          '{VIEW_ECARD_LNK}' => $lang_ecard_php['view_ecard'],
 110          '{VIEW_ECARD_LNK_PLAINTEXT}' => $lang_ecard_php['view_ecard_plaintext'],
 111          '{PIC_URL}' => $n_picname,
 112          '{URL_PREFIX}' => $gallery_url_prefix,
 113          '{GREETINGS}' => $greetings,
 114          '{MESSAGE}' => bb_decode($msg_content),
 115          '{PLAINTEXT_MESSAGE}' => $message,
 116          '{SENDER_EMAIL}' => $sender_email,
 117          '{SENDER_NAME}' => $sender_name,
 118          '{VIEW_MORE_TGT}' => $CONFIG['ecards_more_pic_target'],
 119          '{VIEW_MORE_LNK}' => $lang_ecard_php['view_more_pics'],
 120          '{PID}' => $pid,
 121          '{PIC_TITLE}' => $pic_title,
 122          '{PIC_CAPTION}' => $pic_caption,
 123          );
 124  
 125                                  $message = template_eval($template_ecard, $params);
 126                                  $plaintext_message = template_eval($template_ecard_plaintext, $params);
 127  
 128          $tempTime = time();
 129          $message .= sprintf($lang_ecard_php['ecards_footer'], $sender_name, $_SERVER['REMOTE_ADDR'], localised_date(-1,$comment_date_fmt));
 130                                  $subject = sprintf($lang_ecard_php['ecard_title'], $sender_name);
 131  
 132                                  $result = cpg_mail($recipient_email, $subject, $message, 'text/html', $sender_name, $sender_email, $plaintext_message);
 133  
 134          //write ecard log

 135          if ($CONFIG['log_ecards'] == 1) {
 136            $result_log = cpg_db_query("INSERT INTO {$CONFIG['TABLE_ECARDS']} (sender_name, sender_email, recipient_name, recipient_email, link, date, sender_ip) VALUES ('$sender_name', '$sender_email', '$recipient_name', '$recipient_email',   '$encoded_data', '$tempTime', '{$_SERVER["REMOTE_ADDR"]}')");
 137            }
 138  
 139      if (!USER_ID) {
 140          $USER['name'] = $sender_name;
 141          $USER['email'] = $sender_email;
 142      }
 143  
 144      if ($result) {
 145          //pageheader($lang_ecard_php['title']);

 146          msg_box($lang_cpg_die[INFORMATION], $lang_ecard_php['send_success'], $lang_continue, "displayimage.php?album=$album&amp;pos=$pos");
 147                                  echo '<br />';
 148                                  starttable('100%', $lang_ecard_php['preview']);
 149                                  echo '<tr><td>';
 150                                  echo template_eval($template_ecard, $params);
 151                                  echo '</td></tr>';
 152                                  endtable();
 153          pagefooter();
 154          ob_end_flush();
 155          exit;
 156      } else {
 157          cpg_die(ERROR, $lang_ecard_php['send_failed'], __FILE__, __LINE__);
 158      }
 159          }
 160  }//submit

 161  
 162  elseif (isset($_POST['preview'])) {
 163  
 164      if ($CONFIG['make_intermediate'] && max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width']) {
 165          $n_picname = get_pic_url($row, 'normal');
 166      } else {
 167          $n_picname = get_pic_url($row, 'fullsize');
 168      }
 169      if (!stristr($n_picname, 'http:')) $n_picname = $gallery_url_prefix . $n_picname;
 170      $msg_content = process_smilies($message, $gallery_url_prefix);
 171      $data = array(
 172          'sn' => $_POST['sender_name'],
 173          'se' => $sender_email,
 174          'p' => $n_picname,
 175          'g' => $greetings,
 176          'm' => $message,
 177          'pid' => $pid,
 178          'pt' => $pic_title,
 179          'pc' => $pic_caption,
 180          );
 181  
 182      $params = array('{LANG_DIR}' => $lang_text_dir,
 183          '{TITLE}' => sprintf($lang_ecard_php['ecard_title'], $sender_name),
 184          '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
 185          '{VIEW_ECARD_TGT}' => "{$gallery_url_prefix}displayecard.php?data=$encoded_data",
 186          '{VIEW_ECARD_LNK}' => $lang_ecard_php['preview_view_ecard'],
 187          '{PIC_URL}' => $n_picname,
 188          '{URL_PREFIX}' => $gallery_url_prefix,
 189          '{GREETINGS}' => $greetings,
 190          '{MESSAGE}' => bb_decode($msg_content),
 191          '{SENDER_EMAIL}' => $sender_email,
 192          '{SENDER_NAME}' => $sender_name,
 193          '{VIEW_MORE_TGT}' => $CONFIG['ecards_more_pic_target'],
 194          '{VIEW_MORE_LNK}' => $lang_ecard_php['view_more_pics'],
 195          '{PID}' => $pid,
 196          '{PIC_TITLE}' => $pic_title,
 197          '{PIC_CAPTION}' => $pic_caption,
 198          );
 199  
 200                                  starttable('100%', $lang_ecard_php['preview']);
 201                                  echo '<tr><td>';
 202                                  echo template_eval($template_ecard, $params);
 203                                  echo '</td></tr>';
 204                                  endtable();
 205                                  echo '<br />';
 206  }//preview

 207  
 208  //pageheader($lang_ecard_php['title']);

 209  
 210  //ecard form

 211  if ($CONFIG['show_bbcode_help']) {$captionLabel = '&nbsp;'. cpg_display_help('f=index.html&amp;base=64&amp;h='.urlencode(base64_encode(serialize($lang_bbcode_help_title))).'&amp;t='.urlencode(base64_encode(serialize($lang_bbcode_help))),470,245);}
 212  starttable("100%", $lang_ecard_php['title'], 3);
 213  
 214  echo <<<EOT
 215          <tr>
 216                  <td class="tableh2" colspan="2"><b>{$lang_ecard_php['from']}</b></td>
 217                  <td rowspan="6" align="center" valign="top" class="tableb">
 218                          <a href="displayimage.php?pos=-{$pid}">
 219                                                                                                  <img src="$thumb_pic_url" alt="" vspace="8" border="0" class="image" /></a><br />
 220                  </td>
 221          </tr>
 222          <tr>
 223                  <td class="tableb" valign="top" width="40%">
 224                          <form method="post" name="post" action="{$_SERVER['PHP_SELF']}?album=$album&amp;pid=$pid&amp;pos=$pos">
 225                          {$lang_ecard_php['your_name']}<br />
 226                  </td>
 227                  <td valign="top" class="tableb" width="60%">
 228                          <input type="text" class="textinput" name="sender_name"  value="$sender_name" style="width: 100%;" /><br />
 229                  </td>
 230          </tr>
 231          <tr>
 232                  <td class="tableb" valign="top" width="40%">
 233                          {$lang_ecard_php['your_email']}<br />
 234                  </td>
 235                  <td valign="top" class="tableb" width="60%">
 236                          {$sender_box}
 237                          {$sender_email_warning}
 238                  </td>
 239          </tr>
 240          <tr>
 241                  <td class="tableh2" colspan="2"><b>{$lang_ecard_php['to']}</b></td>
 242          </tr>
 243          <tr>
 244                  <td class="tableb" valign="top" width="40%">
 245                          {$lang_ecard_php['rcpt_name']}<br />
 246                  </td>
 247                  <td valign="top" class="tableb" width="60%">
 248                          <input type="text" class="textinput" name="recipient_name"  value="$recipient_name" style="width: 100%;" /><br />
 249                  </td>
 250          </tr>
 251          <tr>
 252                  <td class="tableb" valign="top" width="40%">
 253                          {$lang_ecard_php['rcpt_email']}<br />
 254                  </td>
 255                  <td valign="top" class="tableb" width="60%">
 256                          <input type="text" class="textinput" name="recipient_email"  value="$recipient_email" style="width: 100%;" /><br />
 257                          $recipient_email_warning
 258                  </td>
 259          </tr>
 260          <tr>
 261                  <td class="tableh2" colspan="3"><b>{$lang_ecard_php['greetings']}</b></td>
 262          </tr>
 263          <tr>
 264                  <td class="tableb" colspan="3">
 265                          <input type="text" class="textinput" name="greetings"  value="$greetings" style="width: 100%;" /><br />
 266                  </td>
 267          </tr>
 268          <tr>
 269                  <td class="tableh2" colspan="3"><b>{$lang_ecard_php['message']}$captionLabel</b></td>
 270          </tr>
 271          <tr>
 272                  <td class="tableb" colspan="3" valign="top"><br />
 273                          <textarea name="message" class="textinput" rows="8" cols="40"  onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" style="width: 100%;">$message</textarea><br /><br />
 274                  </td>
 275          </tr>
 276          <tr>
 277                  <td class="tableb" colspan="3" valign="top">
 278  
 279  EOT;
 280  echo generate_smilies();
 281  echo <<<EOT
 282                  </td>
 283          </tr>
 284          <tr>
 285                  <td colspan="3" align="center" class="tablef">
 286                          <input type="submit" class="button" name="preview" title="{$lang_ecard_php['preview_button']}" value="{$lang_ecard_php['preview_button']}" />
 287                                                                                                  &nbsp;&nbsp;
 288                          <input type="submit" class="button" name="submit" title="{$lang_ecard_php['submit_button']}" value="{$lang_ecard_php['submit_button']}" />
 289                          </form>
 290                  </td>
 291          </tr>
 292  EOT;
 293  
 294  endtable();
 295  pagefooter();
 296  ob_end_flush();
 297  
 298  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]