コード例 #1
0
ファイル: class.post.php プロジェクト: adncentral/mapi-geoCMS
 public function delete()
 {
     $deleted = $this->delete_record();
     if ($deleted) {
         return mapi_report_message('Your content was sucessfully deleted.', 'success');
     }
 }
コード例 #2
0
ファイル: mbin.auth.php プロジェクト: adncentral/mapi-geoCMS
 static function do_login()
 {
     if (!self::cookie_support()) {
         return null;
     }
     $current_visitor = self::details();
     if (!isset($current_visitor['ip']) || !isset($current_visitor['browser'])) {
         return null;
     }
     $user = new M_User(MGet::string('user'), true);
     if ($user && $user->is_enabled() && $user->compare_pass(MGet::string('pass'))) {
         if (strlen($user->get_username()) > 0) {
             $username = $user->get_username();
         } else {
             return null;
         }
         $msession = mapi_random(24);
         $time = date_format(new DateTime('now'), 'Y-m-d H:i:s');
         $rand = $username . ' ' . $msession;
         self::send_auth_cookie($rand, $time, $current_visitor['browser']);
         $user->update_lastlogin($rand, $time, $current_visitor['browser']);
         header('Location: ' . $_SERVER['REQUEST_URI']);
         exit(0);
     }
     mapi_report_message('Invalid username/password.', 'error');
 }
コード例 #3
0
 protected function set_vars($event)
 {
     if (!is_object($event)) {
         return null;
     }
     if ($this->text) {
         $event->text = MPurifier::clean($this->text);
     } else {
         $event->text = null;
     }
     if ($this->start && MValidate::date($this->start)) {
         $event->start = $this->start;
     } else {
         return mapi_report_message('Not a valid start date.');
     }
     if ($this->end && MValidate::date($this->end)) {
         $event->end = $this->end;
     } else {
         return mapi_report_message('Not a valid end date.');
     }
     $start = new DateTime($event->start);
     $end = new DateTime($event->end);
     if (!$end > $start) {
         return mapi_report_message('Event end is before it\'s starting time.');
     }
     return true;
 }
コード例 #4
0
ファイル: muser.php プロジェクト: adncentral/mapi-geoCMS
 static function change_password($id, $newuser = false)
 {
     if (!MGet::string('user_pass')) {
         return null;
     }
     $user = self::get_user($id);
     if ($user) {
         if (MGet::string('user_pass') != MGet::string('user_pass_repeat')) {
             return mapi_report_message('Passwords do not match');
         }
         $user->change_password(MGet::string('user_pass'), $newuser);
     }
 }
コード例 #5
0
ファイル: profile.php プロジェクト: adncentral/mapi-geoCMS
 static function change_password()
 {
     if (!MGet::string('user_pass')) {
         return null;
     }
     $profile = self::get_profile();
     if ($profile) {
         if (MGet::string('user_pass') != MGet::string('user_pass_repeat')) {
             return mapi_report_message('Passwords do not match');
         }
         $profile->change_password(MGet::string('user_pass'), false);
     }
 }
コード例 #6
0
ファイル: class.url.php プロジェクト: adncentral/mapi-geoCMS
 protected function set_vars($post)
 {
     if (!$post || !is_object($post)) {
         return null;
     }
     if ($this->text) {
         $post->text = MPurifier::clean($this->text);
     } else {
         $this->text = '';
     }
     if ($this->url && MValidate::url($this->url)) {
         $post->url = urlencode($this->url);
     } else {
         return mapi_report_message('Not a valid url.');
     }
     return true;
 }
コード例 #7
0
ファイル: mwidget.php プロジェクト: adncentral/mapi-geoCMS
 static function install_widget($name)
 {
     if (!MExtension::check_widget($name)) {
         return mapi_report_message('Not a valid widget.');
     }
     $markdown = MExtension::markdown('widget', $name);
     $widget = ORM::for_table('widgets')->create();
     if ($widget) {
         $widget->name = strval($name);
         $widget->title = strval($markdown['title']);
         $widget->version = strval($markdown['version']);
         if (isset($markdown['description'])) {
             $widget->description = $markdown['description'];
         }
         $widget->enabled = 1;
         if ($widget->save()) {
             return mapi_report_message('Widget sucessfully installed.', 'success');
         } else {
             return mapi_report_message('There was an error installing your widget.');
         }
     }
 }
