Ejemplo n.º 1
0
 /**
  * Constructs a new delegate in order to assign it to a member
  *
  * @param mixed $uExpectedReturn Expected return value for interruption
  *
  * @return object a delegate
  */
 public static function assign($uExpectedReturn = false)
 {
     $tNewInstance = new Delegate($uExpectedReturn);
     return function ($uCallback = null, $uState = null, $uPriority = 10) use($tNewInstance) {
         if ($uCallback !== null) {
             $tNewInstance->add($uCallback, $uState, $uPriority);
         }
         return $tNewInstance;
     };
 }
Ejemplo n.º 2
0
 function setDelegate($delegate)
 {
     if ($delegate instanceof Filter) {
         $delegate = new Delegate($filter);
     }
     if (!$delegate instanceof Delegate || !$delegate->isType('IO\\Filter')) {
         throw new \Core\Exception('Filter delegate must be instance of a Filter');
     }
     $this->delegate = $delegate;
 }
Ejemplo n.º 3
0
 public function __invoke($data, $context = null)
 {
     $data = parent::__invoke($data, $context);
     $list = is_array($data) ? array_values($data) : null;
     // Data is not a list.
     if ($list !== $data) {
         // Wrap.
         return [$data];
     }
     // Data is a list.
     return $data;
 }
Ejemplo n.º 4
0
Archivo: App.php Proyecto: NePTeR/sonic
 /**
  * pushes over the first domino
  *
  * @param string $mode
  * @param bool $load used for unit tests to prevent fatal errors
  * @return void
  */
 public function start($mode = self::WEB, $load = true)
 {
     if ($this->_delegate) {
         $this->_delegate->appStartedLoading($mode);
     }
     $this->addSetting(self::MODE, $mode);
     // this could use App::includeFile() but it is faster to duplicate
     // that logic here
     if ($load) {
         include 'Sonic/Exception.php';
         $this->_included['Sonic/Exception.php'] = true;
         include 'Sonic/Request.php';
         $this->_included['Sonic/Request.php'] = true;
         include 'Sonic/Router.php';
         $this->_included['Sonic/Router.php'] = true;
         include 'Sonic/Controller.php';
         $this->_included['Sonic/Controller.php'] = true;
         include 'Sonic/View.php';
         $this->_included['Sonic/View.php'] = true;
         include 'Sonic/Layout.php';
         $this->_included['Sonic/Layout.php'] = true;
     }
     if ($this->getSetting(self::AUTOLOAD)) {
         $this->autoload();
     }
     if ($this->_delegate) {
         $this->_delegate->appFinishedLoading();
     }
     // if we are calling this app from command line then all we want to do
     // is load the core application files
     if ($mode != self::WEB) {
         return;
     }
     if ($this->getSetting(self::TURBO) && $this->_robotnikWins()) {
         $this->addSetting(self::TURBO, false);
     }
     // try to get the controller and action
     // if an exception is thrown that means the page requested does not exist
     $controller = $this->getRequest()->getControllerName();
     $action = $this->getRequest()->getAction();
     if ($this->_delegate) {
         $this->_delegate->appStartedRunning();
     }
     $this->runController($controller, $action);
     if ($this->_delegate) {
         $this->_delegate->appFinishedRunning();
     }
 }
Ejemplo n.º 5
0
 public function postEditProfile()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('First_Name' => 'required|max:50', 'Last_Name' => 'required|max:50'));
     if ($validator->fails()) {
         return Redirect::route('delegate-profile')->withErrors($validator)->withInput();
     } else {
         $firstname = Input::get('First_Name');
         $lastname = Input::get('Last_Name');
         $myprofile = Delegate::where('user_id', '=', Auth::user()->id)->first();
         $myprofile->firstname = $firstname;
         $myprofile->lastname = $lastname;
         $saved = $myprofile->save();
         if ($saved) {
             return View::make('delegate.success');
         }
     }
     return Redirect::route('delegate-profile')->with('global', 'Failed!! Please retry');
 }
