$i = 0; while ($row = db_array($result['result'])) { $fTo = $row[0]; $fHeaders = 'To: ' . $fTo . "\n"; $fHeaders .= 'From: ' . $b_name . ' <' . $smtp_from_email . ">\n"; $fHeaders .= 'Subject: ' . $b_subject . "\n"; $fHeaders .= 'MIME-Version: 1.0' . "\n"; $fHeaders .= 'Content-Type: text/plain; charset=UTF-8' . "\n"; $fHeaders .= 'Content-Transfer-Encoding: base64' . "\n"; $fHeaders .= $b_message; if (!smtp_mail($fTo, $smtp_from_email, $fHeaders)) { flash_error(Config::lang_f('pSendmail_result_error', $fTo)); } else { flash_info(Config::lang_f('pSendmail_result_success', $fTo)); } } } flash_info($PALANG['pBroadcast_success']); $smarty->assign('smarty_template', 'message'); $smarty->display('index.tpl'); // echo '<p>'.$PALANG['pBroadcast_success'].'</p>'; } } if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1) { $smarty->assign('smtp_from_email', $smtp_from_email); $smarty->assign('error', $error); $smarty->assign('smarty_template', 'broadcast-message'); $smarty->display('index.tpl'); // include ("templates/broadcast-message.tpl"); } /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
$smtp_from_email = smtp_get_admin_email(); if ($_SERVER['REQUEST_METHOD'] == "POST") { $fTo = safepost('fTo'); $fFrom = $smtp_from_email; $fSubject = safepost('fSubject'); $tBody = $_POST['fBody']; if (get_magic_quotes_gpc()) { $tBody = stripslashes($tBody); # TODO: check for get_magic_quotes_gpc inside safepost/safeget } $email_check = check_email($fTo); if (empty($fTo) or $email_check != '') { $error = 1; $tTo = escape_string($_POST['fTo']); $tSubject = escape_string($_POST['fSubject']); flash_error($PALANG['pSendmail_to_text_error']); # TODO: superfluous? flash_error($email_check); } if ($error != 1) { if (!smtp_mail($fTo, $fFrom, $fSubject, $tBody)) { flash_error(Config::lang_f('pSendmail_result_error', $fTo)); } else { flash_info(Config::lang_f('pSendmail_result_success', $fTo)); } } } $smarty->assign('smtp_from_email', $smtp_from_email); $smarty->assign('smarty_template', 'sendmail'); $smarty->display('index.tpl'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
if (safeget('token') != $_SESSION['PFA_token']) { die('Invalid token!'); } $username = authentication_get_username(); # enforce login $id = safeget('delete'); $table = safeget('table'); $handlerclass = ucfirst($table) . 'Handler'; if (!preg_match('/^[a-z]+$/', $table) || !file_exists("model/{$handlerclass}.php")) { # validate $table die("Invalid table name given!"); } $is_admin = authentication_has_role('admin'); $handler = new $handlerclass(0, $username, $is_admin); $formconf = $handler->webformConfig(); if ($is_admin) { authentication_require_role($formconf['required_role']); } else { if (empty($formconf['user_hardcoded_field'])) { die($handlerclass . ' is not available for users'); } } if ($handler->init($id)) { # errors will be displayed as last step anyway, no need for duplicated code ;-) $handler->delete(); } flash_error($handler->errormsg); flash_info($handler->infomsg); header("Location: " . $formconf['listview']); exit; /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
/** * Сохранение индекса * * @param type $path */ public function save_action() { $this->hookAdminMenu(1); $this->hookAdminMenu(2); if ($index = session('admin.lang.index')) { if ($path = session('admin.lang.scan.path')) { $path .= $this->prepareFilePath(); $this->updateLangFile($path, $index); flash_success(t('Индекс успешно записан в файл <b>%s</b>!', File::pathToUri($path))); flash_info(t('Индекс удалён.')); cogear()->session->remove('admin.lang.scan.path'); } else { flash_error(t('Не указан путь файла, в который необходимо записать индекс.')); } } else { flash_error(t('Индекс пуст.')); } back(); }
/** * Update gears * * @param array $gears */ private function update_gears($gears) { $cogear = getInstance(); $result = array(); foreach ($gears as $gear) { $cogear->update($gear); $result[] = t($gear, 'Gears'); } $result && flash_info(t('Following gears were updated: ') . '<b>' . implode('</b>, <b>', $result) . '</b>.'); }
$tMessage = $PALANG['pUsersVacation_result_error']; } // add the goto record back in... $comma = ''; if (strlen($tGoto) > 1) { $comma = ','; } $goto = $tGoto . $comma . $vacation_goto; $result = db_query("UPDATE {$table_alias} SET goto='{$goto}',modified=NOW() WHERE address='{$USERID_USERNAME}'"); if ($result['rows'] != 1) { $error = 1; $tMessage = $PALANG['pUsersVacation_result_error']; } else { flash_info($PALANG['pVacation_result_added']); header("Location: main.php"); exit; } } if (!empty($fBack)) { if ($tMessage == '' || ($tMessage = $PALANG['pUsersVacation_result_success'])) { flash_info($PALANG['pVacation_result_removed']); header("Location: main.php"); exit; } } } include "../templates/header.php"; include "../templates/users_menu.php"; include "../templates/users_vacation.php"; include "../templates/footer.php"; /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
# do not change password to empty one $password_query = ", password='******'"; } $result = db_query("UPDATE {$table_admin} SET modified=NOW(),active='{$sqlActive}' {$password_query} WHERE username='******'"); if ($fSadmin == "on") { $fSadmin = 'ALL'; } // delete everything, and put it back later on.. db_query("DELETE FROM {$table_domain_admins} WHERE username = '******'"); if ($fSadmin == 'ALL') { $fDomains = array('ALL'); } foreach ($fDomains as $domain) { $result = db_query("INSERT INTO {$table_domain_admins} (username,domain,created) VALUES ('{$username}','{$domain}',NOW())"); } flash_info($PALANG['pAdminEdit_admin_result_success']); header("Location: list-admin.php"); exit(0); } else { flash_error($PALANG['pAdminEdit_admin_result_error']); } } if (isset($_GET['username'])) { $username = escape_string($_GET['username']); } $tAllDomains = list_domains(); $tDomains = list_domains_for_admin($username); $tActive = ''; $tPassword = $admin_details['password']; if ($admin_details['active'] == 't' || $admin_details['active'] == 1) { $tActive = $admin_details['active'];
flash_error($validpass[0]); # TODO: honor all error messages, not only the first one $error += 1; } $mh = new MailboxHandler(); if (!$mh->login($username, $fPassword_current)) { $error += 1; $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error']; } if (empty($fPassword) or $fPassword != $fPassword2) { $error += 1; $pPassword_password_text = $PALANG['pPassword_password_text_error']; } if ($error == 0) { $mh->init($username); # TODO: error handling if ($mh->change_pw($fPassword, $fPassword_current)) { flash_info(Config::Lang_f('pPassword_result_success', $username)); header("Location: main.php"); exit(0); } else { flash_error(Config::Lang_f('pPassword_result_error', $username)); } } } $smarty->assign('SESSID_USERNAME', $username); $smarty->assign('pPassword_password_current_text', $pPassword_password_current_text, false); $smarty->assign('pPassword_password_text', $pPassword_password_text, false); $smarty->assign('smarty_template', 'password'); $smarty->display('index.tpl'); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
/** * Default dispatcher * * @param string $action */ public function index_action($action = '', $subaction = NULL) { if (!empty($_POST['token'])) { // Get the profile of authorized user $UserProfile = $this->api->getAuthInfo($_POST['token']); // Check for errors if (!empty($UserProfile->error_type)) { // Debug info for developer error(t($UserProfile->error_type . ": " . $UserProfile->error_message)); } elseif (empty($UserProfile)) { error(t('Temporary error with Loginza authentification.')); } else { $this->session->loginza = $UserProfile; } } if ($loginza = $this->session->loginza) { /** * There we have 3 ways of workflow * * 1. User is logged in. Add new identity to database if it's not exist. * 2. User is registred. Authorize. * 3. User is not registred. Show register form connected and fullfilled with Loginza data (login, e-mail and so on). */ $user = new Db_ORM('users_loginza'); $user->identity = $loginza->identity; // If user is logged in if ($this->user->id) { // If integration is found if ($user->find()) { // If integration belongs to the current user if ($user->uid == $this->user->id) { $user->loginza->data = json_encode($loginza); $user->update(); flash_info(t('Your integration with profile <b>%s</b> was updated successfully.', 'Loginza', $loginza->identity), t('Updated succeed.')); } else { flash_error(t('Profile <b>%s</b> is integrated with sombody else account. You cannot use it before someone would left it out.', 'Loginza', $loginza->identity), t('Update failure.')); } } else { // Create new database record $user->uid = $this->user->id; $user->provider = $loginza->provider; $UserProfile = new Loginza_UserProfile($loginza); isset($loginza->photo) && ($user->photo = $loginza->photo); $user->full_name = $UserProfile->genFullName(); $user->data = json_encode($loginza); $user->save(); } $this->session->loginza = NULL; // Redirect to user profile redirect(Url::gear('user') . 'edit/#tab-social'); } else { // Record found → try to log in if ($user->find()) { $search = new User_Object(); $search->id = $user->uid; if ($search->find()) { $this->user->forceLogin($user->uid, 'id'); } else { flash_error(t('Cannot find user with id <b>%s</b>.', 'Loginza', $user->uid)); } $this->session->loginza = NULL; // This tiny little redirect caused error by Loginza "Invalid / empty session data! Retry auth.: // Left it where it is for memories. // Important! Do not uncomment! //back(); } else { if (!access('user register')) { return info('You don\'t have an access to registration'); } success('First step of registration is done. Please, fill some fields to complete your registration.'); $form = new Form('User.register'); $UserProfile = new Loginza_UserProfile($loginza); $tpl = new Template('Loginza.register'); $tpl->loginza = $loginza; $tpl->profile = $UserProfile; append('content', $tpl->render()); $data['login'] = $UserProfile->genFullName(); isset($loginza->email) && ($data['email'] = $loginza->email); $form->setValues($data); if ($data = $form->result()) { $this->user->object($data); $this->user->hashPassword(); if ($uid = $this->user->save()) { // Create new database record $user->uid = $uid; $user->provider = $loginza->provider; $UserProfile = new Loginza_UserProfile($loginza); isset($loginza->photo) && ($user->photo = $loginza->photo); $user->full_name = $UserProfile->genFullName(); $user->data = json_encode($loginza); $user->save(); } $this->session->loginza = NULL; flash_success('User was successfully registered! Please, check your email for further instructions.', 'Registration succeed.'); redirect(); } append('content', $form->render()); } } } }
} if ($save) { if ($new) { $sql = "INSERT INTO fetchmail (" . implode(",", escape_string(array_keys($formvars))) . ") VALUES ('" . implode("','", escape_string($formvars)) . "')"; } else { # $edit foreach (array_keys($formvars) as $key) { $formvars[$key] = escape_string($key) . "='" . escape_string($formvars[$key]) . "'"; } $sql = "UPDATE fetchmail SET " . implode(",", $formvars) . ",returned_text='', date=NOW() WHERE id=" . $edit; } $result = db_query($sql); if ($result['rows'] != 1) { flash_error($PALANG['pFetchmail_database_save_error']); } else { flash_info($PALANG['pFetchmail_database_save_success']); $edit = 0; $new = 0; # display list after saving } } else { $formvars['src_password'] = ''; # never display password } } elseif ($edit) { # edit entry form $formvars = $edit_row; $formvars['src_password'] = ''; } elseif ($new) { # create entry form foreach (array_keys($fm_struct) as $value) {
//if change, remove old one, then perhaps set new one if (!empty($fBack)) { if (!$vh->remove()) { $error = 1; } } } // If NO error then diplay flash message and go back to right url where we came from if ($error == 0) { if (!empty($fBack)) { flash_info(sprintf($PALANG['pVacation_result_removed'], htmlentities($tUseremail))); header("Location: {$Return_url}"); exit; } if (!empty($fChange)) { flash_info(sprintf($PALANG['pVacation_result_added'], htmlentities($tUseremail))); header("Location: {$Return_url}"); exit; } } else { flash_error(sprintf($PALANG['pVacation_result_error'], htmlentities($fUsername))); } $today = date("Y-m-d"); if (empty($tActiveFrom)) { $tActiveFrom = $today; } if (empty($tActiveUntil)) { $tActiveUntil = $today; } if (!$details['active']) { # if vacation is disabled, there's no point in displaying the date of the last vacation ;-)
$result = db_query("SELECT * FROM {$table_mailbox} WHERE username='******' AND password='******'"); if ($result['rows'] != 1) { $error = 1; $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error']; } } else { $error = 1; $pPassword_email_text = $PALANG['pPassword_email_text_error']; } if (empty($fPassword) or $fPassword != $fPassword2) { $error = 1; $pPassword_password_text = $PALANG['pPassword_password_text_error']; } if ($error != 1) { $password = pacrypt($fPassword); $result = db_query("UPDATE {$table_mailbox} SET password='******',modified=NOW() WHERE username='******'"); if ($result['rows'] == 1) { flash_info($PALANG['pPassword_result_success']); db_log($USERID_USERNAME, $USERID_DOMAIN, 'edit_password', "{$USERID_USERNAME}"); header("Location: main.php"); exit(0); } else { $tMessage = $PALANG['pPassword_result_error']; } } } include "../templates/header.php"; include "../templates/users_menu.php"; include "../templates/users_password.php"; include "../templates/footer.php"; /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */