Example #1
0
 public static function award_points($points, $eventmsg = false, $user = false)
 {
     if (!$user) {
         if (!user::logged()) {
             return false;
         }
         $user = user::get();
     } else {
         if (!$user instanceof Model_User) {
             $user = ORM::factory('User', $user_id);
             if (!$user->loaded()) {
                 return false;
             }
         }
     }
     if ($eventmsg) {
         $event = ORM::factory('User_Event');
         $event->user_id = $user->id;
         $event->message = $eventmsg;
         $event->created = $user->timestamp();
         $event->save();
     }
     $user->points += $points;
     $user->save();
 }
Example #2
0
 public function getSectorLink($x, $y, &$i)
 {
     if (isset($this->data[$i]) && $this->data[$i]['x'] == $x && $this->data[$i]['y'] == $y) {
         if ($this->data[$i]['type'] != 2) {
             $output = 'href="javascript: fetch(\'getGrid.php\', \'x=' . $x . '&y=' . $y . '\')" onMouseOver="setSectorData(labels[' . $this->data[$i]['type'] . '], \'-\', \'-\')" onMouseOut="setSectorData(\'-\', \'-\', \'-\')"';
         } else {
             $node = new node();
             $node->get('id', $this->data[$i]['id']);
             $user = new user();
             $user->get('id', $node->data['user']);
             $alliancename = '-';
             if ($user->data['alliance']) {
                 $alliance = new alliance();
                 $alliance->get('user', $user->data['id']);
                 $alliancename = $alliance->data['name'];
             }
             $output = 'href="javascript: fetch(\'getGrid.php\', \'x=' . $x . '&y=' . $y . '\')" onMouseOver="setSectorData(\'' . $node->data['name'] . '\', \'' . $user->data['name'] . '\', \'' . $alliancename . '\')" onMouseOut="setSectorData(\'-\', \'-\', \'-\')"';
         }
         if ($i < count($this->data) - 1) {
             $i++;
         }
     } else {
         $output = 'href="javascript: fetch(\'getGrid.php\', \'x=' . $x . '&y=' . $y . '\')"';
     }
     return $output;
 }
Example #3
0
 public function action_login()
 {
     if ((bool) arr::get($_GET, 'return', false)) {
         site::set_last_url($this->request->referrer());
     }
     $error = false;
     if ($_POST) {
         $email = arr::get($_POST, 'email', '');
         $password = arr::get($_POST, 'password', '');
         $remember = arr::get($_POST, 'remember', '') == 'yes';
         if (user::login($email, $password, $remember)) {
             $user = user::get();
             notes::success('You have been logged in. Welcome back!');
             $lasturl = site::get_last_url();
             if ($lasturl) {
                 site::redirect($lasturl);
             }
             site::redirect('write');
         } else {
             //notes::error('Wrong username or password. Please try again.');
             $error = true;
         }
     }
     $this->bind('error', $error);
 }
Example #4
0
function user_data($vars = null)
{
    $vars['uid'] or iPHP::warning('iCMS&#x3a;user&#x3a;data 标签出错! 缺少"uid"属性或"uid"值为空.');
    $uid = $vars['uid'];
    if ($uid == 'me') {
        $uid = 0;
        $auth = user::get_cookie();
        $auth && ($uid = user::$userid);
    }
    if (strpos($uid, ',') === false) {
        $user = (array) user::get($uid);
        if ($vars['data']) {
            $user += (array) user::data($uid);
        }
    } else {
        $uid_array = explode(',', $uid);
        foreach ($uid_array as $key => $value) {
            $user[$key] = (array) user::get($uid);
            if ($vars['data']) {
                $user[$key] += (array) user::data($uid);
            }
        }
    }
    return $user[0] === false ? false : (array) $user;
}
Example #5
0
 public function add()
 {
     global $db;
     $recipient = new user();
     if ($recipient->get('name', $this->data['recipient']) == 'done') {
         $sender = new user();
         if ($sender->get('name', $this->data['sender']) == 'done') {
             if (!$sender->isBlocked($recipient->data['id'])) {
                 $this->data['id'] = misc::newId('messages');
                 $sent = strftime('%Y-%m-%d %H:%M:%S', time());
                 $db->query('insert into messages (id, sender, recipient, subject, body, sent, viewed) values ("' . $this->data['id'] . '", "' . $sender->data['id'] . '", "' . $recipient->data['id'] . '", "' . $this->data['subject'] . '", "' . $this->data['body'] . '", "' . $sent . '", "' . $this->data['viewed'] . '")');
                 if ($db->affected_rows() > -1) {
                     $status = 'done';
                 } else {
                     $status = 'error';
                 }
             } else {
                 $status = 'blocked';
             }
         } else {
             $status = 'noSender';
         }
     } else {
         $status = 'noRecipient';
     }
     return $status;
 }
