Пример #1
0
 public function __construct($userId = null)
 {
     if ($userId == null) {
         loadUser();
     } else {
         $this->userId = $userId;
         $this->userName = "******";
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     if (empty(loadGuideByTitleOrId($id))) {
         flash()->error('That guide does not exist.')->important();
         return redirect('guides');
     }
     $guide = loadGuideByTitleOrId($id)[0];
     $author = loadUser($guide->writerId)[0];
     return view('guides.show', compact('guide', 'author'));
 }
Пример #3
0
function isLoggedIn() {
	global $User, $_COOKIE;

	if (isset($User)) return true;

	if (isset($_COOKIE['auth'])) {
		$r = redisLink();
		$authCookie = $_COOKIE['auth'];
		if ($uid = $r->hget("auths", $authCookie)) {
			if ($r->hget("user:$uid", "auth") != $authCookie) return false;
			loadUser($uid);
			return true;
		}
	}

	return false;
}
 private static function buildUserNotifcations($notification)
 {
     $string = "";
     $user = loadUser($notification->generator_user_id)[0];
     $username = '******' . $notification->generator_user_id . '>' . $user->username . '</a>';
     switch ($notification->type) {
         case "friend request":
             $string = (object) array_merge((array) $notification, array('message' => $username . ' has sent you a friend request.'));
             break;
         case "friend request accepted":
             $string = (object) array_merge((array) $notification, array('message' => $username . ' has accepted your friend request.'));
             break;
         case "friend request declined":
             $string = (object) array_merge((array) $notification, array('message' => $username . ' has declined your friend request.'));
             break;
         case "join group request":
             $groupname = loadGroup($notification->object_id)[0]->name;
             $group = '<a href=/groups/' . $notification->object_id . '/manageMembers>' . $groupname . '</a>';
             $string = (object) array_merge((array) $notification, array('message' => $username . ' has requested to join your group \'' . $group . '\'.'));
             break;
         case "series completed":
             $seriesTitle = loadSerieWithId($notification->object_id)[0]->title;
             $series = '<a href=/series/' . $notification->object_id . '>\'' . $seriesTitle . '\'</a>.';
             $string = (object) array_merge((array) $notification, array('message' => $username . ' has completed your series ' . $series));
             break;
         case "exercise completed":
             $exercise = '<a href=/exercises/' . $notification->object_id . '>exercise</a>.';
             $string = (object) array_merge((array) $notification, array('message' => $username . ' has accomplished an ' . $exercise));
             break;
         case "answer shared":
             $string = (object) array_merge((array) $notification, array('message' => $username . ' has shared <a href=/sreies/>an answer</a> with you.'));
             break;
         case "challenged":
             $string = (object) array_merge((array) $notification, array('message' => $username . ' has <a href=/challenges/>challenged</a> you.'));
             break;
         case "challenge beaten":
             $string = (object) array_merge((array) $notification, array('message' => $username . ' has beaten your <a href=/challenges/>challenge</a>!'));
             break;
     }
     return $string;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($userId, $exId)
 {
     $user = loadUser($userId)[0];
     if (loadChallengeByUsersExercise(\Auth::id(), $user->id, $exId) == []) {
         storeChallenge(\Auth::id(), $user->id, $exId);
         $challengeId = loadChallengeByUsersExercise(\Auth::id(), $user->id, $exId)[0]->id;
         setWinner($challengeId, \Auth::id());
         $newScore = loadUser(\Auth::id())[0]->score + 1;
         setUserScore(\Auth::id(), $newScore);
         flash()->success("{$user->username} was challenged succefully");
         storeNotification($user->id, "challenged", \Auth::id(), $challengeId);
     } else {
         flash()->error("This challenge already exists");
     }
     $sId = \Session::get('currentSerie');
     $nextEx = nextExerciseofSerie($exId, $sId);
     if ($nextEx == []) {
         return redirect('series/');
     }
     return redirect('exercises/' . $nextEx[0]->id);
 }
Пример #6
0
} else {
    $populate_fields = false;
    $button_submit_text = "Create user";
    $target = "create_user.php";
    $box_title = "New User";
    $username_disable_str = "";
}
$user_name = "";
$display_name = "";
$email = "";
$user_title = "";
$user_active = "0";
$user_enabled = "0";
// If we're in update mode, load user data
if ($populate_fields) {
    $user = loadUser($user_id);
    $user_name = $user['user_name'];
    $display_name = $user['display_name'];
    $email = $user['email'];
    $user_title = $user['title'];
    $user_active = $user['active'];
    $user_enabled = $user['enabled'];
    $primary_group_id = $user['primary_group_id'];
    if ($user['last_sign_in_stamp'] == '0') {
        $last_sign_in_date = "Brand new!";
    } else {
        $last_sign_in_date_obj = new DateTime();
        $last_sign_in_date_obj->setTimestamp($user['last_sign_in_stamp']);
        $last_sign_in_date = $last_sign_in_date_obj->format('l, F j Y');
    }
    $sign_up_date_obj = new DateTime();
Пример #7
0
function loadUserList()
{
    global $MAIN_TABLE, $DAY_TABLE, $db;
    $sql = "SELECT name, SUM(time) AS total, SUM(CASE WHEN YEAR(date)=YEAR(CURDATE()) THEN time ELSE 0 END) as season FROM robonauts_day GROUP BY name ORDER BY season DESC;";
    $result = $db->query($sql);
    $data = array();
    while ($row = $result->fetch_array()) {
        $row[] = loadUser($row[0]);
        $data[] = $row;
    }
    $result->free();
    echo json_encode($data);
}
Пример #8
0
function modifySiteAdminUser($userId, $siteAdmin)
{
    if (!isSiteAdmin()) {
        return FALSE;
    }
    if ($userId == $_SESSION['user']['user_id']) {
        return FALSE;
    }
    $userObj = loadUser($userId);
    if (!$userObj) {
        return FALSE;
    }
    if (!userIsActive($userId)) {
        return FALSE;
    }
    $userRoleId = getRoleId('user');
    $adminRoleId = getRoleId('admin');
    if ($userObj['role_id'] != $userRoleId && $userObj['role_id'] != $adminRoleId) {
        return FALSE;
    }
    $newRoleId = $userRoleId;
    if ($siteAdmin) {
        $newRoleId = $adminRoleId;
    }
    $updates = array('role_id' => $newRoleId);
    $conditions = array('user_id' => $userId);
    return db_update('virtual_users', $updates, $conditions);
}
Пример #9
0
     } elseif (empty($_POST['password'])) {
         $msg = $strEnterPassword;
     } else {
         if (ENCRYPTPASSWORD) {
             $encP = encryptPass($_POST['password']);
             $canlogin = false;
             $canlogin = !empty($encP) && !empty($_POST['password']) && !empty($emailcheck) && $encP == $userpassword && $_POST['email'] == $emailcheck;
             #      print $_POST['password'].' '.$encP.' '.$userpassword.' '.$canlogin; exit;
         } else {
             $canlogin = $_POST['password'] == $userpassword && $_POST['email'] == $emailcheck;
         }
     }
     if (!$canlogin) {
         $msg = '<p class="error">' . $strInvalidPassword . '</p>';
     } else {
         loadUser($emailcheck);
         $_SESSION['userloggedin'] = $_SERVER['REMOTE_ADDR'];
     }
 } elseif (!empty($_POST['forgotpassword'])) {
     # forgot password button pushed
     if (!empty($_POST['email']) && $_POST['email'] == $emailcheck) {
         sendMail($emailcheck, $GLOBALS['strPasswordRemindSubject'], $GLOBALS['strPasswordRemindMessage'] . ' ' . $userpassword, system_messageheaders());
         $msg = $GLOBALS['strPasswordSent'];
     } else {
         $msg = $strPasswordRemindInfo;
     }
 } elseif (isset($_SESSION['userdata']['email']['value']) && $_SESSION['userdata']['email']['value'] == $emailcheck) {
     # Entry without any button pushed (first time) test and, if needed, ask for password
     $canlogin = $_SESSION['userloggedin'];
     $msg = $strEnterPassword;
 }
 /**
  * Display a list of messages between the logged in user and user $id.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $userr = loadUser($id);
     if (empty($userr)) {
         flash()->error('That user does not exist');
         return redirect('/messages');
     }
     if ($userr[0]->id == \Auth::id()) {
         return $this->index();
     }
     if (!empty(loadConversation($id))) {
         $conversationId = loadConversation($id)[0]->conversationId;
         //Load all messages with in conversation $id
         //dd($conversationId);
         $messages = loadAllMessages($conversationId);
         //dd($messages);
         //Then get user with $id to show him
         $user = $userr[0];
         updateMessagesToSeen($conversationId);
         //Then get all conversations for the logged in user to show those in the sidebar
         $conversations = loadLastNConversationsWithMessage(999);
         //Find the last message that has been read by user $id
         $lastRead = "";
         if (!empty(loadLastReadMessage($id))) {
             $lastRead = loadLastReadMessage($id)[0]->message;
         }
         //Add a Carbon time object to each message
         foreach ($messages as &$message) {
             $carbon = Carbon::createFromFormat('Y-n-j G:i:s', $message->date);
             $message = (object) array_merge((array) $message, array('carbon' => $carbon));
             //Give seen status only to the last seen message, not all of them
             if ($message->message == $lastRead) {
                 $message = (object) array_merge((array) $message, array('seen' => 1));
             } else {
                 $message = (object) array_merge((array) $message, array('seen' => 0));
             }
         }
         //Add a Carbon time object to each $conversation
         foreach ($conversations as &$conversation) {
             $carbon = Carbon::createFromFormat('Y-n-j G:i:s', $conversation->date);
             $conversation = (object) array_merge((array) $conversation, array('carbon' => $carbon));
         }
         return view('pages.messages', compact('messages', 'user', 'conversations'));
     } else {
         //create a new conversation between the logged in user and $id
         $toId2 = loadUser($id)[0]->id;
         storeConversation($toId2);
         return $this->show($id);
     }
 }
Пример #11
0
if (!isset($_GET['action']) && isset($_GET['id'])) {
    $user = new User(loadUser($db, $_GET['id']));
    //$user->display();
    $userHtml = $user->display();
} elseif ($_GET['action'] == 'create') {
    //create a new user if url specifies create action
    //get new user info from post
    //TODO sanitize user information and make sure it is complete
    //TODO check that email is valid
    $newUser = $_POST;
    //add file info for user profile picture
    $newUser['userimage'] = $_FILES['userimage']['name'];
    createUser($newUser, $_FILES['userimage'], $db);
} elseif ($_GET['action'] == 'edit') {
    $user = new User($_SESSION['userData']);
    $viewedUser = new User(loadUser($db, $_GET['id']));
    echo $user->isAdmin();
    echo $user->getID();
    if ($_GET['id'] == $user->getID()) {
        echo 'can edit this entry';
        $userHtml = $viewedUser->displayEditable();
    } else {
        echo 'cannot edit this entry';
        $userHtml = $viewedUser->display();
    }
} elseif ($_GET['action'] == 'update') {
}
function createUser($user, $userImage, $db)
{
    $query = 'INSERT INTO users VALUES (null, :email , :password , :fName, :lName, :imageName, :admin) ';
    try {
Пример #12
0
			</tr>
		</table>
			<table style="border-style: solid; border-collapse: collapse; font-size: 12px; direction: rtl; width:90%; height: 10cm;" border="2">
		<tbody>
		<tr>
			<td rowspan="3" colspan="3" style="width:4cm;height:3cm;" >
			<b>   <?php 
    echo $customer->name;
    ?>
</b>
			<br>
			<?php 
    echo hamed_pdate1($ticket->regtime);
    ?>
			<br> <?php 
    echo loadUser($ticket->user_id);
    ?>
			</td>
			<td colspan="2" style="height:0.8cm;font-size: 7px;"  >
			<b>
			<br />
		کوپن مدیریت
			</b>
			</td>
			<td style="text-align: left;height:0.8cm;" colspan="8">
				<table style="font-size: 6px;width:100%;">
					<tr>
						<td>
								<img src='../img/arm_gcom.png' width="20px" >
									<br/>گستره‌ارتباطات‌شرق
						</td>
Пример #13
0
function forwardExists($destination, $userId = FALSE)
{
    if (!$destination) {
        return FALSE;
    }
    $user = $_SESSION['user']['user'];
    $domainId = $_SESSION['user']['domain_id'];
    if (!$userId) {
        $userId = $_SESSION['user']['user_id'];
    }
    if ($userId != $_SESSION['user']['user_id']) {
        $userObj = loadUser($userId);
        $adminDomains = getAdminDomains();
        $domain = $userObj['domain'];
        if (!in_array($domain, $adminDomains)) {
            return FALSE;
        }
        $user = $userObj['user'];
        $domainId = $userObj['domain_id'];
    }
    $sql = 'SELECT' . '  COUNT(*)' . '  FROM virtual_aliases' . '  WHERE username = ?' . '    AND domain_id = ?' . '    AND destination = ?';
    $numForwards = db_getval($sql, array($user, $domainId, $destination));
    if ($numForwards > 0) {
        return TRUE;
    } else {
        return FALSE;
    }
}
Пример #14
0
function initUser()
{
    return loadUser(42);
}
@extends('master')

@section('title')
<?php 
$userA = loadUser($challenge->userA)[0];
$userB = loadUser($challenge->userB)[0];
$winner = [];
$loser = [];
if ($challenge->winner == $userA->id) {
    $winner = $userA;
    $loser = $userB;
} else {
    if ($challenge->winner == $userB->id) {
        $winner = $userB;
        $loser = $userA;
    }
}
?>
Exercise: <a href="/exercises/{{$challenge->exId}}" style="font-style: italic; color: #ffffff">{{ firstChars(strip_tags(loadExercise($challenge->exId)[0]->question), 50) }}</a> <br/>
<a href="/users/{{ $userA->username }}"  style="color: #ffffff">{{ $userA->username }}</a>
<i>vs</i>
<a href="/users/{{ $userB->username }}"  style="color: #ffffff">{{ $userB->username }}</a>
@stop

@section('content')
<div>
    @if ($winner == [])
        <h2> Tie </h2>

    @else
    <div>
Пример #16
0
<?php

session_start();
require "database/connect.php";
require "database/employees.php";
require "database/messages.php";
require "database/users.php";
require "includes/common.php";
if ($_POST["procedure"] == "Send") {
    if ($_POST["pm"] == "on") {
        saveMessage($_POST["userID"], $_POST["subject"], $_POST["message"], $_SESSION["id"], $_SESSION["username"], 0, 0);
    }
    if ($_POST["email"] == "on") {
        loadUser($_POST["userID"]);
        $subject = $_POST["subject"];
        $body = $_POST["message"];
        $from = $_SESSION["username"];
        if (mail($emp_email, $subject, $body, "From: " . $from . "\n")) {
            //echo("<p>Email successfully sent.</p>");
        } else {
            //echo("<p>Email delivery failed.</p>");
        }
    }
    header('Location: inbox.php');
}
$pageTitle = "Main";
$javascript = "message.js";
if ($_SESSION["type"] == "3") {
    require 'includes/adminHeader.php';
} else {
    require 'includes/userHeader.php';
            <?php 
$name = loadUser($challenge->userA)[0]->username;
?>
        @endif
        <li><a href="/exercises/{{$challenge->exId}}">Exercise {{ firstChars(strip_tags(loadExercise($challenge->exId)[0]->question), 20) }} </a></br>
            <div style="text-indent: 2em"><a href="/challenges/{{$challenge->id}}"><em>(vs {{ $name }} )</em></a></div>
    @endforeach
    </ul>
    <h3> Challenges you won </h3>
    <ul>
    @foreach($challengesB as $challenge)
        {{-- Get opponent --}}
        @if ( $challenge->userA == \Auth::id() )
            <?php 
$name = loadUser($challenge->userB)[0]->username;
?>
        @else
            <?php 
$name = loadUser($challenge->userA)[0]->username;
?>
        @endif
        <li><a href="/exercises/{{$challenge->exId}}">Exercise {{ firstChars(strip_tags(loadExercise($challenge->exId)[0]->question), 20) }} </a></br>
            <div style="text-indent: 2em"><a href="/challenges/{{$challenge->id}}"><em>(vs {{ $name }} )</em></a></div>
    @endforeach
    </ul>
@endif
</div>
</div>
@stop

Пример #18
0
     $_SESSION["currentpage"] = "Transport";
     $arrScriptFiles = array("script", "Transport.js", "manage_Transport.js", "AutoComplete.js", "baseConnection.js", "msgPopup.js", "formPopup.js", "manage_Cookie.js");
     $arrStyleFiles = array("style", "styles.css", "Transport.css");
     array_push($arrFilesForLoad, $arrStyleFiles);
     array_push($arrFilesForLoad, $arrScriptFiles);
     loadHeader($arrFilesForLoad);
     loadTransport($_GET);
     break;
 case "User":
     $_SESSION["currentpage"] = "User";
     $arrScriptFiles = array("script", "User.js", "manage_User.js", "AutoComplete.js", "baseConnection.js", "msgPopup.js", "formPopup.js", "manage_Cookie.js");
     $arrStyleFiles = array("style", "styles.css", "User.css");
     array_push($arrFilesForLoad, $arrStyleFiles);
     array_push($arrFilesForLoad, $arrScriptFiles);
     loadHeader($arrFilesForLoad);
     loadUser($_GET);
     break;
 case "Village":
     $_SESSION["currentpage"] = "Village";
     $arrScriptFiles = array("script", "Village.js", "manage_Village.js", "AutoComplete.js", "baseConnection.js", "msgPopup.js", "formPopup.js", "manage_Cookie.js");
     $arrStyleFiles = array("style", "styles.css", "Village.css");
     array_push($arrFilesForLoad, $arrStyleFiles);
     array_push($arrFilesForLoad, $arrScriptFiles);
     loadHeader($arrFilesForLoad);
     loadVillage($_GET);
     break;
 case "Village_agriculture":
     $_SESSION["currentpage"] = "Village_agriculture";
     $arrScriptFiles = array("script", "Village_agriculture.js", "manage_Village_agriculture.js", "AutoComplete.js", "baseConnection.js", "msgPopup.js", "formPopup.js", "manage_Cookie.js");
     $arrStyleFiles = array("style", "styles.css", "Village_agriculture.css");
     array_push($arrFilesForLoad, $arrStyleFiles);
}
// Create appropriate labels
if ($get['user_id']) {
    $populate_fields = true;
    $button_submit_text = "Update user";
    $target = "update_user.php";
    $box_title = "Update User";
} else {
    $populate_fields = false;
    $button_submit_text = "Create user";
    $target = "create_user.php";
    $box_title = "New User";
}
// If we're in update mode, load user data
if ($populate_fields) {
    $user = loadUser($get['user_id']);
    $deleteLabel = $user['user_name'];
    $user_groups = loadUserGroups($get['user_id']);
    if ($get['render_mode'] == "panel") {
        $box_title = $user['display_name'];
    }
} else {
    $user = array();
    $deleteLabel = "";
}
$fields_default = ['user_name' => ['type' => 'text', 'label' => 'Username', 'display' => 'disabled', 'validator' => ['minLength' => 1, 'maxLength' => 25, 'label' => 'Username'], 'placeholder' => 'Please enter the user name'], 'display_name' => ['type' => 'text', 'label' => 'Display Name', 'display' => 'disabled', 'validator' => ['minLength' => 1, 'maxLength' => 50, 'label' => 'Display name'], 'placeholder' => 'Please enter the display name'], 'email' => ['type' => 'text', 'label' => 'Email', 'display' => 'disabled', 'icon' => 'fa fa-envelope', 'icon_link' => 'mailto: {{value}}', 'validator' => ['minLength' => 1, 'maxLength' => 150, 'email' => true, 'label' => 'Email'], 'placeholder' => 'Email goes here'], 'title' => ['type' => 'text', 'label' => 'Title', 'display' => 'disabled', 'validator' => ['minLength' => 1, 'maxLength' => 100, 'label' => 'Title'], 'default' => 'New User'], 'sign_up_stamp' => ['type' => 'text', 'label' => 'Registered Since', 'display' => 'disabled', 'icon' => 'fa fa-calendar', 'preprocess' => 'formatSignInDate'], 'last_sign_in_stamp' => ['type' => 'text', 'label' => 'Last Sign-in', 'display' => 'disabled', 'icon' => 'fa fa-calendar', 'preprocess' => 'formatSignInDate', 'default' => 0], 'password' => ['type' => 'password', 'label' => 'Password', 'display' => 'hidden', 'icon' => 'fa fa-key', 'validator' => ['minLength' => 8, 'maxLength' => 50, 'label' => 'Password', 'passwordMatch' => 'passwordc']], 'passwordc' => ['type' => 'password', 'label' => 'Confirm password', 'display' => 'hidden', 'icon' => 'fa fa-key', 'validator' => ['minLength' => 8, 'maxLength' => 50, 'label' => 'Password']], 'groups' => ['display' => 'disabled']];
$fields = array_merge_recursive_distinct($fields_default, $get['fields']);
// Buttons (optional)
// submit: display the submission button for this form.
// edit: display the edit button for panel mode.
// disable: display the enable/disable button.
Пример #20
0
<?php

include_once '../lib/session.inc.php';
include_once '../lib/user.inc.php';
requireLogin();
$mode = $_POST['mode'];
if ($mode == 'load') {
    $userId = $_SESSION['user']['user_id'];
    $_SESSION['user'] = loadUser($userId);
    print json_encode(array('success' => TRUE, 'data' => array('name' => $_SESSION['user']['name'])));
} else {
    if ($mode == 'save') {
        $name = $_POST['name'];
        $name = trim($name);
        if (!$name) {
            print json_encode(array('success' => FALSE, 'errors' => array('name' => 'This field is required')));
            exit;
        }
        if (changeName($name)) {
            print json_encode(array('success' => TRUE));
        } else {
            print json_encode(array('success' => FALSE, 'errors' => array('name' => 'Error changing name')));
        }
    }
}
Пример #21
0
$theDate = date("d F Y");
if ($_POST["theDate"] != "") {
    $theDate = $_POST["theDate"];
}
$lastSunday = strtotime("last Sunday", strtotime($theDate));
$day1 = date("l, F j", $lastSunday);
$day2 = date("l, F j", strtotime("+1 day", $lastSunday));
$day3 = date("l, F j", strtotime("+2 day", $lastSunday));
$day4 = date("l, F j", strtotime("+3 day", $lastSunday));
$day5 = date("l, F j", strtotime("+4 day", $lastSunday));
$day6 = date("l, F j", strtotime("+5 day", $lastSunday));
$day7 = date("l, F j", strtotime("+6 day", $lastSunday));
loadSettings(1);
$empID = "-1";
$userID = $_SESSION["id"];
loadUser($userID);
$jobs = array();
$jobs[1] = loadEmployeeJob($empID, date("Y", $lastSunday), date("m", $lastSunday), date("d", $lastSunday));
$jobs[2] = loadEmployeeJob($empID, date("Y", $lastSunday), date("m", $lastSunday), date("d", $lastSunday) + 1);
$jobs[3] = loadEmployeeJob($empID, date("Y", $lastSunday), date("m", $lastSunday), date("d", $lastSunday) + 2);
$jobs[4] = loadEmployeeJob($empID, date("Y", $lastSunday), date("m", $lastSunday), date("d", $lastSunday) + 3);
$jobs[5] = loadEmployeeJob($empID, date("Y", $lastSunday), date("m", $lastSunday), date("d", $lastSunday) + 4);
$jobs[6] = loadEmployeeJob($empID, date("Y", $lastSunday), date("m", $lastSunday), date("d", $lastSunday) + 5);
$jobs[7] = loadEmployeeJob($empID, date("Y", $lastSunday), date("m", $lastSunday), date("d", $lastSunday) + 6);
padBegin(6, 6);
?>

<input type="hidden" id="day1" name="day1" />
<input type="hidden" id="day2" name="day2" />
<input type="hidden" id="day3" name="day3" />
<input type="hidden" id="day4" name="day4" />
$provider = empty($args[0]) ? '' : strtolower($args[0]);
$ingesterParams = ['debug' => isset($options['d']), 'reupload' => isset($options['r'])];
// check if allow to upload file
if ($wgEnableUploads === false) {
    die("File upload is disabled.\n");
}
// check for read only mode
if (wfReadOnly()) {
    die("Read only mode.\n");
}
// Make it clear when we're in debug mode
if ($ingesterParams['debug']) {
    echo "== DEBUG MODE ==\n";
}
// Populate $wgUser with Wikia Video Library
loadUser('Wikia Video Library');
// Determine which providers to pull from
$providersVideoFeed = loadProviders($provider);
// Loop through each provider and ingest video metadata
foreach ($providersVideoFeed as $provider) {
    print "Starting import for provider {$provider}...\n";
    /** @var VideoFeedIngester $feedIngester */
    $feedIngester = FeedIngesterFactory::getIngester($provider, $ingesterParams);
    // get WikiFactory data
    $ingestionData = $feedIngester->getWikiIngestionData();
    if (empty($ingestionData)) {
        die("No ingestion data found in wikicities. Aborting.");
    }
    // When necessary download a list of resources into $file and reformat
    // the start and end date for each provider
    $file = '';