コード例 #8
0
ファイル: mtemplate.php プロジェクト: adncentral/mapi-geoCMS
 static function install_template($name)
 {
     if (!MExtension::check_template($name)) {
         return mapi_report_message('Not a valid template.');
     }
     $markdown = MExtension::markdown('template', $name);
     $template = ORM::for_table('templates')->create();
     if ($template) {
         $template->name = strval($name);
         $template->title = strval($markdown['title']);
         $template->version = strval($markdown['version']);
         if (isset($markdown['description'])) {
             $template->description = $markdown['description'];
         }
         $template->enabled = 1;
         if ($template->save()) {
             return mapi_report_message('The template was sucessfully installed.', 'success');
         } else {
             return mapi_report_message('There was an error installing your template.');
         }
     }
     print_r($module);
 }
コード例 #9
0
ファイル: class.user.php プロジェクト: adncentral/mapi-geoCMS
 private function setup_object($user, $newuser = false)
 {
     if (!$user || !is_object($user)) {
         return null;
     }
     if ($this->group_id && MValidate::id($this->group_id)) {
         $user->group_id = $this->group_id;
     } else {
         return mapi_report_message('Not a valid group.');
     }
     if ($this->username && MValidate::username($this->username)) {
         $user->username = $this->username;
     } else {
         return mapi_report_message('Not a valid username.');
     }
     if (!$newuser) {
         if (!mapi_check_double('users', 'username', $this->username)) {
             return mapi_report_message('Username not available.');
         }
     }
     if ($this->email && MValidate::email($this->email)) {
         $user->email = $this->email;
     } else {
         return mapi_report_message('Not a valid email address.');
     }
     if ($this->name && MValidate::title($this->name)) {
         $user->name = $this->name;
     } else {
         return mapi_report_message('Not a valid name.');
     }
     if ($this->enabled && 1 == $this->enabled) {
         $user->enabled = 1;
     } else {
         $user->enabled = 0;
     }
     return true;
 }
コード例 #10
0
ファイル: helper.php プロジェクト: adncentral/mapi-geoCMS
function mapi_report($message = null, $type = 'warning')
{
    mapi_report_message($message, $type);
}
コード例 #11
0
ファイル: class.meta.php プロジェクト: adncentral/mapi-geoCMS
 private function setup_object($meta)
 {
     if (isset($this->name) && isset($this->value)) {
         if (MValidate::meta_name($this->name)) {
             $meta->name = $this->name;
         } else {
             return mapi_report_message('Not a valid meta name: ' . $this->name);
         }
         if (MValidate::meta_value($this->value)) {
             $meta->value = $this->value;
         } else {
             return mapi_report_message('Not a valid meta value: ' . $this->value);
         }
     }
     return true;
 }
コード例 #12
0
ファイル: class.page.php プロジェクト: adncentral/mapi-geoCMS
 private function setup_object($page, $newpage = false)
 {
     if (!$page || !is_object($page)) {
         return null;
     }
     if ($this->title && MValidate::title($this->title)) {
         $page->title = $this->title;
     } else {
         echo $this->title;
         return mapi_report_message('Not a valid page title.');
     }
     $page->name = $this->name;
     if ($newpage) {
         if (!mapi_check_double('pages', 'name', $this->name)) {
             return mapi_report_message('Page with that name already exists.');
         }
     }
     if (in_array($this->type, $this->types)) {
         $page->type = $this->type;
     } else {
         $page->type = 'url';
     }
     if ($this->url && MValidate::url($this->url)) {
         $page->url = $this->url;
     } else {
         return mapi_report_message('Not a valid url.');
     }
     if ($this->blank && 1 == $this->blank) {
         $page->blank = 1;
     } else {
         $page->blank = 0;
     }
     if ($this->enabled && 1 == $this->enabled) {
         $page->enabled = 1;
     } else {
         $page->enabled = 0;
     }
     return true;
 }
