コード例 #1
0
ファイル: ajax.php プロジェクト: jotavejv/CMS
 public function gallery_upload($cid, $uid)
 {
     //if (!$this->loginmanager->is_logged_in())
     //show_error('You are not logged in!', 403);
     $content = Content::factory((int) $cid);
     $u = User::factory((int) $uid);
     $config['upload_path'] = "iu-assets/galleries/";
     $config['allowed_types'] = 'png|jpg|jpeg|jpe|gif';
     $this->load->library('upload', $config);
     //file_put_contents('uploadify', json_encode($_FILES));
     if (!$this->upload->do_upload("Filedata")) {
         $error = $this->upload->display_errors();
         // do stuff
         show_error('Couldn\'t upload!', 500);
     } else {
         $data = $this->upload->data();
         $gi = new GalleryItem();
         $gi->image = $config['upload_path'] . $data['file_name'];
         $gi->order = 0;
         $gi->save(array($content, $content->page->get()->user->get()));
         $content->updated = time();
         $content->save();
     }
     echo 'OK!';
 }
コード例 #2
0
ファイル: EmailController.php プロジェクト: rajatkhanduja/opc
 public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         throw new Exception("Please login");
     }
     $user = User::factory($auth->getIdentity());
     if (!$user->isAdmin()) {
         throw new Exception("You must be an admin to view this page.");
     }
     $this->_helper->viewRenderer->setNoRender();
     Zend_Loader::loadClass("UserModel");
     $usermodel = new UserModel();
     $users = $usermodel->getUserList();
     foreach ($users as $username) {
         $user = User::factory($username);
         $memcount = $usermodel->getMemberCount($user);
         for ($i = 0; $i < $memcount; $i++) {
             $member = $usermodel->getMember($user, $i);
             if (!empty($member->email)) {
                 echo "{$member->email}, ";
             }
         }
     }
 }
コード例 #3
0
ファイル: log.php プロジェクト: jotavejv/CMS
 public function message()
 {
     if (empty($this->user_id)) {
         return $this->ip_addr . ' ' . $this->message;
     } else {
         return User::factory($this->user_id)->name . ' ' . $this->message();
     }
 }
コード例 #4
0
ファイル: users_test.php プロジェクト: vicioux/apisdk
 public function testUsersFactory()
 {
     Client::relateIQ(GlobalVar::KEY, GlobalVar::SECRET);
     $data = ['id' => '538530d2e4b00530d85ae1bf'];
     $other = User::factory($data);
     $this->assertInstanceOf('User', $other);
     $this->assertEquals($data['id'], $other->id());
 }
コード例 #5
0
ファイル: CS_Controller.php プロジェクト: jotavejv/CMS
 public function __construct()
 {
     parent::__construct();
     //$this->output->enable_profiler(TRUE);
     //check if config file is empty or it's not empty but script is not installed
     if ((is_db_conf_empty() || !is_installed()) && !defined('CS_EXTERNAL')) {
         redirect("setup/index");
     }
     //load database, datamapper and login manager
     $this->load->database();
     $this->load->library('datamapper');
     $this->load->library('translate');
     $this->load->library('loginmanager');
     //hack for datamapper prefix
     DataMapper::$config['prefix'] = $this->db->dbprefix;
     //set web site name in title
     $this->templatemanager->set_title(Setting::value('website_title', CS_PRODUCT_NAME));
     //test if should save uri
     $should = true;
     if ($this instanceof Process) {
         $uri = $path = trim($this->uri->uri_string());
         $file = new File();
         $file->path = $path;
         $mime = $file->mime_type();
         if ($mime !== 'text/html') {
             $should = false;
         }
     }
     //set current url for auth controller to know where to redirect
     if (!$this instanceof Auth && !$this instanceof JS && !$this->is_ajax_request() && $should) {
         $this->loginmanager->set_redirect(current_url());
     }
     //set time zone
     date_default_timezone_set(Setting::value('default_time_zone', 'Europe/Belgrade'));
     //set language
     $sess_lang = $this->session->userdata('lang');
     if (!empty($sess_lang)) {
         if (is_numeric($sess_lang)) {
             $lang = Language::factory()->get_by_id((int) $sess_lang)->name;
         } else {
             $lang = $sess_lang;
         }
     } else {
         $lang = Setting::value('default_language', 'English');
     }
     $this->translate->set_language($lang);
     //fetch user from the database if logged in
     if ($this->loginmanager->is_logged_in()) {
         $this->user = User::factory($this->loginmanager->user->id);
         $this->templatemanager->assign('user', $this->user);
     }
     $this->templatemanager->set_template_name($this->in_admin() ? "administration" : "");
     if ($this->in_admin() && isset($_GET['iu-popup'])) {
         $this->templatemanager->popup();
     }
 }