Example #6
0
 public function action_index()
 {
     $this->require_login();
     $this->bind('user', user::get());
     seo::instance()->title("Morning Pages Profile");
     seo::instance()->description("By default, Morning Pages has private profiles. If you'd like, however, you may turn it on at any time.");
 }
Example #7
0
 public function action_index()
 {
     $user = user::get();
     $messages = array();
     $usermessages = $user->messages->find_all();
     if ((bool) $usermessages->count()) {
         foreach ($usermessages as $message) {
             $messages[] = $message->info();
         }
     }
     $roles = $user->roles->find_all();
     $roleids = array();
     if ((bool) $roles->count()) {
         foreach ($roles as $role) {
             $roleids[] = $role->id;
         }
     }
     if ((bool) count($roleids)) {
         $rolemessages = ORM::factory('Message')->where('role_id', 'in', $roleids)->where('user_id', '!=', $user->id)->find_all();
         if ((bool) $rolemessages->count()) {
             foreach ($rolemessages as $message) {
                 $messages[] = $message->info();
             }
         }
     }
     reply::ok(View::factory('Cms/Messages/index', array('messages' => $messages, 'roles' => user::get()->roles->find_all()->as_array())), 'messages', array('viewModel' => 'viewModels/Messages/index', 'messages' => $messages));
 }
Example #8
0
 public function action_all()
 {
     $dashboards = user::get()->dashboards->find_all();
     $darray();
     foreach ($dashboards as $dashboard) {
         $darray[] = $dashboard->info();
     }
     ajax::success('', array('dashboards' => $darray));
 }
    public static function getChat($clientid)
    {
        $return = '';
        $user = new beuser($_SESSION['beuser_id']);
        $RS = $user->getChat(0, $clientid);
        $client = new user($clientid);
        foreach ($RS as $msg) {
            if ($msg['recipient_id'] == 0) {
                // FROM client
                $return .= '<div class="row chat_entry chat_relo" data-msgid="' . $msg['id'] . '">
		                        <div class="col-xs-1">
		                        	<img class="chat_userimg" src="../data/img/_users/_thumbs/' . $client->get('profilepic') . '">
		                        </div>

		                        <div class="col-xs-6 chat_message">
		                        	<div class="chat_time">
		                        		' . $client->get('firstname') . ' ' . $client->get('lastname') . ' | ' . date('d.m.Y H:i', $msg['time']) . '
			                        </div>
		                        		' . $msg['text'] . '
		                        </div>
		                    </div>';
            } else {
                if ($msg['recipient_id'] == $clientid) {
                    //FROM RELO
                    $messenger = new beuser($msg['sender_id']);
                    $return .= '<div class="row chat_entry chat_client" data-msgid="' . $msg['id'] . '">

		                        <div class="col-xs-6 col-xs-offset-5 text-right chat_message">
		                        	<div class="chat_time text-right">
			                        	' . $user->get('firstname') . ' ' . $user->get('lastname') . ' | ' . date('d.m.Y H:i', $msg['time']) . '
			                        </div>
		                        		' . $msg['text'] . '
		                        </div>

		                        <div class="col-xs-1">
		                        	<img class="chat_userimg" src="../data/img/_users/_thumbs/' . $user->get('profilepic') . '">
		                        </div>
		                    </div>';
                }
            }
        }
        //end foreach
        return $return;
    }
Example #10
0
 public function getCblockList($id = 0, $maxlevel = 0, $roleid = 0, $filterArray)
 {
     if ($filterArray[0]['CBID']) {
         $limit = array('CBID' => $filterArray[0]['CBID']);
         $coList = \sCblockMgr()->filterEntrymasks(false, $this->getFilter(), $limit, false);
     } else {
         $limit = array('FOLDER' => $id);
         $coList = \sCblockMgr()->filterEntrymasks(false, $this->getFilter(), $limit, false);
     }
     // Get additional data for each formfield (and strip folders)
     $finalCoList = array();
     foreach ($coList as $coListItem) {
         if ($coListItem['FOLDER'] == 0) {
             // get last modifier
             $history = \sCblockMgr()->history->getList($coListItem['CBID']);
             if ($allMailingsItem['CHANGEDBY']) {
                 $userObj = new \user($history[0]['UID'] ? $history[0]['UID'] : $coListItem['CHANGEDBY']);
             } else {
                 $userObj = new \user($history[0]['UID'] ? $history[0]['UID'] : $coListItem['CREATEDBY']);
             }
             $userInfo = $userObj->get();
             $userProps = $userObj->properties->getValues($userInfo['ID']);
             $userInfo['PROPS'] = $userProps;
             // Get controls
             $cb = new \Cblock($coListItem['CBID']);
             $coListItem['ENTRYMASKS'] = $cb->getEntrymasks();
             // Get additional control info
             $col1Data = array(array('CO_NAME' => $coListItem['NAME'], 'FORMFIELD' => 101, 'OBJECTIDENTIFIER' => true));
             $col2Data = array(array('USER_NAME' => trim($userInfo['PROPS']['FIRSTNAME'] . ' ' . $userInfo['PROPS']['LASTNAME']), 'USER_ID' => $userInfo['ID'], 'FORMFIELD' => 100));
             $col3Data = array(array('CHANGEDTS' => TStoLocalTS($coListItem['CHANGEDTS']), 'FORMFIELD' => 103));
             $result[0] = $col1Data;
             $result[1] = $col2Data;
             $result[2] = $col3Data;
             $data = array('CBID' => $coListItem['CBID'], 'CBVERSION' => $coListItem['CBVERSION'], 'NAME' => $coListItem['NAME'], 'HASCHANGED' => $coListItem['HASCHANGED'], 'FIELDS' => $result, 'RREAD' => $coListItem['RREAD'], 'RWRITE' => $coListItem['RWRITE'], 'RDELETE' => $coListItem['RDELETE'], 'RSUB' => $coListItem['RSUB'], 'RSTAGE' => $coListItem['RSTAGE'], 'RMODERATE' => $coListItem['RMODERATE'], 'RCOMMENT' => $coListItem['RCOMMENT']);
             array_push($finalCoList, $data);
         }
     }
     if (!$filterArray[0]['CBID']) {
         $pageDirOrderBy = $filterArray[1]['VALUE'];
         $pageDirOrderDir = $filterArray[1]['VALUE2'];
         if (strlen($pageDirOrderBy) && strlen($pageDirOrderDir)) {
             $listColumns = $this->getListColumns();
             usort($finalCoList, array('com\\nt\\DefaultCblockListView', $listColumns['COLUMNS'][$pageDirOrderBy]['SORTFUNC']));
             if ($pageDirOrderDir == -1) {
                 $finalCoList = array_reverse($finalCoList);
             }
         }
         $pageDirFrom = $filterArray[0]['VALUE'];
         $pageDirCount = $filterArray[0]['VALUE2'];
         if (strlen($pageDirFrom) && strlen($pageDirCount)) {
             $finalCoList = array_slice($finalCoList, $pageDirFrom, $pageDirCount);
         }
     }
     return $finalCoList;
 }
Example #11
0
 public static function get_current()
 {
     $dashboard = ORM::factory('Dashboard')->where('user_id', '=', user::get()->id)->where('current', '=', '1')->find();
     if (!$dashboard->loaded()) {
         $dashboard->user_id = user::get()->id;
         $dashboard->current = 1;
         $dashboard->order = 0;
         $dashboard->name = 'Default';
         $dashboard->save();
     }
     return $dashboard;
 }
Example #12
0
 function superuser($id = "")
 {
     if (!$id and $id = user::id()) {
         $id = user::id();
     }
     $userArray = user::get($id);
     if (group::superuser($userArray[group])) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
 /**
  * Login
  * Load user information in session
  * @param int $id User ID
  * @return bool User found
  */
 public static function login($id)
 {
     $user = new user((int) $id);
     if ($user->ok()) {
         $_SESSION['user'] = $user->get();
         $_SESSION['user']['login'] = time();
         self::save();
         return true;
     } else {
         return false;
     }
 }
Example #14
0
 public function action_write()
 {
     $errors = false;
     $page = false;
     if (user::logged()) {
         $page = $this->request->param('page');
         if ($_POST && strlen(arr::get($_POST, 'content', '')) > 0) {
             $content = arr::get($_POST, 'content', '');
             if ($page->type == 'page') {
                 $raw = $page->rawcontent();
                 if ($raw != "") {
                     $content = $raw . "\n" . $content;
                 }
             } else {
                 if ($page->type == 'autosave') {
                     $page->type = 'page';
                 }
             }
             try {
                 $page->wordcount = site::count_words($content);
                 $page->content = $content;
                 if ($page->wordcount >= 750 && !(bool) $page->counted) {
                     user::update_stats($page);
                     $page->counted = 1;
                 }
                 $page->duration = $page->duration + (time() - arr::get($_POST, 'start', 999));
                 $page->update();
                 $oldsaves = ORM::factory('Page')->where('type', '=', 'autosave')->where('user_id', '=', user::get()->id)->find_all();
                 if ((bool) $oldsaves->count()) {
                     foreach ($oldsaves as $old) {
                         $old->delete();
                     }
                 }
                 achievement::check_all(user::get());
                 notes::success('Your page has been saved!');
                 //site::redirect('write/'.$page->day);
             } catch (ORM_Validation_Exception $e) {
                 $errors = $e->errors('models');
             }
         }
     } else {
         if ($_POST) {
             notes::error('You must be logged in to save your page. Please log in and submit again.');
         }
     }
     $this->bind('errors', $errors);
     $this->bind('page', $page);
     $this->template->daystamp = $this->request->param('daystamp');
     $this->template->page = $page;
     seo::instance()->title("Write Your Morning Pages");
     seo::instance()->description("Morning Pages is about writing three pages of stream of consciousness thought every day. Become a better person by using MorninPages.net");
 }
Example #15
0
 function fetchXML()
 {
     $this->isAllianceStandings_ = false;
     $this->isCorporationStandings_ = false;
     if ($this->isUser_) {
         // is a player feed - take details from logged in user
         if (user::get('usr_pilot_id')) {
             $myEveCharAPI = new API_CharacterSheet();
             $this->html .= $myEveCharAPI->fetchXML();
             $skills = $myEveCharAPI->getSkills();
             $this->connections_ = 0;
             $this->diplomacy_ = 0;
             foreach ((array) $skills as $myTempData) {
                 if ($myTempData['typeID'] == "3359") {
                     $this->connections_ = $myTempData['Level'];
                 }
                 if ($myTempData['typeID'] == "3357") {
                     $this->diplomacy_ = $myTempData['Level'];
                 }
             }
             $myKeyString = array();
             $myKeyString["userID"] = $this->API_userID_;
             $myKeyString["apiKey"] = $this->API_apiKey_;
             $myKeyString["characterID"] = $this->API_characterID_;
             $data = $this->loaddata($myKeyString, "char");
         } else {
             return "You are not logged in.";
         }
     } else {
         // is a corp feed
         $myKeyString = "userID=" . $this->API_userID_ . "&apiKey=" . $this->API_apiKey_ . "&characterID=" . $this->API_characterID_;
         $data = $this->loaddata($myKeyString, "corp");
     }
     $xml_parser = xml_parser_create();
     xml_set_object($xml_parser, $this);
     xml_set_element_handler($xml_parser, "startElement", "endElement");
     xml_set_character_data_handler($xml_parser, 'characterData');
     if (!xml_parse($xml_parser, $data, true)) {
         return "<i>Error getting XML data from " . API_SERVER . "/Standings.xml.aspx  </i><br><br>";
     }
     xml_parser_free($xml_parser);
     // sort the arrays (in descending order of standing)
     $this->Factions_ = $this->mysortarray($this->Factions_);
     $this->Characters_ = $this->mysortarray($this->Characters_);
     $this->Corporations_ = $this->mysortarray($this->Corporations_);
     $this->Alliances_ = $this->mysortarray($this->Alliances_);
     $this->Agents_ = $this->mysortarray($this->Agents_);
     $this->NPCCorporations_ = $this->mysortarray($this->NPCCorporations_);
     $this->AllianceCorporations_ = $this->mysortarray($this->AllianceCorporations_);
     $this->AllianceAlliances_ = $this->mysortarray($this->AllianceAlliances_);
     return $this->html;
 }
Example #16
0
 public function action_getautosave()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in');
     }
     $user = user::get();
     $autosave = ORM::factory('Page')->where('user_id', '=', $user->id)->where('type', '=', 'autosave')->find();
     $content = '';
     if ($autosave->loaded() && $autosave->content != '') {
         $content = $autosave->decode($autosave->content);
         $autosave->delete();
     }
     ajax::success('', array('content' => $content, 'md5' => md5($content)));
 }
