Exemplo n.º 1
0
/**
 * db backup render start
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 */
function db_backup_render_start()
{
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin' && SECOND_PARAMETER == 'db-backup') {
        define('TITLE', l('database_backup', 'db_backup'));
        /* registry object */
        $registry = Redaxscript\Registry::getInstance();
        $registry->set('title', l('database_backup', 'db_backup'));
        /* config object */
        $config = Redaxscript\Config::getInstance();
        /* download database backup */
        if (THIRD_PARAMETER == 'download') {
            define('RENDER_BREAK', 1);
            db_backup($config::get('name'), 0);
        }
        /* send database backup */
        if (THIRD_PARAMETER == 'send') {
            define('CENTER_BREAK', 1);
            /* prepare body parts */
            $urlLink = anchor_element('external', '', '', ROOT, ROOT);
            $fileName = $config::get('name') . '-' . db_backup_clean_date(NOW) . '.sql';
            /* prepare mail inputs */
            $toArray = $fromArray = array(s('author') => s('email'));
            $subject = l('database_backup', 'db_backup');
            $bodyArray = array('<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink, '<strong>' . l('database') . l('colon') . '</strong> ' . $config::get('name'), '<br />', '<strong>' . l('message') . l('colon') . '</strong> ' . l('save_attachment', 'db_backup') . l('point'));
            $attachmentArray = array($fileName => db_backup($config::get('name'), 1));
            /* mail object */
            $mail = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray, $attachmentArray);
            $mail->send();
        }
    }
}
Exemplo n.º 2
0
/**
 * install
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Install
 * @author Henry Ruhs
 */