コード例 #6
0
 public function preDispatch()
 {
     $this->contestmodel = new ContestModel();
     $this->state = $this->contestmodel->getContestState(webconfig::getContestId());
     if ($this->state != "ongoing") {
         $user = User::factory(Zend_Auth::getInstance()->getIdentity());
         if (!$user || !$user->isAdmin()) {
             $this->_forward("{$this->state}", "error", NULL, array());
         }
     }
 }
コード例 #7
0
ファイル: external.php プロジェクト: jotavejv/CMS
 public function __construct()
 {
     parent::__construct();
     $this->load->database();
     $this->load->library('datamapper');
     $this->load->library('loginmanager');
     //hack for datamapper prefix
     DataMapper::$config['prefix'] = $this->db->dbprefix;
     if ($this->loginmanager->is_logged_in()) {
         $this->user = User::factory($this->loginmanager->user->id);
     }
 }
コード例 #8
0
ファイル: UploadTest.php プロジェクト: rajatkhanduja/opc
	/**
	 * @dataProvider provider
	 */

	public function testUploadHashWorks ($user, $prob, $lang, $source, $owner, $score)
	{
		config::$enable_hash_test = true;
                $a = UploadSubmission::upload ($user, $prob, $lang, $source, $owner);
                $b = UploadSubmission::upload ($user, $prob, $lang, $source, $owner);

		$user = User::factory ($user);

		if (!$user->isAdmin())
			$this->assertEquals (-1, $b);
		else
			$this->assertGreaterThan (0, $b);
		
	}	
コード例 #9
0
ファイル: RanksController.php プロジェクト: rajatkhanduja/opc
 public function indexAction()
 {
     if (webconfig::getContest()->isQueuePrivate()) {
         $user = User::factory(Zend_Auth::getInstance()->getIdentity());
         if (!$user || !$user->isAdmin()) {
             $this->_forward("privacy", "error", NULL, array());
         }
     }
     $user = $this->_request->get("user");
     $prob = $this->_request->get("prob");
     $this->view->user = $user;
     $this->view->prob = $prob;
     Zend_Loader::loadClass("RanklistModel");
     $ranklist = new RanklistModel();
     $this->view->ranks = $ranklist->getRanks($user, $prob, webconfig::getContestId());
 }
コード例 #10
0
ファイル: QueueController.php プロジェクト: rajatkhanduja/opc
 public function indexAction()
 {
     $offset = (int) $this->_request->get("offset");
     $limit = (int) $this->_request->get("limit");
     if (empty($offset)) {
         $offset = 0;
     }
     if (empty($limit)) {
         $limit = 100;
     }
     $user = $this->_request->get("user");
     $uid = $this->_request->get("uid");
     $problem = $this->_request->get("problem");
     $state = $this->_request->get("state");
     if (webconfig::getContest()->isQueuePrivate()) {
         $auth = Zend_Auth::getInstance();
         if (!$auth->hasIdentity()) {
             $this->_forward("login", "error", NULL, array());
         } else {
             $userobj = User::factory($auth->getIdentity());
             if (!$userobj->isAdmin() and !isset($uid)) {
                 $this->_forward("privacy", "error", NULL, array());
             }
         }
     }
     Zend_Loader::loadClass("Zend_Paginator");
     Zend_Loader::loadClass("Zend_Paginator_Adapter_DbSelect");
     $db = contestDB::get_zend_db();
     $query = $db->select()->from('submissionqueue')->join("users", "submissionqueue.uid = users.uid")->where("owner = ?", webconfig::getContestId())->order("id desc");
     if (!empty($user)) {
         $query = $query->where("users.username = ?", $user);
     }
     if (!empty($uid)) {
         $query = $query->where("users.uid = ?", $uid);
     }
     if (!empty($problem)) {
         $query = $query->where("submissionqueue.problemid = ?", $problem);
     }
     if (!empty($state)) {
         $query = $query->where("submissionqueue.state = ?", $state);
     }
     $adapter = new Zend_Paginator_Adapter_DbSelect($query);
     $this->view->paginator = new Zend_Paginator($adapter);
     $this->view->paginator->setCurrentPageNumber($this->_getParam('page'));
     $this->view->paginator->setItemCountPerPage(50);
 }
コード例 #11
0
ファイル: usermanager.php プロジェクト: onyxnz/quartzpos
 public function getUsersList()
 {
     $tblName = Privileges::$privilegesTable;
     $sql = "SELECT `User`, `Host`, `Password` FROM {$tblName} ORDER BY `User`, `Host`";
     if (false == $this->db->query($sql)) {
         return array();
     }
     $users = array();
     while ($row = $this->db->fetchRow()) {
         $user = User::factory($this->legacy);
         $user->userName = $row['User'];
         $user->host = $row['Host'];
         $user->password = $row['Password'];
         $users[] = $user;
     }
     return $users;
 }
コード例 #12
0
ファイル: SuController.php プロジェクト: rajatkhanduja/opc
 public function indexAction()
 {
     /* make sure I'm an admin */
     $curuser = Zend_Auth::getInstance()->getIdentity();
     if (empty($curuser) || !User::factory($curuser)->isAdmin()) {
         $this->_forward("illegal", "error");
         return;
     }
     $user = $this->_request->get("user");
     $authAdapter = new SuAuthAdapter($user);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     if ($result->isValid()) {
         $this->_redirect("/pages/home");
     } else {
         $this->_forward("illegal", "error");
     }
 }
コード例 #13
0
ファイル: UsersController.php プロジェクト: rajatkhanduja/opc
 public function indexAction()
 {
     $_user = $this->_request->get("user");
     if (webconfig::getContest()->isQueuePrivate()) {
         $user = User::factory(Zend_Auth::getInstance()->getIdentity());
         if (!$user || !$user->isAdmin()) {
             $this->_forward("privacy", "error", NULL, array());
         }
     }
     if (empty($_user)) {
         $this->_redirect(webconfig::getContestRelativeBaseUrl());
     }
     /* fillin information from User XML data */
     Zend_Loader::loadClass("UserModel");
     $userm = new UserModel();
     $user = $userm->getRow($_user);
     $this->view->username = $user->_username;
     $this->view->inst = $userm->getInstitute($user);
     $this->view->name = $userm->getMember($user, 0)->name;
 }
コード例 #14
0
ファイル: loginmanager.php プロジェクト: jotavejv/CMS
 public function __construct()
 {
     $this->framework =& get_instance();
     $this->session =& $this->framework->session;
     if (empty($this->framework->session)) {
         $this->framework->load->library('session');
         $this->session =& $this->framework->session;
     }
     if ($this->session->userdata('logged_in_user') !== false) {
         $usr = unserialize($this->session->userdata('logged_in_user'));
         $this->user = User::factory($usr->id);
     }
     //log out if not remembered and is inactive for (more than) 1 hour
     $remember = $this->session->userdata('remember');
     $last_active = $this->session->userdata('last_activity');
     $diff = time() - (int) $last_active;
     $diff = $diff / 3600;
     if ($this->is_logged_in() && !$remember && $diff > 1) {
         $this->process_logout();
         redirect($this->get_redirect());
     }
 }
コード例 #15
0
ファイル: OwnerCheck.php プロジェクト: o-log/php-auth
 /**
  * @param $user_id
  * @param $obj InterfaceOwner
  * @return bool
  */
 public static function userOwnsObj($user_id, $obj)
 {
     \OLOG\Assert::assert($obj instanceof InterfaceOwner, 'Object must implement ' . \OLOG\Auth\InterfaceOwner::class . ' interface');
     $current_user_obj = User::factory($user_id);
     if ($current_user_obj->getHasFullAccess()) {
         return true;
     }
     $current_user_usertogroup_ids_arr = UserToGroup::getIdsArrForUserIdByCreatedAtDesc($user_id);
     $current_user_groups_ids_arr = [];
     foreach ($current_user_usertogroup_ids_arr as $usertogroup_id) {
         $usertogroup_obj = UserToGroup::factory($usertogroup_id);
         $current_user_groups_ids_arr[] = $usertogroup_obj->getGroupId();
     }
     if ($obj->getOwnerUserId() == $user_id) {
         return true;
     }
     $obj_owner_group_id = $obj->getOwnerGroupId();
     if (in_array($obj_owner_group_id, $current_user_groups_ids_arr)) {
         return true;
     }
     return false;
 }
コード例 #16
0
 public function indexAction()
 {
     $uid = Zend_Auth::getInstance();
     if (!$uid->hasIdentity()) {
         $this->_forward("login", "error", null, array());
         return;
     }
     $user = User::factory($uid->getIdentity());
     $this->contestmodel = new ContestModel();
     $this->state = $this->contestmodel->getContestState(webconfig::getContestId());
     $is_admin = $user->isAdmin();
     if (!$is_admin and $this->state == "pending_result") {
         $this->_forward("pending", "error", null, array());
         return;
     }
     $this->view->id = (int) $this->getRequest()->get("id");
     $download = $this->getRequest()->get("download");
     $this->view->sub = SubmissionTable::get_submission($this->view->id);
     if (empty($this->view->sub)) {
         $this->_forward("404", "error");
         return;
     }
     $this->view->user = Zend_Auth::getInstance()->getIdentity();
     $this->view->admin = User::factory($this->view->user)->isAdmin();
     if (empty($this->view->sub) or $this->view->user != $this->view->sub->uid and !$this->view->admin) {
         $this->_forward("illegal", "error");
         return;
     }
     if ($download == "true") {
         $this->_helper->layout->disableLayout();
         $this->view->download = true;
         $this->_response->setHeader("Content-Type", "text/src");
     } else {
         $this->view->download = false;
     }
 }
コード例 #17
0
ファイル: pages.php プロジェクト: jotavejv/CMS
 public function save($id = NULL)
 {
     if (!empty($id)) {
         $page = Page::factory((int) $id);
     } else {
         $page = new Page();
         $page->uri = $this->input->post('uri', true);
     }
     $page->title = $this->input->post('title', true);
     $page->keywords = $this->input->post('keywords', true);
     $page->description = $this->input->post('description', true);
     $page->editor_id = $this->user->id;
     //caching?
     $page->custom_caching = $this->input->post('custom_caching') == 'yes';
     if ($page->custom_caching) {
         $page->custom_caching_duration = (int) str_replace(array(',', '.'), '', $this->input->post('cache_duration'));
     }
     //save editors
     $editors = $this->input->post('editors');
     $editors_users = User::factory()->where_in('id', $editors)->get();
     $not_editors_users = User::factory()->where_not_in('id', $editors)->get();
     //file
     $fid = $this->input->post('template', true);
     $save2 = array();
     if (!empty($fid)) {
         if (is_numeric($fid)) {
             $file = File::factory()->get_by_id((int) $fid);
         } else {
             $file = File::factory()->get_by_path($fid);
             if (!$file->exists()) {
                 $file->path = $fid;
                 $file->checksum = md5_file($fid);
                 $file->editor_id = $this->user->id;
                 $file->save();
             }
         }
         $tpl = $file->path;
         if (empty($tpl) && !empty($id)) {
             $tpl = $page->file->path;
         }
         if (!$file->exists()) {
             if (is_file($tpl)) {
                 $file->path = $tpl;
                 $file->save();
             } else {
                 show_error("Template file does not exist!");
             }
         }
         $save2[] = $file;
     }
     if ($this->user->can_edit_page($page)) {
         $owner_id = (int) $this->input->post('user');
         if (!empty($owner_id)) {
             $save2[] = User::factory($owner_id);
         } else {
             $save2[] = $this->user;
         }
     }
     $page->save($save2);
     if ($this->user->can_edit_page($page)) {
         //remove non editors, save editors
         $page->delete_editor($not_editors_users->all);
         $page->save_editor($editors_users->all);
     }
     $basename = basename($page->uri);
     $this->templatemanager->notify_next("Page {$basename} is successfully saved!", 'success');
     redirect('administration/pages/edit/' . $page->uri);
 }
コード例 #18
0
ファイル: pages_edit.php プロジェクト: JordietYahii/CMS
          <?php 
        $content = Content::factory()->where('div', $div_id)->group_start()->where_related_page('id', $page->id)->or_where('is_global', true)->group_end()->limit(1)->get();
        ?>
          <tr data-rel="<?php 
        echo $content->exists() ? $content->id : 0;
        ?>
" class="grade<?php 
        echo !$content->exists() ? 'X' : (!empty($content->is_global) ? 'C' : 'A');
        ?>
">
          <td class="center"><?php 
        echo $div_id;
        ?>
</td>
                <td class="center"><?php 
        echo !$content->exists() ? "&mdash;" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $content->updated == 0 ? $content->created : $content->updated) . '">' . relative_time($content->updated == 0 ? $content->created : $content->updated) . '</span> ' . __('by %s', User::factory($content->editor_id)->name);
        ?>
</td>
          <td class="actBtns">
          <a title="Edit" href="<?php 
        echo $content->exists() ? site_url('administration/contents/edit/' . $content->id . '/' . $div_id) : site_url('administration/contents/add/' . $page->id . '/' . $div_id);
        ?>
" class="tipN"><img src="<?php 
        echo $template->base_url();
        ?>
images/icons/dark/pencil.png" alt=""></a>
          <a title="Remove" onclick="remove_content(<?php 
        echo $content->exists() ? $content->id : 0;
        ?>
, '<?php 
        echo str_replace("'", "`", $content->exists() ? $content->div : 'undefined');
コード例 #19
0
ファイル: index.php プロジェクト: jlodom/planworld
function userLastLoginTimeGet($params)
{
    $loginTime = 0;
    $argToken =& $params[0];
    $argUsernameToGet =& $params[1];
    $tokenObject = new NodeToken();
    $tokenObject->retrieveToken($argToken);
    if ($tokenObject->valid && $argUsernameToGet != null) {
        $targetUser = User::factory($argUsernameToGet);
        $loginTime = $targetUser->getLastLogin();
        statusCode(200);
    } else {
        statusCode(401);
        $loginTime = 0;
    }
    return $loginTime;
}
コード例 #20
0
ファイル: CookieAuth.php プロジェクト: netconstructor/LampCMS
 /**
  * Get arr of UserInfo from
  * cache
  * @return object of type User
  *
  * @throws Lampcms\LoginException
  * in case user does not exist
  */
 protected function getSidUser()
 {
     $arrResult = $this->Registry->Mongo->USERS->findOne(array('_id' => $this->uid));
     if (empty($arrResult)) {
         d('user not found with id ' . $this->uid);
         $this->logLoginError($this->uid, $this->sid, false, null, 'cookie');
         throw new CookieAuthException('no user by uid cookie');
     }
     return User::factory($this->Registry, $arrResult);
 }
コード例 #21
0
ファイル: repeatables.php プロジェクト: jotavejv/CMS
 public function edit($id)
 {
     $item = RepeatableItem::factory((int) $id);
     $item->user->get();
     $item->content->get();
     $item->content->page->get();
     if (!$this->user->can_edit_content($item->content)) {
         $this->templatemanager->notify_next("You don't have enough permissions to edit this item's content!", 'failure');
         redirect('administration/dashboard');
     }
     if ($item->timestamp > time()) {
         $this->templatemanager->notify("This item is scheduled to be published in future!", 'information');
     }
     $users = User::factory()->get();
     $this->templatemanager->assign('item', $item);
     $this->templatemanager->assign('users', $users);
     $this->templatemanager->set_title("Edit News/Blog");
     $this->templatemanager->show_template('repeatableitem_edit');
 }
コード例 #22
0
ファイル: Auth.php プロジェクト: o-log/php-auth
 /**
  * @param $requested_permissions_arr
  * @return bool
  */
 public static function currentUserHasAnyOfPermissions($requested_permissions_arr)
 {
     $auth_cookie_name = AuthConfig::getFullAccessCookieName();
     if ($auth_cookie_name) {
         if (isset($_COOKIE[$auth_cookie_name])) {
             return true;
         }
     }
     $current_user_id = self::currentUserId();
     if (!$current_user_id) {
         return false;
     }
     $current_user_obj = User::factory($current_user_id);
     return $current_user_obj->hasAnyOfPermissions($requested_permissions_arr);
 }