Пример #23
0
<?php

session_start();
require "database/connect.php";
require "database/common.php";
require "database/users.php";
require "database/employees.php";
require "includes/common.php";
$pageTitle = "Profile";
require "includes/userHeader.php";
//load emp_id
loadUser($_SESSION["id"]);
//save profile
if ($_POST["submitBtn"] == "Edit") {
    updateProfile($empID, $_POST["first"], $_POST["last"], $_POST["address"], $_POST["phone1"] . $_POST["phone2"], $_POST["email"]);
    if ($_POST["loginID"] > "") {
        saveLogin($empID, $_POST["loginID"], $_POST["loginPassword"]);
        $body = "Your account has been created / edited.<br />Username: "******"loginID"] . "<br />Password: "******"loginPassword"];
        //mail("*****@*****.**", "Shift Scheduler Account Created", $body);
    }
}
//load profile
loadEmployee($empID);
padBegin(6, 6);
?>

<table>
<tr>
    <td align="right" nowrap>First Name</td>
    <td><input name="first" id="first" type="text" value="<?php 
echo $emp_first_name;
 public function storeAnswer($id, CreateAnswerRequest $request)
 {
     $input = $request->all();
     // Get time between exercise load and store answer.
     $endTime = microtime(true);
     $diffTime = $endTime - $input['start_time'];
     $exercise = loadExercise($id)[0];
     //must check for empty answers & stuff like that...
     //must also find a way to avoid duplicate answers since 'text' types can't be used as key
     $ans = new Answer();
     $ans->given_code = $input['given_code'];
     $ans->time = $diffTime;
     $result = preg_replace('/[^A-Za-z0-9\\-\\ ,\\.;:\\[\\]\\?\\!@#$%&\\*\\(\\)\\-=\\+\\.^\\P{C}\\n]/', '', $input['result']);
     // dd($result);
     // dd(preg_match("/^[hH]ello, [wW]orld$/", substr_replace($result, "", -1)));
     // dd(preg_match("/^Hello, world$/", $result));
     if ($exercise->expected_result == '*') {
         $ans->success = true;
     } else {
         $rule = "/" . $exercise->expected_result . "/";
         // dd($rule);
         if (preg_match($rule, $result)) {
             $ans->success = true;
         } elseif (compare(bin2hex($result), bin2hex($exercise->expected_result . chr(0xd) . chr(0xa)))) {
             $ans->success = true;
         } else {
             $ans->success = false;
         }
     }
     $ans->uId = Auth::id();
     $ans->eId = $id;
     storeAnswer($ans);
     if ($exercise->expected_result != '*') {
         if ($ans->success) {
             flash()->success("You solved the exercise in " . $diffTime . " seconds.");
             \Session::flash('correctAnswer', 'blabla');
         } else {
             flash()->error("Too bad, the answer was wrong.");
         }
     }
     // $result = $input['result'];
     $answer = $input['given_code'];
     $sId = \Session::get('currentSerie');
     $challenges = loadChallengesByUserExercise(\Auth::id(), $id);
     // Only update challenge if the given answer is correct.
     if ($ans->success) {
         foreach ($challenges as $c) {
             if ($c->winner != \Auth::id()) {
                 if ($c->userA == \Auth::id()) {
                     if (!empty(loadCorrectAnswers($c->userB, $id)) && $diffTime < loadCorrectAnswers($c->userB, $id)[0]->time) {
                         $newScore = loadUser(\Auth::id())[0]->score;
                         $newScore += 1;
                         setUserScore(\Auth::id(), $newScore);
                         setWinner($c->id, \Auth::id());
                         storeNotification($c->userB, "challenge beaten", \Auth::id(), $c->id);
                     }
                 } else {
                     if (!empty(loadCorrectAnswers($c->userA, $id)) && $diffTime < loadCorrectAnswers($c->userA, $id)[0]->time) {
                         $newScore = loadUser(\Auth::id())[0]->score;
                         $newScore += 1;
                         setUserScore(\Auth::id(), $newScore);
                         setWinner($c->id, \Auth::id());
                         storeNotification($c->userA, "challenge beaten", \Auth::id(), $c->id);
                     }
                 }
             }
         }
     }
     return redirect('exercises/' . $id)->with(['result' => $result, 'answer' => $answer]);
 }