Example #17
0
    static function getSqlForRights()
    {
        if (empty(self::$where)) {
            $state = system::$isAdmin && reg::getKey(self::getPrefix() . '/no_view_no_edit') ? '= 2' : '> 0';
            $groups = '';
            $m = user::getGroups();
            while (list($key, $val) = each($m)) {
                $groups .= ' or r_group_id = "' . $key . '"';
            }
            self::$where = ' and r_obj_id = o_id and r_state ' . $state . ' and
	        		  (r_group_id is NULL or r_group_id = "' . user::get('id') . '"' . $groups . ') GROUP BY o_id';
        }
        return self::$where;
    }
Example #18
0
 public function getcurrent()
 {
     $current = ORM::factory('dashboard')->where('current', '=', 1)->where('user_id', '=', user::get()->id)->find();
     if (!$current->loaded()) {
         $current = ORM::factory('dashboard')->where('user_id', '=', user::get()->id)->find();
         if (!$current->loaded()) {
             $current->user_id = user::get()->id;
             $current->current = 1;
             $current->name = 'Kontrolpanel';
             $current->order = 0;
             $current->save();
         }
     }
     return $current;
 }
Example #19
0
 /**
  * @return HTML
  * @param string $templ_name - Шаблон оформления
  * @desc МАКРОС: Выводит форму обратной связи (добавления отзыва, вопрос-ответа и пр.)
  */
 public function form($templ_name = 'default')
 {
     $templ_file = '/feedback/' . $templ_name . '.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('feedback.form', $templ_file);
     }
     if (!user::isGuest()) {
         page::assign('feedback.name', user::get('surname') . ' ' . user::get('name'));
         page::assign('feedback.email', user::get('email'));
     }
     page::assignSavingPost('feedback');
     // Парсим текст сообщения об ошибке
     page::parseError('feedback');
     return page::parse($TEMPLATE['frame'], 1);
 }
Example #20
0
 public static function save_update_current()
 {
     if (true || !user::logged('admin')) {
         $session = Session::instance();
         $visitor = ORM::factory('Visitor', $session->get('active_visitor'));
         $base = request::detect_uri();
         $queries = isset($_GET) && !empty($_GET) ? '?' . http_build_query($_GET) : '';
         $uri = request::detect_uri() . $queries;
         //substr($base, 1, strlen($base))
         if ($visitor->loaded() && $uri == $visitor->page) {
             // This is just a reload of the current page.
             return;
         }
         if (!$visitor->loaded()) {
             $numvisits = cookie::get('numvisits');
             if (!$numvisits) {
                 $numvisits = 0;
             }
             cookie::set('numvisits', $numvisits + 1);
             $visitor->numvisits = $numvisits + 1;
             $visitor->start = time();
             $visitor->referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
             $visitor->ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
             $visitor->geolocation = 'todo';
         }
         if (empty($visitor->client)) {
             $visitor->client = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
         }
         $visitor->page = $uri;
         if (user::logged()) {
             $visitor->user_id = user::get()->id;
         }
         $history = json_decode($visitor->history);
         if (!is_array($history)) {
             $history = array();
         }
         $history[] = $uri;
         $visitor->history = json_encode($history);
         $visitor->time = time();
         $visitor->save();
         $session->set('active_visitor', $visitor->id);
     }
 }
    public static function getChat()
    {
        $return = '';
        $user = new user($_SESSION['user_id']);
        $RS = $user->getChat();
        foreach ($RS as $msg) {
            $remoteuser = new user($msg['sender_id']);
            if ($msg['recipient_id'] == $_SESSION['user_id']) {
                // msg from relo
                $return .= '<div class="row chat_entry chat_relo" data-msgid="' . $msg['id'] . '">
		                        <div class="col-xs-1">
		                        	<img class="chat_userimg" src="data/img/_users/_thumbs/' . $remoteuser->get('profilepic') . '">
		                        </div>

		                        <div class="col-xs-6 chat_message">
		                        	<div class="chat_time">
		                        		Florian Lenz ' . date('d.m.Y H:i', $msg['time']) . '
			                        </div>
		                        		' . $msg['text'] . '
		                        </div>
		                    </div>';
            }
            if ($msg['sender_id'] == $_SESSION['user_id']) {
                // msg sent by client
                $return .= '<div class="row chat_entry chat_client" data-msgid="' . $msg['id'] . '">
		                        
		                        <div class="col-xs-6 col-xs-offset-5 text-right chat_message">
		                        	<div class="chat_time text-right">
			                        	Florian Lenz | ' . date('d.m.Y H:i', $msg['time']) . '
			                        </div>
		                        		' . $msg['text'] . '
		                        </div>

		                        <div class="col-xs-1">
		                        	<img class="chat_userimg" src="data/img/_users/_thumbs/' . $user->get('profilepic') . '">
		                        </div>
		                    </div>';
            }
        }
        //end foreach
        return $return;
    }