function install()
{
    global $name, $user, $password, $email;
    /* installer */
    $installer = new Redaxscript\Installer();
    $installer->init(Redaxscript\Config::getInstance());
    $installer->rawDrop();
    $installer->rawCreate();
    $installer->insertData(array('adminName' => $name, 'adminUser' => $user, 'adminPassword' => $password, 'adminEmail' => $email));
    /* send login information */
    $urlLink = anchor_element('external', '', '', ROOT, ROOT);
    $toArray = $fromArray = array($name => $email);
    $subject = l('installation');
    $bodyArray = array('<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink);
    /* mailer object */
    $mailer = new Redaxscript\Mailer();
    $mailer->init($toArray, $fromArray, $subject, $bodyArray);
    $mailer->send();
}
/**
 * comment post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Comments
 * @author Henry Ruhs
 */
function comment_post()
{
    $emailValidator = new Redaxscript\Validator\Email();
    $captchaValidator = new Redaxscript\Validator\Captcha();
    $urlValidator = new Redaxscript\Validator\Url();
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/comment'] == 'visited') {
        $author = $r['author'] = clean($_POST['author'], 0);
        $email = $r['email'] = clean($_POST['email'], 3);
        $url = $r['url'] = clean($_POST['url'], 4);
        $text = break_up($_POST['text']);
        $text = $r['text'] = clean($text, 1);
        $r['language'] = clean($_POST['language'], 0);
        $r['date'] = clean($_POST['date'], 5);
        $article = $r['article'] = clean($_POST['article'], 0);
        $r['rank'] = Redaxscript\Db::forTablePrefix('comments')->max('rank') + 1;
        $r['access'] = Redaxscript\Db::forTablePrefix('articles')->whereIdIs($article)->access;
        if ($r['access'] == '') {
            $r['access'] = null;
        }
        $task = $_POST['task'];
        $solution = $_POST['solution'];
        $route = build_route('articles', $article);
    }
    /* validate post */
    if ($author == '') {
        $error = l('author_empty');
    } else {
        if ($email == '') {
            $error = l('email_empty');
        } else {
            if ($text == '') {
                $error = l('comment_empty');
            } else {
                if ($emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                    $error = l('email_incorrect');
                } else {
                    if ($url && $urlValidator->validate($url) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                        $error = l('url_incorrect');
                    } else {
                        if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                            $error = l('captcha_incorrect');
                        } else {
                            if (COMMENTS_NEW == 0 && s('moderation') == 1) {
                                $r['status'] = 0;
                                $success = l('comment_moderation');
                            } else {
                                $r['status'] = 1;
                                $success = l('comment_sent');
                            }
                            /* send comment notification */
                            if (s('notification') == 1) {
                                /* prepare body parts */
                                $emailLink = anchor_element('email', '', '', $email);
                                if ($url) {
                                    $urlLink = anchor_element('external', '', '', $url);
                                }
                                $articleRoute = ROOT . '/' . REWRITE_ROUTE . $route;
                                $articleLink = anchor_element('external', '', '', $articleRoute, $articleRoute);
                                /* prepare mail inputs */
                                $toArray = array(s('author') => s('email'));
                                $fromArray = array($author => $email);
                                $subject = l('comment_new');
                                $bodyArray = array('<strong>' . l('author') . l('colon') . '</strong> ' . $author, '<br />', '<strong>' . l('email') . l('colon') . '</strong> ' . $emailLink, '<br />', '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink, '<br />', '<strong>' . l('article') . l('colon') . '</strong> ' . $articleLink, '<br />', '<br />', '<strong>' . l('comment') . l('colon') . '</strong> ' . $text);
                                /* mailer object */
                                $mailer = new Redaxscript\Mailer();
                                $mailer->init($toArray, $fromArray, $subject, $bodyArray);
                                $mailer->send();
                            }
                            /* create comment */
                            Redaxscript\Db::forTablePrefix('comments')->create()->set($r)->save();
                        }
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        notification(l('error_occurred'), $error, l('back'), $route);
    } else {
        notification(l('operation_completed'), $success, l('continue'), $route);
    }
    $_SESSION[ROOT . '/comment'] = '';
}
/**
 * reminder post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Reminder
 * @author Henry Ruhs
 */
function reminder_post()
{
    $emailValidator = new Redaxscript\Validator\Email();
    $captchaValidator = new Redaxscript\Validator\Captcha();
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/reminder'] == 'visited') {
        $email = clean($_POST['email'], 3);
        $task = $_POST['task'];
        $solution = $_POST['solution'];
    }
    /* validate post */
    if ($email == '') {
        $error = l('email_empty');
    } else {
        if ($emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::FAILED) {
            $error = l('email_incorrect');
        } else {
            if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                $error = l('captcha_incorrect');
            } else {
                if (Redaxscript\Db::forTablePrefix('users')->where('email', $email)->findOne()->id == '') {
                    $error = l('email_unknown');
                } else {
                    /* query users */
                    $result = Redaxscript\Db::forTablePrefix('users')->where(array('email' => $email, 'status' => 1))->findArray();
                    if ($result) {
                        foreach ($result as $r) {
                            if ($r) {
                                foreach ($r as $key => $value) {
                                    ${$key} = stripslashes($value);
                                }
                            }
                            /* send reminder information */
                            $passwordResetRoute = ROOT . '/' . REWRITE_ROUTE . 'password_reset/' . $id . '/' . sha1($password);
                            $passwordResetLink = anchor_element('external', '', '', $passwordResetRoute, $passwordResetRoute);
                            $toArray = array(s('author') => s('email'));
                            $fromArray = array($name => $email);
                            $subject = l('reminder');
                            $bodyArray = array('<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password_reset') . l('colon') . '</strong> ' . $passwordResetLink);
                            /* mailer object */
                            $mailer = new Redaxscript\Mailer();
                            $mailer->init($toArray, $fromArray, $subject, $bodyArray);
                            $mailer->send();
                        }
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        notification(l('error_occurred'), $error, l('back'), 'reminder');
    } else {
        notification(l('operation_completed'), l('reminder_sent'), l('login'), 'login');
    }
    $_SESSION[ROOT . '/reminder'] = '';
}
/**
 * registration post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Registration
 * @author Henry Ruhs
 */
function registration_post()
{
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/registration'] == 'visited') {
        $name = $r['name'] = clean($_POST['name'], 0);
        $user = $r['user'] = clean($_POST['user'], 0);
        $email = $r['email'] = clean($_POST['email'], 3);
        $password = substr(sha1(uniqid()), 0, 10);
        $passwordHash = new Redaxscript\Hash(Redaxscript\Config::getInstance());
        $passwordHash->init($password);
        $r['password'] = $passwordHash->getHash();
        $r['description'] = '';
        $r['language'] = Redaxscript\Registry::get('language');
        $r['first'] = $r['last'] = NOW;
        $r['groups'] = Redaxscript\Db::forTablePrefix('groups')->where('alias', 'members')->findOne()->id;
        if ($r['groups'] == '') {
            $r['groups'] = 0;
        }
        $task = $_POST['task'];
        $solution = $_POST['solution'];
    }
    /* validate post */
    $loginValidator = new Redaxscript\Validator\Login();
    $emailValidator = new Redaxscript\Validator\Email();
    $captchaValidator = new Redaxscript\Validator\Captcha();
    if ($name == '') {
        $error = l('name_empty');
    } else {
        if ($user == '') {
            $error = l('user_empty');
        } else {
            if ($email == '') {
                $error = l('email_empty');
            } else {
                if ($loginValidator->validate($user) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                    $error = l('user_incorrect');
                } else {
                    if ($emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                        $error = l('email_incorrect');
                    } else {
                        if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                            $error = l('captcha_incorrect');
                        } else {
                            if (Redaxscript\Db::forTablePrefix('users')->where('user', $user)->findOne()->id) {
                                $error = l('user_exists');
                            } else {
                                if (USERS_NEW == 0 && s('verification') == 1) {
                                    $r['status'] = 0;
                                    $success = l('registration_verification');
                                } else {
                                    $r['status'] = 1;
                                    $success = l('registration_sent');
                                }
                                /* send login information */
                                $loginRoute = ROOT . '/' . REWRITE_ROUTE . 'login';
                                $loginLink = anchor_element('external', '', '', $loginRoute, $loginRoute);
                                $toArray = array($name => $email);
                                if (s('notification') == 1) {
                                    $toArray[s('author')] = s('email');
                                }
                                $fromArray = array($author => $email);
                                $subject = l('registration');
                                $bodyArray = array('<strong>' . l('name') . l('colon') . '</strong> ' . $name, '<br />', '<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('login') . l('colon') . '<strong> ' . $loginLink);
                                /* mailer object */
                                $mailer = new Redaxscript\Mailer();
                                $mailer->init($toArray, $fromArray, $subject, $bodyArray);
                                $mailer->send();
                                /* create user */
                                Redaxscript\Db::forTablePrefix('users')->create()->set($r)->save();
                            }
                        }
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        notification(l('error_occurred'), $error, l('back'), 'registration');
    } else {
        notification(l('operation_completed'), $success, l('login'), 'login');
    }
    $_SESSION[ROOT . '/registration'] = '';
}
/**
 * password reset post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Password
 * @author Henry Ruhs
 */
function password_reset_post()
{
    $captchaValidator = new Redaxscript\Validator\Captcha();
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/password_reset'] == 'visited') {
        $post_id = clean($_POST['id'], 0);
        $post_password = clean($_POST['password'], 0);
        $password = substr(sha1(uniqid()), 0, 10);
        $task = $_POST['task'];
        $solution = $_POST['solution'];
    }
    /* query user information */
    if ($post_id && $post_password) {
        $users_result = Redaxscript\Db::forTablePrefix('users')->where(array('id' => $post_id, 'status' => 1))->findArray();
        foreach ($users_result as $r) {
            foreach ($r as $key => $value) {
                $key = 'my_' . $key;
                ${$key} = stripslashes($value);
            }
        }
    }
    /* validate post */
    if ($post_id == '' || $post_password == '') {
        $error = l('input_incorrect');
    } else {
        if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) {
            $error = l('captcha_incorrect');
        } else {
            if ($my_id == '' || sha1($my_password) != $post_password) {
                $error = l('access_no');
            } else {
                /* send new password */
                $loginRoute = ROOT . '/' . REWRITE_ROUTE . 'login';
                $loginLink = anchor_element('external', '', '', $loginRoute, $loginRoute);
                $toArray = array($my_name => $my_email);
                $fromArray = array(s('author') => s('email'));
                $subject = l('password_new');
                $bodyArray = array('<strong>' . l('password_new') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('login') . l('colon') . '</strong> ' . $loginLink);
                /* mailer object */
                $mailer = new Redaxscript\Mailer();
                $mailer->init($toArray, $fromArray, $subject, $bodyArray);
                $mailer->send();
                /* update password */
                $passwordHash = new Redaxscript\Hash(Redaxscript\Config::getInstance());
                $passwordHash->init($password);
                Redaxscript\Db::forTablePrefix('users')->where(array('id' => $post_id, 'status' => 1))->findOne()->set('password', $passwordHash->getHash())->save();
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        if ($post_id && $post_password) {
            $back_route = 'password_reset/' . $post_id . '/' . $post_password;
        } else {
            $back_route = 'reminder';
        }
        notification(l('error_occurred'), $error, l('back'), $back_route);
    } else {
        notification(l('operation_completed'), l('password_sent'), l('login'), 'login');
    }
    $_SESSION[ROOT . '/password_reset'] = '';
}
Exemplo n.º 7
0
/**
 * contact post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 */
function contact_post()
{
    $emailValidator = new Redaxscript\Validator\Email();
    $captchaValidator = new Redaxscript\Validator\Captcha();
    $urlValidator = new Redaxscript\Validator\Url();
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/contact'] == 'visited') {
        $author = clean($_POST['author'], 0);
        $email = clean($_POST['email'], 3);
        $url = clean($_POST['url'], 4);
        $text = break_up($_POST['text']);
        $text = clean($text, 1);
        $task = $_POST['task'];
        $solution = $_POST['solution'];
    }
    /* validate post */
    if ($author == '') {
        $error = l('author_empty');
    } else {
        if ($email == '') {
            $error = l('email_empty');
        } else {
            if ($text == '') {
                $error = l('message_empty');
            } else {
                if ($emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                    $error = l('email_incorrect');
                } else {
                    if ($url && $urlValidator->validate($url) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                        $error = l('url_incorrect');
                    } else {
                        if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) {
                            $error = l('captcha_incorrect');
                        } else {
                            /* prepare body parts */
                            $emailLink = anchor_element('email', '', '', $email, $email);
                            if ($url) {
                                $urlLink = anchor_element('external', '', '', $url, $url);
                            }
                            /* prepare mail inputs */
                            $toArray = array(s('author') => s('email'));
                            $fromArray = array($author => $email);
                            $subject = l('contact');
                            $bodyArray = array('<strong>' . l('author') . l('colon') . '</strong> ' . $author, '<br />', '<strong>' . l('email') . l('colon') . '</strong> ' . $emailLink, '<br />', '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink, '<br />', '<br />', '<strong>' . l('message') . l('colon') . '</strong> ' . $text);
                            /* mailer object */
                            $mailer = new Redaxscript\Mailer();
                            $mailer->init($toArray, $fromArray, $subject, $bodyArray);
                            $mailer->send();
                        }
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        notification(l('error_occurred'), $error, l('home'), ROOT);
    } else {
        notification(l('operation_completed'), l('message_sent', '_contact'), l('home'), ROOT);
    }
    $_SESSION[ROOT . '/contact'] = '';
}
Exemplo n.º 8
0
/**
 * password reset post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Password
 * @author Henry Ruhs
 */
function password_reset_post()
{
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/password_reset'] == 'visited') {
        $post_id = clean($_POST['id'], 0);
        $post_password = clean($_POST['password'], 0);
        $password = hash_generator(10);
        $task = $_POST['task'];
        $solution = $_POST['solution'];
    }
    /* query user information */
    if ($post_id && $post_password) {
        $users_query = 'SELECT id, name, email, password FROM ' . PREFIX . 'users WHERE id = ' . $post_id . ' && password = \'' . $post_password . '\' && status = 1';
        $users_result = mysql_query($users_query);
        while ($r = mysql_fetch_assoc($users_result)) {
            foreach ($r as $key => $value) {
                $key = 'my_' . $key;
                ${$key} = stripslashes($value);
            }
        }
    }
    /* validate post */
    if ($post_id == '' || $post_password == '') {
        $error = l('input_incorrect');
    } else {
        if (sha1($task) != $solution) {
            $error = l('captcha_incorrect');
        } else {
            if ($my_id == '' || $my_password == '') {
                $error = l('access_no');
            } else {
                /* send new password */
                $loginRoute = ROOT . '/' . REWRITE_ROUTE . 'login';
                $loginLink = anchor_element('external', '', '', $loginRoute, $loginRoute);
                $toArray = array($my_name => $my_email);
                $fromArray = array(s('author') => s('email'));
                $subject = l('password_new');
                $bodyArray = array('<strong>' . l('password_new') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('login') . l('colon') . '</strong> ' . $loginLink);
                /* mailer object */
                $mailer = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray);
                $mailer->send();
                /* update password */
                $query = 'UPDATE ' . PREFIX . 'users SET password = \'' . sha1($password) . SALT . '\' WHERE id = ' . $post_id . ' && password = \'' . $post_password . '\' && status = 1';
                mysql_query($query);
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        if ($post_id && $post_password) {
            $back_route = 'password_reset/' . $post_id . '/' . $post_password;
        } else {
            $back_route = 'reminder';
        }
        notification(l('error_occurred'), $error, l('back'), $back_route);
    } else {
        notification(l('operation_completed'), l('password_sent'), l('login'), 'login');
    }
    $_SESSION[ROOT . '/password_reset'] = '';
}
Exemplo n.º 9
0
/**
 * install
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Install
 * @author Henry Ruhs
 */
function install()
{
    global $d_host, $d_name, $d_user, $d_password, $d_prefix, $d_salt, $name, $user, $password, $email;
    $r['create_database'] = 'CREATE DATABASE IF NOT EXISTS ' . $d_name;
    $r['grant_privileges'] = 'GRANT ALL PRIVILEGES ON ' . $d_name . '.* TO \'' . $d_user . '\'@\'' . $d_host . '\' IDENTIFIED BY \'' . $d_password . '\'';
    $r['flush_privileges'] = 'FLUSH PRIVILEGES';
    $r['create_articles'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'articles (
		id int(10) NOT NULL AUTO_INCREMENT,
		title varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		keywords varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		text longtext COLLATE utf8_unicode_ci,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		template varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		date datetime DEFAULT NULL,
		category int(10) DEFAULT NULL,
		headline int(1) DEFAULT NULL,
		infoline int(1) DEFAULT NULL,
		comments int(1) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		rank int(10) DEFAULT NULL,
		access varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 2';
    $r['create_categories'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'categories (
		id int(10) NOT NULL AUTO_INCREMENT,
		title varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		keywords varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		template varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		parent int(10) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		rank int(10) DEFAULT NULL,
		access varchar(255)COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 2';
    $r['create_comments'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'comments (
		id int(10) NOT NULL AUTO_INCREMENT,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		email varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		url varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		text longtext COLLATE utf8_unicode_ci,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		date datetime DEFAULT NULL,
		article int(10) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		rank int(10) DEFAULT NULL,
		access varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 1';
    $r['create_extras'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'extras (
		id int(10) NOT NULL AUTO_INCREMENT,
		title varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		text longtext COLLATE utf8_unicode_ci,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		date datetime DEFAULT NULL,
		category int(10) DEFAULT NULL,
		article int(10) DEFAULT NULL,
		headline int(1) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		rank int(10) DEFAULT NULL,
		access varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 6';
    $r['create_groups'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'groups (
		id int(10) NOT NULL AUTO_INCREMENT,
		name varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		categories varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		articles varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		extras varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		comments varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		groups varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		users varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		modules varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		settings int(1) DEFAULT NULL,
		filter int(1) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 3';
    $r['create_modules'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'modules (
		id int(10) NOT NULL AUTO_INCREMENT,
		name varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		version varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		status int(1) DEFAULT NULL,
		access varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 2';
    $r['create_settings'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'settings (
		id int(10) NOT NULL AUTO_INCREMENT,
		name varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		value varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 27';
    $r['create_users'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'users (
		id int(10) NOT NULL AUTO_INCREMENT,
		name varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		user varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		password varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		email varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		first datetime DEFAULT NULL,
		last datetime DEFAULT NULL,
		status int(1) DEFAULT NULL,
		groups varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 2';
    $r['insert_articles'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'articles (id, title, alias, author, description, keywords, text, language, template, date, category, headline, infoline, comments, status, rank, access) VALUES (1, \'Welcome\', \'welcome\', \'' . $user . '\', \'\', \'\', \'<p>Congratulations! Redaxscript has been successfully installed.</p>\', \'\', \'\', \'' . NOW . '\', 1, 1, 0, 0, 1, 1, \'0\')';
    $r['insert_categories'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'categories (id, title, alias, author, description, keywords, language, template, parent, status, rank, access) VALUES (1, \'Home\', \'home\', \'' . $user . '\', \'\', \'\', \'\', \'\', 0, 1, 1, \'0\')';
    $r['insert_extras'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'extras (id, title, alias, author, text, language, date, category, article, headline, status, rank, access) VALUES (1, \'Categories\', \'categories\', \'' . $user . '\', \'<function>\\n{\\n\\t"navigation_list":\\n\\t{\\n\\t\\t"table": "categories",\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar",\\n\\t\\t\\t"children": 1\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 1, 1, \'0\'), (2, \'Articles\', \'articles\', \'' . $user . '\', \'<function>\\n{\\n\\t"navigation_list":\\n\\t{\\n\\t\\t"table": "articles",\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar"\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 1, 2, \'0\'), (3, \'Comments\', \'comments\', \'' . $user . '\', \'<function>\\n{\\n\\t"navigation_list":\\n\\t{\\n\\t\\t"table": "comments",\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar"\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 1, 3, \'0\'), (4, \'Languages\', \'languages\', \'' . $user . '\', \'<function>\\n{\\n\\t"languages_list":\\n\\t{\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar"\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 0, 4, \'0\'), (5, \'Templates\', \'templates\', \'' . $user . '\', \'<function>\\n{\\n\\t"templates_list":\\n\\t{\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar"\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 0, 5, \'0\'), (6, \'Footer\', \'footer\', \'' . $user . '\', \'<div class="box_first grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/general" title="General">General</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/introduction" title="Introduction">Introduction</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/feature-list" title="Feature list">Feature list</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/benchmark" title="Benchmark">Benchmark</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/service" title="Service">Service</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/about" title="About">About</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\\n\\n<div class="box_second grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/download" title="Download">Download</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/download/releases" title="Releases">Releases</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/download/templates" title="Templates">Templates</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/download/languages" title="Languages">Languages</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/download/modules" title="Modules">Modules</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\\n\\n<div class="box_third grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/support" title="Support">Support</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/support/getting-started" title="Getting started">Getting started</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/support/installation-guide" title="Installation guide">Installation guide</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/support/troubleshooting" title="Troubleshooting">Troubleshooting</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/support/faq" title="FAQ">FAQ</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\\n\\n<div class="box_fourth grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/develop" title="Develop">Develop</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/source-code" title="Source code">Source code</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/github-guide" title="Github guide">Github guide</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/documentation" title="Documentation">Documentation</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/roadmap" title="Roadmap">Roadmap</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/changelog" title="Changelog">Changelog</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\\n\\n<div class="box_last grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/community" title="Community">Community</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/community/facebook-group" title="Facebook group">Facebook group</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/community/team" title="Team">Team</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/community/contribute" title="Contribute">Contribute</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\', \'\', \'' . NOW . '\', 0, 0, 0, 0, 6, \'0\')';
    $r['insert_groups'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'groups (id, name, alias, description, categories, articles, extras, comments, groups, users, modules, settings, filter, status) VALUES (1, \'Administrators\', \'administrators\', \'Unlimited access\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', 1, 0, 1), (2, \'Members\', \'members\', \'Default members group\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\', 0, 1, 1)';
    $r['insert_settings'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'settings (id, name, value) VALUES (1, \'language\', \'detect\'), (2, \'template\', \'default\'), (3, \'title\', \'Redaxscript\'), (4, \'author\', \'\'), (5, \'copyright\', \'\'), (6, \'description\', \'Ultra lightweight CMS\'), (7, \'keywords\', \'\'), (8, \'robots\', \'all\'), (9, \'email\', \'' . $email . '\'), (10, \'subject\', \'Redaxscript\'), (11, \'notification\', \'0\'), (12, \'charset\', \'utf-8\'), (13, \'divider\', \' • \'), (14, \'time\', \'H:i\'), (15, \'date\', \'d.m.Y\'), (16, \'homepage\', \'0\'), (17, \'limit\', \'10\'), (18, \'order\', \'asc\'), (19, \'pagination\', \'1\'), (20, \'moderation\', \'0\'), (21, \'registration\', \'1\'), (22, \'verification\', \'0\'), (23, \'reminder\', \'1\'), (24, \'captcha\', \'0\'), (25, \'blocker\', \'1\'), (26, \'version\', \'' . l('redaxscript_version') . '\')';
    if (file_exists('modules/call_home/install.php')) {
        $r['insert_modules'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'modules (name, alias, author, description, version, status, access) VALUES (\'Call home\', \'call_home\', \'Redaxmedia\', \'Call home module\', \'' . l('redaxscript_version') . '\', 1, 0)';
    }
    $r['insert_users'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'users (id, name, user, password, email, description, language, first, last, status, groups) VALUES (1, \'' . $name . '\', \'' . $user . '\', \'' . sha1($password) . $d_salt . '\', \'' . $email . '\', \'God admin\', \'\', \'' . NOW . '\', \'' . NOW . '\', 1, \'1\')';
    /* install database */
    foreach ($r as $key => $value) {
        mysql_query($value);
    }
    /* send login information */
    $urlLink = anchor_element('external', '', '', ROOT, ROOT);
    $toArray = $fromArray = array($name => $email);
    $subject = l('installation');
    $bodyArray = array('<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink);
    /* mail object */
    $mail = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray);
    $mail->send();
}
Exemplo n.º 10
0
/**
 * registration post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Registration
 * @author Henry Ruhs
 */
function registration_post()
{
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/registration'] == 'visited') {
        $name = $r['name'] = clean($_POST['name'], 0);
        $user = $r['user'] = clean($_POST['user'], 0);
        $email = $r['email'] = clean($_POST['email'], 3);
        $password = hash_generator(10);
        $r['password'] = sha1($password) . SALT;
        $r['description'] = '';
        $r['language'] = LANGUAGE;
        $r['first'] = $r['last'] = NOW;
        $r['groups'] = retrieve('id', 'groups', 'alias', 'members');
        if ($r['groups'] == '') {
            $r['groups'] = 0;
        }
        $task = $_POST['task'];
        $solution = $_POST['solution'];
    }
    /* validate post */
    $loginValidator = new Redaxscript\Validator\Login();
    $emailValidator = new Redaxscript\Validator\Email();
    $captchaValidator = new Redaxscript\Validator\Captcha();
    if ($name == '') {
        $error = l('name_empty');
    } else {
        if ($user == '') {
            $error = l('user_empty');
        } else {
            if ($email == '') {
                $error = l('email_empty');
            } else {
                if ($loginValidator->validate($user) == Redaxscript\Validator\Validator::FAILED) {
                    $error = l('user_incorrect');
                } else {
                    if ($emailValidator->validate($email) == Redaxscript\Validator\Validator::FAILED) {
                        $error = l('email_incorrect');
                    } else {
                        if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\Validator::FAILED) {
                            $error = l('captcha_incorrect');
                        } else {
                            if (retrieve('id', 'users', 'user', $user)) {
                                $error = l('user_exists');
                            } else {
                                if (USERS_NEW == 0 && s('verification') == 1) {
                                    $r['status'] = 0;
                                    $success = l('registration_verification');
                                } else {
                                    $r['status'] = 1;
                                    $success = l('registration_sent');
                                }
                                /* send login information */
                                $loginRoute = ROOT . '/' . REWRITE_ROUTE . 'login';
                                $loginLink = anchor_element('external', '', '', $loginRoute, $loginRoute);
                                $toArray = array($name => $email);
                                if (s('notification') == 1) {
                                    $toArray[s('author')] = s('email');
                                }
                                $fromArray = array($author => $email);
                                $subject = l('registration');
                                $bodyArray = array('<strong>' . l('name') . l('colon') . '</strong> ' . $name . ' (' . MY_IP . ')', '<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<strong>' . l('password') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('login') . l('colon') . '<strong> ' . $loginLink);
                                /* mailer object */
                                $mailer = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray);
                                $mailer->send();
                                /* build key and value strings */
                                $r_keys = array_keys($r);
                                $last = end($r_keys);
                                foreach ($r as $key => $value) {
                                    $key_string .= $key;
                                    $value_string .= '\'' . $value . '\'';
                                    if ($last != $key) {
                                        $key_string .= ', ';
                                        $value_string .= ', ';
                                    }
                                }
                                /* insert user */
                                $query = 'INSERT INTO ' . PREFIX . 'users (' . $key_string . ') VALUES (' . $value_string . ')';
                                mysql_query($query);
                            }
                        }
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        notification(l('error_occurred'), $error, l('back'), 'registration');
    } else {
        notification(l('operation_completed'), $success, l('login'), 'login');
    }
    $_SESSION[ROOT . '/registration'] = '';
}
Exemplo n.º 11
0
/**
 * comment post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Comments
 * @author Henry Ruhs
 */
function comment_post()
{
    $emailValidator = new Redaxscript\Validator\Email();
    $captchaValidator = new Redaxscript\Validator\Captcha();
    $urlValidator = new Redaxscript\Validator\Url();
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/comment'] == 'visited') {
        $author = $r['author'] = clean($_POST['author'], 0);
        $email = $r['email'] = clean($_POST['email'], 3);
        $url = $r['url'] = clean($_POST['url'], 4);
        $text = break_up($_POST['text']);
        $text = $r['text'] = clean($text, 1);
        $r['language'] = clean($_POST['language'], 0);
        $r['date'] = clean($_POST['date'], 1);
        $article = $r['article'] = clean($_POST['article'], 0);
        $r['rank'] = query_plumb('rank', 'comments', 'max') + 1;
        $r['access'] = clean($_POST['access'], 0);
        if ($r['access'] == '') {
            $r['access'] = 0;
        }
        $task = $_POST['task'];
        $solution = $_POST['solution'];
        $route = build_route('articles', $article);
    }
    /* validate post */
    if ($author == '') {
        $error = l('author_empty');
    } else {
        if ($email == '') {
            $error = l('email_empty');
        } else {
            if ($text == '') {
                $error = l('comment_empty');
            } else {
                if ($emailValidator->validate($email) == Redaxscript\Validator\Validator::FAILED) {
                    $error = l('email_incorrect');
                } else {
                    if ($url && $urlValidator->validate($url) == Redaxscript\Validator\Validator::FAILED) {
                        $error = l('url_incorrect');
                    } else {
                        if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\Validator::FAILED) {
                            $error = l('captcha_incorrect');
                        } else {
                            if (COMMENTS_NEW == 0 && s('moderation') == 1) {
                                $r['status'] = 0;
                                $success = l('comment_moderation');
                            } else {
                                $r['status'] = 1;
                                $success = l('comment_sent');
                            }
                            /* send comment notification */
                            if (s('notification') == 1) {
                                /* prepare body parts */
                                $emailLink = anchor_element('email', '', '', $email);
                                if ($url) {
                                    $urlLink = anchor_element('external', '', '', $url);
                                }
                                $articleRoute = ROOT . '/' . REWRITE_ROUTE . $route;
                                $articleLink = anchor_element('external', '', '', $articleRoute, $articleRoute);
                                /* prepare mail inputs */
                                $toArray = array(s('author') => s('email'));
                                $fromArray = array($author => $email);
                                $subject = l('comment_new');
                                $bodyArray = array('<strong>' . l('author') . l('colon') . '</strong> ' . $author . ' (' . MY_IP . ')', '<strong>' . l('email') . l('colon') . '</strong> ' . $emailLink, '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink, '<br />', '<strong>' . l('comment') . l('colon') . '</strong> ' . $text, '<br />', '<strong>' . l('article') . l('colon') . '</strong> ' . $articleLink);
                                /* mailer object */
                                $mailer = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray);
                                $mailer->send();
                            }
                            /* build key and value strings */
                            $r_keys = array_keys($r);
                            $last = end($r_keys);
                            foreach ($r as $key => $value) {
                                $key_string .= $key;
                                $value_string .= '\'' . $value . '\'';
                                if ($last != $key) {
                                    $key_string .= ', ';
                                    $value_string .= ', ';
                                }
                            }
                            /* insert comment */
                            $query = 'INSERT INTO ' . PREFIX . 'comments (' . $key_string . ') VALUES (' . $value_string . ')';
                            mysql_query($query);
                        }
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        notification(l('error_occurred'), $error, l('back'), $route);
    } else {
        notification(l('operation_completed'), $success, l('continue'), $route);
    }
    $_SESSION[ROOT . '/comment'] = '';
}
Exemplo n.º 12
0
/**
 * reminder post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Reminder
 * @author Henry Ruhs
 */
function reminder_post()
{
    $emailValidator = new Redaxscript\Validator\Email();
    $captchaValidator = new Redaxscript\Validator\Captcha();
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/reminder'] == 'visited') {
        $email = clean($_POST['email'], 3);
        $task = $_POST['task'];
        $solution = $_POST['solution'];
    }
    /* validate post */
    if ($email == '') {
        $error = l('email_empty');
    } else {
        if ($emailValidator->validate($email) == Redaxscript\Validator\Validator::FAILED) {
            $error = l('email_incorrect');
        } else {
            if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\Validator::FAILED) {
                $error = l('captcha_incorrect');
            } else {
                if (retrieve('id', 'users', 'email', $email) == '') {
                    $error = l('email_unknown');
                } else {
                    /* query users */
                    $query = 'SELECT id, user, password FROM ' . PREFIX . 'users WHERE email = \'' . $email . '\' && status = 1';
                    $result = mysql_query($query);
                    if ($result) {
                        while ($r = mysql_fetch_assoc($result)) {
                            if ($r) {
                                foreach ($r as $key => $value) {
                                    ${$key} = stripslashes($value);
                                }
                            }
                            /* send reminder information */
                            $passwordResetRoute = ROOT . '/' . REWRITE_ROUTE . 'password_reset/' . $id . '/' . $password;
                            $passwordResetLink = anchor_element('external', '', '', $passwordResetRoute, $passwordResetRoute);
                            $toArray = array(s('author') => s('email'));
                            $fromArray = array($name => $email);
                            $subject = l('reminder');
                            $bodyArray = array('<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password_reset') . l('colon') . '</strong> ' . $passwordResetLink);
                            /* mailer object */
                            $mailer = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray);
                            $mailer->send();
                        }
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        notification(l('error_occurred'), $error, l('back'), 'reminder');
    } else {
        notification(l('operation_completed'), l('reminder_sent'), l('login'), 'login');
    }
    $_SESSION[ROOT . '/reminder'] = '';
}