Ejemplo n.º 6
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']);
Ejemplo n.º 7
0
 public function Render(Renderer $renderer)
 {
     $result = array();
     $this->dataset->AddFieldFilter($this->captionFieldName, FieldFilter::Contains($this->globals->GetGetValue(self::SearchTermParamName)));
     $highLightCallback = Delegate::CreateFromMethod($this, 'ApplyHighlight')->Bind(array(Argument::$Arg3 => $this->captionFieldName, Argument::$Arg4 => $this->globals->GetGetValue(self::SearchTermParamName)));
     if (!StringUtils::IsNullOrEmpty($this->parentIdFieldName) && $this->globals->IsGetValueSet(self::ParentParamName)) {
         $this->dataset->AddFieldFilter($this->parentIdFieldName, FieldFilter::Equals($this->globals->GetGetValue(self::ParentParamName)));
     }
     $this->dataset->Open();
     while ($this->dataset->Next()) {
         $result[] = array('id' => $this->dataset->GetFieldValueByName($this->idFieldName), 'value' => $this->dataset->GetFieldValueByName($this->captionFieldName), 'label' => $highLightCallback->Call($this->dataset->GetFieldValueByName($this->captionFieldName), $this->captionFieldName));
     }
     $this->dataset->Close();
     echo SystemUtils::ToJSON($result);
 }
