function email_quote($quote_id, $quote_template, $from, $to, $subject, $body, $cc = NULL, $bcc = NULL) { $CI =& get_instance(); $CI->load->helper('mailer/phpmailer'); $CI->load->helper('template'); $CI->load->helper('pdf'); $quote = generate_quote_pdf($quote_id, FALSE, $quote_template); $db_quote = $CI->mdl_quotes->where('ip_quotes.quote_id', $quote_id)->get()->row(); $message = nl2br(parse_template($db_quote, $body)); return phpmail_send($from, $to, $subject, $message, $quote, $cc, $bcc); }
function cache_templates($templatetitles) { global $con; foreach ($templatetitles as $templatetitle) { if (!parsed_is_current($templatetitle)) { parse_template($templatetitle); } if (file_exists(parsedtemplatepath($templatetitle))) { $con->templatecache[$templatetitle] = file_get_contents(parsedtemplatepath($templatetitle)); } } }
function index() { $data = array(); $data['page'] = 'about'; if ($this->sg_auth->is_logged_in()) { $data['logged_in'] = true; $uuid = $this->sg_auth->get_uuid(); $data['user_data'] = $this->simiangrid->get_user($uuid); } else { $data['logged_in'] = false; } parse_template('about', $data); }
/** * JETLEE * 与模板处理相关的辅助类 * * */ function subtplcheck($subfiles, $mktime, $tpl, $tplrefresh = 0) { if ($tplrefresh && ($tplrefresh == 1 || mt_rand(1, $tplrefresh) == 1)) { $subfiles = explode('|', $subfiles); foreach ($subfiles as $subfile) { $tplfile = $subfile . '.htm'; @($submktime = filemtime($tplfile)); if ($submktime > $mktime) { include_once APPPATH . 'libraries/Template.php'; parse_template($tpl); break; } } } }
function email_quote($quote_id, $quote_template, $from, $to, $subject, $body, $cc = null, $bcc = null, $attachments = null) { $CI =& get_instance(); $CI->load->helper('mailer/phpmailer'); $CI->load->helper('template'); $CI->load->helper('pdf'); $quote = generate_quote_pdf($quote_id, false, $quote_template); $db_quote = $CI->mdl_quotes->where('ip_quotes.quote_id', $quote_id)->get()->row(); $message = parse_template($db_quote, $body); $subject = parse_template($db_quote, $subject); $cc = parse_template($db_quote, $cc); $bcc = parse_template($db_quote, $bcc); $from = array(parse_template($db_quote, $from[0]), parse_template($db_quote, $from[1])); return phpmail_send($from, $to, $subject, $message, $quote, $cc, $bcc, $attachments); }
public static function select_html($selected = 0, $name = "userrole_id", $class = "select", $template = '%name%') { $roles = new UserRole(); $roles->get_iterated(); echo "<select name='{$name}' class='{$class}'>"; foreach ($roles as $role) { if ($selected == $role->id) { $selstr = " selected='selected'"; } else { $selstr = ""; } $format = parse_template($template, $role->stored); echo "<option value='{$role->id}' class='user_select'{$selstr}>" . $format . "</option>\n"; } echo "</select>"; }
$textwithlinks .= "</tr>\n"; } $textwithlinks .= "</table>\n"; } if ($cleantext != "" && isset($_REQUEST['pastebin'])) { $url = pastebin($cleantext, $name); $pastebin = "Pastebin url: <a href=\"{$url}\" target=\"_blank\">{$url}</a>"; } $cleantext = "<h1>translated for copy and paste</h1>\n<pre>{$cleantext}</pre>"; return array('PASTEBIN' => $pastebin, 'RESULTCLEAN' => $cleantext, 'RESULTHTML' => $textwithlinks); } $res['PASTEBIN'] = ""; /*initianlize vars for template*/ $res['RESULTHTML'] = ""; $res['RESULTCLEAN'] = ""; $res['TEXTAREA'] = getinfolog(); $res['TRANSLATOR'] = "http://springrts.com:8000"; $res['INFO'] = ""; if ($res['TEXTAREA'] != "") { limit(); $tmp = xmlrpcrequest($res['TRANSLATOR'], $res['TEXTAREA']); /* if (array_key_exists('faultString',$tmp)){ $res['INFO']="<h1>Warning: using local translator, as remote can't translate</h1>"; $res['TRANSLATOR']="http://abma.de:8000"; $tmp=xmlrpcrequest($res['TRANSLATOR'],$res['TEXTAREA']); }*/ $res = array_merge($res, parse_result($tmp, getVersion($res['TEXTAREA']))); } $res['ACTION'] = $_SERVER['SCRIPT_NAME']; echo parse_template("index.tpl", $res);
} } // Display most popular comments if (!empty($top_likes)) { echo "\t" . '<br><b class="cmtfont">' . $text['popular_cmts'] . ' Comment' . (count($top_likes) != '1' ? 's' : '') . ':</b>' . PHP_EOL; $variable = ''; foreach ($top_likes as $file) { $likes_array = parse_comments($file, array(), 'no'); } parse_template(array_values($likes_array), $top_cmts); } // Display comment count echo "\t" . '<br><b class="cmtfont">' . $text['showing_cmts'] . ' ' . ($script = $cmt_count == "1" ? '0 Comments:</b>' . PHP_EOL : display_count() . ':</b>' . PHP_EOL); // Display comments, if there are no comments display a note if (!empty($show_cmt)) { parse_template($show_cmt, $total_count); } else { echo "\t" . '<div style="margin: 16px 0px 12px 0px;" class="cmtdiv">' . PHP_EOL; echo "\t\t" . '<span class="cmtnumber"><img width="' . $icon_size . '" height="' . $icon_size . '" src="/img/first-comment.png"></span>' . PHP_EOL; echo "\t\t" . '<div style="height: ' . $icon_size . 'px;" class="cmtbubble">' . PHP_EOL; echo "\t\t\t" . '<b class="cmtnote cmtfont" style="color: #000000;">Be the first to comment!</b>' . PHP_EOL; echo "\t\t" . '</div>' . PHP_EOL; echo "\t" . '</div>' . PHP_EOL; } ?> <br><center> HashOver Comments · <?php if (!empty($show_cmt)) { echo "\t\t" . '<a href="http://' . $domain . '/hashover.php?rss=' . $page_url . '" target="_blank">RSS Feed</a> ·' . PHP_EOL;
function ajax_send_email() { $this->form_validation->set_rules('client_name', 'client name', 'trim|required|xss_clean'); $this->form_validation->set_rules('email_subject', 'email subject', 'trim|required|xss_clean'); $this->form_validation->set_rules('email_template', 'email template', 'trim|required|xss_clean'); $this->form_validation->set_rules('email_body', 'email body', 'trim|required|xss_clean'); $this->form_validation->set_error_delimiters('<p class="has-error"><label class="control-label">', '</label></p>'); if ($this->form_validation->run()) { $this->load->helper('template'); $quote_id = $this->input->post('quote_id'); $email_subject = $this->input->post('email_subject'); $email_body = $this->input->post('email_body'); $quote_data = $this->quotes_model->get_quote_details($quote_id); $message_body = parse_template($quote_data, $email_body); $quote_details = $this->quotes_model->previewquote($quote_id); $this->load->helper('pdf'); $pdf_quote = generate_pdf_quote($quote_details, false, NULL); $to = $quote_data->client_email; if (send_email($email_subject, $to, $message_body, $pdf_quote)) { $this->session->set_flashdata('success', 'The quote has been emailed successfully !!'); $response = array('success' => 1); } else { $response = array('success' => 0, 'errormsg' => 'Please set the company name and the company email in system settings first !!'); } } else { $this->load->helper('json_error'); $response = array('success' => 0, 'validation_errors' => json_errors()); } echo json_encode($response); }
/**********************/ /***********************/ /* PAGE CREATION */ /***********************/ /* choix du template principal : page normale (par defaut), pop-up ou page pour impression */ if (eregi("fen_pop", $_SERVER['QUERY_STRING'])) { $page['fen'] = "pop"; } if (eregi("fen_impression", $_SERVER['QUERY_STRING'])) { $page['fen'] = "impression"; } if (isset($page['fen']) and $page['fen'] == "pop") { $template = $tpl['general']['pop']; $html_code = parse_template(TPL_URL . $template, $index); } elseif (isset($_GET['fen']) and $_GET['fen'] == "pop") { $template = $tpl['general']['pop']; $html_code = parse_template(TPL_URL . $template, $index); } elseif (isset($page['fen']) and $page['fen'] == "ajax") { $html_code = $index['contenu']; } elseif (isset($page['fen']) and $page['fen'] == "impression") { $template = $tpl['general']['imprime']; $html_code = parse_template(TPL_URL . $template, $index); } else { $template = $tpl['general']['index']; $html_code = parse_template(TPL_URL . $template, $index); } echo $html_code; /***********************/
$parse_main['{width_preview_elements}'] = ''; $parse_main['{height_preview_elements}'] = ''; if (isset($config['width_preview_elements']) and $config['width_preview_elements'] != '') { $parse_main['{width_preview_elements}'] = 'value="' . $config['width_preview_elements'] . '" '; } elseif (isset($config['height_preview_elements']) and $config['height_preview_elements'] != '') { $parse_main['{height_preview_elements}'] = 'value="' . $config['height_preview_elements'] . '" '; } if (isset($error) and is_array($error)) { $parse_main['{error}'] = parse_template(get_template('info'), array("{type}" => 'error', "{title}" => "Ошибка!", "{text}" => implode("<br />", $error))); } else { $parse_main['{error}'] = ''; } $cachefile = $config['cachefile']; if (!file_exists($cachefile) or time() - @filemtime($cachefile) > $config['cache_time']) { touch($cachefile); //чтобы только один пользователь запускал подсчет list($size, $images_total, $images_h24) = get_dir_size($config['uploaddir']); $size = formatfilesize($size); file_put_contents($cachefile, "{$images_total}|{$size}|{$images_h24}"); } elseif (file_exists($cachefile)) { list($images_total, $size, $images_h24) = explode("|", file_get_contents($cachefile)); } $parse_main['{size}'] = $size; $parse_main['{images}'] = $images_total; $parse_main['{images24}'] = $images_h24; $parse_main['{site_http_path}'] = $config['site_url']; if (!$parse_main['{content}']) { $parse_main['{content}'] = ''; } echo parse_template(get_template('index'), $parse_main);
function template($file, $language = 'templates') { global $tplrefresh, $tpldir, $styleid, $timestamp; $tpldir = $tpldir ? $tpldir : 'templates/default'; $templateid = $styleid ? $styleid : 1; $tplfile = CYASK_ROOT . './' . $tpldir . '/' . $file . '.html'; $objfile = CYASK_ROOT . './askdata/templates/' . $templateid . '_' . $file . '.tpl.php'; if ($tplrefresh == 1 || $tplrefresh > 1 && substr($timestamp, -1) > $tplrefresh) { if (@filemtime($tplfile) > @filemtime($objfile)) { require_once CYASK_ROOT . './include/template.func.php'; parse_template($file, $language, $tpldir, $templateid); } } return $objfile; }
function index() { $data = array(); $data['page'] = 'about'; parse_template('about', $data); }
function template($tplfile, $fullpath = 0) { global $_SCONFIG; if (empty($fullpath)) { $filename = 'templates/' . $_SCONFIG['template'] . '/' . $tplfile . '.html.php'; $objfile = S_ROOT . './cache/tpl/tpl_' . $_SCONFIG['template'] . '_' . $tplfile . '.php'; $tplfile = S_ROOT . './' . $filename; } else { $filename = $tplfile; $objfile = str_replace('/', '_', $filename); $objfile = S_ROOT . './cache/tpl/tpl_' . $objfile . '.php'; $tplfile = S_ROOT . './' . $filename; } $tplrefresh = 1; if (file_exists($objfile)) { if (empty($_SCONFIG['tplrefresh'])) { $tplrefresh = 0; } else { if (@filemtime($tplfile) <= @filemtime($objfile)) { $tplrefresh = 0; } } } if ($tplrefresh) { include_once S_ROOT . './function/template.func.php'; parse_template($tplfile, $objfile); } return $objfile; }
function template($file, $tpldir = '') { global $setting; $tpldir = '' == $tpldir ? $setting['tpl_dir'] : $tpldir; $tplfile = TIPASK_ROOT . '/view/' . $tpldir . '/' . $file . '.html'; $objfile = TIPASK_ROOT . '/data/view/' . $tpldir . '_' . $file . '.tpl.php'; if ('default' != $tpldir && !is_file($tplfile)) { $tplfile = TIPASK_ROOT . '/view/default/' . $file . '.html'; $objfile = TIPASK_ROOT . '/data/view/default_' . $file . '.tpl.php'; } if (!file_exists($objfile) || @filemtime($tplfile) > @filemtime($objfile)) { require_once TIPASK_ROOT . '/lib/template.func.php'; parse_template($tplfile, $objfile); } return $objfile; }
/** * @param $id * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function send($id) { $invoice = $this->invoice->with('items', 'client')->getById($id); if ($invoice) { $settings = $this->setting->first(); $invoiceSettings = $this->invoiceSetting->first(); $invoice->totals = $this->invoice->invoiceTotals($id); $pdf = \PDF::loadView('invoices.pdf', compact('settings', 'invoice', 'invoiceSettings')); $data['emailBody'] = 'An invoice has been generated'; $data['emailTitle'] = 'An invoice has been generated'; $template = $this->template->where('name', 'invoice')->first(); if ($template) { $data_object = new \stdClass(); $data_object->invoice = $invoice; $data_object->settings = $settings; $data_object->client = $invoice->client; $data['emailBody'] = parse_template($data_object, $template->body); $data['emailTitle'] = $template->subject; } $data['logo'] = $settings->logo; \Mail::send(['html' => 'emails.layout'], $data, function ($message) use($pdf, $invoice, $settings) { $message->sender($settings->email, $settings->name); $message->to($invoice->client->email, $invoice->client->name); $message->subject('Invoice Generated'); $message->attachData($pdf->output(), 'invoice_' . $invoice->number . '_' . date('Y-m-d') . '.pdf'); }); \Flash::success('Invoice has been emailed to the client'); } return redirect('invoices'); }
<?php // Basic script that builds the entire page from the templates // Standard includes include "admin/config.php"; include "{$site_root}/libs/lib_db.php"; include "{$site_root}/libs/lib_templates.php"; include "{$site_root}/libs/lib_html.php"; // Log page access in database include "{$site_root}/logging/inc_logger.php"; // Connect to database $links_id = db_connect("mtbwales"); // ---------------------------------------------------------------- // Page code starts below // ---------------------------------------------------------------- $html = ""; // ---------------------------------------------------------------- // Page code ends above // ---------------------------------------------------------------- // Format any HTML that we created if (!empty($html)) { $html = pretty_html($html); } // Create local templates for the page create_local_template("nav_bar", ""); create_local_template("content_area", $html); // Define the content of the page and then display it to the browser parse_template("<tpl>whole_page</tpl>", $site_id);
function parse_template_file($filename) { return parse_template(file_get_contents($filename)); }
//если картинка одна - нафиг мульти if (isset($bb_img_arr)) { if (count($bb_img_arr) < 2) { $view_one_template = preg_replace("/\\[multi_img\\](.*?)\\[\\/multi_img\\]/isu", '', $view_one_template); } else { $view_summary_template = get_template('view_summary'); $parse_multi_img['{multi_pages}'] = implode("\n", $page_img_arr); $parse_multi_img['{multi_img}'] = implode("\n", $direct_img_arr); $parse_multi_img['{multi_bb_img}'] = implode("\n", $bb_img_arr); $parse_multi_img['{multi_html_img}'] = implode("\n", $html_img_arr); if (count($bb_prev_and_img_arr) > 1) { $parse_multi_img['{multi_bb_prev_and_img}'] = implode(' ', $bb_prev_and_img_arr); $parse_multi_img['{multi_html_prev_and_img}'] = implode(' ', $html_prev_and_img_arr); $parse_multi_img['[multi_img_prev]'] = ''; $parse_multi_img['[/multi_img_prev]'] = ''; } else { preg_match("/\\[multi_img_prev\\](.*?)\\[\\/multi_img_prev\\]/isu", $view_summary_template, $multi_img_prev_out); $parse_multi_img[$multi_img_prev_out['0']] = ''; } $parse_main['{content}'] .= parse_template($view_summary_template, $parse_multi_img); } } } else { $parse_main['{content}'] = ''; if (isset($_REQUEST['v']) and $_REQUEST['v']) { header('HTTP/1.0 404 Not Found'); $error[] = 'Изображение не найдено.'; } else { $error[] = 'Ошибка загрузки изображения.'; } }
echo '</div>'; } } else { ?> <div style="font-size:0.7em; float:right"> <a href="<?php echo SITE; ?> /index.php?a=edit&q=<?php echo htmlspecialchars($url); ?> " style="color:white">编辑</a> </div> <?php echo '<div style="padding-right:1em">'; echo parse_link(parse_template($content)); if ($special) { require __DIR__ . '/special.php'; } echo '</div>'; } ?> </td> </tr> <tr style="height:0"> <td style="height:0"> <footer>符文工房中文百科的全部文字在<a href="https://creativecommons.org/licenses/by-sa/3.0/deed.zh">知识共享 署名-相同方式共享 3.0</a>协议之条款下提供。</footer> </td> </tr> </table> </body>
/** * 消息模板渲染 * * @access public * @param int $message * 一条消息记录 * * @return string 消息内容 */ public function get_message_html($message = array()) { $this->lang->load('space/team_msg'); $lang_temp = $this->lang->language; if (isset($lang_temp['msg'][$message['type']])) { $template = $lang_temp['msg'][$message['type']]; $params = array('uid' => $message['uid'], 'fuid' => $message['fuid'], 'username' => $message['username'], 'fusername' => $message['fusername'], 'tid' => $message['ex_id'], 'object_name' => $message['obj_name']); if (is_array($template)) { $res = array(); foreach ($template as $k => $v) { $res[$k] = parse_template($v, $params); } return $res; } else { return parse_template($template, $params); } } else { return 'NULL'; } }
function send_quotation() { $this->load->helper('template'); $quotation_id = $this->input->post('quotation_id'); $email_subject = $this->input->post('email_subject'); $to = implode(',',$this->input->post('recipients')); $email_body = $this->input->post('message_body'); $message_body = parse_template($email_body); $quotation_pdf = $this->input->post('quotation_pdf'); if(send_email($email_subject, $to, $message_body,$quotation_pdf)) { echo "success"; } else{ echo "not sent"; } }
function subtplcheck($subfiles, $mktime, $tpl) { $subfiles = explode('|', $subfiles); foreach ($subfiles as $subfile) { $tplfile = S_ROOT . './' . $subfile . '.htm'; @($submktime = filemtime($tplfile)); if ($submktime > $mktime) { include_once S_ROOT . './source/function_template.php'; parse_template($tpl); break; } } }
function display_coupons($post, $template = '') { if (is_numeric($post)) { $post = get_post($post); } $curr_views = (int) (get_post_meta($post->ID, 'views', true) ? get_post_meta($post->ID, 'views', true) : 0); $new_views = $curr_views + 1; update_post_meta($post->ID, 'views', $new_views); $file = file_get_contents(PLUGIN_BASE . "/templates/" . (get_option("dv_coupon_template") != '' ? get_option("dv_coupon_template") : 'Mycoupons') . "/coupon_snippet.html"); $text = $post->post_content; $post_meta = get_post_meta($post->ID); $likes = $post_meta['likes'][0]; $dislikes = $post_meta['dislikes'][0]; $clicks = $post_meta['clicks'][0]; $verify_class = get_post_meta($post->ID, 'is_verified', true) == 'on' ? ' verified ' : ''; $store_data = wp_get_post_terms($post->ID, 'stores'); $feat_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); if (get_option("dv_use_timthumb") == 'true') { $feat_image = PLUGIN_DIR . "timthumb.php?h=120&w=120&src=" . $feat_image; } $store_url = $post_meta['coupon_store_url'][0]; /* * Checking if date has passed or not ! */ if (strcspn($post_meta['coupon_expiry_date'][0], '0123456789') != strlen($post_meta['coupon_expiry_date'][0])) { list($y, $m, $d) = explode("-", $post_meta['coupon_expiry_date'][0]); $date = mktime(0, 0, 0, $m, $d, $y); $today = mktime(0, 0, 0, date("m"), date("d"), date("Y")); if ($date < $today) { $expiry_msg = $post_meta['coupon_expiry_date'][0] . ' <span class="red">(Expired)</span>'; } else { $expiry_msg = $post_meta['coupon_expiry_date'][0]; } } else { $expiry_msg = $post_meta['coupon_expiry_date'][0]; } $tags = array("coupon_permalink" => get_permalink($post->ID), "coupon_code" => $post_meta['coupon_code'][0], "coupon_discount" => $post_meta['coupon_discount'][0], "coupon_title" => $post->post_title, "expiry_date" => $expiry_msg, "coupon_text_contents" => $post->post_excerpt, "post_id" => $post->ID, "featured_image" => $feat_image, "store_url" => get_option("dv_use_cloaked_url") == 'true' ? get_cloaked_url_by_actual($store_url) : $store_url, "coupon_views" => get_option('dv_display_clicks') == 'true' ? empty($clicks) ? '0 Clicks' : $clicks . ' Clicks' : '', "likes" => get_option('dv_display_likes') == 'true' ? empty($likes) ? '0' : $likes : '', "dislikes" => get_option('dv_display_dislikes') == 'true' ? empty($dislikes) ? '0' : $dislikes : '', "class_dislike" => get_option('dv_display_dislikes') == 'true' ? '' : 'hide', "class_like" => get_option('dv_display_likes') == 'true' ? '' : 'hide', "class_clicks" => get_option('dv_display_clicks') == 'true' ? '' : 'hide', "more_from_this_store" => site_url() . '?stores=' . $store_data->slug, "store_name" => $store_data->name, "verify_class" => $verify_class); return parse_template($file, $tags); }
function subtplcheck($subfiles, $mktime, $tpl) { global $_SC, $_SCONFIG; if ($_SC['tplrefresh'] && ($_SC['tplrefresh'] == 1 || mt_rand(1, $_SC['tplrefresh']) == 1)) { $subfiles = explode('|', $subfiles); foreach ($subfiles as $subfile) { $tplfile = S_ROOT . './' . $subfile . '.htm'; if (!file_exists($tplfile)) { $tplfile = str_replace('/' . $_SCONFIG['template'] . '/', '/default/', $tplfile); } @($submktime = filemtime($tplfile)); if ($submktime > $mktime) { include_once S_ROOT . './source/function_template.php'; parse_template($tpl); break; } } } }
$page['ms_show_form'] = MS_SHOW_FORM; if (!isset($_POST['season']) and MS_SEASON != '') { $page['value_season'] = MS_SEASON; } if (!isset($_POST['competition']) and MS_COMPETITION != '') { $page['value_competition'] = MS_COMPETITION; } if (!isset($_POST['round']) and MS_ROUND != '') { $page['value_round'] = MS_ROUND; } $included = 1; include create_path("match/standings.php"); unset($included); if ($page['ms_show_form'] == 0) { $page['season'] = array(); $page['competition'] = array(); $page['round'] = array(); } # link $page['form_action'] = convert_url("index.php?r=" . $lang['general']['idurl_match'] . "&v1=mini_standings"); $page['link_standings'] = convert_url("index.php?r=" . $lang['general']['idurl_match'] . "&v1=standings&v2=" . $page['value_competition'] . "&v3=" . $page['value_round'] . "&v4=" . $page['value_season']); # text $page['L_place'] = $lang['match']['place_ab']; $page['L_show_standings'] = $lang['match']['show_standings']; # template if (!isset($included_mini_standings) or $included_mini_standings == 0) { $page['fen'] = "ajax"; } $page['template'] = $tpl['match']['mini_standings']; $_SESSION['session_mini_standings'] = parse_template(TPL_URL . $page['template'], $page);
function checktplrefresh($maintpl, $subtpl, $timecompare, $templateid, $tpldir) { global $tplrefresh; if (empty($timecompare) || $tplrefresh == 1 || $tplrefresh > 1 && !($GLOBALS['timestamp'] % $tplrefresh)) { if (empty($timecompare) || @filemtime($subtpl) > $timecompare) { require_once DISCUZ_ROOT . './include/template.func.php'; parse_template($maintpl, $templateid, $tpldir); return TRUE; } } return FALSE; }
break; case "message": include_once "message.php"; break; case "update": include_once "update.php"; break; default: include_once "home.php"; } } else { include_once "lg_installation_fr.php"; include_once "../include/lg_general_fr.php"; if ($type_installation == "update") { include_once "update.php"; } else { include_once "home.php"; } } $index['version'] = VERSION; # text $index['L_realisation'] = $lang['general']['realisation']; $index['L_version'] = $lang['general']['version']; if ($type_installation == "update") { $index['L_installation'] = $lang['installation']['update']; } else { $index['L_installation'] = $lang['installation']['installation']; } $index['contenu'] = parse_template($page['template'], $page); echo parse_template("tpl/index.html", $index);
function parse_template($tpl, $data) { $file = file_get_contents($tpl['path']); $regex = preg_replace('(<nome>)', $data['name'], $file); $regex = preg_replace('(<message>)', $tpl['message'], $regex); return $regex; } function get_template($con) { $sql = "select * from template_email teem, messages mess where teem.messages_idmessage = mess.idmessage and mess.bl_active = 'S' and teem.bl_active = 'S' and teem.cd_template = 'BIRTHDAY'"; $tpl = $con->prepare($sql); $tpl->execute(); return $tpl->fetch(PDO::FETCH_ASSOC); } //Birthday $sql = "select name, DATE_FORMAT(dt_birthday, '%d/%m/%Y') as dt_birthday, email from user where bl_active = 's'"; $retUser = $con->prepare($sql); $retUser->execute(); $sysdate = date("d/m/Y"); echo $sysdate . "\n"; while ($linha = $retUser->fetch(PDO::FETCH_ASSOC)) { echo "dt_birthday:[" . $linha['dt_birthday'] . "]\n"; $split = explode("/", $linha['dt_birthday']); if (date("d") == $split[0] && date("m") == $split[1]) { echo "Happy Birthday name:[" . $linha['name'] . "]\n"; $dataTpl = get_template($con); echo "Template..:" . $dataTpl['path'] . "\n"; $tplParsed = parse_template($dataTpl, $linha); sendMail($tplParsed, $dataTpl, $linha); } }
delete_template("rbox1"); delete_template("rbox2"); delete_template("rbox3"); delete_template("main_col1"); delete_template("main_col2"); delete_template("main_col3"); delete_template("header"); delete_template("footer"); delete_template("middle"); delete_template("body"); delete_template("head"); // Now define some content for our templates //insert_template("lbox1","<!-- start of first left hand box -->\n<table width=100% border=1 valign=top>\n<tr>\n<td>\nBox 1\n</td>\n</tr>\n</table>\n<!-- end of first left hand box -->"); //insert_template("lbox2","<!-- start of second left hand box -->\n<table width=100% border=1 valign=top>\n<tr>\n<td>\nBox 2\n</td>\n</tr>\n</table>\n<!-- end of second left hand box -->"); //insert_template("lbox3","<!-- start of third left hand box -->\n<table width=100% border=1 valign=top>\n<tr>\n<td>\nBox 3\n</td>\n</tr>\n</table>\n<!-- end of third left hand box -->"); //insert_template("rbox1","<!-- start of first right hand box -->\n<table width=100% border=1 valign=top>\n<tr>\n<td>\nBox 1\n</td>\n</tr>\n</table>\n<!-- end of first right hand box -->\n"); //insert_template("rbox2","<!-- start of second right hand box -->\n<table width=100% border=1 valign=top>\n<tr>\n<td>\nBox 2\n</td>\n</tr>\n</table>\n<!-- end of second right hand box -->\n"); //insert_template("rbox3","<!-- start of third right hand box -->\n<table width=100% border=1 valign=top>\n<tr>\n<td>\nBox 3\n</td>\n</tr>\n</table>\n<!-- end of third right hand box -->\n"); //insert_template("main_col1","<!-- start of first column -->\n<td width=20%><tpl>lbox1</tpl><tpl>lbox2</tpl><tpl>lbox3</tpl>\n</td>\n<!-- end of first column -->\n"); //insert_template("main_col2","<!-- start of second column -->\n<td>\n<tpl>main_text</tpl>\n</td>\n<!-- end of second column -->\n"); //insert_template("main_col3","<!-- start of first column -->\n<td width=20%><tpl>rbox1</tpl><tpl>rbox2</tpl><tpl>rbox3</tpl>\n</td>\n<!-- end of first column -->\n"); //insert_template("header","<!-- start of header -->\n<tr>\n<td colspan=3>\nHeader\n</td>\n</tr>\n<!-- end of header -->\n"); //insert_template("footer","<!-- start of footer section -->\n<tr>\n<td colspan=3>\nFooter\n</td>\n</tr>\n"); //insert_template("middle","<!-- start of middle section -->\n<tr><tpl>main_col1</tpl><tpl>main_col2</tpl><tpl>main_col3</tpl>\n</tr>\n<!-- end of middle section -->\n"); //insert_template("body","<body>\n<table width=100% border=1><tpl>header</tpl><tpl>middle</tpl><tpl>footer</tpl>\n</table>\n<!-- start of footer text -->\n<center>That's all folks</center>\n<!-- end of footer text -->\n</body>\n"); //insert_template("head","<head>\n<title>This is a dynamic test page with nested tables</title>\n</head>\n"); // Define the main content $input_string = "<html><tpl>head</tpl><tpl>body</tpl></html>"; // Parse the template file parse_template($input_string);