コード例 #23
0
ファイル: statistics.php プロジェクト: jotavejv/CMS
 public function days($days = 30)
 {
     //hits
     $hits = Hit::factory()->fetch(time() - 3600 * 24 * $days)->cnt();
     $hitsflow = Hit::timeflow(time() - 3600 * 24 * $days, null, 30, false);
     $unique = Hit::factory()->fetch(time() - 3600 * 24 * $days)->unique()->cnt();
     $uniqueflow = Hit::timeflow(time() - 3600 * 24 * $days, null, 30, true);
     $this->templatemanager->assign('hits', $hits);
     $this->templatemanager->assign('hitsflow', $hitsflow);
     $this->templatemanager->assign('unique', $unique);
     $this->templatemanager->assign('uniqueflow', $uniqueflow);
     $this->templatemanager->assign('days', $days);
     //pages
     $pagehits = Hit::factory()->select('*')->select_func('COUNT', '@id', 'cnt')->include_related('page', null, TRUE, TRUE)->where('page_id >', 0)->fetch(time() - 3600 * 24 * $days)->unique('page_id')->limit(100)->get();
     for ($i = 0; $i < count($pagehits->all); $i++) {
         $pagehits->all[$i]->timeflow = Hit::timeflow(time() - 3600 * 24 * $days, null, 30, false, $pagehits->all[$i]->page_id);
     }
     $this->templatemanager->assign('pagehits', $pagehits);
     //sasa
     $returning = Hit::factory()->fetch(time() - 3600 * 24 * $days)->unique()->where('returning', true)->cnt();
     $returningflow = Hit::timeflow(time() - 3600 * 24 * $days, null, 30, true, null, true);
     $this->templatemanager->assign('returning', $returning);
     $this->templatemanager->assign('returningflow', $returningflow);
     //contents edited
     $cnt_edits = ContentRevision::factory()->where('created >=', time() - 3600 * 24 * $days)->get()->result_count();
     $new_users = User::factory()->where('created >=', time() - 3600 * 24 * $days)->get();
     $new_users = $new_users->result_count();
     $new_pages = Page::factory()->where('created >=', time() - 3600 * 24 * $days)->get()->result_count();
     $repeats = RepeatableItem::factory()->where('timestamp >=', time() - 3600 * 24 * $days)->get()->result_count();
     $this->templatemanager->assign('cnt_edits', $cnt_edits);
     $this->templatemanager->assign('new_users', $new_users);
     $this->templatemanager->assign('new_pages', $new_pages);
     $this->templatemanager->assign('repeatables', $repeats);
     //get stats for browsers
     $browsers = Hit::factory()->select('browser')->select_func('COUNT', '@id', 'cnt')->fetch(time() - 3600 * 24 * $days)->unique('browser')->order_by('cnt DESC')->get();
     $browsersarr = array();
     $browsers->iu_total = 0;
     foreach ($browsers as $bro) {
         $browsers->iu_total += $bro->cnt;
     }
     $limit = $browsers->result_count() > 10 ? 10 : $browsers->result_count();
     for ($i = 0; $i < $limit; $i++) {
         $br = $browsers->all[$i];
         $obj = new stdClass();
         $obj->label = str_replace("'", "\\'", $br->browser) . ' (' . percent($br->cnt, $browsers->iu_total) . '%)';
         $obj->data = (int) $br->cnt;
         $browsersarr[] = $obj;
     }
     //usort($browsersarr, array($this, 'compare_series'));
     $this->templatemanager->assign('browsers', $browsers);
     $this->templatemanager->assign('browsers_series', $browsersarr);
     //get stats for operating systems
     $oses = Hit::factory()->select('os')->select_func('COUNT', '@id', 'cnt')->fetch(time() - 3600 * 24 * $days)->unique('os')->order_by('cnt DESC')->get();
     $osarr = array();
     $oses->iu_total = 0;
     foreach ($oses as $osi) {
         $oses->iu_total += $osi->cnt;
     }
     $limit = $oses->result_count() > 10 ? 10 : $oses->result_count();
     for ($i = 0; $i < $limit; $i++) {
         $os = $oses->all[$i];
         $obj = new stdClass();
         $obj->label = str_replace("'", "\\'", $os->os) . ' (' . percent($os->cnt, $oses->iu_total) . '%)';
         $obj->data = (int) $os->cnt;
         $osarr[] = $obj;
     }
     //usort($osarr, array($this, 'compare_series'));
     $this->templatemanager->assign('oses', $oses);
     $this->templatemanager->assign('oses_series', $osarr);
     //get stats for countries
     $geoip_db_filename = './iu-resources/geoip/GeoIP.dat';
     if (is_file($geoip_db_filename)) {
         $countries = Hit::factory()->select('country')->select_func('COUNT', '@id', 'cnt')->fetch(time() - 3600 * 24 * $days)->unique('country')->order_by('cnt DESC')->get();
         $conarr = array();
         $countries->iu_total = 0;
         foreach ($countries as $cou) {
             $countries->iu_total += $cou->cnt;
         }
         //var_dump(percent(20,100));
         $limit = $countries->result_count() > 10 ? 10 : $countries->result_count();
         for ($i = 0; $i < $limit; $i++) {
             $c = $countries->all[$i];
             $obj = new stdClass();
             $obj->label = str_replace("'", "\\'", empty($c->country) ? __("(unknown)") : $c->country) . ' (' . percent($c->cnt, $countries->iu_total) . '%)';
             $obj->data = (int) $c->cnt;
             $conarr[] = $obj;
         }
         //usort($conarr, array($this, 'compare_series'));
         $this->templatemanager->assign('countries', $countries);
         $this->templatemanager->assign('countries_series', $conarr);
     }
     $this->templatemanager->show_template('statistics');
 }
コード例 #24
0
ファイル: users.php プロジェクト: jotavejv/CMS
 public function remove($id)
 {
     $id = (int) $id;
     $user = User::factory($id);
     if (!$this->user->can('manage_users')) {
         $this->templatemanager->notify_next("You are not allowed to edit users!", 'failure');
         redirect('administration/dashboard');
     } else {
         if ($id != $this->user->id) {
             if (!empty($user->picture) && $user->picture != 'user.jpg') {
                 unlink('images/' . $user->picture);
             }
             $user->delete();
             redirect('administration/users');
         } else {
             $this->loginmanager->show_error("You can not delete yourself!", "Error", null);
         }
     }
 }
