예제 #1
0
<?php

require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
$delegate = new Delegate();
/**
 * Redirect to 'draw' if we are alredy logged or if we have 'remember me' option active
 * 
 * [1] Session method
 * Check is user id session is set and is numeric
 */
if (isset($_SESSION['userId']) and is_numeric($_SESSION['userId'])) {
    // Load user as object, from SQL by id
    $loggedUser = $delegate->userGetById(abs(intval($_SESSION['userId'])));
    // If exists a logged user
    if (is_numeric($loggedUser->id)) {
        redirect('./editor.php');
    }
    /**
     * [2] Cookie method
     * Check if user cookie is set
     */
} elseif (isset($_COOKIE['biscuit'])) {
    // Decode the cookie data
    $userCookie = packer($_COOKIE['biscuit'], PACKER_UNPACK);
    // Validate data
    if (validateEmail($userCookie['email'], null) and validateString($userCookie['password'], null, 1)) {
        // Load user as object, from SQL by id
        $loggedUser = $delegate->userGetByEmailAndCryptedPassword($userCookie['email'], $userCookie['password']);
예제 #2
0
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
$page = 'mydiagrams';
require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
require_once dirname(__FILE__) . '/common/rememberme.php';
if (!isset($_SESSION['userId']) || !is_numeric($_SESSION['userId'])) {
    addError("Access denied");
    redirect('./editor.php');
}
$delegate = new Delegate();
$loggedUser = $delegate->userGetById($_SESSION['userId']);
$allDiagrams = $delegate->diagramGetAll();
/**Exctracts the name of an email address*/
function firstName($email)
{
    $rez = strpos($email, '@');
    if ($rez) {
        return substr($email, 0, $rez);
    } else {
        return substr($email, 0, 5);
    }
}
?>

<!DOCTYPE html>
<html>
예제 #3
0
function declineInvitationExe()
{
    if (!is_numeric($_SESSION['userId'])) {
        print "Wrong way";
        exit;
    }
    if (!isset($_REQUEST['invitationId'])) {
        print "Wrong Invitation";
        exit;
    }
    $d = new Delegate();
    $loggedUser = $d->userGetById($_SESSION['userId']);
    $invitation = $d->invitationGetById($_REQUEST['invitationId']);
    if ($invitation->email == $loggedUser->email) {
        //a match made in stars...how lovely :)
        $d->invitationDelete($invitation->id);
        addMessage("Invitation declined.");
    }
    redirect('../myDiagrams.php');
}