public function actionLogout() { alog(at("User logged out.")); AdminUser::model()->deleteAll('userid=:id', array(':id' => Yii::app()->user->id)); Yii::app()->user->logout(); fok(at('Thank You! You are now logged out.')); $this->redirect(array('/login')); }
function uploadFileDone($cmd, $volumes, $result) { // Get result if (isset($result['added'])) { foreach ($result['added'] as $dir) { alog(at("Media Manager: Upload Completed '{name}'", array('{name}' => $dir['name']))); } } }
/** * Logout action */ public function actionLogout() { // Log Message alog(at("User logged out.")); // Delete records for this users from admin logged in AdminUser::model()->deleteAll('userid=:id', array(':id' => Yii::app()->user->id)); Yii::app()->user->logout(); fok(at('Thank You! You are now logged out.')); $this->redirect(array('/admin/login')); }
public function actionIndex() { // Submitted form if (isset($_POST['dashboard_staff_message'])) { // Check access checkAccessThrowException('op_dashboard_update_staff_message'); // Update message Setting::model()->updateSettingByKey('dashboard_staff_message', $_POST['dashboard_staff_message']); // Log Message alog(at("Updated Staff Message")); // Updated redirect fok(at('Message Saved.')); $this->redirect(array('index')); } $logModel = new AdminLog(); $this->render('index', array('logModel' => $logModel)); }
/** * Delete city action */ public function actionDelete() { // Check Access checkAccessThrowException('op_uscities_deletepages'); if (isset($_GET['id']) && ($model = USCity::model()->findByPk($_GET['id']))) { alog(at("Deleted City Record '{name}'.", array('{name}' => $model->city_name))); $model->delete(); fok(at('City Record Deleted.')); $this->redirect(array('city/index')); } else { $this->redirect(array('city/index')); } }
/** * Delete page action */ public function actionDelete() { // Check Access checkAccessThrowException('op_custompages_deletepages'); if (isset($_GET['id']) && ($model = CustomPage::model()->findByPk($_GET['id']))) { alog(at("Deleted Custom Page '{name}'.", array('{name}' => $model->title))); $model->delete(); fok(at('Page Deleted.')); $this->redirect(array('custompages/index')); } else { $this->redirect(array('custompages/index')); } }
/** * Delete help topic action */ public function actionDelete() { // Check Access checkAccessThrowException('op_helptopics_delete'); if (isset($_GET['id']) && ($model = HelpTopic::model()->findByPk($_GET['id']))) { alog(at("Deleted Help Topic '{name}'.", array('{name}' => $model->name))); $model->delete(); fok(at('Help Topic Deleted.')); $this->redirect(array('helptopics/index')); } else { $this->redirect(array('helptopics/index')); } }
/** * Delete help topic action */ public function actionDelete() { // Check Access checkAccessThrowException('op_personalmessages_delete'); if (isset($_GET['id']) && ($model = PersonalMessageTopic::model()->findByPk($_GET['id']))) { alog(at("Deleted Personal Message '{name}'.", array('{name}' => $model->title))); // Make sure we are allowed to delete this if ($model->author_id != Yii::app()->user->id) { ferror(at('Sorry, You are not the author of this personal message so you can not delete it.')); alog(at("Tried Deleting a Personal Message '{name}' When he is not the author.", array('{name}' => $model->title))); $this->redirect(getReferrer('personalmessages/index')); } $model->delete(); fok(at('Personal Message Deleted.')); $this->redirect(array('personalmessages/index')); } else { $this->redirect(array('personalmessages/index')); } }
/** * Check if user has access to $key * if not throw an exception * @param string $key * @return exception */ function checkAccessThrowException($key) { if (!checkAccess($key)) { // Log Message alog(at("User tried accessing a restricted area. Has no permission: {name}", array('{name}' => $key))); throw new CHttpException(403, Yii::t('error', 'Sorry, You don\'t have the required permissions to enter or perform this action.')); } }
function sendmail($to, $subject, $text, $header = "") { alog("MAIL: to: {$to} subject: {$subject}"); mail($to, $subject, $text, $header); }
/** * Delete field action */ public function actionDelete() { // Check Access checkAccessThrowException('op_usercustomfields_deleteposts'); if (isset($_GET['id']) && ($model = UserCustomField::model()->findByPk($_GET['id']))) { alog(at("Deleted Custom Field '{name}'.", array('{name}' => $model->title))); $model->delete(); fok(at('Field Deleted.')); $this->redirect(array('usercustomfields/index')); } else { $this->redirect(array('usercustomfields/index')); } }
/** * adding auth item child relationships */ public function actionAddItemChild() { // Check Access checkAccessThrowException('op_permission_add_item_child'); $model = new AuthItemChild(); $roles = AuthItem::model()->findAll(array('order' => 'type DESC, name ASC')); $_roles = array(); if (count($roles)) { foreach ($roles as $role) { $_roles[AuthItem::model()->types[$role->type]][$role->name] = $role->description . ' (' . $role->name . ')'; } } // Did we choose a parent already? if (isset($_GET['parent']) && $_GET['parent'] != '') { $model->parent = $_GET['parent']; } if (isset($_POST['AuthItemChild'])) { if (isset($_POST['AuthItemChild']['child']) && count($_POST['AuthItemChild']['child'])) { // We need to delete all child items selected up until now $existsalready = AuthItemChild::model()->findAll('parent=:parent', array(':parent' => $model->parent)); if (count($existsalready)) { foreach ($existsalready as $existitem) { Yii::app()->authManager->removeItemChild($existitem->parent, $existitem->child); } } $added = 0; foreach ($_POST['AuthItemChild']['child'] as $childItem) { $model->child = $childItem; if ($model->validate()) { $added++; } } // Get model parent $authItem = AuthItem::model()->find('name=:name', array(':name' => $model->parent)); fok(at('{number} Child item(s) Added.', array('{number}' => $added))); // Log Message alog(at("Added {number} child items for {name}", array('{number}' => $added, '{name}' => $model->parent))); if ($authItem) { $this->redirect(array('view', 'id' => $authItem->id, '#' => 'tabs-2')); } else { $this->redirect(array('index')); } } } // Selected values $selected = AuthItemChild::model()->findAll('parent=:parent', array(':parent' => $model->parent)); $_selected = array(); if (count($selected)) { foreach ($selected as $select) { $_selected[] = $select->child; } } $model->child = $_selected; // Add Breadcrumb $this->addBreadCrumb(at('Adding Child Permissions')); $this->title[] = at('Adding Child Permissions'); $this->render('child_form', array('model' => $model, 'roles' => $_roles)); }
fclose($fp); } function login($id, $pw) { global $ment_ini; return $id === $ment_ini["id"] && $pw === $ment_ini["pw"]; } function cookieCheck() { global $sg; global $ment_ini; parse_str($_COOKIE[$sg["COOKIE_KEY"]], $ar); return $ar["id"] === $ment_ini["id"] && $ar["pw"] === $ment_ini["pw"]; } $secret = false; alog(); $nn = get_included_files(); $fn = basename(array_shift($nn)); $head_title = isset($head_titles[$fn]) ? $head_titles[$fn] : "家計簿くん"; $paging = ""; if (isset($_COOKIE["g_secret"])) { $secret = true; } $logout_msg = ""; if (isset($_GET["logout"])) { // ログアウト setcookie($sg["COOKIE_KEY"], '', time() - 3600); // Cookie削除 $_COOKIE[$sg["COOKIE_KEY"]] = null; $logout_msg = "<p class=\"error\">ログアウトしました</p><br />"; }
/** * Delete Form Template action */ public function actionDelete() { // Check Access checkAccessThrowException('op_formtemplate_delete'); if (isset($_GET['id']) && ($model = FormTemplate::model()->findByPk($_GET['id']))) { alog(at("Deleted Form Template '{name}'.", array('{name}' => $model->title))); $model->delete(); fok(at('Form Template Deleted.')); $this->redirect(array('formtemplate/index')); } else { $this->redirect(array('formtemplate/index')); } }
/** * Import language */ public function actionImport() { // Check access checkAccessThrowException('op_language_import_language'); $file = CUploadedFile::getInstanceByName('file'); $update = getPostParam('update', 0); // Did we upload anything? if (!$file || !$file->getTempName()) { ferror(at('File was not uploaded properly.')); $this->redirect(array('language/index')); } // Make sure it's an xml file if ($file->getType() != 'text/xml') { ferror(at('You must upload an XML file.')); $this->redirect(array('language/index')); } // Make file has contents if (!$file->getSize()) { ferror(at('File Uploaded is empty.')); $this->redirect(array('language/index')); } // Grab data from file $xml = new ClassXML(); $xml->loadXML(file_get_contents($file->getTempName())); // Check to see if it has language details foreach ($xml->fetchElements('language_row') as $lang) { // Grab first language $langData = $xml->fetchElementsFromRecord($lang); break; } // Make sure we have data if (!count($langData)) { ferror(at('Could not locate language data.')); $this->redirect(array('language/index')); } // See if language data missing the name and short form if (!isset($langData['name']) || !isset($langData['abbr'])) { ferror(at('Language data missing name or abbreviation.')); $this->redirect(array('language/index')); } $langName = $langData['name']; $langAbbr = $langData['abbr']; $langId = null; // Check if that language exists $langModel = Language::model()->find('abbr=:abbr', array(':abbr' => $langAbbr)); // If we have the model then set the id if ($langModel) { $langId = $langModel->id; } // Grab the strings $stringsToImport = array(); foreach ($xml->fetchElements('message_row') as $string) { // Grab first language $stringData = $xml->fetchElementsFromRecord($string); $stringsToImport[] = $stringData; } // Make sure we have strings if (!count($stringsToImport)) { ferror(at('Could not locate any strings to import.')); $this->redirect(array('language/index')); } // Do we need to create a new language? if (!$langModel) { // Create new language $newLang = new Language(); $newLang->name = $langName; $newLang->abbr = $langAbbr; if (!$newLang->save()) { ferror(at('Could not save the new language.')); $this->redirect(array('language/index')); } $langId = $newLang->id; } $imported = 0; $updated = 0; $skipped = 0; // Run each string and check if the one exists in the current language if it does and we have the update then update // otherwise skip foreach ($stringsToImport as $r) { // Get orig id if exists if not create orig $orig = SourceMessage::model()->find('category=:category AND message=:message', array(':category' => $r['category'], ':message' => $r['orig'])); if ($orig) { // It exists so we have the original message id $origId = $orig->id; } else { // It does not exists create and get newly created id $newSource = new SourceMessage(); $newSource->category = $r['category']; $newSource->message = $r['orig']; $newSource->save(false); $origId = $newSource->id; } // Now that we have the original id check if we need to update or create $exists = Message::model()->find('id=:id AND language_id=:lang', array(':id' => $origId, ':lang' => $langId)); if ($exists) { if ($update) { // Exists and update $exists->translation = $r['translation']; $exists->update(); $updated++; } else { // Exists do not update $skipped++; } } else { // Does not exist create $newMessage = new Message(); $newMessage->id = $origId; $newMessage->language = $langAbbr; $newMessage->language_id = $langId; $newMessage->translation = $r['translation']; $newMessage->save(false); $imported++; } } // Log and save flash message if ($langModel) { alog(at("Update Language '{name}'", array('{name}' => $langName))); fok(at('Language Updated. {i} Strings Imported, {u} Strings Updated, {s} Strings Skipped.', array('{i}' => $imported, '{u}' => $updated, '{s}' => $skipped))); } else { alog(at("Imported New Language '{name}'", array('{name}' => $langName))); fok(at("New Language Created '{name}'. <b>{i}</b> Strings Imported, <b>{u}</b> Strings Updated, <b>{s}</b> Strings Skipped.", array('{name}' => $langName, '{i}' => $imported, '{u}' => $updated, '{s}' => $skipped))); } $this->redirect(array('language/index')); }
/** * Delete page action */ public function actionDelete() { // Check Access checkAccessThrowException('op_blog_deleteposts'); if (isset($_GET['id']) && ($model = BlogPost::model()->findByPk($_GET['id']))) { alog(at("Deleted Blog Post '{name}'.", array('{name}' => $model->title))); $model->delete(); fok(at('Page Deleted.')); $this->redirect(array('blog/index')); } else { $this->redirect(array('blog/index')); } }
/** * Add the missing settings if we found one * */ protected function addMissingSetting($key, $default = null) { // Ignore if key is protected if (in_array($key, $this->protectedSettings)) { return; } // First make sure we haven't already added it // without looking in the db $missingSettings = Yii::app()->cache->get('missingSettings'); if ($missingSettings === false) { // Init $missingSettings = array(); } // Do we have that setting in the array if (!in_array($key, $missingSettings)) { // We don't so look up the db $settingExists = Setting::model()->find('settingkey=:key', array(':key' => $key)); if (!$settingExists) { // We didn't find anything so add it // Do we have the missing setting cat? $missingCat = SettingCat::model()->find('groupkey=:key', array(':key' => 'missing_settings')); if (!$missingCat) { $missingCat = new SettingCat(); $missingCat->title = 'Missing Settings'; $missingCat->description = 'Settings that were accessed but were not found in the db'; $missingCat->groupkey = 'missing_settings'; if (!$missingCat->save()) { alog('Could not create the missing setting category.'); } } // Add the new setting $newSetting = new Setting(); $newSetting->title = ucwords(str_replace('_', ' ', $key)); $newSetting->settingkey = $key; $newSetting->category = $missingCat->id; $newSetting->type = 'text'; $newSetting->default_value = $default ? $default : '0'; if (!$newSetting->save()) { alog(sprintf("Could not create a setting with the key '%s'", $key)); } } $missingSettigns[$key] = $key; // Save Yii::app()->cache->set('missing_settings', $missingSettigns); } $this->clearCache(); }
/** * Delete user */ public function actionDelete($id) { // Check Access checkAccessThrowException('op_users_delete'); $model = User::model()->findByPk($id); if ($model) { // Log Message alog(at("Deleted user: '******'.", array('{name}' => $model->name))); $model->delete(); fok(at('User Deleted!')); } else { throw new CHttpException(404, at('Sorry, That record was not found.')); } }
/** * Revert setting action */ public function actionrevertsetting() { // Check Access checkAccessThrowException('op_settings_revert_settings'); if (isset($_GET['id'])) { $setting = Setting::model()->findByPk($_GET['id']); Setting::model()->updateByPk($_GET['id'], array('value' => $setting->default_value)); if ($setting) { $setting->value = $setting->default_value; // Store setting and run the php code for storing // Evaluate php code if ($setting->php) { $show = 0; $save = 0; $store = 1; eval($setting->php); } } // Log Message alog(at("Reverted Setting '{name}'", array('{name}' => $setting->title))); // Clear cache Yii::app()->settings->clearCache(); fok(at('Setting Reverted.')); $this->redirect(array('setting/viewgroup', 'id' => $setting->category)); } else { $this->redirect(array('setting/index')); } }
/** * Sync theme */ public function actionSync($id) { // Check Access checkAccessThrowException('op_theme_sync'); if ($model = Theme::model()->findByPk($id)) { $total = $model->SyncTheme(); alog(at("Synced Theme '{name}'.", array('{name}' => $model->name))); fok(at('Theme Synced. Total {n} files synced.', array('{n}' => $total))); $this->redirect(array('themes/index')); } else { $this->redirect(array('themes/index')); } }