Example #22
0
 public function action_takechallenge()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in to sign up for the challenge!');
     }
     $user = user::get();
     if ($user->doing_challenge()) {
         ajax::error('You are already doing the challenge! Complete it first, then sign up again.');
     }
     $challenge = ORM::factory('User_Challenge');
     $challenge->user_id = $user->id;
     $challenge->start = $user->timestamp();
     $challenge->progress = 0;
     if ($user->wrote_today()) {
         $challenge->progress = 1;
     }
     $challenge->save();
     $user->add_event('Signed up for the 30 day challenge!');
     ajax::success('Awesome! You have signed up for the challenge! Good luck!', array('progress' => $challenge->progress));
 }
Example #23
0
 public function action_info()
 {
     maintenance::delete_inactive_visitors();
     $messages = 0;
     if (user::logged()) {
         $user = user::get();
         $messages += $user->messages->where('read', '=', '0')->count_all();
         $roles = $user->roles->find_all();
         $roleids = array();
         if ((bool) $roles->count()) {
             foreach ($roles as $role) {
                 $roleids[] = $role->id;
             }
         }
         if ((bool) count($roleids)) {
             $messages += ORM::factory('Message')->where('role_id', 'in', $roleids)->where('read', '=', '0')->where('user_id', '!=', $user->id)->count_all();
         }
     }
     ajax::success('', array('current_visitors' => $visitors = ORM::factory('Visitor')->count_all(), 'unread_messages' => $messages));
 }
Example #24
0
    protected function load_user()
    {
        $user = login::$user;
        // vise en spesiell bruker?
        if (isset($_GET['u_id']) && access::has("admin")) {
            // hent bruker
            $user = user::get((int) $_GET['u_id']);
            // fant ikke?
            if (!$user) {
                echo '
<h1>Meldinger</h1>
<p>Fant ingen bruker med ID <b>' . htmlspecialchars($_GET['u_id']) . '</b>.</p>';
                $this->load_page();
            }
            $this->show_deleted = true;
        }
        $this->inbox = new user_innboks($user);
        // logg visning av innboks
        putlog("PROFILVIS", "%c5%bVIS-MELDINGER:%b%c %u" . login::$user->player->data['up_name'] . "%u ({$_SERVER['REQUEST_URI']})");
        // lagre redirect adresse
        redirect::store($this->addr());
    }