コード例 #25
0
ファイル: contents.php プロジェクト: lukamacun/CMS
 public function save($id)
 {
     $relations = array();
     //file_put_contents('post', json_encode($_POST));
     $pid = $this->input->post('pid');
     //$div_id = $this->input->post('div');
     $html = $this->input->post('html');
     if (!empty($pid)) {
         $page = Page::factory()->get_by_id((int) $pid);
         $relations[] = $page;
     }
     $content = Content::factory()->get_by_id($id);
     if (!$this->user->can_edit_content($content)) {
         if ($this->is_ajax_request()) {
             die(json_encode(array('status' => 'Error', 'message' => __("You don't have enough permissions to edit this content!"))));
         } else {
             $this->templatemanager->notify_next("You don't have enough permissions to edit this content!", 'failure');
             redirect('administration/dashboard');
         }
     }
     $old_html = $content->contents;
     $old_editor = $content->editor_id;
     $old_ts = !empty($content->updated) ? $content->updated : $content->created;
     //set/unset editors
     $editors = $this->input->post('editors');
     if (!empty($editors)) {
         $editors_users = User::factory()->where_in('id', $editors)->get();
         $not_editors_users = User::factory()->where_not_in('id', $editors)->get();
     }
     //set page and content editor
     $page->editor_id = $this->user->id;
     $content->editor_id = $this->user->id;
     //set contents
     $content->contents = empty($html) ? '' : $html;
     //save page and contents
     $page->save();
     //set content type
     $ctype_id = (int) $this->input->post('type');
     if ($ctype_id > 0 && $this->user->owns_page($page)) {
         $relations[] = ContentType::factory($ctype_id);
     }
     if ($this->user->owns_page($page)) {
         $content->is_global = $this->input->post('global') == 'yes';
     }
     //remove non and save editors
     if (!empty($editors) && $this->user->owns_page($page)) {
         $content->delete_editor($not_editors_users->all);
         $content->save_editor($editors_users->all);
     }
     $content->save($relations);
     //create revision
     $rev = new ContentRevision();
     $rev->contents = $old_html;
     $rev->user_id = $old_editor;
     $rev->created = $old_ts;
     $rev->save(array($content, $this->user));
     $this->templatemanager->notify_next(__("Content \"%s\" is saved!", $content->div), 'success');
     if ($this->is_ajax_request()) {
         echo json_encode(array('status' => 'OK', 'message' => __("Content \"%s\" is saved!", $div_id)));
     } else {
         redirect('administration/contents/edit/' . $content->id . '/' . $content->div);
     }
 }
コード例 #26
0
 public function preDispatch()
 {
     $curuser = Zend_Auth::getInstance()->getIdentity();
     $user = User::factory($curuser);
     if (!empty($curuser) && !empty($user) && $user->isAdmin()) {
         return;
         /* no other tests needed for admin */
     }
     Zend_Loader::loadClass("ContestModel");
     $this->contestmodel = new ContestModel();
     $this->state = $this->contestmodel->getContestState(webconfig::getContestId());
     if ($this->state == "before") {
         $this->_forward("before", "error", NULL, array());
     }
 }
コード例 #27
0
ファイル: repeatables_list.php プロジェクト: jotavejv/CMS
</a></span></td>
			<td><span<?php 
    echo strlen($page->uri) > $l ? ' class="tipW" title="' . $page->uri . '"' : "";
    ?>
><a href="<?php 
    echo site_url($page->uri);
    ?>
" class="highlightLink"><?php 
    echo ellipsize($page->uri, $l, 0.5);
    ?>
</a></span><span style="display: none;"><?php 
    echo $page->uri;
    ?>
</span></td>
            <td class="center"><?php 
    echo empty($rep->updated) ? "&mdash;" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $rep->updated) . '">' . relative_time($rep->updated) . '</span> ' . __('by %s', User::factory($rep->editor_id)->name);
    ?>
</td>
			<td class="center"><?php 
    $fnd = $rep->repeatableitem->get()->result_count();
    echo $fnd;
    ?>
 item<?php 
    echo $fnd != 1 ? 's' : '';
    ?>
 found</td>
            <td class="actBtns">
				<a title="Edit" href="<?php 
    echo site_url('administration/contents/edit/' . $rep->id . '/' . $rep->div);
    ?>
"  class="tipN"><img src="<?php 
コード例 #28
0
 public function update2Action()
 {
     $this->view->mode = "update";
     try {
         $this->validate();
     } catch (Exception $e) {
         $this->log->info("Error in updated profile: " . $e->getMessage());
         $this->error_message = $e->getMessage();
         $this->copyToView();
         return;
     }
     $this->saveXML();
     $this->copyToView();
     User::factory($this->user)->setPassword($this->password);
     $this->_redirect(webconfig::getContestRelativeBaseUrl() . "/profile/profile-update-success");
 }
コード例 #29
0
ファイル: UserModel.php プロジェクト: rajatkhanduja/opc
 public function getRow($user)
 {
     return User::factory($user);
 }