コード例 #13
0
 private function setup_object($record, $new = false)
 {
     if (!$record || !is_object($record)) {
         return null;
     }
     if ($this->title && MValidate::title($this->title)) {
         $record->title = $this->title;
     } else {
         return mapi_report_message('Not a valid content title: ' . $this->title);
     }
     if ($this->license && MValidate::id($this->license) && in_array($this->license, mapi_available_ids('licenses'))) {
         $record->license = $this->license;
     } else {
         return mapi_report_message('Not a valid content license: ' . $this->license);
     }
     $record->name = $this->name;
     if ($new) {
         if (!mapi_check_double('contents', 'name', $this->name)) {
             return mapi_report_message('Content with that name already exists: ' . $this->name);
         }
     }
     if ($this->address && MValidate::address($this->address)) {
         $record->address = $this->address;
     } else {
         return mapi_report_message('Not a valid content address: ' . $this->address);
     }
     if (isset($this->meta_name)) {
         if ($this->meta_name && MValidate::meta_name($this->meta_name)) {
             $record->meta_name = $this->meta_name;
         } else {
             return mapi_report_message('Not a valid meta name: ' . $this->meta_name);
         }
     }
     if (isset($this->meta_value)) {
         if ($this->meta_value && MValidate::meta_value($this->meta_value)) {
             $record->meta_value = $this->meta_value;
         } else {
             return mapi_report_message('Not a valid meta value: ' . $this->meta_value);
         }
     }
     if ($this->lat && MValidate::coord($this->lat)) {
         $record->lat = $this->lat;
     } else {
         return mapi_report_message('Not a valid latitude.');
     }
     if ($this->lng && MValidate::coord($this->lng)) {
         $record->lng = $this->lng;
     } else {
         return mapi_report_message('Not a valid longitude.');
     }
     if ($this->hits && $this->hits > 0) {
         $record->hits = intval($this->hits);
     }
     if ($this->parent) {
         $record->parent = intval($this->parent);
     }
     if ($this->language) {
         $record->language = strval($this->language);
     }
     if ($this->translation && 1 == $this->translation) {
         $record->translation = 1;
     }
     if ($this->enabled && 1 == $this->enabled) {
         $record->enabled = 1;
     } else {
         $record->enabled = 0;
     }
     return true;
 }
コード例 #14
0
ファイル: class.menu.php プロジェクト: adncentral/mapi-geoCMS
 private function setup_object($menu, $newmenu)
 {
     if (!$menu || !is_object($menu)) {
         return null;
     }
     if ($this->title && MValidate::title($this->title)) {
         $menu->title = $this->title;
     } else {
         return mapi_report_message('Not a valid title.');
     }
     $menu->name = $this->name;
     if ($newmenu) {
         if (!mapi_check_double('menus', 'name', $this->name)) {
             return mapi_report_message('Menu with that name already exists.');
         }
     }
     $menu->pages = $this->save_pages();
     if ($this->enabled && 1 == $this->enabled) {
         $menu->enabled = 1;
     } else {
         $menu->enabled = 0;
     }
     return true;
 }
コード例 #15
0
 private function setup_object($category, $new = false)
 {
     if (!$category || !is_object($category)) {
         return null;
     }
     if ($this->title && MValidate::title($this->title)) {
         $category->title = $this->title;
     } else {
         return mapi_report_message('Not a valid category title: ' . $this->title);
     }
     $category->name = $this->name;
     if ($new) {
         if (!mapi_check_double('categories', 'name', $this->name)) {
             return mapi_report_message('Category with that name already exists: ' . $this->name);
         }
     }
     $category->contents = $this->save_contents();
     if ($this->flagship) {
         if (MValidate::id($this->flagship)) {
             $category->flagship = $this->flagship;
         } else {
             return mapi_report_message('Not a valid flagship product.');
         }
     }
     if ($this->enabled && 1 == $this->enabled) {
         $category->enabled = 1;
     } else {
         $category->enabled = 0;
     }
     return true;
 }