/** * 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); }
public function __construct($runner, $formname, $params, &$repost_form_after_submit = false) { $this->runner = $runner; $this->fid = str_replace('.', '_', uniqid('', true)); $this->path = $runner->path . $runner->route; $this->formname = $formname; $this->id_field .= str_replace('/', '_', $this->path . '/' . $this->formname); if (\Routerunner\Routerunner::$slim->request) { $request_params = \Routerunner\Routerunner::$slim->request->params(); if (!empty($request_params[$this->id_field])) { $this->fid = $request_params[$this->id_field]; } $form_method = $repost_form_after_submit && ($repost_form_after_submit === 'put' || $repost_form_after_submit === 'get' || $repost_form_after_submit === 'post' || $repost_form_after_submit === 'delete') ? $repost_form_after_submit : \Routerunner\Routerunner::$static->request; switch ($form_method) { case "put": case "post": case "delete": $method = $request_params && (isset($request_params[$formname]) || isset($request_params["submit"]) && isset($params["input"]["submit"]["value"]) && $request_params["submit"] == $params["input"]["submit"]["value"]) ? 'submit' : 'form'; break; default: $method = 'form'; } $repost_form_after_submit = $method; $this->view = trim($runner->route, '\\') . '.' . $formname . '.' . $method . '.php'; if (!file_exists($runner->router->scaffold_root . DIRECTORY_SEPARATOR . $this->path . DIRECTORY_SEPARATOR . $this->view)) { $method = 'form'; $this->view = trim($runner->route, '\\') . '.' . $formname . '.' . $method . '.php'; } $flash = $params['form']; $flash['fields'] = array_keys($params['input']); if ($method == 'form') { $this->nonce = uniqid(rand(0, 1000000)); $_SESSION["nonce-" . $this->fid] = \Routerunner\Crypt::crypter($this->nonce); \Routerunner\Routerunner::$slim->flash($this->path . DIRECTORY_SEPARATOR . $formname, $flash); } $this->params = $params["form"]; $this->fields = $params["input"]; $this->fields[$this->id_field] = array('type' => 'hidden', 'field' => $this->id_field, 'input-id' => '_routerunner_form_id', 'value' => $this->fid); $this->fields['_routerunner_form_nonce'] = array('type' => 'hidden', 'field' => '_routerunner_form_nonce', 'input-id' => '_routerunner_form_nonce', 'value' => $this->nonce); if (isset($params["unset"])) { $this->unset = $params["unset"]; } if (isset($params["set"])) { $this->set = $params["set"]; } if ($runner->model) { if (is_array($runner->model) && $runner->model) { $this->class = get_class(current($runner->model)); } elseif (is_object($runner->model)) { $this->class = get_class($runner->model); } if ($this->class) { $this->class = trim(substr($this->class, strrpos($this->class, DIRECTORY_SEPARATOR)), DIRECTORY_SEPARATOR); } } foreach ($this->fields as $field_name => &$field_param) { if ((!isset($field_param['value']) || !$field_param['value']) && isset($runner->model->{$field_name})) { $field_param['value'] = $runner->model->{$field_name}; } if ((!isset($field_param['value']) || !$field_param['value']) && isset($runner->context[$field_name])) { $field_param['value'] = $runner->context[$field_name]; } if ((!isset($field_param['value']) || !$field_param['value']) && isset($request_params[$field_name])) { $field_param['value'] = $request_params[$field_name]; } } $runner->form[$formname] = $this; \Routerunner\Form::$forms[$formname] = $this; } }
* 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"]));
* 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>';
} 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"); }