// You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. require_once 'lib/global.php'; require_once 'template.php'; require_once 'utility.php'; $functions = array('stats' => '_xStatsShow', 'forgot' => '_xForgotPasswordShow', 'remind' => '_xForgotPasswordConfirm', 'confirm' => '_xForgotPasswordConfirmed'); prepare_request(); $t = new Template(); $t->AssignByRef('g_config', $C); $t->AssignByRef('g_request', $_REQUEST); if (!$C['flag_allow_login']) { $t->Display('trade-stats-disabled.tpl'); exit; } $r = $_REQUEST['r']; if (isset($functions[$r])) { call_user_func($functions[$r]); } else { _xStatsLoginShow(); } function _xStatsLoginShow() { global $t, $C; $t->Display('trade-stats-login.tpl');
function trade_add(&$data, $registered = false) { global $C; require_once 'dirdb.php'; require_once 'mailer.php'; require_once 'template.php'; $t = new Template(); $t->AssignByRef('g_config', $C); $t->AssignByRef('g_trade', $data); $db = new TradeDB(); $db->Add(trade_prepare_data($data)); // Create stats file $packed_record = trade_packed_record(); $fp = fopen(DIR_TRADE_STATS . "/{$data['domain']}", 'w'); for ($i = 0; $i < HOURS_PER_DAY + MINUTES_PER_DAY; $i++) { fwrite($fp, $packed_record, RECORD_SIZE_STATS); } fclose($fp); @chmod(DIR_TRADE_STATS . "/{$data['domain']}", 0666); // Create log files file_create(DIR_TRADE_STATS . "/{$data['domain']}-clicks"); file_create(DIR_TRADE_STATS . "/{$data['domain']}-history"); file_create(DIR_TRADE_STATS . "/{$data['domain']}-in"); file_create(DIR_TRADE_STATS . "/{$data['domain']}-out"); if ($data['flag_confirm']) { require_once 'textdb.php'; $data['confirm_id'] = md5(uniqid(rand(), true)); $confdb = new RegisterConfirmsDB(); $confdb->Add(array('confirm_id' => $data['confirm_id'], 'domain' => $data['domain'], 'timestamp' => time())); $m = new Mailer(); $m->Mail('email-register-confirm.tpl', $t, $data['email'], $data['email']); } else { if ($C['flag_register_email_user'] && !string_is_empty($data['email']) && $registered) { $m = new Mailer(); $m->Mail('email-register-complete.tpl', $t, $data['email'], $data['email']); } if ($C['flag_register_email_admin']) { $m = new Mailer(); $m->Mail('email-register-admin.tpl', $t, $C['email_address'], $C['email_name']); } } }
function tbxAdministratorEmail($administrator, $xtable, $template = null) { $DB = GetDB(); if (empty($template)) { $template = array(); $template['subject'] = Request::Get('subject'); $template['message'] = Request::Get('message'); } $t = new Template(); $t->Assign('g_config', Config::GetAll()); $t->AssignByRef('g_administrator', $administrator); $mailer = new Mailer(); $mailer->Mail($template, $t, $administrator['email'], $administrator['name']); }
function _xTradesEmail() { global $C, $compiler; require_once 'mailer.php'; $v =& Validator::Get(); $v->Register($_REQUEST[MAILER_KEY_SUBJECT], VT_NOT_EMPTY, "The 'Subject' field is required"); $v->Register($_REQUEST[MAILER_KEY_BODY], VT_NOT_EMPTY, "The 'Body' field is required"); if (!$v->Validate()) { return JSON::Warning(array(JSON_KEY_MESSAGE => 'E-mail could not be sent; please fix the following items', JSON_KEY_WARNINGS => $v->GetErrors())); } require_once 'dirdb.php'; require_once 'template.php'; require_once 'compiler.php'; $_REQUEST[MAILER_KEY_SUBJECT] = $compiler->Compile($_REQUEST[MAILER_KEY_SUBJECT]); $_REQUEST[MAILER_KEY_BODY] = $compiler->Compile($_REQUEST[MAILER_KEY_BODY]); $mailer = new Mailer(); $db = new TradeDB(); $t = new Template(); $t->AssignByRef('g_config', $C); foreach (explode(',', $_REQUEST['domain']) as $domain) { $trade = $db->Retrieve($domain); if (!empty($trade) && !string_is_empty($trade['email'])) { $t->AssignByRef('g_trade', $trade); $mailer->Mail($_REQUEST, $t, $trade['email'], string_is_empty($trade['nickname']) ? $trade['email'] : $trade['nickname']); } } JSON::Success('E-mail message has been sent to the selected trades'); }