Ejemplo n.º 8
0
print uniqid() . "\n";
class Delegate extends SQLite3
{
    function __construct()
    {
        $this->open(dirname(__FILE__) . '/test.db');
    }
    /**a wrapper method for executing a query*/
    public function executeSQL($query)
    {
        $result = $this->query($query);
        return $result;
    }
}
$d = new Delegate();
$qCreate = <<<EOQ
CREATE TABLE `entry` (
`id` INTEGER PRIMARY KEY,
`title` VARCHAR(255),
`description` TEXT
);
EOQ;
#$d->executeSQL($qCreate);
for ($i = 0; $i < 10; $i++) {
    $qAdd = sprintf("insert into `entry` (title, description) values ('%s','%s') ", uniqid(), uniqid());
    $d->executeSQL($qAdd);
}
$qGet = sprintf("select * from entry limit 0, 10");
$result = $d->executeSQL($qGet);
while ($row = $result->fetchArray()) {
Ejemplo n.º 9
0
 /**
  * @param Renderer $renderer
  * @return void
  */
 public function Render(Renderer $renderer)
 {
     if (GetApplication()->GetSuperGlobals()->IsGetValueSet('term')) {
         $this->dataset->AddFieldFilter($this->valueField, new FieldFilter('%' . GetApplication()->GetSuperGlobals()->GetGetValue('term') . '%', 'ILIKE', true));
     }
     $this->dataset->Open();
     $result = array();
     $highLightCallback = Delegate::CreateFromMethod($this, 'ApplyHighlight')->Bind(array(Argument::$Arg3 => $this->valueField, Argument::$Arg4 => GetApplication()->GetSuperGlobals()->GetGetValue('term')));
     $this->dataset->SetLimit(20);
     while ($this->dataset->Next()) {
         $result[] = array("id" => $this->dataset->GetFieldValueByName($this->idField), "label" => $highLightCallback->Call($this->dataset->GetFieldValueByName($this->valueField), $this->valueField), "value" => $this->dataset->GetFieldValueByName($this->valueField));
     }
     echo SystemUtils::ToJSON($result);
     $this->dataset->Close();
 }
Ejemplo n.º 10
0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.
*/
require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
if (!is_numeric($_REQUEST['diagramId'])) {
    echo 'No diagram Id';
    exit;
}
$delegate = new Delegate();
$diagram = $delegate->diagramGetById($_REQUEST['diagramId']);
$diagramdata = $delegate->diagramdataGetByDiagramIdAndType($_REQUEST['diagramId'], Diagramdata::TYPE_CSV);
$links = array();
if ($diagramdata->fileSize > 0) {
    $fh = fopen(getStorageFolder() . '/' . $diagramdata->diagramId . '.csv', 'r');
    $data = fread($fh, $diagramdata->fileSize);
    fclose($fh);
    $csvLines = explode("\n", $data);
    foreach ($csvLines as $csvLine) {
        $shards = explode(',', $csvLine);
        $links[] = $shards;
    }
}
//check if diagram is public
if (!is_object($diagram)) {
Ejemplo n.º 11
0
 public function __invoke($data, $context = null)
 {
     return array_unique(parent::__invoke($data, $context));
 }
Ejemplo n.º 12
0
<?php

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('./index.php');
}
if (!is_numeric($_REQUEST['diagramId'])) {
    print "Wrond Diagram";
    exit;
}
$delegate = new Delegate();
$loggedUser = $delegate->userGetById($_SESSION['userId']);
$diagram = $delegate->diagramGetById($_REQUEST['diagramId']);
$selfUrl = selfURL();
//find full URL to this script
$url = strleft($selfUrl, '/exportDiagram.php');
//find the URL of the application
$WEBADDRESS = $delegate->settingsGetByKeyNative('WEBADDRESS');
//$svgLink = $WEBADDRESS . '/editor/raster.php?type=svg&diagramId=' . $diagram->id;
$pngLink = $WEBADDRESS . '/editor/png.php?type=png&diagramId=' . $diagram->id;
//$jpgLink = $WEBADDRESS . '/editor/raster.php?type=jpg&diagramId=' . $diagram->id;
$dmoLink = $WEBADDRESS . '/editor/dmo.php?diagramId=' . $diagram->id;
$page = 'export';
$rawLicense = $delegate->settingsGetByKeyNative('LICENSE');
$l = new License();
if (trim($rawLicense) != '') {
Ejemplo n.º 13
0
<?php

require_once "include/Delegate.php";
require_once "include/Curl.php";
$delegate = new Delegate();
$curl = new Curl();
if ($delegate->usingMinions()) {
    if (empty($_POST["server"])) {
        if (!empty($_POST["mix_id"])) {
            $mixId = $_POST["mix_id"];
        } else {
            $output->error("mix_id is empty.");
        }
        // TODO: need to set this dynamically for songza etc. support
        $table = "8tracks_playlists";
        $server = $delegate->getServer($mixId, $table);
    } else {
        $server = $_POST["server"];
        if (!$delegate->verifyServer($server)) {
            $output->error("invalid server: " . $server);
        }
    }
    $results = $curl->post($server . $script, $_POST);
} else {
    $server = "/api/stuff/download/";
    $results = $curl->localPost(__DIR__ . "/download", $script);
}
$results = json_decode($results, true);
$results["server"] = $server;
$output->successWithData($results);
Ejemplo n.º 14
0
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.
*/
require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
require_once dirname(__FILE__) . '/common/rememberme.php';
$delegate = new Delegate();
#print_r($_SESSION['userId']);
$loggedUser = null;
if (isset($_SESSION['userId']) && is_numeric($_SESSION['userId'])) {
    $loggedUser = $delegate->userGetById($_SESSION['userId']);
}
//start diagram guardian
if (isset($_REQUEST['diagramId']) && is_numeric($_REQUEST['diagramId'])) {
    if (!isset($_SESSION['userId'])) {
        print "Not allocated to this diagram";
        exit;
    }
}
//end diagram guardian
//get the address where the app reside
$WEBADDRESS = $delegate->settingsGetByKeyNative('WEBADDRESS');
Ejemplo n.º 15
0
<?php

require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
$delegate = new Delegate();
$publicDiagrams = $delegate->diagramdataGetAllPublic();
?>

<!DOCTYPE html>
<html>
    <!--Copyright 2010 Scriptoid s.r.l-->
    <head>
        <title>Public diagrams</title>
        <link rel="stylesheet" media="screen" type="text/css" href="assets/css/style.css" />
    </head>
    <body>
        <?php 
//require_once dirname(__FILE__) . '/header.php';
?>
        
        <div id="content" style="text-align: center; margin-left: auto; margin-right: auto;">
            <?php 
require_once dirname(__FILE__) . '/common/messages.php';
?>
            <br/>
            
           
            
            <!--My diagrams-->
Ejemplo n.º 16
0
<?php

/* This page is used for both logged users and outsiders to */
require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
if (!isset($_SESSION['userId'])) {
    echo "Sic";
    exit;
}
if (!isset($_REQUEST['diagramId'])) {
    echo "No diagram selected";
    exit;
}
$d = new Delegate();
$userdiagram = $d->userdiagramGetByIds($_SESSION['userId'], $_REQUEST['diagramId']);
if (!is_object($userdiagram) || !is_numeric($userdiagram->userId)) {
    echo "No rights to edit that diagram";
    exit;
}
$diagram = $d->diagramGetById($_REQUEST['diagramId']);
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Diagramo - Edit diagram</title>
        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
        <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
        <link href="./assets/css/style.css" type="text/css" rel="stylesheet"/>
Ejemplo n.º 17
0
<body>
<div id="header">
<?php 
include_once 'header.php';
?>
</div>
<div id="sidebaar">
<?php 
include_once 'sidebar.php';
?>
</div>
<div id="content">
<?php 
include_once 'class.inc.php';
$d = new Delegate();
$regd = $_GET['regno'];
if ($regd) {
    $res = $d->getInfo($regd);
}
if (is_array($res)) {
    if (isset($_POST['submit'])) {
        echo "Your Delegate Card No. is : TT" . $d->add($_POST['regno'], $_POST['name'], $_POST['contact'], $_POST['email']);
    } else {
        ?>

<form method="post" name="regForm" id="regForm">
Name: 
<input type="text" name="name" value="<?php 
        echo $res['Name'];
        ?>
 /**
  * @param Renderer $renderer
  * @return void
  */
 public function Render(Renderer $renderer)
 {
     $params = ArrayWrapper::createGetWrapper();
     $term = $params->isValueSet('term') ? $params->getValue('term') : '';
     if ($params->isValueSet('term')) {
         $this->dataset->AddFieldFilter($this->valueField, new FieldFilter('%' . $term . '%', 'ILIKE', true));
     }
     if ($params->isValueSet('id')) {
         $this->dataset->AddFieldFilter($this->idField, FieldFilter::Equals($params->getValue('id')));
     }
     if ($this->itemCount > 0) {
         $this->dataset->SetUpLimit(0);
         $this->dataset->SetLimit($this->itemCount);
     }
     $this->dataset->Open();
     $result = array();
     $highLightCallback = Delegate::CreateFromMethod($this, 'ApplyHighlight')->Bind(array(Argument::$Arg3 => $this->valueField, Argument::$Arg4 => $term));
     while ($this->dataset->Next()) {
         $result[] = array("id" => $this->dataset->GetFieldValueByName($this->idField), "label" => $highLightCallback->Call($this->dataset->GetFieldValueByName($this->valueField), $this->valueField), "value" => $this->dataset->GetFieldValueByName($this->valueField));
     }
     echo SystemUtils::ToJSON($result);
     $this->dataset->Close();
 }
Ejemplo n.º 19
0
<?php

require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
if (is_numeric($_REQUEST['diagramId'])) {
    $d = new Delegate();
    $diagram = $d->diagramGetById($_REQUEST['diagramId']);
    $d->close();
    if (is_numeric($_SESSION['userId']) || $diagram->public) {
        $filePath = dirname(__FILE__) . '/data/diagrams/' . $_REQUEST['diagramId'] . '.png';
        if (file_exists($filePath)) {
            $fileSize = filesize($filePath);
            $fh = fopen($filePath, 'rb');
            $data = fread($fh, $fileSize);
            fclose($fh);
            header('Content-Type: image/png');
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Content-Disposition: attachment; filename="' . $_REQUEST['diagramId'] . '.png' . '"');
            header('Pragma: public');
            header('Content-Length: ' . $fileSize);
            print $data;
            //print 'Alex';
            flush();
        } else {
            print "No file";
        }
    }
Ejemplo n.º 20
0
 public function __construct(Strategy $strategy)
 {
     parent::__construct($strategy);
     $this->strategy = $strategy;
 }
Ejemplo n.º 21
0
<?php

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('./index.php');
}
$delegate = new Delegate();
$loggedUser = $delegate->userGetById($_SESSION['userId']);
$rawLicense = $delegate->settingsGetByKeyNative('LICENSE');
$page = "license";
$DIAGRAMO = $delegate->settingsGetByKeyNative('DIAGRAMO');
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Diagramo - manage license</title>
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
        <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
        <link href="./assets/css/style.css" type="text/css" rel="stylesheet"/>
        
        <script type="text/javascript" src="./assets/javascript/dropdownmenu.js?<?php 
echo time();
?>
"></script>    
Ejemplo n.º 22
0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.
*/
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('./index.php');
}
$delegate = new Delegate();
$loggedUser = $delegate->userGetById($_SESSION['userId']);
//only Admin can edit another user
if ($loggedUser->level != User::LEVEL_ADMIN) {
    echo "No right to edit user";
    exit;
}
if (!is_numeric($_REQUEST['userId'])) {
    echo "Wrong user";
    exit;
}
$user = $delegate->userGetById($_REQUEST['userId']);
?>

<!DOCTYPE html>
<html>
Ejemplo n.º 23
0
require_once dirname(__FILE__) . '/common/delegate.php';
//print $_SERVER['REQUEST_URI'];
//print_r($_REQUEST);
//exit;
if (!isset($_SESSION)) {
    session_start();
}
if (!isset($_REQUEST['hash'])) {
    echo 'No hash';
    exit;
}
if (strlen(trim($_REQUEST['hash'])) != 6) {
    print "Wrong hash";
    exit;
}
$delegate = new Delegate();
$diagram = $delegate->diagramGetByHash(trim($_REQUEST['hash']));
if (!is_object($diagram)) {
    print "No diagram";
    exit;
}
$diagram = $delegate->diagramGetById($diagram->id);
//GUARDIAN: see if we can display this diagram
$display = false;
if ($diagram->public) {
    $display = true;
} else {
    $loggedUser = $delegate->userGetById($_SESSION['userId']);
    //do we have a logged user
    if (is_object($loggedUser)) {
        $userdiagram = $delegate->userdiagramGetByIds($loggedUser->id, $diagram->id);
Ejemplo n.º 24
0
distributed under the License is distributed on an "AS IS" BASIS,
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.
*/
/**Colaborators are per diagram*/
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('./index.php');
}
$delegate = new Delegate();
$loggedUser = $delegate->userGetById($_SESSION['userId']);
$users = $delegate->userGetAll();
$page = 'users';
$rawLicense = $delegate->settingsGetByKeyNative('LICENSE');
$l = new License();
if (trim($rawLicense) != '') {
    $l->load($rawLicense);
}
$currentHost = $_SERVER['HTTP_HOST'];
if (strpos($currentHost, ':')) {
    $currentHost = substr($currentHost, 0, strpos($currentHost, ':'));
}
?>

<!DOCTYPE html>
Ejemplo n.º 25
0
limitations under the License.
*/
/* This page is used for both logged users and outsiders to */
require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
if (!isset($_SESSION['userId'])) {
    echo "Sic";
    exit;
}
if (!isset($_REQUEST['diagramId'])) {
    echo "No diagram selected";
    exit;
}
$delegate = new Delegate();
$diagram = $delegate->diagramGetById($_REQUEST['diagramId']);
//print_r($diagram);
//exit();
$page = 'editDiagram';
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Diagramo - Edit diagram</title>
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
        <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
        <link href="./assets/css/style.css" type="text/css" rel="stylesheet"/>
        
Ejemplo n.º 26
0
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.
*/
require_once dirname(__FILE__) . '/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
$delegate = new Delegate();
$VERSION = $delegate->settingsGetByKeyNative('VERSION');
/**
 * 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 (isset($loggedUser) && is_numeric($loggedUser->id)) {
        redirect('./editor.php');
    }
    /**
Ejemplo n.º 27
0
distributed under the License is distributed on an "AS IS" BASIS,
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>
Ejemplo n.º 28
0
<?php

/**This fragment tries to make a login based on the cookie stored on the client's browser*/
require_once dirname(__FILE__) . '/delegate.php';
$delegate = new Delegate();
if (!isset($_SESSION['userId']) && isset($_COOKIE['biscuit'])) {
    //if no user logged and we have a biscuit (cookie with credentials)
    //If we do not have an user logged we are gonna try to see if we have a biscuit (cookie with credentials) */
    // 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']);
        // If user is an object
        if (is_object($loggedUser)) {
            $_SESSION['userId'] = $loggedUser->id;
        }
    }
}
Ejemplo n.º 29
0
<?php

require_once dirname(__FILE__) . '/editor/common/delegate.php';
if (!isset($_SESSION)) {
    session_start();
}
$title = "Register | Diagramo";
$description = $title;
$key = explode(" ", $description);
$keywords = trim($key[0]);
for ($i = 1; $i < count($key); $i++) {
    $keywords .= "," . trim($key[$i]);
}
if (isset($_REQUEST['i'])) {
    $d = new Delegate();
    $invitation = $d->invitationGetByToken($_REQUEST['i']);
}
?>

<!DOCTYPE html>
<html>

    <head>
        <title><?php 
echo $title;
?>
</title>
        <meta name="description" content="<?php 
echo $description;
?>
" />
Ejemplo n.º 30
0
 private function GetThumbnailFileName($original_file_name, $original_file_extension, $file_size)
 {
     $result = '';
     $handled = false;
     $this->generateFileNameDelegate->CallFromArray(array(&$result, &$handled, $original_file_name, $original_file_extension, $file_size));
     $targetFolder = FormatDatasetFieldsTemplate($this->GetDataset(), $this->directoryToSaveThumbnails);
     FileUtils::ForceDirectories($this->directoryToSaveThumbnails);
     if (!$handled) {
         $filename = FileUtils::AppendFileExtension(rand(), $original_file_extension);
         $result = Path::Combine($targetFolder, $filename);
         while (file_exists($result)) {
             $filename = FileUtils::AppendFileExtension(rand(), $original_file_extension);
             $result = Path::Combine($targetFolder, $filename);
         }
     }
     return $result;
 }