/** * Created by PhpStorm. * User: csibi * Date: 2015.08.23. * Time: 20:59 */ function pwd($email, $pwd) { $input = $email . ";" . $pwd; $unique_salt = \runner::config("pwd_salt"); $unique_logarithm = \runner::config("pwd_logarithm"); $unique_method = \runner::config("pwd_method"); return \Routerunner\Crypt::crypter($input, null, null, 0, $unique_salt, $unique_logarithm, $unique_method); }
/** * Created by PhpStorm. * User: csibi * Date: 2015.02.18. * Time: 14:55 */ function logincrypt($email, $pwd, &$error = false) { $isOk = false; $unique_salt = \runner::config("pwd_salt"); $unique_logarithm = \runner::config("pwd_logarithm"); $unique_method = \runner::config("pwd_method"); $input = $email . ";" . $pwd; //var_dump(\Routerunner\Crypt::crypter($input, null, null, 0, $unique_salt, $unique_logarithm, $unique_method)); $SQL = "SELECT pwd, confirm_date FROM member WHERE email = :email"; if ($result = \Routerunner\Db::query($SQL, array(":email" => $email))) { $result = $result[0]; if (is_null($result["confirm_date"])) { $error = "User has not been confirmed!"; } $isOk = \Routerunner\Crypt::checker($input, $result["pwd"], $unique_salt, $unique_logarithm, $unique_method); if (!$isOk) { $error = "Incorrect password!"; } } else { $error = "User is not exists!"; } return $isOk; }
public static function submit($forms, &$errors = array(), &$return_SQL = false, &$return_params = false, &$values = array()) { if (!is_array($forms)) { $forms = array($forms); } foreach ($forms as $frm_name => $form) { $flashed = \Routerunner\Routerunner::$slim->flash($form->path . DIRECTORY_SEPARATOR . $form->formname); $params = \Routerunner\Bootstrap::$params; $halt = false; if (isset($flashed, $flashed['fields'])) { // check form fields $fields = $flashed['fields']; $form_fields = array_keys($form->fields); if (($_routerunner_form_id_index = array_search($form->id_field, $form_fields)) && ($_routerunner_form_nonce_index = array_search('_routerunner_form_nonce', $form_fields))) { unset($form_fields[$_routerunner_form_id_index], $form_fields[$_routerunner_form_nonce_index]); } if (\Routerunner\Common::arrDiff($fields, $form_fields)) { // exception $halt = true; } unset($flashed['fields']); // check form params /* if (\Routerunner\Common::arrDiff($flashed, $form->params)) { // exception $halt = true; } */ $form->params = $flashed; } else { $errors[] = 'Form not exists or the page has been refreshed!'; } $fid = false; if (!empty($form->fields[$form->id_field]['value'])) { $fid = $form->fields[$form->id_field]['value']; } if ($fid && !empty($form->fields['_routerunner_form_nonce']['value'])) { if (!isset($_SESSION['nonce-' . $fid]) || !\Routerunner\Crypt::checker($form->fields['_routerunner_form_nonce']['value'], $_SESSION['nonce-' . $fid])) { $errors[] = 'Error in form submit or data has been sent already!'; $halt = true; } } if (!$halt) { unset($form->fields[$form->id_field]); unset($form->fields['_routerunner_form_nonce']); unset($_SESSION['nonce-' . $fid]); } $succeed = false; if (!$halt) { $error_row = isset($form->params['error_format']) ? $form->params['error_format'] : '<p class="err">%s</p>' . PHP_EOL; $succeed = true; $submit_params = array(); if (isset($form->unset) && is_array($form->unset)) { foreach ($form->unset as $field) { if (isset($form->fields[$field], $form->fields[$field]["value"])) { $values[$field] = $form->fields[$field]["value"]; } elseif (isset($form->fields[$field])) { $values[$field] = $form->fields[$field]["value"]; } unset($form->fields[$field]); } } if (isset($form->set) && is_array($form->set)) { foreach ($form->set as $field => $value) { $values[$field] = $value; $form->fields[$field] = array("field" => $field, "value" => $value); } } foreach ($form->fields as $field => $field_param) { $field_succeed = true; $values[$field] = null; if (!isset($params[$field]) && isset($field_param['value'])) { $params[$field] = $field_param['value']; } $regexps = isset($field_param['regexp']) ? $field_param['regexp'] : false; if ($regexps && !is_array($regexps)) { $regexps = array($regexps); } elseif (!$regexps) { $regexps = array(); } if (!isset($params[$field]) || !$params[$field]) { if (isset($field_param['default_on_fail'], $field_param['default']) && $field_param['default_on_fail']) { $params[$field] = $field_param['default']; } elseif (isset($field_param['errormsg'])) { $errors[$field] = sprintf($error_row, $field_param['errormsg']); if (isset($field_param['mandatory']) && $field_param['mandatory']["value"] === true) { if (isset($field_param['mandatory']['msg']) && !isset($errors[$field])) { $errors[$field] = sprintf($error_row, $field_param['mandatory']['msg']); } $field_succeed = false; $regexps = array(); } } elseif (isset($field_param['mandatory']) && $field_param['mandatory']["value"] === true) { if (isset($field_param['mandatory']['msg']) && !isset($errors[$field])) { $errors[$field] = sprintf($error_row, $field_param['mandatory']['msg']); } $field_succeed = false; $regexps = array(); } } foreach ($regexps as $regexp) { $isOk = false; if (is_array($regexp["value"])) { foreach ($regexp["value"] as $regexp_key => $regexp_value) { $pattern = "~" . trim($regexp_value, "/~ ") . "~"; if (isset($regexp['options'])) { $pattern .= is_array($regexp["options"]) && isset($regexp["options"][$regexp_key]) ? $regexp["options"][$regexp_key] : $regexp["options"]; } if (preg_match($pattern, $params[$field])) { $isOk = true; } } } else { $pattern = "~" . trim($regexp["value"], "~/ ") . "~"; if (isset($regexp['options'])) { $pattern .= $regexp['options']; } $isOk = preg_match($pattern, $params[$field]); } if (isset($params[$field]) && !$isOk) { if (isset($regexp['msg']) && !isset($errors[$field])) { $errors[$field] = sprintf($error_row, $regexp['msg']); } $field_succeed = false; } } if ($field_succeed) { if (isset($params[$field]) && isset($field_param["field"])) { if (isset($field_param['function']) && function_exists($field_param['function'])) { $fn = $field_param['function']; $submit_params[$field] = $fn($params[$field]); } else { $submit_params[$field] = $params[$field]; } $values[$field] = $submit_params[$field]; } } else { $succeed = false; } } } if ($succeed) { $method = isset($form->params['xmethod']) ? $form->params['xmethod'] : $form->params['method']; if (isset($form->params[$method . '_sql'])) { $sql = $form->params[$method . '_sql']; if (preg_match('/\\:[a-z0-9]+/im', $sql)) { // named parameters array_walk($sql_params, function ($value, &$key) { if (substr($key, 0, 1) != ':') { $key = ':' . $key; } }); } } else { $from = isset($form->params['from']) ? $form->params['from'] : $form->class; $from = \Routerunner\Common::dbField($from); $sql_params = array(); if ($method === 'post') { $sql = 'INSERT INTO ' . $from . ' ('; $fields = array(); foreach ($submit_params as $field => $submit_value) { $field_param = $form->fields[$field]; if (isset($params[$field]) && (!isset($field_param['fixed']) || $field_param['fixed'] !== true) && (!isset($field_param['field']) || $field_param['field'] !== false)) { $_field = isset($field_param['field']) ? $field_param['field'] : $field; $fields[] = \Routerunner\Common::dbField($_field); $param_key = \Routerunner\Common::dbField($_field, ':', '', '.', '` .', '.'); $sql_params[$param_key] = $submit_value; /* if (isset($submit_params[$field])) { $sql_params[$param_key] = $submit_params[$field]; } else { $sql_params[$param_key] = $params[$field]; } */ } } $sql .= implode(', ', $fields) . ') VALUES (' . implode(', ', array_keys($sql_params)) . ')'; } elseif ($method == 'put') { $sql = 'UPDATE ' . $from . ' SET '; $fields = array(); foreach ($submit_params as $field => $submit_value) { $field_param = $form->fields[$field]; if (isset($params[$field]) && (!isset($field_param['fixed']) || $field_param['fixed'] !== true) && (!isset($field_param['field']) || $field_param['field'] !== false)) { $_field = isset($field_param['field']) ? $field_param['field'] : $field; $row = \Routerunner\Common::dbField($_field) . ' = '; $param_key = \Routerunner\Common::dbField($_field, ':', '', '.', '` .', '.'); $row .= $param_key; $sql_params[$param_key] = $submit_value; /* if (isset($submit_params[$field])) { $sql_params[$param_key] = $submit_params[$field]; } else { $sql_params[$param_key] = $params[$field]; } */ $fields[] = $row; } } $sql .= implode(', ', $fields) . ' WHERE '; if (isset($form->params['condition'])) { $conditions = $form->params['condition']; while ($condition = array_shift($conditions)) { if (!is_array($condition)) { $condition = array($condition); } $add_condition = true; if (isset($condition[1]) && is_array($condition[1])) { foreach ($condition[1] as $condition_field => $condition_value) { if (isset($form->fields[$condition_value]['value'])) { $sql_params[$condition_field] = $form->fields[$condition_value]['value']; } else { $add_condition = false; } } } elseif (isset($condition[1])) { $sql_params[] = $condition[1]; } else { $add_condition = false; } if ($add_condition) { $sql .= $condition[0]; if (count($conditions) && isset($condition[2])) { $sql .= ' ' . $condition[2] . ' '; } } } } else { // exception } } elseif ($method == 'delete') { $sql = 'DELETE FROM ' . $from . ' WHERE '; if (isset($form->params['condition'])) { $conditions = $form->params['condition']; while ($condition = array_shift($conditions)) { if (!is_array($condition)) { $condition = array($condition); } $add_condition = true; if (isset($condition[1]) && is_array($condition[1])) { foreach ($condition[1] as $condition_field => $condition_value) { if (isset($form->fields[$condition_value]['value'])) { $sql_params[$condition_field] = $form->fields[$condition_value]['value']; } else { $add_condition = false; } } } elseif (isset($condition[1])) { $sql_params[] = $condition[1]; } else { $add_condition = false; } if ($add_condition) { $sql .= $condition[0]; if (count($conditions) && isset($condition[2])) { $sql .= ' ' . $condition[2] . ' '; } } } } elseif (isset($submit_params) && $submit_params) { $fields = array(); foreach ($submit_params as $field => $submit_value) { $field_param = $form->fields[$field]; if (isset($params[$field]) && (!isset($field_param['fixed']) || $field_param['fixed'] !== true) && (!isset($field_param['field']) || $field_param['field'] !== false)) { $_field = isset($field_param['field']) ? $field_param['field'] : $field; $row = \Routerunner\Common::dbField($_field) . ' = '; $param_key = \Routerunner\Common::dbField($_field, ':', '', '.', '` .', '.'); $row .= $param_key; $sql_params[$param_key] = $submit_value; /* if (isset($submit_params[$field])) { $sql_params[$param_key] = $submit_params[$field]; } else { $sql_params[$param_key] = $params[$field]; } */ $fields[] = $row; } } $sql .= implode(' AND ', $fields); } else { // exception } } } if ($return_SQL || $return_params) { $return_SQL = $sql; $return_params = $sql_params; } else { \Routerunner\Db::begin_transaction(); if ($method === 'post') { $succeed = \Routerunner\Db::insert($sql, $sql_params); } else { \Routerunner\Db::query($sql, $sql_params); } \Routerunner\Db::commit(); } } } return $succeed; }
<?php /** * Created by PhpStorm. * User: csibi * Date: 2015.07.13. * Time: 11:38 */ $return_SQL = true; if ($succeed = \Routerunner\Form::submit($runner->form, $errors, $return_SQL, $return_params)) { $saved = false; if (isset($return_params[":nonce"], $_SESSION["nonce"]) && \Routerunner\Crypt::checker($return_params[":nonce"], $_SESSION["nonce"])) { unset($_SESSION["nonce"]); $pwd_change = false; if ($return_params[":pwd"] && $return_params[":pwd_confirm"] && $return_params[":pwd"] === $return_params[":pwd_confirm"]) { $return_params[":pwd"] = pwd($return_params[":email"], $return_params[":pwd"]); $pwd_change = true; } elseif (($return_params[":pwd"] || $return_params[":pwd_confirm"]) && $return_params[":pwd"] !== $return_params[":pwd_confirm"]) { $errors["pwd_confirm"] = "Passwords not equals!"; } $is_insert = false; $name = $return_params[":name"]; $usergroup = $return_params[":usergroup"]; if (strpos($return_SQL, "INSERT") === 0) { $return_SQL = str_replace(array("`nonce`, ", "`id`, ", ", `usergroup`", ", `name`", ", `pwd_confirm`"), "", $return_SQL); $return_SQL = str_replace(array(":nonce, ", ":id, ", ", :usergroup", ", :name", ", :pwd_confirm"), "", $return_SQL); if (!$pwd_change) { $return_SQL = str_replace(", `pwd`", "", $return_SQL); $return_SQL = str_replace(", :pwd", "", $return_SQL); } unset($return_params[":id"]);
* User: csibi * Date: 2015.07.13. * Time: 11:27 */ $debug = 1; $method = 'post'; if (isset($_GET["id"])) { $SQL = "SELECT id FROM e_cron WHERE start IS NOT NULL AND finish IS NULL AND id = :id"; if (\db::query($SQL, array(":id" => $_GET["id"]))) { $method = 'put'; } } $form = array('method' => 'post', 'xmethod' => $method, 'name' => 'e_cron', 'error_format' => '<p class="err">%s</p>' . PHP_EOL, 'from' => 'e_cron', 'condition' => array(array('e_cron.id = :id', array(':id' => 'id'), 'AND'))); $nonce = uniqid(rand(0, 1000000)); if (!isset($_POST["nonce"])) { $_SESSION["nonce"] = \Routerunner\Crypt::crypter($nonce); } $value = array("campaign" => "", "test_address" => "", "limit_per_period" => 100, "period" => 3600, "start" => "", "finish" => ""); if (isset($_GET["id"]) && is_numeric($_GET["id"]) && $_GET["id"] > 0) { $SQL = "SELECT campaign, test_address, limit_per_period, period, start, finish FROM `e_cron` WHERE id = ?"; if ($result = \db::query($SQL, array($_GET["id"]))) { $value = array_merge($value, $result[0]); } } if (isset($_GET["cid"]) && is_numeric($_GET["cid"])) { $SQL = "SELECT id, label, category, active FROM `e_campaign` WHERE id = ?"; if ($result = \db::query($SQL, array($_GET["cid"]))) { $campaign_data = $result[0]; } } $input = array('id' => array('type' => 'hidden', 'field' => 'id', 'value' => isset($_GET["id"]) ? $_GET["id"] : ""), 'campaign' => array('type' => 'hidden', 'field' => 'campaign', 'value' => $campaign_data["id"]), 'nonce' => array('type' => 'hidden', 'field' => 'nonce', 'value' => $nonce), 'label' => array('type' => 'label', 'field' => 'label', 'label' => 'Campaign label', 'input-id' => 'frm-label', 'class' => '', 'value' => $campaign_data["label"]), 'category' => array('type' => 'label', 'field' => 'category', 'label' => 'Campaign category', 'input-id' => 'frm-category', 'class' => '', 'value' => $campaign_data["category"]), 'active' => array('type' => 'label', 'field' => 'active', 'label' => 'Is active?', 'input-id' => 'frm-active', 'class' => '', 'value' => $campaign_data["active"] == "1" ? "yes" : "no"), 'start' => array('type' => 'label', 'field' => 'start', 'label' => 'Job started', 'input-id' => 'frm-start', 'class' => '', 'value' => $value["start"]), 'finish' => array('type' => 'label', 'field' => 'finish', 'label' => 'Job finished', 'input-id' => 'frm-finish', 'class' => '', 'value' => $value["finish"]));
$pos++; } } if ($e) { $e_camp[] = urldecode($e); } $method = $e_camp[0]; $deliver = hexdec($e_camp[1]); $hash = stripslashes($e_camp[2]); $hashb64 = base64_decode(str_replace(',', '/', $e_camp[2])); $click_url = ""; if (isset($e_camp[3])) { $click_url = $e_camp[3]; } $SQL = "SELECT address_id, uhash FROM e_delivered WHERE id = :deliver"; if (($delivered = \db::query($SQL, array(":deliver" => $deliver))) && isset($delivered[0]["uhash"]) && (\Routerunner\Crypt::checker($delivered[0]["uhash"], $hash) || \Routerunner\Crypt::checker($delivered[0]["uhash"], $hashb64))) { $stat_params = array(":date" => time(), ":deliver_id" => $deliver, ":method" => $method, ":click" => $click_url, ":referer" => isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : (isset($_SERVER["HTTP_FROM"]) ? $_SERVER["HTTP_FROM"] : null), ":ip" => $_SERVER["REMOTE_ADDR"], ":ua" => $_SERVER["HTTP_USER_AGENT"], ":cookie" => print_r($_COOKIE, true), ":server" => print_r($_SERVER, true)); $SQL_stat = "INSERT INTO e_stat (date, deliver_id, method, click, ip, useragent, referer, cookie, server) VALUES (:date, :deliver_id, :method, :click, :ip, :ua, :referer, :cookie, :server)"; \db::insert($SQL_stat, $stat_params); if ($method == "unsubscribe" && isset($delivered[0]["address_id"])) { $SQL_unsubscribe = "UPDATE e_subscriber SET unsubscribe = :time WHERE id = :id"; \db::query($SQL_unsubscribe, array(":time" => time(), ":id" => $delivered[0]["address_id"])); $isOk = false; $SQL_check = "SELECT unsubscribe FROM e_subscriber WHERE id = :id"; if (($check_result = \db::query($SQL_check, array(":id" => $delivered[0]["address_id"]))) && isset($check_result[0]["unsubscribe"]) && !is_null($check_result[0]["unsubscribe"])) { $isOk = true; } if ($isOk) { $url = \runner::config("BASE") . "unsubscribe/success"; } else { $url = \runner::config("BASE") . "unsubscribe/error";
* Time: 14:55 */ $post = $_POST; $msg = ""; $SQL = "SELECT id, email, confirm_date, licence FROM member WHERE email = :email"; if ($result = \Routerunner\Db::query($SQL, array(":email" => $post["email"]))) { $user = $result[0]; if (is_null($user["confirm_date"])) { $msg = "User has not been confirmed!"; } if (!$msg) { // confirm generálás $secret = uniqid(md5(uniqid('', true))); $confirm = 'forgotten/' . implode('/', $user) . '/' . $secret; $expire = time() + 2 * 24 * 60 * 60; $confirm_hash = \Routerunner\Crypt::crypter($confirm, $expire, $user['id'], 0, $secret); $path = runner::config("BASE") . 'admin/forgotten/?' . $user['id'] . '/' . $secret . '/' . $confirm_hash; $user["confirm_code"] = $path; if ($result = \mail::mailer("/mail/forgotten", $user, null)) { $debug = 1; } else { $msg = "E-mail cannot be sent!"; } } } else { $msg = "User is not exists!"; } if ($msg) { echo '<div class="alert alert-forgotten alert-danger">' . $msg . '</div>'; } else { echo '<div class="alert alert-forgotten alert-success">New password confirmation has been sent to your e-mail address!</div>';
public static function load($context, $model, &$pager = array()) { $from = isset($context["from"]) ? $context["from"] : $model->class; $select = array(); $predefined = array('route', 'class', 'reference', 'table_from', 'table_id', 'permission', 'permissions', 'rewrite', 'url', 'override', 'states', 'owner', 'group', 'other', 'parent', 'prev'); foreach (array_keys(get_object_vars($model)) as $var) { if (!in_array($var, $predefined)) { $select[$var] = '`' . $var . '`'; } } if (isset($context["select"]) && is_array($context["select"])) { foreach ($context["select"] as $var => $field) { if (isset($select[$var])) { $select[$var] = $field; } } } $leftJoin = isset($context["leftJoin"]) ? $context["leftJoin"] : false; $where = isset($context["where"]) ? $context["where"] : false; $session = false; $change_id = false; if (isset($where["session"])) { $session = $where["session"]; unset($where["session"]); } if (isset($where["change_id"])) { $change_id = $where["change_id"]; unset($where["change_id"]); } if (isset($where["silent"])) { unset($where["silent"]); } $orderBy = isset($context["orderBy"]) ? $context["orderBy"] : current($select); $groupBy = isset($context["groupBy"]) ? $context["groupBy"] : false; $limit = isset($context["limit"]) ? $context["limit"] : false; $offset = isset($context["offset"]) ? $context["offset"] : false; $random = isset($context["random"]) ? $context["random"] : false; $pk = isset($context["primary_key"]) ? $context["primary_key"] : false; $params = array(); if (\runner::stack("model_create") && isset($model->route, \runner::stack("model_create")["route"]) && $model->route == \runner::stack("model_create")["route"]) { $load = array(); } else { if (isset($where['sections'])) { unset($where['sections']); } if (isset($context["SQL"], $context["SQLhash"]) && \Routerunner\Crypt::checker($context["SQL"], $context["SQLhash"], "SQLchecked")) { $SQL = $context["SQL"]; $params = $where; } else { $SQL = self::SQL_creator($select, $from, $pk, $leftJoin, $where, $params, $orderBy, $groupBy, $limit, $offset); } if (\runner::now("debug::model->load") === true) { \runner::now("debug::model->load", false); echo "debug::model->load" . PHP_EOL . $SQL . PHP_EOL . print_r($params, true); } $load = \Routerunner\Db::query($SQL, $params); } if ((!is_array($load) || !count($load)) && (isset($context['blank']) && $context['blank'] === true)) { foreach ($select as $field => &$value) { $value = ''; } $load = array($select); } if (isset($model->override) && is_array($model->override) && count($model->override)) { if ($load && isset($load[0])) { $load[0] = array_merge($load[0], $model->override); } elseif ($load) { $load = array_merge($load, $model->override); } else { $load = array($model->override); } } if (is_array($load) && count($load) > 0) { $models = self::set_models($load, $model, $pk, $from, $random, $session); $model = $models; if (isset($context["force_list"]) && $context["force_list"] === true && !is_array($model)) { $model = array($model); } elseif (isset($context["force_view"]) && $context["force_view"] === true && is_array($model)) { $model = array_shift($model); } if (isset($context['pager']) && is_array($context['pager'])) { foreach ($context['pager'] as $pager_section => $pager_params) { if (is_array($pager_params)) { $pager_SQL_params = array(); //$pager_params['select'] = (isset($pager_params['select'])) ? $pager_params['select'] : array('c' => 'COUNT(*)'); $pager_params['primary_key'] = isset($pager_params['primary_key']) ? $pager_params['primary_key'] : $pk; $pager_params['select'] = isset($pager_params['select']) ? $pager_params['select'] : array($pager_params['primary_key'] => 'id'); $pager_params['from'] = isset($pager_params['from']) ? $pager_params['from'] : $from; $pager_params['leftJoin'] = isset($pager_params['leftJoin']) ? $pager_params['leftJoin'] : $leftJoin; $pager_params['where'] = isset($pager_params['where']) ? $pager_params['where'] : $where; $pager_params['orderBy'] = isset($pager_params['orderBy']) ? $pager_params['orderBy'] : $orderBy; $pager_params['groupBy'] = isset($pager_params['groupBy']) ? $pager_params['groupBy'] : $groupBy; $pager_params['limit'] = isset($pager_params['limit']) ? $pager_params['limit'] : false; $pager_params['offset'] = isset($pager_params['offset']) ? $pager_params['offset'] : $offset; $pager_SQL = self::SQL_creator($pager_params['select'], $pager_params['from'], $pager_params['primary_key'], $pager_params['leftJoin'], $pager_params['where'], $pager_SQL_params, $pager_params['orderBy'], $pager_params['groupBy'], $pager_params['limit'], $pager_params['offset']); if ($result = \Routerunner\Db::query($pager_SQL, $pager_SQL_params)) { $pager[$pager_section] = count($result); } else { $pager[$pager_section] = 0; } } else { $pager[$pager_section] = $pager_params; } } } if (\runner::now("debug::model->return") === true) { \runner::now("debug::model->return", false); var_dump("debug::model->return", $model); } return $model; } elseif (\runner::config('mode') == 'backend' && ($model_create = \runner::stack("model_create")) && $model && isset($model_create["class"]) && substr(get_class($model), strrpos(get_class($model), "\\") + 1) == $model_create["class"]) { $return = true; if (is_array($model_create)) { $created_model = $model; if (is_array($model)) { $created_model = $model[0]; } foreach ($model_create as $var_name => $var_value) { if (!isset($created_model->{$var_name}) || $created_model->{$var_name} != $var_value) { $return = false; } } } if (!$return) { $model = null; } return $model; } else { if (\runner::now("debug::model->return") === true) { \runner::now("debug::model->return", false); var_dump("debug::model->return", null); } return null; } }
} foreach ($addresses as $address) { if ($sent_email <= $limit && isset($address["email"]) && preg_match("~^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\$~i", trim($address["email"]))) { $address["email"] = trim($address["email"]); $domain = substr($address["email"], strpos($address["email"], "@")); $send_ok = true; if (isset($domain_limits[$domain])) { $domain_sent[$domain]++; if ($domain_sent[$domain] > $domain_limits[$domain]) { $send_ok = false; } } if ($send_ok) { // prepare mail $unique = uniqid(); $hash = str_replace('/', ',', base64_encode(\Routerunner\Crypt::crypter($unique))); if (isset($address["id"])) { $params_deliver = array(":cron" => $cron["cron_id"], ":address" => $address["id"], ":date" => time(), ":hash" => $unique); $delivered = \db::insert($SQL_deliver, $params_deliver); } else { $delivered = 0; } /* $address["open"] = ""; $address["click"] = \runner::config("BASE"); $address["unsubscribe"] = \runner::config("BASE") . "unsubscribe/"; */ $address["open"] = "<img alt='" . \runner::config("SITE") . "' src='" . \runner::config("BASE") . "nl/open/" . dechex($delivered) . "/" . $hash . "/" . "' style='display: none; width: 0; height: 0;'/>"; $address["click"] = \runner::config("BASE") . "nl/click/" . dechex($delivered) . "/" . $hash . "/"; $address["unsubscribe"] = \runner::config("BASE") . "nl/unsubscribe/" . dechex($delivered) . "/" . $hash . "/"; $mail_content = urldecode($mail_raw);
* Date: 2013.11.15. * Time: 11:35 */ /* // model parameters $model = "menu"; $from = "cs_menu"; $select = array("label"); $where = array("cs_menu_id > ?" => 1); $orderBy = 'cs_menu_id DESC'; $limit = 5; // SQL $SQL = "SELECT label FROM cs_menu ORDER BY cs_menu_id"; */ /* $from = \runner::config('PREFIX') . 'models'; $orderBy = \Routerunner\Routerunner::BY_TREE; $where = array( 'parent' => array('reference' => $runner->context['reference']), ); */ $SQL = <<<SQL SELECT models.reference, models.model_class, models.table_id FROM `{PREFIX}models` AS models LEFT JOIN `{PREFIX}model_trees` AS trees ON trees.reference = models.reference WHERE trees.parent_ref = :reference SQL; $SQLhash = \Routerunner\Crypt::crypter($SQL, null, null, 0, 'SQLchecker'); $where = array(':reference' => $runner->context['reference']); $primary_key = 'reference'; $force_list = true;
$crypt_hash = $result_Crypt[0]['hash']; $confirm = 'forgotten/' . implode('/', $user) . '/' . $secret; if (\Routerunner\Crypt::checker($confirm, $crypt_hash, $secret)) { //\Routerunner\Crypt::delete_crypt($crypt_hash, $confirm); $alphabet = "abcdefghijklmnpqrstuwxyzABCDEFGHIJKLMNPQRSTUWXYZ123456789"; $pwd = ""; for ($i = 0; $i < 8; $i++) { $n = rand(0, strlen($alphabet) - 1); $pwd .= substr($alphabet, $n, 1); } $user['pwd'] = $pwd; $input = $user["email"] . ";" . $pwd; $unique_salt = "4pp3t1z3r"; $unique_logarithm = "09"; $unique_method = "CRYPT_BLOWFISH"; $pwd_to_store = \Routerunner\Crypt::crypter($input, null, null, 0, $unique_salt, $unique_logarithm, $unique_method); if (\Routerunner\Mail::mailer('/mail/newpwd', $user)) { $SQL = 'UPDATE member SET pwd = :pwd WHERE id = :id AND email = :email'; $params = array(':pwd' => $pwd_to_store, ':id' => $user['id'], ':email' => $user['email']); \db::query($SQL, $params); $isOk = true; } } } } } if ($isOk) { \runner::now("newpwd", "succeed"); } else { \runner::now("newpwd", "error"); }