Example #25
0
 public function action_new()
 {
     $contenttype = $this->check_contenttype();
     $content = ORM::factory('Content');
     $content->user_id = user::get()->id;
     $content->contenttype_id = $contenttype->id;
     $typeid = $this->request->param('typeid');
     $content->contenttypetype_id = isset($typeid) && !empty($typeid) ? $typeid : '0';
     $content->title = '';
     $content->status = 'draft';
     $content->created = time();
     try {
         $content->save();
         $blocks = $contenttype->blocktypes->where('min', '>', 0)->where('parent', '=', 0)->where('contenttypetype_id', '=', $content->contenttypetype_id)->find_all();
         if ((bool) $blocks->count()) {
             $loop = 0;
             foreach ($blocks as $block) {
                 for ($i = 0; $i < $block->min; $i++) {
                     $contentblock = ORM::factory('Block');
                     $contentblock->content_id = $content->id;
                     $contentblock->blocktype_id = $block->id;
                     $contentblock->order = $loop;
                     $contentblock->save();
                     $loop++;
                 }
             }
         }
         //cms::redirect('content/edit/'.$content->id);
         ajax::success('ok', array('id' => $content->id));
     } catch (HTTP_Exception_Redirect $e) {
         throw $e;
     } catch (exception $e) {
         notes::add('error', 'Der opstod en fejl: ' . $e->getMessage());
         echo 'error';
         //cms::redirect('content/index/'.$contenttype->id);
     }
 }
Example #26
0
 /**
  * @return string
  * @param string $templ_name - Шаблон оформления
  * @param string $services - Список социальных сервисов разделенных "|", в заданном порядке, через которые доступна авторизация
  * @desc МАКРОС: Выводит форму авторизации или ссылку на личный кабинет текущего пользователя
  */
 function authForm($templ_name = 'auth', $services = 'facebook|twitter|vk|ok|google|yandex')
 {
     $templ_file = '/users/' . $templ_name . '.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('users.authForm', $templ_file);
     }
     if (user::isGuest()) {
         // Формируем список социальных кнопок
         $services = explode('|', $services);
         $list = '';
         foreach ($services as $service) {
             if (reg::getKey('/users/' . $service . '_bool') && isset($TEMPLATE['social_btn_' . $service])) {
                 $list .= page::parse($TEMPLATE['social_btn_' . $service]);
             }
         }
         if (!empty($list)) {
             page::assign('list', $list);
             page::fParse('social_buttons', $TEMPLATE['social_buttons']);
         } else {
             page::assign('social_buttons');
         }
         return page::parse($TEMPLATE['frame_form']);
     } else {
         page::assign('user_id', user::get('id'));
         page::assign('user_name', user::get('name'));
         page::assign('user_surname', user::get('surname'));
         $avatar = user::get('avatara');
         if (!empty($avatar)) {
             page::assign('user_avatara', $avatar);
             page::fParse('avatara_block', $TEMPLATE['avatara']);
         } else {
             page::fParse('avatara_block', $TEMPLATE['avatara_empty']);
         }
         return page::parse($TEMPLATE['frame_account']);
     }
 }
Example #27
0
 /**
  * @return HTML - Форма добавления комментария
  * @param int $page_id - ID страницы для которой нужно создать форму
  * @param string $templ_name - Шаблон оформления формы
  * @desc МАКРОС: Строит форму отправки комментария
  */
 public function form($page_id, $templ_name = 'addform')
 {
     $templ_file = '/comments/' . $templ_name . '.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('comments.form', $templ_file);
     }
     page::assign('obj_id', $page_id);
     // Если запрещенно комментировать гостям, выводим соответствующее сообщение
     if (user::isGuest() && reg::getKey('/comments/only_reg')) {
         return page::parse($TEMPLATE['no_auth']);
     }
     // Выводим форму
     if (user::isGuest()) {
         page::fParse('capcha', $TEMPLATE['capcha']);
         page::assign('username', '');
         page::assign('email', '');
     } else {
         page::assign('capcha', '');
         page::assign('username', user::get('name'));
         page::assign('email', user::get('email'));
     }
     return page::parse($TEMPLATE['frame']);
 }
