[8771] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * Plugin Name: Piwecard |
---|
| 4 | * File : ecard.php |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | global $user, $conf; |
---|
| 8 | |
---|
[19732] | 9 | class ecard { |
---|
[8771] | 10 | var $debug = false; |
---|
| 11 | var $my_config ; |
---|
[19732] | 12 | var $infos = array(); // contains all the info of the ecard : message, subject.... |
---|
[8771] | 13 | var $user_groups = array(); |
---|
| 14 | |
---|
| 15 | // Class constructor |
---|
[19732] | 16 | function ecard() { |
---|
[8771] | 17 | $this->load_config(); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | // Load general configuration from config_database |
---|
[19732] | 22 | function load_config() { |
---|
[8771] | 23 | $query = ' |
---|
| 24 | SELECT value |
---|
| 25 | FROM '.CONFIG_TABLE.' |
---|
| 26 | WHERE param = \'ecard\' |
---|
| 27 | ;'; |
---|
| 28 | |
---|
| 29 | $result = pwg_query($query); |
---|
| 30 | |
---|
[19732] | 31 | if(isset($result)) { |
---|
| 32 | $row = mysql_fetch_row($result); |
---|
| 33 | if(is_string($row[0])) { |
---|
| 34 | $this->my_config = unserialize(($row[0])); |
---|
| 35 | } |
---|
[8771] | 36 | } |
---|
| 37 | $this->load_default_config(); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | // Initialize default values of params |
---|
[19732] | 41 | private function load_default_config() { |
---|
[8771] | 42 | include ECARD_INC_PATH.'default_values.inc.php'; |
---|
[19732] | 43 | foreach ($ecard_default_values as $key => $value) { |
---|
| 44 | if (!isset($this->my_config[$key])) |
---|
| 45 | $this->my_config[$key] = $value; |
---|
[8771] | 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | // Save general configuration to config_database |
---|
| 50 | function save_config() |
---|
| 51 | { |
---|
| 52 | $query = ' |
---|
| 53 | REPLACE INTO '.CONFIG_TABLE.' |
---|
| 54 | VALUES( |
---|
| 55 | \'ecard\', |
---|
| 56 | \''.serialize($this->my_config).'\', |
---|
| 57 | \'Configuration ecard\') |
---|
| 58 | ;'; |
---|
| 59 | |
---|
| 60 | $result = pwg_query($query); |
---|
| 61 | |
---|
| 62 | if($result) |
---|
| 63 | return true; |
---|
| 64 | else |
---|
| 65 | return false; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | // Retrieve user groups |
---|
[19732] | 70 | function get_user_groups() { |
---|
[8771] | 71 | global $user; |
---|
[19732] | 72 | |
---|
| 73 | $query = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user['id'] . ';'; |
---|
[8771] | 74 | |
---|
| 75 | $result = pwg_query($query); |
---|
[19732] | 76 | while ($row = mysql_fetch_assoc($result)) { |
---|
| 77 | array_push($this->user_groups, $row['group_id']); |
---|
[8771] | 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
[19732] | 82 | function section_init_ecard() { |
---|
[8771] | 83 | global $tokens, $page; |
---|
[19732] | 84 | |
---|
[8771] | 85 | if ($tokens[0] == 'ecard') |
---|
[19732] | 86 | $page['section'] = 'ecard'; |
---|
[8771] | 87 | } |
---|
| 88 | |
---|
[19732] | 89 | function index_ecard() { |
---|
[8771] | 90 | global $page; |
---|
| 91 | |
---|
[19732] | 92 | if (isset($page['section']) and $page['section'] == 'ecard') { |
---|
[8771] | 93 | include(ECARD_PATH . 'publish.php'); |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | //Générer une chaine de caractère unique et aléatoire |
---|
| 98 | private function random($car) { |
---|
[19732] | 99 | $string = ""; |
---|
| 100 | $chaine = "abcdefghijklmnpqrstuvwxy0123456789"; |
---|
| 101 | srand((double)microtime()*1000000); |
---|
| 102 | for($i=0; $i<$car; $i++) { |
---|
| 103 | $string .= $chaine[rand()%strlen($chaine)]; |
---|
| 104 | } |
---|
| 105 | return $string; |
---|
[8771] | 106 | } |
---|
| 107 | |
---|
| 108 | // NB of days between 2 dates "AAAA-MM-JJ HH:hh:ss" |
---|
[19732] | 109 | function NbJours($debut, $fin) { |
---|
| 110 | $tDeb = explode("-", substr($debut,0,strpos($debut, ' '))); |
---|
| 111 | $tFin = explode("-", substr($fin,0,strpos($fin, ' '))); |
---|
[8771] | 112 | |
---|
[19732] | 113 | $diff = mktime(0, 0, 0, $tFin[1], $tFin[2], $tFin[0]) - mktime(0, 0, 0, $tDeb[1], $tDeb[2], $tDeb[0]); |
---|
[8771] | 114 | |
---|
[19732] | 115 | return(($diff / 86400)); |
---|
[8771] | 116 | } |
---|
| 117 | |
---|
| 118 | function AjoutJours($debut, $jours, $soustrait = false) { |
---|
[19732] | 119 | $tDeb = explode("-", substr($debut,0,strpos($debut, ' '))); |
---|
| 120 | $tDebH = explode(":", substr($debut,strpos($debut, ' ')+1)); |
---|
| 121 | $tFin = ""; |
---|
[8771] | 122 | |
---|
| 123 | $nb_ans = (int)(($jours)/365); |
---|
| 124 | $nb_mois = (int)(( ($jours)%365) / 31); |
---|
| 125 | $nb_jours = (int)(( ($jours)%365) % 31); |
---|
| 126 | |
---|
| 127 | if ($soustrait) |
---|
| 128 | $tFin = date("Y-m-d H:m:s", mktime($tDebH[0], $tDebH[1], $tDebH[2], $tDeb[1] - $nb_mois, $tDeb[2] - $nb_jours, $tDeb[0] - $nb_ans)); |
---|
| 129 | else |
---|
| 130 | $tFin = date("Y-m-d H:m:s", mktime($tDebH[0], $tDebH[1], $tDebH[2], $tDeb[1] + $nb_mois, $tDeb[2] + $nb_jours, $tDeb[0] + $nb_ans)); |
---|
| 131 | |
---|
[19732] | 132 | return($tFin); |
---|
[8771] | 133 | } |
---|
| 134 | |
---|
[19732] | 135 | function parse($data, $_POST = NULL, $image_element = NULL) { |
---|
[8771] | 136 | include (ECARD_PATH.'include/config_param.inc.php'); |
---|
| 137 | |
---|
| 138 | $patterns = array(); |
---|
| 139 | $replacements = array(); |
---|
| 140 | foreach ($ecard_parse as $key => $value) |
---|
| 141 | { |
---|
| 142 | array_push($patterns, $key); |
---|
| 143 | array_push($replacements, $value); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | return str_replace($patterns, $replacements, $data); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | // Get the number of ecard in the database |
---|
[19732] | 150 | function get_nb_ecard() { |
---|
[8771] | 151 | $query = 'SELECT COUNT(DISTINCT numero) as nb FROM '.ECARD_TABLE |
---|
| 152 | . ' ORDER BY date' |
---|
| 153 | .';'; |
---|
| 154 | $result = pwg_query($query); |
---|
[19732] | 155 | if ($result) { |
---|
[8771] | 156 | $nb=mysql_fetch_assoc($result); |
---|
| 157 | return $nb['nb']; |
---|
| 158 | } |
---|
| 159 | else |
---|
| 160 | return 0; |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | // Get the number of valid ecard in the database |
---|
[19732] | 164 | function get_nb_valid_ecard() { |
---|
[8771] | 165 | $query = 'SELECT numero,date,duration FROM '.ECARD_TABLE |
---|
| 166 | .';'; |
---|
| 167 | $result = pwg_query($query); |
---|
| 168 | $count = 0; |
---|
[19732] | 169 | while($ecard_info = mysql_fetch_assoc($result)) { |
---|
| 170 | if ($ecard_info['duration'] == 0 OR $this->NbJours($ecard_info['date'], date("Y-m-d H:m:s")) <= $ecard_info['duration']) // activ ecard |
---|
[8771] | 171 | $count++; |
---|
| 172 | } |
---|
| 173 | return $count; |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | // Get ecard information into array |
---|
[19732] | 178 | function get_ecard($ecard_id = null) { |
---|
| 179 | if ($ecard_id!== null) { |
---|
[8771] | 180 | $query = ' |
---|
| 181 | SELECT * |
---|
| 182 | FROM ' . ECARD_TABLE .' |
---|
| 183 | WHERE numero ="' . $ecard_id . '" |
---|
| 184 | LIMIT 1 |
---|
| 185 | '; |
---|
| 186 | |
---|
| 187 | $result = pwg_query($query); |
---|
| 188 | if ($result) |
---|
| 189 | return mysql_fetch_assoc($result); |
---|
| 190 | else |
---|
| 191 | return false; |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | // Get ecard information into array |
---|
[19732] | 197 | function is_valid($ecard_id = null, $param_date=false) { |
---|
| 198 | if ($ecard_id!== null) { |
---|
[8771] | 199 | $ecard_info = $this->get_ecard($ecard_id); |
---|
| 200 | if ($ecard_info != false) |
---|
| 201 | { |
---|
| 202 | |
---|
| 203 | // Valid duration for an ecard |
---|
| 204 | $duration = ($param_date ? $this->my_config['activ'] : $ecard_info['duration']); |
---|
| 205 | if ($this->debug) |
---|
| 206 | { |
---|
| 207 | foreach ($ecard_info as $i=>$v) |
---|
| 208 | echo "ecard[".$i."]=".$v." \ "; |
---|
| 209 | echo "NBjours = ".$this->NbJours($ecard_info['date'], date("Y-m-d H:m:s"))." -"; |
---|
| 210 | echo "Activenb=".$this->my_config['activ']." -"; |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | |
---|
| 214 | if (isset ($ecard_info) |
---|
[19732] | 215 | AND $duration != 0 // 0 means always activ |
---|
| 216 | AND ($this->NbJours($ecard_info['date'], date("Y-m-d H:m:s")) > $duration) // Inactiv ecard |
---|
[8771] | 217 | ) |
---|
| 218 | { |
---|
| 219 | return false; |
---|
[19732] | 220 | } else { |
---|
[8771] | 221 | return true; |
---|
| 222 | } |
---|
| 223 | } |
---|
| 224 | else |
---|
| 225 | return false; |
---|
[19732] | 226 | } else { |
---|
[8771] | 227 | return true; |
---|
| 228 | } |
---|
| 229 | } |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | // delete one ecard |
---|
| 233 | // force to delete valid ecard |
---|
[19732] | 234 | function delete_ecard($ecard_id = null, $force = false) { |
---|
| 235 | if ($ecard_id!== null) { |
---|
[8771] | 236 | $ecard_info = $this->get_ecard($ecard_id); |
---|
| 237 | if ($this->debug) |
---|
| 238 | { |
---|
| 239 | foreach ($ecard_info as $i=>$v) |
---|
| 240 | echo "ecard[".$i."]=".$v." \ "; |
---|
| 241 | } |
---|
| 242 | if (isset ($ecard_info) |
---|
| 243 | and ( ($this->NbJours($ecard_info['date'], date("Y-m-d H:m:s")) > $this->my_config['activ']) // Inactiv ecard |
---|
| 244 | OR $force // Or force to delete even if activ |
---|
| 245 | ) |
---|
| 246 | ) |
---|
| 247 | |
---|
| 248 | $query = ' |
---|
| 249 | DELETE |
---|
| 250 | FROM ' . ECARD_TABLE .' |
---|
| 251 | WHERE numero ="' . $ecard_id . '" |
---|
| 252 | '; |
---|
| 253 | pwg_query($query); |
---|
| 254 | } |
---|
| 255 | else |
---|
[19732] | 256 | return false; |
---|
[8771] | 257 | } |
---|
| 258 | |
---|
| 259 | // Delete all invalid ecard |
---|
[19732] | 260 | function delete_allinvalid_ecard() { |
---|
[8771] | 261 | $date = $this->AjoutJours(date("Y-m-d H:m:s"), $this->my_config['activ'], true); |
---|
| 262 | |
---|
| 263 | $query = ' |
---|
| 264 | DELETE |
---|
| 265 | FROM ' . ECARD_TABLE .' |
---|
| 266 | WHERE date < "' . $date . '" |
---|
| 267 | '; |
---|
[19732] | 268 | |
---|
[8771] | 269 | pwg_query($query); |
---|
| 270 | |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | // Add tpl to picture.php page to display ecard informations |
---|
[19732] | 274 | function display_ecard_to_picture() { |
---|
| 275 | global $page, $user, $template; |
---|
[19923] | 276 | |
---|
[19732] | 277 | // Init user groups |
---|
[8771] | 278 | $this->get_user_groups(); |
---|
| 279 | |
---|
[19732] | 280 | // Only on category page! |
---|
| 281 | if (isset($page['section'])) { |
---|
[8771] | 282 | $upper_names = null; |
---|
[19732] | 283 | |
---|
| 284 | if (!empty($page['category'])) { |
---|
| 285 | // Gets all upper categories from the image category to test |
---|
| 286 | // - if the parameter for "recursive" is OK |
---|
| 287 | // - if the upper category is activated for this function |
---|
| 288 | $query = 'SELECT * |
---|
| 289 | FROM '.CATEGORIES_TABLE.' |
---|
| 290 | WHERE id = '.pwg_db_real_escape_string($page['category']['id']).' |
---|
| 291 | ;'; |
---|
| 292 | $cat = mysql_fetch_assoc(pwg_query($query)); |
---|
| 293 | |
---|
| 294 | if (empty($cat)) { |
---|
| 295 | $upper_ids = null; |
---|
| 296 | } else { |
---|
| 297 | foreach ($cat as $k => $v) { |
---|
| 298 | // If the field is true or false, the variable is transformed into a |
---|
| 299 | // boolean value. |
---|
| 300 | if ($cat[$k] == 'true' or $cat[$k] == 'false') { |
---|
| 301 | $cat[$k] = get_boolean($cat[$k]); |
---|
| 302 | } |
---|
| 303 | } |
---|
| 304 | $upper_ids = explode(',', $cat['uppercats']); |
---|
| 305 | } |
---|
[8771] | 306 | } |
---|
[19732] | 307 | |
---|
| 308 | if ($this->my_config['user_cat']) { // !Function only allowed on user image |
---|
[8771] | 309 | // Check the category name, user name et img author |
---|
| 310 | // Get all name for upper categories and current category |
---|
[19732] | 311 | if (isset($cat) and !empty($cat)) { |
---|
| 312 | $catname[0] = $cat['name']; |
---|
| 313 | if (isset($upper_ids) and $upper_ids != null) { |
---|
| 314 | $nb=1; |
---|
| 315 | foreach ($upper_ids as $upper_cat) { |
---|
| 316 | // Get upper cat info and store the name |
---|
| 317 | $cat_info = get_cat_info($upper_cat); |
---|
| 318 | $catname[$nb++] = $cat_info['name']; |
---|
| 319 | } |
---|
| 320 | } |
---|
[8771] | 321 | } |
---|
| 322 | // Username or the current user |
---|
| 323 | $username = $user['username']; |
---|
| 324 | |
---|
| 325 | // author of the photo |
---|
| 326 | $authorname = ""; |
---|
| 327 | $query = ' |
---|
| 328 | SELECT author |
---|
| 329 | FROM '.IMAGES_TABLE.' |
---|
| 330 | WHERE id = '.$page['image_id'] |
---|
| 331 | .' LIMIT 1' |
---|
| 332 | .';'; |
---|
| 333 | $result = pwg_query($query); |
---|
[19732] | 334 | if (isset($result)) { |
---|
[8771] | 335 | $img_infos = mysql_fetch_array($result); |
---|
| 336 | $authorname = $img_infos['author']; |
---|
| 337 | } |
---|
[19732] | 338 | } |
---|
[8771] | 339 | |
---|
[19732] | 340 | // Only on available cats |
---|
| 341 | if ($this->my_config['allcats'] // Available on all cats |
---|
| 342 | OR (!empty($page['category']) AND in_array($page['category']['id'], $this->my_config['cats'])) // Available on specific cats |
---|
[8771] | 343 | OR ($this->my_config['recursive'] AND isset($upper_ids) AND // Available on upper cats this recursiv mode |
---|
| 344 | (array_intersect($upper_ids, $this->my_config['cats']) != array())) |
---|
| 345 | OR // Available based on usename |
---|
| 346 | ($this->my_config['user_cat'] |
---|
| 347 | AND (in_array($username, $catname) // Available user categories |
---|
| 348 | OR $username == $authorname) |
---|
| 349 | |
---|
| 350 | ) |
---|
| 351 | ) |
---|
| 352 | { |
---|
[19732] | 353 | // And only available groups |
---|
[8771] | 354 | if (empty($this->my_config['groups']) |
---|
[19732] | 355 | OR (!empty($this->my_config['groups']) |
---|
| 356 | AND (array_intersect($this->user_groups, $this->my_config['groups']) != array())) |
---|
[8771] | 357 | ) |
---|
| 358 | { |
---|
| 359 | |
---|
[19732] | 360 | // Check if user is guest. |
---|
| 361 | // In this case, force mail to default mail (in params) |
---|
| 362 | if (is_a_guest()) { |
---|
| 363 | if (!empty($this->my_config['defaultmail'])) |
---|
| 364 | $user['email'] = $this->my_config['defaultmail']; |
---|
| 365 | } |
---|
[8771] | 366 | |
---|
[19732] | 367 | // Template informations |
---|
[19923] | 368 | $template->assign('ecard', array( |
---|
| 369 | 'subject' => l10n('ecard_send_title'), |
---|
[19732] | 370 | 'message' => l10n('ecard_send_message'), |
---|
[19923] | 371 | 'sender_name' => $user['username'], |
---|
| 372 | 'sender_email' => $user['email'], |
---|
| 373 | 'recipient_name' => l10n('ecard_send_dest_name'), |
---|
| 374 | 'recipient_email' => l10n('ecard_send_dest_mail'), |
---|
[19732] | 375 | 'copy' => $this->my_config['send_copy'] ? 'checked="checked"' : '', |
---|
| 376 | 'changemail' => ($this->my_config['expmail_change'] ? '' : 'disabled="disabled"') |
---|
| 377 | )); |
---|
[8771] | 378 | |
---|
[19732] | 379 | // Template add for the active parameter choice by the user |
---|
| 380 | if ($this->my_config['active_parameter']) { // Allowed for the user |
---|
[19923] | 381 | $template->append('ecard_validity',array('id' => 0, 'name' => l10n('ecard_nolimit'), 'selected' => ($this->my_config['activ'] == 0 ? 'checked' : ''))); |
---|
[19732] | 382 | for($jj=5; $jj < 30; $jj+=5) |
---|
[19923] | 383 | $template->append('ecard_validity',array('id' => $jj, 'name' => $jj , 'selected' => ($this->my_config['activ'] == $jj ? 'checked' : ''))); |
---|
[19732] | 384 | } |
---|
[8771] | 385 | |
---|
[19732] | 386 | // Template add for the send method to be chose, by the user |
---|
| 387 | // default : text |
---|
[19923] | 388 | $template->append('ecard_send_method',array('id' => 0, 'name' => l10n('ecard_maillink'), 'selected' => ($this->my_config['send_HTML'] ? '' : 'checked'))); |
---|
[19732] | 389 | if ($this->my_config['send_HTML']) { // Allowed for the user |
---|
[19923] | 390 | $template->append('ecard_send_method',array('id' => 1, 'name' => l10n('ecard_mailhtml'), 'selected' => ($this->my_config['send_HTML'] ? 'checked' : ''))); |
---|
[19732] | 391 | } |
---|
[8771] | 392 | |
---|
| 393 | // Send the card |
---|
[19732] | 394 | if (isset($_POST['ecard_submit'])) { |
---|
[19923] | 395 | $send_method = $_POST['ecard_send_method']; |
---|
| 396 | |
---|
[19732] | 397 | // If conf doesn't allow to modify the %votremail param, force it to user mail |
---|
[19923] | 398 | if (!isset($_POST['ecard_sender_email'])) |
---|
| 399 | $_POST['ecard_sender_email'] = $user['email']; |
---|
[8771] | 400 | |
---|
[19732] | 401 | // Initialize the array for image element |
---|
| 402 | $image_element = array(); |
---|
[8771] | 403 | |
---|
[19923] | 404 | // Get all image informations |
---|
| 405 | $query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id='.$page['image_id'].' LIMIT 1;'; |
---|
[19732] | 406 | $result = pwg_query($query); |
---|
| 407 | if (isset($result)) |
---|
| 408 | $image_element = mysql_fetch_array($result); |
---|
| 409 | |
---|
[19923] | 410 | // Generate random number |
---|
| 411 | $image_element['next_element_id'] = $this->random(64); |
---|
[19732] | 412 | |
---|
| 413 | // Image infos |
---|
| 414 | if ($this->my_config['ecard_showinfos']) { |
---|
| 415 | if (isset($image_element['name'])) { |
---|
| 416 | $image_element['imginfos'] = $image_element['name']; |
---|
| 417 | if (isset($image_element['author'])) |
---|
| 418 | $image_element['imginfos'] .= ' ('.$image_element['author'].')'; |
---|
[8771] | 419 | } |
---|
[19732] | 420 | } |
---|
[8771] | 421 | |
---|
[19923] | 422 | $insert = array( |
---|
| 423 | 'numero' => $image_element['next_element_id'], |
---|
| 424 | 'nomexp' => $_POST['ecard_sender_name'], |
---|
| 425 | 'nomdest' => $_POST['ecard_recipient_name'], |
---|
| 426 | 'adrexp' => $_POST['ecard_sender_email'], |
---|
| 427 | 'adrdest' => $_POST['ecard_recipient_email'], |
---|
| 428 | 'sujet' => $_POST['ecard_subject'], |
---|
| 429 | 'message' => $_POST['ecard_message'], |
---|
| 430 | 'image' => $image_element['id'], |
---|
| 431 | 'date' => date("Y-m-d H:i:s"), |
---|
| 432 | 'duration' => (isset($_POST['ecard_validity']) ? $_POST['ecard_validity'] : $this->my_config['activ']), |
---|
| 433 | ); |
---|
[19732] | 434 | // TO DO : add valid date (end date or duration) / add number (increment number) / |
---|
[19923] | 435 | single_insert(ECARD_TABLE, $insert); |
---|
[8771] | 436 | |
---|
[19732] | 437 | // Complete the image_element array with Link for the ecard url to be added in the mail |
---|
| 438 | set_make_full_url(); |
---|
[19923] | 439 | $mail_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$image_element['next_element_id']); |
---|
| 440 | $image_element['mail_url'] = $mail_url; |
---|
[19732] | 441 | unset_make_full_url(); |
---|
[8771] | 442 | |
---|
[19732] | 443 | // Complete the image_element with the url to point to the image url |
---|
| 444 | set_make_full_url(); |
---|
[19923] | 445 | $image_element['picture_url'] = duplicate_picture_url( |
---|
| 446 | array( |
---|
| 447 | 'image_id' => $image_element['id'], |
---|
| 448 | 'image_file' => $image_element['file'] |
---|
| 449 | ), |
---|
| 450 | array('start') |
---|
[19732] | 451 | ); |
---|
| 452 | unset_make_full_url(); |
---|
[8771] | 453 | |
---|
[19923] | 454 | $mail_subject = htmlspecialchars_decode($this->parse( $this->my_config['subject_link'], $_POST)); |
---|
[19732] | 455 | |
---|
| 456 | switch($send_method) { |
---|
| 457 | case 0 : // text |
---|
| 458 | // Get the standard message (in admin param) and parse it with the informations |
---|
[19923] | 459 | $mail_message = stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_link'], $_POST, $image_element))); |
---|
| 460 | $mail_arg=array('from' => $_POST['ecard_sender_email'], |
---|
| 461 | 'subject' => $mail_subject, |
---|
| 462 | 'content' => $mail_message, |
---|
[19732] | 463 | 'content_format' => "text/plain", |
---|
| 464 | 'email_format' => "text/html" |
---|
| 465 | ); |
---|
| 466 | |
---|
| 467 | break; |
---|
| 468 | case 1 : // html |
---|
[19923] | 469 | $mail_message_HTML = stripslashes(htmlspecialchars_decode($this->parse($this->my_config['message_HTML'], $_POST, $image_element))); |
---|
| 470 | $mail_arg=array('from' => $_POST['ecard_sender_email'], |
---|
| 471 | 'subject' => $mail_subject, |
---|
| 472 | 'content' => $mail_message_HTML, |
---|
[19732] | 473 | 'content_format' => "text/html", |
---|
| 474 | 'email_format' => "text/html" |
---|
| 475 | ); |
---|
| 476 | break; |
---|
[8771] | 477 | } |
---|
[19732] | 478 | |
---|
| 479 | // Add the copy to expe if param. |
---|
[19923] | 480 | if (isset($_POST['ecard_copy'])) // send copy to sender |
---|
| 481 | $mail_arg['Bcc'] = array((isset($_POST['ecard_sender_email']) ? $_POST['ecard_sender_email'] : $user['email'])); |
---|
[19732] | 482 | |
---|
| 483 | // Send the mail |
---|
[19923] | 484 | pwg_mail($_POST['ecard_recipient_email'], $mail_arg); |
---|
[8771] | 485 | } |
---|
[19732] | 486 | |
---|
[19923] | 487 | $template->set_filenames(array('ecard_template' => ECARD_ROOT.'/template/ecard.tpl')); |
---|
| 488 | $template->concat('COMMENT_IMG', $template->parse('ecard_template', true)); |
---|
[19732] | 489 | } |
---|
[8771] | 490 | } |
---|
| 491 | } |
---|
| 492 | } |
---|
| 493 | } |
---|
[19923] | 494 | ?> |
---|