function loadLastReadMessage($id)
{
    $id2 = loadUser($id)[0]->id;
    return \DB::select('SELECT  M.message
                       FROM     conversations_participants CP1
                       JOIN     conversations_participants CP2  ON  CP1.conversationId = CP2.conversationId
                       JOIN     messages M ON CP1.conversationId = M.conversationId
                       WHERE    CP1.userId = ?
                       AND      CP2.userId = ?
                       AND      M.author   = ?
                       AND      M. is_read = 1
                       ORDER BY M.id DESC', [\Auth::id(), $id2, \Auth::id()]);
}
Пример #26
0
// If a group_id is specified, attempt to load information for all users in the specified group.
// Otherwise, attempt to load all users.
$validator = new Validator();
$limit = $validator->optionalGetVar('limit');
$user_id = $validator->optionalGetVar('user_id');
$group_id = $validator->optionalGetVar('group_id');
// Add alerts for any failed input validation
foreach ($validator->errors as $error) {
    addAlert("danger", $error);
}
if ($user_id) {
    // Special case to load groups for the logged in user
    if ($user_id == "0") {
        $user_id = $loggedInUser->user_id;
    }
    if (!($results = loadUser($user_id))) {
        echo json_encode(array("errors" => 1, "successes" => 0));
        exit;
    }
} else {
    if ($group_id) {
        if (!($results = loadUsersInGroup($group_id))) {
            echo json_encode(array("errors" => 1, "successes" => 0));
            exit;
        }
    } else {
        if (!($results = loadUsers($limit))) {
            echo json_encode(array("errors" => 1, "successes" => 0));
            exit;
        }
    }
 public function declineFriend($id1)
 {
     $id = loadUser($id1)[0]->id;
     if (isFriendRequestPending($id)) {
         declineFriend($id);
         storeNotification($id, 'friend request declined', \Auth::id());
         flash()->info('You declined the friend request.');
         return redirect('users/' . $id1);
     }
     flash()->error('Could not decline the request, try again.');
     return redirect('users/' . $id1);
 }
Пример #28
0
function openam_auth($user, $username, $password)
{
    if (OPENAM_REST_ENABLED) {
        // Let's see if the user is already logged in the IDP
        $tokenId = $_COOKIE[OPENAM_COOKIE_NAME];
        if (!empty($tokenId) and !is_user_logged_in()) {
            openam_debug("openam_auth: TOKENID:" . $tokenId);
            if ($_GET['action'] != 'logout' or $_GET['loggedout'] != 'yes') {
                $am_response = isSessionValid($tokenId);
                if ($am_response['valid'] or $am_response['valid' == 'true'] or $am_response['boolean'] == '1') {
                    // Session was valid
                    openam_debug("openam_auth: Authentication was succesful");
                    $amAttributes = getAttributesFromOpenAM($tokenId, $am_response[OPENAM_WORDPRESS_ATTRIBUTES_USERNAME], OPENAM_WORDPRESS_ATTRIBUTES);
                    $usernameAttr = get_attribute_value($amAttributes, OPENAM_WORDPRESS_ATTRIBUTES_USERNAME);
                    $mailAttr = get_attribute_value($amAttributes, OPENAM_WORDPRESS_ATTRIBUTES_MAIL);
                    openam_debug("openam_auth: UID: " . print_r($usernameAttr, TRUE));
                    openam_debug("openam_auth: MAIL: " . print_r($mailAttr, TRUE));
                    $user = loadUser($usernameAttr, $mailAttr);
                    remove_action('authenticate', 'wp_authenticate_username_password', 20);
                    return $user;
                }
            }
        }
        // If no username nor password, then we are starting here
        if ($username != '' and $password != '') {
            $tokenId = authenticateWithOpenAM($username, $password);
            if (!$tokenId) {
                // User does not exist,  send back an error message
                $user = new WP_Error('denied', __("<strong>ERROR</strong>: The combination username/password was not correct"));
            } elseif ($tokenId == 2) {
                $user = new WP_Error('denied', __("<strong>ERROR</strong>: Error when trying to reach the OpenAM"));
            } else {
                $amAttributes = getAttributesFromOpenAM($tokenId, $username, OPENAM_WORDPRESS_ATTRIBUTES);
                if ($amAttributes) {
                    $usernameAttr = get_attribute_value($amAttributes, OPENAM_WORDPRESS_ATTRIBUTES_USERNAME);
                    $mailAttr = get_attribute_value($amAttributes, OPENAM_WORDPRESS_ATTRIBUTES_MAIL);
                    openam_debug("openam_auth: UID: " . print_r($usernameAttr, TRUE));
                    openam_debug("openam_auth: MAIL: " . print_r($mailAttr, TRUE));
                    $user = loadUser($usernameAttr, $mailAttr);
                    remove_action('authenticate', 'wp_authenticate_username_password', 20);
                    return $user;
                }
            }
        }
    }
    return;
}
 public function removeMember($groupId, $userId)
 {
     $group = loadGroup($groupId)[0];
     if (loadUser($userId)) {
         declineMemberToGroup($userId, $groupId);
         //Just the user as "declined"
         flash()->error('You have kicked the user from your group. They will not be able to request to join your group again.');
         return redirect('groups/' . $group->name . '/manageMembers');
     }
     flash()->error('Could not kick member, try again.');
     return redirect('groups/' . $group->name . '/manageMembers');
 }