本文整理汇总了PHP中osc_genRandomPassword函数的典型用法代码示例。如果您正苦于以下问题:PHP osc_genRandomPassword函数的具体用法?PHP osc_genRandomPassword怎么用?PHP osc_genRandomPassword使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osc_genRandomPassword函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doModel
//.........这里部分代码省略.........
$request_uri = preg_replace('#' . $match . '#', $uri, $request_uri);
if (preg_match('|([&?]{1})page=([^&]*)|', '&' . $request_uri . '&', $match)) {
$page_redirect = $match[2];
if ($page_redirect == '' || $page_redirect == 'login') {
$url_redirect = osc_user_dashboard_url();
}
}
break;
}
}
}
}
require_once LIB_PATH . 'osclass/UserActions.php';
$uActions = new UserActions(false);
$logged = $uActions->bootstrap_login($user['pk_i_id']);
if ($logged == 0) {
osc_add_flash_error_message(_m("The user doesn't exist"));
} else {
if ($logged == 1) {
if (time() - strtotime($user['dt_access_date']) > 1200) {
// EACH 20 MINUTES
osc_add_flash_error_message(sprintf(_m('The user has not been validated yet. Would you like to re-send your <a href="%s">activation?</a>'), osc_user_resend_activation_link($user['pk_i_id'], $user['s_email'])));
} else {
osc_add_flash_error_message(_m('The user has not been validated yet'));
}
} else {
if ($logged == 2) {
osc_add_flash_error_message(_m('The user has been suspended'));
} else {
if ($logged == 3) {
if (Params::getParam('remember') == 1) {
//this include contains de osc_genRandomPassword function
require_once osc_lib_path() . 'osclass/helpers/hSecurity.php';
$secret = osc_genRandomPassword();
User::newInstance()->update(array('s_secret' => $secret), array('pk_i_id' => $user['pk_i_id']));
Cookie::newInstance()->set_expires(osc_time_cookie());
Cookie::newInstance()->push('oc_userId', $user['pk_i_id']);
Cookie::newInstance()->push('oc_userSecret', $secret);
Cookie::newInstance()->set();
}
if ($url_redirect == '') {
$url_redirect = osc_user_dashboard_url();
}
osc_run_hook("after_login", $user, $url_redirect);
$this->redirectTo(osc_apply_filter('correct_login_url_redirect', $url_redirect));
} else {
osc_add_flash_error_message(_m('This should never happen'));
}
}
}
}
if (!$user['b_enabled']) {
$this->redirectTo(osc_user_login_url());
}
$this->redirectTo(osc_user_login_url());
break;
case 'resend':
$id = Params::getParam('id');
$email = Params::getParam('email');
$user = User::newInstance()->findByPrimaryKey($id);
if ($id == '' || $email == '' || !isset($user) || $user['b_active'] == 1 || $email != $user['s_email']) {
osc_add_flash_error_message(_m('Incorrect link'));
$this->redirectTo(osc_user_login_url());
}
if (time() - strtotime($user['dt_access_date']) > 1200) {
// EACH 20 MINUTES
示例2: item_adManage_posted
function item_adManage_posted($catId = '', $itemId)
{
$conn = getConnection();
$r_secret = '';
$r_secret = osc_genRandomPassword();
$conn->osc_dbExec("REPLACE INTO %st_item_adManage_limit (fk_i_item_id, r_secret, r_times) VALUES (%d, '%s', %d)", DB_TABLE_PREFIX, $itemId, $r_secret, 0);
}
示例3: doModel
function doModel()
{
switch ($this->action) {
case 'change_email_confirm':
//change email confirm
if (Params::getParam('userId') && Params::getParam('code')) {
$userManager = new User();
$user = $userManager->findByPrimaryKey(Params::getParam('userId'));
if ($user['s_pass_code'] == Params::getParam('code') && $user['b_enabled'] == 1) {
$userEmailTmp = UserEmailTmp::newInstance()->findByPk(Params::getParam('userId'));
$code = osc_genRandomPassword(50);
$userManager->update(array('s_email' => $userEmailTmp['s_new_email']), array('pk_i_id' => $userEmailTmp['fk_i_user_id']));
Item::newInstance()->update(array('s_contact_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
ItemComment::newInstance()->update(array('s_author_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
Alerts::newInstance()->update(array('s_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
Session::newInstance()->_set('userEmail', $userEmailTmp['s_new_email']);
UserEmailTmp::newInstance()->delete(array('s_new_email' => $userEmailTmp['s_new_email']));
osc_add_flash_ok_message(_m('Your email has been changed successfully'));
$this->redirectTo(osc_user_profile_url());
} else {
osc_add_flash_error_message(_m('Sorry, the link is not valid'));
$this->redirectTo(osc_base_url());
}
} else {
osc_add_flash_error_message(_m('Sorry, the link is not valid'));
$this->redirectTo(osc_base_url());
}
break;
case 'activate_alert':
$email = Params::getParam('email');
$secret = Params::getParam('secret');
$result = 0;
if ($email != '' && $secret != '') {
$result = Alerts::newInstance()->activate($email, $secret);
}
if ($result == 1) {
osc_add_flash_ok_message(_m('Alert activated'));
} else {
osc_add_flash_error_message(_m('Ops! There was a problem trying to activate alert. Please contact the administrator'));
}
$this->redirectTo(osc_base_url(true));
break;
case 'unsub_alert':
$email = Params::getParam('email');
$secret = Params::getParam('secret');
if ($email != '' && $secret != '') {
Alerts::newInstance()->delete(array('s_email' => $email, 'S_secret' => $secret));
osc_add_flash_ok_message(_m('Unsubscribed correctly'));
} else {
osc_add_flash_error_message(_m('Ops! There was a problem trying to unsubscribe you. Please contact the administrator'));
}
$this->redirectTo(osc_base_url());
break;
default:
$this->redirectTo(osc_user_login_url());
break;
}
}
示例4: basic_info
function basic_info()
{
require_once LIB_PATH . 'osclass/model/Admin.php';
require_once LIB_PATH . 'osclass/model/Preference.php';
require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
if ($_POST['s_name'] == '') {
$admin = 'admin';
} else {
$admin = $_POST['s_name'];
}
if ($_POST['s_passwd'] == '') {
$password = osc_genRandomPassword();
} else {
$password = $_POST['s_passwd'];
}
Admin::newInstance()->insert(array('s_name' => 'Administrator', 's_username' => $admin, 's_password' => sha1($password), 's_email' => $_POST['email']));
$mPreference = Preference::newInstance();
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'pageTitle', 's_value' => $_POST['webtitle'], 'e_type' => 'STRING'));
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'contactEmail', 's_value' => $_POST['email'], 'e_type' => 'STRING'));
$body = 'Welcome ' . $_POST['webtitle'] . ',<br/><br/>';
$body .= 'Your OSClass installation at ' . WEB_PATH . ' is up and running. You can access to the administration panel with this data access:<br/>';
$body .= '<ul>';
$body .= '<li>username: ' . $admin . '</li>';
$body .= '<li>password: ' . $password . '</li>';
$body .= '</ul>';
$body .= 'Regards,<br/>';
$body .= 'The <a href=\'http://osclass.org/\'>OSClass</a> team';
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
try {
require_once LIB_PATH . 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(true);
$mail->CharSet = "utf-8";
$mail->Host = "localhost";
$mail->From = 'osclass@' . $sitename;
$mail->FromName = 'OSClass';
$mail->Subject = 'OSClass successfully installed!';
$mail->AddAddress($_POST['email'], 'OSClass administrator');
$mail->Body = $body;
$mail->AltBody = $body;
if (!$mail->Send()) {
return array('email_status' => $_POST['email'] . "<br>" . $mail->ErrorInfo, 's_password' => $password);
} else {
return array('email_status' => '', 's_password' => $password);
}
} catch (phpmailerException $exception) {
}
}
示例5: basic_info
function basic_info()
{
require_once LIB_PATH . 'osclass/model/Admin.php';
require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
$admin = Params::getParam('s_name');
if ($admin == '') {
$admin = 'admin';
}
$password = Params::getParam('s_passwd', false, false);
if ($password == '') {
$password = osc_genRandomPassword();
}
Admin::newInstance()->insert(array('s_name' => 'Administrator', 's_username' => $admin, 's_password' => osc_hash_password($password), 's_email' => Params::getParam('email')));
$mPreference = Preference::newInstance();
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'pageTitle', 's_value' => Params::getParam('webtitle'), 'e_type' => 'STRING'));
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'contactEmail', 's_value' => Params::getParam('email'), 'e_type' => 'STRING'));
$body = sprintf(__('Привет %s,'), Params::getParam('webtitle')) . "<br/><br/>";
$body .= sprintf(__('Osclass успешно установлен %s и запущен. Вы можете получить доступ к панели администрирования:'), WEB_PATH) . '<br/>';
$body .= '<ul>';
$body .= '<li>' . sprintf(__('username: %s'), $admin) . '</li>';
$body .= '<li>' . sprintf(__('password: %s'), $password) . '</li>';
$body .= '</ul>';
$body .= sprintf(__('Помните, если у вас появяться вопросы вы можете прочитать <a href="%1$s">документацию</a>, спросить на <a href="%2$s">форуме</a> или в <a href="%3$s">блоге</a>.'), 'http://os-class.ru/wiki', 'http://os-class.ru/frm', 'http://os-class.ru/category/articles');
$body .= sprintf(' ' . __('Osclass doesn’t run any developments but we can put you in touch with third party developers through a Premium Support. And hey, if you would like to contribute to Osclass - learn how <a href="%1$s">here</a>!'), 'http://blog.osclass.org/2012/11/22/how-to-collaborate-to-osclass/') . '<br/><br/>';
$body .= __('Аплодисменты,') . "<br/>";
$body .= __('Ваш <a href="http://os-class.ru/">Osclass Rus Team</a> team');
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
try {
require_once LIB_PATH . 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(true);
$mail->CharSet = "utf-8";
$mail->Host = "localhost";
$mail->From = 'osclass@' . $sitename;
$mail->FromName = 'Osclass';
$mail->Subject = 'Osclass успешно установлен!';
$mail->AddAddress(Params::getParam('email'), 'Osclass administrator');
$mail->Body = $body;
$mail->AltBody = $body;
if (!$mail->Send()) {
return array('email_status' => Params::getParam('email') . "<br>" . $mail->ErrorInfo, 's_password' => $password);
}
return array('email_status' => '', 's_password' => $password);
} catch (phpmailerException $exception) {
return array('email_status' => Params::getParam('email') . "<br>" . $exception->errorMessage(), 's_password' => $password);
}
}
示例6: basic_info
function basic_info()
{
require_once LIB_PATH . 'osclass/model/Admin.php';
require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
$admin = Params::getParam('s_name');
if ($admin == '') {
$admin = 'admin';
}
$password = Params::getParam('s_passwd', false, false);
if ($password == '') {
$password = osc_genRandomPassword();
}
Admin::newInstance()->insert(array('s_name' => 'Administrator', 's_username' => $admin, 's_password' => sha1($password), 's_email' => Params::getParam('email')));
$mPreference = Preference::newInstance();
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'pageTitle', 's_value' => Params::getParam('webtitle'), 'e_type' => 'STRING'));
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'contactEmail', 's_value' => Params::getParam('email'), 'e_type' => 'STRING'));
$body = sprintf(__('Welcome %s,'), Params::getParam('webtitle')) . "<br/><br/>";
$body .= sprintf(__('Your OSClass installation at %s is up and running. You can access the administration panel with these details:'), WEB_PATH) . "<br/>";
$body .= '<ul>';
$body .= '<li>' . sprintf(__('username: %s'), $admin) . '</li>';
$body .= '<li>' . sprintf(__('password: %s'), $password) . '</li>';
$body .= '</ul>';
$body .= __('Regards,') . "<br/>";
$body .= __('The <a href="http://osclass.org/">OSClass</a> team');
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
try {
require_once LIB_PATH . 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(true);
$mail->CharSet = "utf-8";
$mail->Host = "localhost";
$mail->From = 'osclass@' . $sitename;
$mail->FromName = 'OSClass';
$mail->Subject = 'OSClass successfully installed!';
$mail->AddAddress(Params::getParam('email'), 'OSClass administrator');
$mail->Body = $body;
$mail->AltBody = $body;
if (!$mail->Send()) {
return array('email_status' => Params::getParam('email') . "<br>" . $mail->ErrorInfo, 's_password' => $password);
}
return array('email_status' => '', 's_password' => $password);
} catch (phpmailerException $exception) {
return array('email_status' => Params::getParam('email') . "<br>" . $exception->errorMessage(), 's_password' => $password);
}
}
示例7: doModel
function doModel()
{
switch ($this->action) {
case 'login_post':
//post execution for the login
if (Params::getParam('user') == '' && Params::getParam('password', false, false) == '') {
$this->redirectTo(osc_admin_base_url());
}
if (Params::getParam('user') == '') {
osc_add_flash_error_message(_m('The username field is empty'), 'admin');
$this->redirectTo(osc_admin_base_url());
}
if (Params::getParam('password') == '') {
osc_add_flash_error_message(_m('The password field is empty'), 'admin');
$this->redirectTo(osc_admin_base_url());
}
// fields are not empty
$admin = Admin::newInstance()->findByUsername(Params::getParam('user'));
if (!$admin) {
osc_add_flash_error_message(sprintf(_m('Sorry, incorrect username. <a href="%s">Have you lost your password?</a>'), osc_admin_base_url(true) . '?page=login&action=recover'), 'admin');
$this->redirectTo(osc_admin_base_url());
}
if ($admin["s_password"] !== sha1(Params::getParam('password', false, false))) {
osc_add_flash_error_message(sprintf(_m('Sorry, incorrect password. <a href="%s">Have you lost your password?</a>'), osc_admin_base_url(true) . '?page=login&action=recover'), 'admin');
$this->redirectTo(osc_admin_base_url());
}
if (Params::getParam('remember')) {
// this include contains de osc_genRandomPassword function
require_once osc_lib_path() . 'osclass/helpers/hSecurity.php';
$secret = osc_genRandomPassword();
Admin::newInstance()->update(array('s_secret' => $secret), array('pk_i_id' => $admin['pk_i_id']));
Cookie::newInstance()->set_expires(osc_time_cookie());
Cookie::newInstance()->push('oc_adminId', $admin['pk_i_id']);
Cookie::newInstance()->push('oc_adminSecret', $secret);
Cookie::newInstance()->push('oc_adminLocale', Params::getParam('locale'));
Cookie::newInstance()->set();
}
// we are logged in... let's go!
Session::newInstance()->_set('adminId', $admin['pk_i_id']);
Session::newInstance()->_set('adminUserName', $admin['s_username']);
Session::newInstance()->_set('adminName', $admin['s_name']);
Session::newInstance()->_set('adminEmail', $admin['s_email']);
Session::newInstance()->_set('adminLocale', Params::getParam('locale'));
$this->redirectTo(osc_admin_base_url());
break;
case 'recover':
// form to recover the password (in this case we have the form in /gui/)
$this->doView('gui/recover.php');
break;
case 'recover_post':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url());
}
// post execution to recover the password
$admin = Admin::newInstance()->findByEmail(Params::getParam('email'));
if ($admin) {
if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) {
if (!osc_check_recaptcha()) {
osc_add_flash_error_message(_m('The Recaptcha code is wrong'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=login&action=recover');
return false;
// BREAK THE PROCESS, THE RECAPTCHA IS WRONG
}
}
require_once osc_lib_path() . 'osclass/helpers/hSecurity.php';
$newPassword = osc_genRandomPassword(40);
Admin::newInstance()->update(array('s_secret' => $newPassword), array('pk_i_id' => $admin['pk_i_id']));
$password_url = osc_forgot_admin_password_confirm_url($admin['pk_i_id'], $newPassword);
osc_run_hook('hook_email_user_forgot_password', $admin, $password_url);
}
osc_add_flash_ok_message(_m('A new password has been sent to your e-mail'), 'admin');
$this->redirectTo(osc_admin_base_url());
break;
case 'forgot':
// form to recover the password (in this case we have the form in /gui/)
$admin = Admin::newInstance()->findByIdSecret(Params::getParam('adminId'), Params::getParam('code'));
if (!$admin) {
osc_add_flash_error_message(_m('Sorry, the link is not valid'), 'admin');
$this->redirectTo(osc_admin_base_url());
}
$this->doView('gui/forgot_password.php');
break;
case 'forgot_post':
$admin = Admin::newInstance()->findByIdSecret(Params::getParam('adminId'), Params::getParam('code'));
if (!$admin) {
osc_add_flash_error_message(_m('Sorry, the link is not valid'), 'admin');
$this->redirectTo(osc_admin_base_url());
}
if (Params::getParam('new_password', false, false) == Params::getParam('new_password2', false, false)) {
Admin::newInstance()->update(array('s_secret' => osc_genRandomPassword(), 's_password' => sha1(Params::getParam('new_password', false, false))), array('pk_i_id' => $admin['pk_i_id']));
osc_add_flash_ok_message(_m('The password has been changed'), 'admin');
$this->redirectTo(osc_admin_base_url());
} else {
osc_add_flash_error_message(_m("Error, the password don't match"), 'admin');
$this->redirectTo(osc_forgot_admin_password_confirm_url(Params::getParam('adminId'), Params::getParam('code')));
}
break;
}
}
示例8: doModel
function doModel()
{
switch ($this->action) {
case 'change_email_confirm':
//change email confirm
if (Params::getParam('userId') && Params::getParam('code')) {
$userManager = new User();
$user = $userManager->findByPrimaryKey(Params::getParam('userId'));
if ($user['s_pass_code'] == Params::getParam('code') && $user['b_enabled'] == 1) {
$userEmailTmp = UserEmailTmp::newInstance()->findByPk(Params::getParam('userId'));
$code = osc_genRandomPassword(50);
$userManager->update(array('s_email' => $userEmailTmp['s_new_email']), array('pk_i_id' => $userEmailTmp['fk_i_user_id']));
Item::newInstance()->update(array('s_contact_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
ItemComment::newInstance()->update(array('s_author_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
Alerts::newInstance()->update(array('s_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
Session::newInstance()->_set('userEmail', $userEmailTmp['s_new_email']);
UserEmailTmp::newInstance()->delete(array('s_new_email' => $userEmailTmp['s_new_email']));
osc_add_flash_ok_message(_m('Your email has been changed successfully'));
$this->redirectTo(osc_user_profile_url());
} else {
osc_add_flash_error_message(_m('Sorry, the link is not valid'));
$this->redirectTo(osc_base_url());
}
} else {
osc_add_flash_error_message(_m('Sorry, the link is not valid'));
$this->redirectTo(osc_base_url());
}
break;
case 'activate_alert':
$email = Params::getParam('email');
$secret = Params::getParam('secret');
$result = 0;
if ($email != '' && $secret != '') {
$result = Alerts::newInstance()->activate($email, $secret);
}
if ($result == 1) {
osc_add_flash_ok_message(_m('Alert activated'));
} else {
osc_add_flash_error_message(_m('Ops! There was a problem trying to activate alert. Please contact the administrator'));
}
$this->redirectTo(osc_base_url(true));
break;
case 'unsub_alert':
$email = Params::getParam('email');
$secret = Params::getParam('secret');
if ($email != '' && $secret != '') {
Alerts::newInstance()->delete(array('s_email' => $email, 'S_secret' => $secret));
osc_add_flash_ok_message(_m('Unsubscribed correctly'));
} else {
osc_add_flash_error_message(_m('Ops! There was a problem trying to unsubscribe you. Please contact the administrator'));
}
$this->redirectTo(osc_base_url());
break;
case 'pub_profile':
$userID = Params::getParam('id');
$user = User::newInstance()->findByPrimaryKey($userID);
// user doesn't exist
if (!$user) {
$this->redirectTo(osc_base_url());
}
View::newInstance()->_exportVariableToView('user', $user);
$items = Item::newInstance()->findByUserIDEnabled($user['pk_i_id'], 0, 3);
View::newInstance()->_exportVariableToView('items', $items);
$this->doView('user-public-profile.php');
break;
case 'contact_post':
$user = User::newInstance()->findByPrimaryKey(Params::getParam('id'));
View::newInstance()->_exportVariableToView('user', $user);
if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) {
if (!osc_check_recaptcha()) {
osc_add_flash_error_message(_m('The Recaptcha code is wrong'));
Session::newInstance()->_setForm("yourEmail", Params::getParam('yourEmail'));
Session::newInstance()->_setForm("yourName", Params::getParam('yourName'));
Session::newInstance()->_setForm("phoneNumber", Params::getParam('phoneNumber'));
Session::newInstance()->_setForm("message_body", Params::getParam('message'));
$this->redirectTo(osc_user_public_profile_url());
return false;
// BREAK THE PROCESS, THE RECAPTCHA IS WRONG
}
}
osc_run_hook('hook_email_contact_user', Params::getParam('id'), Params::getParam('yourEmail'), Params::getParam('yourName'), Params::getParam('phoneNumber'), Params::getParam('message'));
$this->redirectTo(osc_user_public_profile_url());
break;
default:
$this->redirectTo(osc_user_login_url());
break;
}
}
示例9: doModel
//.........这里部分代码省略.........
$json['msg'] = _m('The item doesn\'t belong to you');
echo json_encode($json);
return false;
}
// Check if the secret passphrase match with the item
if ($userId == null && $aItem['fk_i_user_id'] == null && $secret != $aItem['s_secret']) {
$json['success'] = false;
$json['msg'] = _m('The item doesn\'t belong to you');
echo json_encode($json);
return false;
}
// Does id & code combination exist?
$result = ItemResource::newInstance()->existResource($id, $code);
if ($result > 0) {
// Delete: file, db table entry
osc_deleteResource($id);
ItemResource::newInstance()->delete(array('pk_i_id' => $id, 'fk_i_item_id' => $item, 's_name' => $code));
$json['msg'] = _m('The selected photo has been successfully deleted');
$json['success'] = 'true';
} else {
$json['msg'] = _m("The selected photo couldn't be deleted");
$json['success'] = 'false';
}
echo json_encode($json);
return true;
break;
case 'alerts':
// Allow to register to an alert given (not sure it's used on admin)
$alert = Params::getParam("alert");
$email = Params::getParam("email");
$userid = Params::getParam("userid");
if ($alert != '' && $email != '') {
if (preg_match("/^[_a-z0-9-+]+(\\.[_a-z0-9-+]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})\$/", $email)) {
$secret = osc_genRandomPassword();
if (Alerts::newInstance()->createAlert($userid, $email, $alert, $secret)) {
if ((int) $userid > 0) {
$user = User::newInstance()->findByPrimaryKey($userid);
if ($user['b_active'] == 1 && $user['b_enabled'] == 1) {
Alerts::newInstance()->activate($email, $secret);
echo '1';
return true;
} else {
echo '-1';
return false;
}
} else {
osc_run_hook('hook_email_alert_validation', $alert, $email, $secret);
}
echo "1";
} else {
echo "0";
}
return true;
} else {
echo '-1';
return false;
}
}
echo '0';
return false;
break;
case 'runhook':
//Run hooks
$hook = Params::getParam("hook");
switch ($hook) {
case 'item_form':
示例10: doModel
//.........这里部分代码省略.........
} else {
$img_normal = $path . $resource['pk_i_id'] . ".*";
$aImages = glob($img_normal);
if (count($aImages) == 1) {
$image_tmp = $aImages[0];
} else {
$img_thumbnail = $path . $resource['pk_i_id'] . "_thumbnail*";
$aImages = glob($img_thumbnail);
$image_tmp = $aImages[0];
}
}
// extension
preg_match('/\\.(.*)$/', $image_tmp, $matches);
if (isset($matches[1])) {
$extension = $matches[1];
// Create normal size
$path_normal = $path = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . '.jpg';
$size = explode('x', osc_normal_dimensions());
ImageResizer::fromFile($image_tmp)->resizeTo($size[0], $size[1])->saveToFile($path);
if (osc_is_watermark_text()) {
$wat->doWatermarkText($path, osc_watermark_text_color(), osc_watermark_text(), 'image/jpeg');
} elseif (osc_is_watermark_image()) {
$wat->doWatermarkImage($path, 'image/jpeg');
}
// Create preview
$path = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . '_preview.jpg';
$size = explode('x', osc_preview_dimensions());
ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
// Create thumbnail
$path = osc_content_path() . 'uploads/' . $resource['pk_i_id'] . '_thumbnail.jpg';
$size = explode('x', osc_thumbnail_dimensions());
ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);
// update resource info
ItemResource::newInstance()->update(array('s_path' => 'oc-content/uploads/', 's_name' => osc_genRandomPassword(), 's_extension' => 'jpg', 's_content_type' => 'image/jpeg'), array('pk_i_id' => $resource['pk_i_id']));
osc_run_hook('regenerated_image', ItemResource::newInstance()->findByPrimaryKey($resource['pk_i_id']));
// si extension es direfente a jpg, eliminar las imagenes con $extension si hay
if ($extension != 'jpg') {
@unlink(osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "." . $extension);
@unlink(osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "_original." . $extension);
@unlink(osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "_preview." . $extension);
@unlink(osc_content_path() . 'uploads/' . $resource['pk_i_id'] . "_thumbnail." . $extension);
}
// ....
} else {
// no es imagen o imagen sin extesión
}
}
osc_add_flash_ok_message(_m('Re-generation complete'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=media');
break;
case 'update':
// update index view
$iUpdated = 0;
$sPageTitle = Params::getParam('pageTitle');
$sPageDesc = Params::getParam('pageDesc');
$sContactEmail = Params::getParam('contactEmail');
$sLanguage = Params::getParam('language');
$sDateFormat = Params::getParam('dateFormat');
$sCurrency = Params::getParam('currency');
$sWeekStart = Params::getParam('weekStart');
$sTimeFormat = Params::getParam('timeFormat');
$sTimezone = Params::getParam('timezone');
$sNumRssItems = Params::getParam('num_rss_items');
$maxLatestItems = Params::getParam('max_latest_items_at_home');
$numItemsSearch = Params::getParam('default_results_per_page');
$contactAttachment = Params::getParam('enabled_attachment');
示例11: getConnection
<?php
$adManage_plugin_data = Plugins::getInfo('advanced_ad_management/index.php');
if (Params::getParam('addExistingAds') == 1) {
$conn = getConnection();
$allItem = $conn->osc_dbFetchResults("SELECT DISTINCT * FROM %st_item_description", DB_TABLE_PREFIX);
$dao_preference = new Preference();
foreach ($allItem as $itemB) {
$r_secret = '';
$r_secret = osc_genRandomPassword();
$conn->osc_dbExec("REPLACE INTO %st_item_adManage_limit (fk_i_item_id, r_secret, r_times) VALUES (%d, '%s', %d)", DB_TABLE_PREFIX, $itemB['fk_i_item_id'], $r_secret, 0);
}
$dao_preference->update(array("s_value" => '1'), array("s_section" => "plugin-item_adManage", "s_name" => "adManageed_installed"));
unset($dao_preference);
echo '<script>location.href="' . osc_admin_base_url(true) . '?page=plugins&action=renderplugin&file=advanced_ad_management/admin.php"</script>';
}
// end of the addExistingAds section
//Master setting for expired days.
//Jesse's Ad Expiration plugin.
$days = '';
if (Params::getParam('days') != '') {
$days = Params::getParam('days');
} else {
$conn = getConnection();
$data = $conn->osc_dbFetchResult("SELECT * FROM %st_category", DB_TABLE_PREFIX);
$days = $data['i_expiration_days'];
}
if (Params::getParam('option') == 'update') {
if ($days > 999) {
$days = 999;
}
示例12: doModel
function doModel()
{
switch ($this->action) {
case 'dashboard':
//dashboard...
$max_items = Params::getParam('max_items') != '' ? Params::getParam('max_items') : 5;
$aItems = Item::newInstance()->findByUserIDEnabled(Session::newInstance()->_get('userId'), 0, $max_items);
//calling the view...
$this->_exportVariableToView('items', $aItems);
$this->_exportVariableToView('max_items', $max_items);
$this->doView('user-dashboard.php');
break;
case 'profile':
//profile...
$user = User::newInstance()->findByPrimaryKey(Session::newInstance()->_get('userId'));
$aCountries = Country::newInstance()->listAll();
$aRegions = array();
if ($user['fk_c_country_code'] != '') {
$aRegions = Region::newInstance()->findByCountry($user['fk_c_country_code']);
} elseif (count($aCountries) > 0) {
$aRegions = Region::newInstance()->findByCountry($aCountries[0]['pk_c_code']);
}
$aCities = array();
if ($user['fk_i_region_id'] != '') {
$aCities = City::newInstance()->findByRegion($user['fk_i_region_id']);
} else {
if (count($aRegions) > 0) {
$aCities = City::newInstance()->findByRegion($aRegions[0]['pk_i_id']);
}
}
//calling the view...
$this->_exportVariableToView('countries', $aCountries);
$this->_exportVariableToView('regions', $aRegions);
$this->_exportVariableToView('cities', $aCities);
$this->_exportVariableToView('user', $user);
$this->doView('user-profile.php');
break;
case 'profile_post':
//profile post...
$userId = Session::newInstance()->_get('userId');
require_once LIB_PATH . 'osclass/UserActions.php';
$userActions = new UserActions(false);
$success = $userActions->edit($userId);
osc_add_flash_ok_message(_m('Your profile has been updated successfully'));
$this->redirectTo(osc_user_profile_url());
break;
case 'alerts':
//alerts
$aAlerts = Alerts::newInstance()->findByUser(Session::newInstance()->_get('userId'));
$user = User::newInstance()->findByPrimaryKey(Session::newInstance()->_get('userId'));
foreach ($aAlerts as $k => $a) {
$search = osc_unserialize(base64_decode($a['s_search']));
$search->limit(0, 3);
$aAlerts[$k]['items'] = $search->doSearch();
}
$this->_exportVariableToView('alerts', $aAlerts);
View::newInstance()->_reset('alerts');
$this->_exportVariableToView('user', $user);
$this->doView('user-alerts.php');
break;
case 'change_email':
//change email
$this->doView('user-change_email.php');
break;
case 'change_email_post':
//change email post
if (!preg_match("/^[_a-z0-9-\\+]+(\\.[_a-z0-9-\\+]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})\$/", Params::getParam('new_email'))) {
osc_add_flash_error_message(_m('The specified e-mail is not valid'));
$this->redirectTo(osc_change_user_email_url());
} else {
$user = User::newInstance()->findByEmail(Params::getParam('new_email'));
if (!isset($user['pk_i_id'])) {
$userEmailTmp = array();
$userEmailTmp['fk_i_user_id'] = Session::newInstance()->_get('userId');
$userEmailTmp['s_new_email'] = Params::getParam('new_email');
UserEmailTmp::newInstance()->insertOrUpdate($userEmailTmp);
$code = osc_genRandomPassword(30);
$date = date('Y-m-d H:i:s');
$userManager = new User();
$userManager->update(array('s_pass_code' => $code, 's_pass_date' => $date, 's_pass_ip' => $_SERVER['REMOTE_ADDR']), array('pk_i_id' => Session::newInstance()->_get('userId')));
$validation_url = osc_change_user_email_confirm_url(Session::newInstance()->_get('userId'), $code);
osc_run_hook('hook_email_new_email', Params::getParam('new_email'), $validation_url);
$this->redirectTo(osc_user_profile_url());
} else {
osc_add_flash_error_message(_m('The specified e-mail is already in use'));
$this->redirectTo(osc_change_user_email_url());
}
}
break;
case 'change_password':
//change password
$this->doView('user-change_password.php');
break;
case 'change_password_post':
//change password post
$user = User::newInstance()->findByPrimaryKey(Session::newInstance()->_get('userId'));
if (Params::getParam('password') == '' || Params::getParam('new_password') == '' || Params::getParam('new_password2') == '') {
osc_add_flash_warning_message(_m('Password cannot be blank'));
$this->redirectTo(osc_change_user_password_url());
}
//.........这里部分代码省略.........
示例13: doModel
function doModel()
{
switch ($this->action) {
case 'login_post':
//post execution for the login
if (!osc_users_enabled()) {
osc_add_flash_error_message(_m('Users are not enabled'));
$this->redirectTo(osc_base_url());
}
require_once LIB_PATH . 'osclass/UserActions.php';
$user = User::newInstance()->findByEmail(Params::getParam('email'));
$url_redirect = osc_user_dashboard_url();
$page_redirect = '';
if (osc_rewrite_enabled()) {
if (isset($_SERVER['HTTP_REFERER'])) {
$request_uri = urldecode(preg_replace('@^' . osc_base_url() . '@', "", $_SERVER['HTTP_REFERER']));
$tmp_ar = explode("?", $request_uri);
$request_uri = $tmp_ar[0];
$rules = Rewrite::newInstance()->listRules();
foreach ($rules as $match => $uri) {
if (preg_match('#' . $match . '#', $request_uri, $m)) {
$request_uri = preg_replace('#' . $match . '#', $uri, $request_uri);
if (preg_match('|([&?]{1})page=([^&]*)|', '&' . $request_uri . '&', $match)) {
$page_redirect = $match[2];
}
break;
}
}
}
} else {
if (preg_match('|[\\?&]page=([^&]+)|', $_SERVER['HTTP_REFERER'] . '&', $match)) {
$page_redirect = $match[1];
}
}
if (Params::getParam('http_referer') != '') {
Session::newInstance()->_setReferer(Params::getParam('http_referer'));
$url_redirect = Params::getParam('http_referer');
} else {
if (Session::newInstance()->_getReferer() != '') {
Session::newInstance()->_setReferer(Session::newInstance()->_getReferer());
$url_redirect = Session::newInstance()->_getReferer();
} else {
if ($page_redirect != '' && $page_redirect != 'login') {
Session::newInstance()->_setReferer($_SERVER['HTTP_REFERER']);
$url_redirect = $_SERVER['HTTP_REFERER'];
}
}
}
if (!$user) {
osc_add_flash_error_message(_m('The username doesn\'t exist'));
$this->redirectTo(osc_user_login_url());
}
if ($user["s_password"] != sha1(Params::getParam('password'))) {
osc_add_flash_error_message(_m('The password is incorrect'));
$this->redirectTo(osc_user_login_url());
}
$uActions = new UserActions(false);
$logged = $uActions->bootstrap_login($user['pk_i_id']);
if ($logged == 0) {
osc_add_flash_error_message(_m('The username doesn\'t exist'));
} else {
if ($logged == 1) {
osc_add_flash_error_message(_m('The user has not been validated yet'));
} else {
if ($logged == 2) {
osc_add_flash_error_message(_m('The user has been suspended'));
} else {
if ($logged == 3) {
if (Params::getParam('remember') == 1) {
//this include contains de osc_genRandomPassword function
require_once osc_lib_path() . 'osclass/helpers/hSecurity.php';
$secret = osc_genRandomPassword();
User::newInstance()->update(array('s_secret' => $secret), array('pk_i_id' => $user['pk_i_id']));
Cookie::newInstance()->set_expires(osc_time_cookie());
Cookie::newInstance()->push('oc_userId', $user['pk_i_id']);
Cookie::newInstance()->push('oc_userSecret', $secret);
Cookie::newInstance()->set();
}
$this->redirectTo($url_redirect);
} else {
osc_add_flash_error_message(_m('This should never happens'));
}
}
}
}
if (!$user['b_enabled']) {
$this->redirectTo(osc_user_login_url());
}
$this->redirectTo(osc_user_login_url());
break;
case 'recover':
//form to recover the password (in this case we have the form in /gui/)
$this->doView('user-recover.php');
break;
case 'recover_post':
//post execution to recover the password
require_once LIB_PATH . 'osclass/UserActions.php';
// e-mail is incorrect
if (!preg_match('|^[a-z0-9\\.\\_\\+\\-]+@[a-z0-9\\.\\-]+\\.[a-z]{2,3}$|i', Params::getParam('s_email'))) {
osc_add_flash_error_message(_m('Invalid email address'));
//.........这里部分代码省略.........
示例14: uploadItemResources
public function uploadItemResources($aResources,$itemId)
{
if($aResources != '') {
$itemResourceManager = ItemResource::newInstance();
$folder = osc_uploads_path().(floor($itemId/100))."/";
$numImagesItems = osc_max_images_per_item();
$numImages = $itemResourceManager->countResources($itemId);
foreach ($aResources['error'] as $key => $error) {
if($numImagesItems==0 || ($numImagesItems>0 && $numImages<$numImagesItems)) {
if ($error == UPLOAD_ERR_OK) {
$tmpName = $aResources['tmp_name'][$key];
$imgres = ImageResizer::fromFile($tmpName);
$extension = osc_apply_filter('upload_image_extension', $imgres->getExt());
$mime = osc_apply_filter('upload_image_mime', $imgres->getMime());
// Create normal size
$normal_path = $path = $tmpName."_normal";
$size = explode('x', osc_normal_dimensions());
$img = ImageResizer::fromFile($tmpName)->autoRotate()->resizeTo($size[0], $size[1]);
if( osc_is_watermark_text() ) {
$img->doWatermarkText(osc_watermark_text(), osc_watermark_text_color());
} else if ( osc_is_watermark_image() ){
$img->doWatermarkImage();
}
$img->saveToFile($path, $extension);
// Create preview
$path = $tmpName."_preview";
$size = explode('x', osc_preview_dimensions());
ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path, $extension);
// Create thumbnail
$path = $tmpName."_thumbnail";
$size = explode('x', osc_thumbnail_dimensions());
ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path, $extension);
$numImages++;
$itemResourceManager->insert(array(
'fk_i_item_id' => $itemId
));
$resourceId = $itemResourceManager->dao->insertedId();
if(!is_dir($folder)) {
if (!@mkdir($folder, 0755, true)) {
return 3; // PATH CAN NOT BE CREATED
}
}
osc_copy($tmpName.'_normal', $folder.$resourceId.'.'.$extension);
osc_copy($tmpName.'_preview', $folder.$resourceId.'_preview.'.$extension);
osc_copy($tmpName.'_thumbnail', $folder.$resourceId.'_thumbnail.'.$extension);
if( osc_keep_original_image() ) {
$path = $folder.$resourceId.'_original.'.$extension;
osc_copy($tmpName, $path);
}
@unlink($tmpName."_normal");
@unlink($tmpName."_preview");
@unlink($tmpName."_thumbnail");
@unlink($tmpName);
$s_path = str_replace(osc_base_path(), '', $folder);
$itemResourceManager->update(
array(
's_path' => $s_path
,'s_name' => osc_genRandomPassword()
,'s_extension' => $extension
,'s_content_type' => $mime
)
,array(
'pk_i_id' => $resourceId
,'fk_i_item_id' => $itemId
)
);
osc_run_hook('uploaded_file', ItemResource::newInstance()->findByPrimaryKey($resourceId));
}
}
}
unset($itemResourceManager);
}
return 0; // NO PROBLEMS
}
示例15: register_user
function register_user($user)
{
$manager = User::newInstance();
$input['s_name'] = $user['name'];
$input['s_email'] = $user['email'];
$input['s_password'] = sha1(osc_genRandomPassword());
$input['dt_reg_date'] = date('Y-m-d H:i:s');
$input['s_secret'] = osc_genRandomPassword();
$email_taken = $manager->findByEmail($input['s_email']);
if ($email_taken == null) {
$manager->insert($input);
$userID = $manager->dao->insertedId();
$result = $manager->dao->replace();
osc_run_hook('user_register_completed', $userID);
$userDB = $manager->findByPrimaryKey($userID);
if (osc_notify_new_user()) {
osc_run_hook('hook_email_admin_new_user', $userDB);
}
if (osc_version() >= 310) {
$manager->update(array('b_active' => '1', 's_username' => $userID), array('pk_i_id' => $userID));
} else {
$manager->update(array('b_active' => '1'), array('pk_i_id' => $userID));
}
insert_facebook_user_data($userID, $user['id']);
osc_run_hook('hook_email_user_registration', $userDB);
osc_run_hook('validate_user', $userDB);
osc_add_flash_ok_message(sprintf(__('Your account has been created successfully', 'facebook'), osc_page_title()));
}
}