コード例 #30
0
ファイル: dashboard.php プロジェクト: jotavejv/CMS
 public function index()
 {
     //get stats
     $last15 = Hit::factory()->fetch(time() - 60 * 15)->unique()->cnt();
     $last15bymin = Hit::timeflow(time() - 60 * 15, null, 15);
     $last4hrs = Hit::factory()->fetch(time() - 3600 * 4)->unique()->cnt();
     $last4hrsbymin = Hit::timeflow(time() - 3600 * 4, null, 16);
     $today = Hit::factory()->fetch(mktime(0, 0, 0))->unique()->cnt();
     $todaybymin = Hit::timeflow(mktime(0, 0, 0), null, 24);
     $yesterday = Hit::factory()->fetch(mktime(0, 0, 0) - 3600 * 24, mktime(0, 0, 0))->unique()->cnt();
     $yesterdaybymin = Hit::timeflow(mktime(0, 0, 0) - 3600 * 24, mktime(0, 0, 0), 24);
     $lastweek = Hit::factory()->fetch(mktime(0, 0, 0) - 3600 * 24 * 7)->unique()->cnt();
     $lastweekbymin = Hit::timeflow(mktime(0, 0, 0) - 3600 * 24 * 7, null, 14);
     $lastmonth = Hit::factory()->fetch(mktime(0, 0, 0) - 3600 * 24 * 30)->unique()->cnt();
     $lastmonthbymin = Hit::timeflow(mktime(0, 0, 0) - 3600 * 24 * 7, null, 30);
     $returning = Hit::factory()->fetch(time() - 3600 * 24 * 30)->unique()->where('returning', true)->cnt();
     $new_pages = Page::factory()->where('created >=', time() - 3600 * 24 * 30)->get()->result_count();
     $countries = Hit::factory()->fetch(time() - 3600 * 24 * 30)->group_by('country')->cnt();
     $pagehits = Hit::factory()->select('*,count(page_id) as cnt')->include_related('page', null, TRUE, TRUE)->where('page_id >', 0)->fetch(time() - 3600 * 24 * 7)->group_by('page_id')->limit(1)->get();
     $this->templatemanager->assign('pagehits', $pagehits);
     $ping = false;
     $pingset = Setting::factory('last_ping');
     $lastping = (int) $pingset->value;
     if (time() - $lastping > 3600 * 24 * 7) {
         $ping = true;
     }
     $pingset->value = time();
     $pingset->save();
     $this->templatemanager->assign('last15', $last15);
     $this->templatemanager->assign('last15bymin', $last15bymin);
     $this->templatemanager->assign('last4hrs', $last4hrs);
     $this->templatemanager->assign('last4hrsbymin', $last4hrsbymin);
     $this->templatemanager->assign('today', $today);
     $this->templatemanager->assign('todaybymin', $todaybymin);
     $this->templatemanager->assign('yesterday', $yesterday);
     $this->templatemanager->assign('yesterdaybymin', $yesterdaybymin);
     $this->templatemanager->assign('lastweek', $lastweek);
     $this->templatemanager->assign('lastweekbymin', $lastweekbymin);
     $this->templatemanager->assign('lastmonth', $lastmonth);
     $this->templatemanager->assign('lastmonthbymin', $lastmonthbymin);
     $this->templatemanager->assign('returning', $returning);
     $this->templatemanager->assign('new_pages', $new_pages);
     $this->templatemanager->assign('countries', $countries);
     $this->templatemanager->assign('ping', $ping);
     //latest repeatables
     $last_repeatables = RepeatableItem::factory()->order_by('timestamp DESC')->limit(5)->get();
     $this->templatemanager->assign('last_repeatables', $last_repeatables);
     //latest contents updated
     $last_contents = Content::factory()->where_related_contenttype('classname', 'Html')->order_by('updated DESC, created DESC')->limit(10)->get();
     $this->templatemanager->assign('last_contents', $last_contents);
     //count content updates (revisions)
     $revs = ContentRevision::factory()->count();
     $this->templatemanager->assign('revisions', $revs);
     //if geoip is old, notify
     $geoip_db_filename = './iu-resources/geoip/GeoIP.dat';
     if (is_file($geoip_db_filename)) {
         $month_earlier = time() - 3600 * 24 * 30;
         $filemtime = filemtime($geoip_db_filename);
         if ($this->user->can('edit_settings') && $filemtime <= $month_earlier) {
             $lnk = site_url('administration/maintenance');
             $this->templatemanager->notify(__("Your GeoIP database is now older than one month! Consider <a href='{$lnk}'>updating it</a>!"), 'information');
         }
     }
     //get latest users
     $users = User::factory()->order_by('created DESC')->limit(5)->get();
     $this->templatemanager->assign('users', $users);
     $this->templatemanager->show_template("dashboard");
 }