Example #28
0
 public function action_xml()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in to use this feature');
     }
     $user = user::get();
     $pages = $user->pages->where('type', '=', 'page')->find_all();
     $xml = '<?xml version="1.0" encoding="UTF-8"?>';
     $xml .= '<channel>';
     $namelen = strlen($user->username);
     $possessive = $user->username . "'s";
     if (substr($user->username, $namelen - 1, $namelen) == 's') {
         $possessive = $user->username . "'";
     }
     $xml .= '<title>' . $possessive . ' morning pages</title>';
     $xml .= '<language>en-US</language>';
     $xml .= '<author>' . $user->username . '</author>';
     $xml .= '<pages>';
     if ((bool) $pages->count()) {
         foreach ($pages as $page) {
             $xml .= '<page>';
             $xml .= '<published>';
             $xml .= '<date>' . $page->daystamp() . '</date>';
             $xml .= '<timestamp>' . $page->created . '</timestamp>';
             $xml .= '</published>';
             $xml .= '<content><![CDATA[' . $page->rawcontent() . ']]></content>';
             $xml .= '<wordcount>' . $page->wordcount . '</wordcount>';
             $xml .= '</page>';
         }
     }
     $xml .= '</pages>';
     $xml .= '</channel>';
     $this->response->headers('Content-Type', 'text/xml');
     $this->response->body($xml);
     $this->response->send_file(true, 'pages.xml');
 }
Example #29
0
 protected function record_user(\StdClass $data)
 {
     if ($data->unicity !== true) {
         throw new \Exception(\config\errors::e307);
     }
     $uid = $this->new_uid();
     $entry = array();
     $entry["objectclass"] = $data->objectclass;
     $entry["ou"] = $data->ou;
     $entry["cn"] = $data->cn;
     $entry["sn"] = $data->sn;
     if ($entry["ou"] === 'journalist') {
         $ou = 'awaiting';
     } else {
         $entry["uid"] = $uid;
         $ou = $entry["ou"] . 's';
     }
     $user = new user($entry, $ou);
     $this->user = $user->get();
     $entry["description"] = $this->code->encode($this->user);
     if (property_exists($this, $ou)) {
         $user_dn = 'cn=' . $entry["cn"] . ',' . $this->{$ou};
         $this->set($user_dn, $entry);
     }
     if ($this->user_exist($data->cn) && $this->user_valid($data->cn)) {
         //generate token
         $length = 78;
         $token = \bin2hex(\openssl_random_pseudo_bytes($length));
         //Send email (and password stuffs)
         $to = $entry["cn"];
         $subject = \config\mails::m001;
         $message = \config\mails::m002 . '\\<br>' . '<a href="https://dev.innov24/index.php?action=finalize_registration&token=' . $token . '">click me</a>';
         $headers = "From: " . \config\mails::m0 . "\r\n";
         $headers .= "Reply-To: " . \config\mails::m0 . "\r\n";
         $headers .= "MIME-Version: 1.0\r\n";
         $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
         mail('test@localhost', $subject, $message);
         return true;
     } elseif ($this->user_exist($data->cn) && $this->user_wait($data->cn)) {
         throw new \Exception(\config\errors::e305);
         //Awaiting validation
     } else {
         throw new \Exception(\config\errors::e303);
         //Unexpected error
     }
 }
Example #30
0
         $_POST[$key] = misc::clean($value, 'numeric');
     } else {
         if (!in_array($key, array('name', 'attackerFocus'))) {
             $nr = count($_POST[$key]);
             for ($i = 0; $i < $nr; $i++) {
                 $_POST[$key][$i] = misc::clean($_POST[$key][$i], 'numeric');
             }
         } else {
             $_POST[$key] = misc::clean($value);
         }
     }
 }
 $target = new node();
 if ($target->get('name', $_POST['name']) == 'done') {
     $targetUser = new user();
     if ($targetUser->get('id', $target->data['user']) == 'done') {
         $alliance = new alliance();
         $targetAlliance = new alliance();
         if ($targetAlliance->get('id', $targetUser->data['alliance']) == 'done' && $alliance->get('id', $_SESSION[$shortTitle . 'User']['alliance']) == 'done') {
             $war = $alliance->getWar($targetAlliance->data['id']);
             if (isset($war['type'])) {
                 $gotStatic = false;
                 $data = array();
                 $data['input']['attacker']['focus'] = $_POST['attackerFocus'];
                 $data['input']['attacker']['faction'] = $node->data['faction'];
                 foreach ($_POST['attackerGroupUnitIds'] as $key => $unitId) {
                     $data['input']['attacker']['groups'][$key] = array('unitId' => $unitId, 'quantity' => $_POST['attackerGroups'][$key]);
                     if (!$game['units'][$node->data['faction']][$unitId]['speed']) {
                         $gotStatic = true;
                     }
                 }