Esempio n. 1
0
 public function newServerFileAction()
 {
     if ($this->request->isPost() && $this->request->isAjax()) {
         $data = array();
         $filename = $this->request->getPost("filename");
         if (!Phalcon\Text::endsWith($filename, ".java")) {
             $filename .= ".java";
         }
         $team_id = $this->request->getPost("team_id");
         $cond = "friendlyName = :friendlyName: AND team_id = :team_id:";
         $para = array("friendlyName" => $filename, "team_id" => $team_id);
         $serverFile = ServerFiles::findFirst(array($cond, "bind" => $para));
         if ($serverFile) {
             $data["success"] = false;
             $data["message"] = "You already have a file with that name";
             echo json_encode($data);
             return;
         }
         $name = Phalcon\Text::random(Phalcon\Text::RANDOM_ALNUM, rand(13, 17));
         $serverFile = new ServerFiles();
         $serverFile->setTeam(Teams::findFirst($team_id));
         $serverFile->setFriendlyName($filename);
         $serverFile->setPath("../app/data/{$name}");
         $serverFile->setLastSave($this->request->getPost("lastSave"));
         if ($serverFile->save() && fopen($serverFile->getPath(), "w")) {
             $data["success"] = true;
             $data["friendlyName"] = $serverFile->getFriendlyName();
         } else {
             $serverFile->delete();
             $data["success"] = false;
             $data["message"] = "There was an error saving your file. Please try again.";
             echo json_encode($data);
             return;
         }
         echo json_encode($data);
         return;
     }
 }
Esempio n. 2
0
<?php

echo Phalcon\Text::random(Phalcon\Text::RANDOM_ALNUM);
//"aloiwkqz"
Esempio n. 3
0
 /**
  * Magic method to use attribute in snake_case
  * For example $ex->a_method = $value is same as $ex->setAMethod($value)
  * @param string $property The property in snake_case
  * @param array $params The value that will be passed to set method
  * @return mixed Call the method if it exists, otherwise call parent __set() method
  */
 public function __set($property, $params)
 {
     $method = 'set' . Phalcon\Text::camelize($property);
     if (method_exists($this, $method)) {
         return $this->{$method}($params);
     }
     parent::__set($property, $params);
 }
                                </a>
                            </th>
                            <th><?php 
echo $this->lang->query('th.name');
?>
</th>
                            <th><?php 
echo $this->lang->query('th.email');
?>
</th>
                            <th style="width:15%">
                                <a href="<?php 
echo $this->url->getBaseUri();
?>
admin/user?orderby=status&ordertype=<?php 
if (Phalcon\Text::lower($formData['orderType']) == 'desc') {
    ?>
asc<?php 
} else {
    ?>
desc<?php 
}
if ($formData['conditions']['keyword'] != '') {
    ?>
&keyword=<?php 
    echo $formData['conditions']['keyword'];
}
?>
">
                                    <?php 
echo $this->lang->query('th.status');
<div class="row">
	<div class="col-md-3">
		<div class="list-group">
			<?php 
$options = array('dashboard' => 'Dashboard', 'products' => 'Products', 'categories' => 'Categories');
?>
			<?php 
foreach ($options as $controller => $label) {
    ?>
				<?php 
    if (Phalcon\Text::lower($this->dispatcher->getControllerName()) == $controller) {
        ?>
					<?php 
        echo $this->tag->linkTo(array('admin/' . $controller, $label, 'class' => 'list-group-item active'));
        ?>
				<?php 
    } else {
        ?>
					<?php 
        echo $this->tag->linkTo(array('admin/' . $controller, $label, 'class' => 'list-group-item'));
        ?>
				<?php 
    }
    ?>
			<?php 
}
?>
		</div>
	</div>
	<div class="col-md-9">
		<?php 
<p>
    <label for="medewerker">medewerker</label>
     <div class="input-field col s12 m6">
    <select name="gebruiker_id" class="select">
     <option value="" disabled selected> kies een medewerker</option>
        <?php 
foreach ($gebruiker as $af) {
    ?>
            <?php 
    if ($af->rol == 'admin') {
        ?>
                <option value="<?php 
        echo $af->id;
        ?>
"><?php 
        echo $this->escaper->escapeHtml(Phalcon\Text::upper($af->voornaam));
        ?>
</option>
            <?php 
    }
    ?>
        <?php 
}
?>
    </select>
    </div>
</p>
<p>
    <?php 
echo $this->tag->submitButton(array('bevestig'));
?>
Esempio n. 7
0
<?php

echo Phalcon\Text::camelize('CocoBongo');
//coco_bongo
                    </div>
                </th>
                <th>Action</th>
            </tr>
            </thead>
            <tbody>
            <?php 
foreach ($joueurs as $joueur) {
    ?>
            <tr>
                <td><?php 
    echo $joueur->id;
    ?>
</td>
                <td><?php 
    echo Phalcon\Text::upper($joueur->nom);
    ?>
</td>
                <td><?php 
    echo ucwords($joueur->prenom);
    ?>
</td>
                <td><?php 
    echo ucwords($joueur->pays->libelle);
    ?>
</td>
                <td>
                    <?php 
    echo $this->tag->linkTo(array('joueur/view/' . $joueur->id, '<span class="glyphicon glyphicon-eye-open"></span>', 'class' => 'btn btn-xs btn-info'));
    ?>
                    <?php 
Esempio n. 9
0
 public function problemsAction()
 {
     if (!$this->checkLogin()) {
         return;
     }
     if ($this->request->isPost() && $this->request->hasPost("type") && $this->security->checkToken()) {
         $this->session->set("changeOccurred", true);
         $this->session->set("changeSuccessful", true);
         $this->session->set("teamsGenerated", false);
         switch ($this->request->getPost("type")) {
             case 'update':
                 $problem = Problems::findFirst(intval($this->request->getPost("id")));
                 if ($problem) {
                     $problem->setName($this->request->getPost("name"));
                     $problem->setRuntime($this->request->getPost("runtime"));
                     if ($this->request->hasPost("hasDataFile")) {
                         if ($this->request->hasFiles()) {
                             // Adding data file
                             foreach ($this->request->getUploadedFiles() as $file) {
                                 if ($file->getKey() == "dataFile") {
                                     unlink($problem->getDataFile());
                                     $dataFileLocation = "../app/data/" . Phalcon\Text::random(Phalcon\Text::RANDOM_ALNUM, rand(13, 17));
                                     $problem->setDataFile($dataFileLocation);
                                     $problem->setDataFileFriendly($file->getName());
                                     $file->moveTo($dataFileLocation);
                                 }
                             }
                         }
                     } else {
                         if ($problem->getDataFile() != null) {
                             // Removing data file
                             unlink($problem->getDataFile());
                             $problem->setDataFile(null);
                             $problem->setDataFileFriendly(null);
                         }
                     }
                     if ($this->request->hasPost("hasJudgeFile")) {
                         if ($this->request->hasFiles()) {
                             // Adding judge file
                             foreach ($this->request->getUploadedFiles() as $file) {
                                 if ($file->getKey() == "judgeFile") {
                                     unlink($problem->getJudgeFile());
                                     $judgeFileLocation = "../app/data/" . Phalcon\Text::random(Phalcon\Text::RANDOM_ALNUM, rand(13, 17));
                                     $problem->setJudgeFile($judgeFileLocation);
                                     $problem->setJudgeFileFriendly($file->getName());
                                     $file->moveTo($judgeFileLocation);
                                 }
                             }
                         }
                     } else {
                         // Removing judge file
                         if ($problem->getJudgeFile() != null) {
                             unlink($problem->getJudgeFile());
                             $problem->setJudgeFile(null);
                             $problem->setJudgeFileFriendly(null);
                         }
                     }
                     if (!$problem->save()) {
                         $this->session->set("changeSuccessful", false);
                     }
                 } else {
                     $this->session->set("changeSuccessful", false);
                 }
                 break;
             case 'create':
                 $error = false;
                 $problem = new Problems();
                 $problem->setName($this->request->getPost("name"));
                 $problem->setRuntime($this->request->getPost("runtime"));
                 if ($this->request->hasFiles()) {
                     foreach ($this->request->getUploadedFiles() as $file) {
                         if ($file->getKey() == "dataFile" && $this->request->hasPost("hasDataFile")) {
                             $dataFileLocation = "../app/data/" . Phalcon\Text::random(Phalcon\Text::RANDOM_ALNUM, rand(13, 17));
                             $problem->setDataFile($dataFileLocation);
                             $problem->setDataFileFriendly($file->getName());
                             $file->moveTo($dataFileLocation);
                         }
                         if ($file->getKey() == "judgeFile" && $this->request->hasPost("hasJudgeFile")) {
                             $judgeFileLocation = "../app/data/" . Phalcon\Text::random(Phalcon\Text::RANDOM_ALNUM, rand(13, 17));
                             $problem->setJudgeFile($judgeFileLocation);
                             $problem->setJudgeFileFriendly($file->getName());
                             $file->moveTo($judgeFileLocation);
                         }
                     }
                 }
                 if ($error || !$problem->save()) {
                     $this->session->set("changeSuccessful", false);
                 }
                 break;
             case 'delete':
                 $problem = Problems::findFirst(intval($this->request->getPost("id")));
                 $dataLocation = $problem->getDataFile();
                 $judgeLocation = $problem->getJudgeFile();
                 if ($problem->delete()) {
                     unlink($dataLocation);
                     unlink($judgeLocation);
                 } else {
                     $this->session->set("changeSuccessful", false);
                 }
                 break;
             default:
                 $this->session->set("changeSuccessful", false);
                 break;
         }
         return $this->response->redirect("/admin/problems");
     } else {
         if ($this->session->has("changeOccurred")) {
             $this->view->changeOccurred = $this->session->get("changeOccurred");
             $this->session->remove("changeOccurred");
         }
         if ($this->session->has("changeSuccessful")) {
             $this->view->changeSuccessful = $this->session->get("changeSuccessful");
             $this->session->remove("changeSuccessful");
         }
     }
     $this->view->problems = Problems::find();
 }
    </thead>
    <tbody>
        <?php 
foreach ($classement as $classement) {
    ?>
            <tr>
                <td><?php 
    echo $classement->joueur->id;
    ?>
</td>
                <td><?php 
    echo $classement->rang;
    ?>
</td>
                <td><?php 
    echo Phalcon\Text::upper($classement->joueur->nom);
    ?>
</td>
                <td><?php 
    echo ucwords($classement->joueur->prenom);
    ?>
</td>
                <td><?php 
    echo ucwords($classement->joueur->pays->libelle);
    ?>
</td>
                <td><?php 
    echo $classement->points;
    ?>
</td>
                <td><?php 
Esempio n. 11
0
<?php

//Create the router
//The order of routes in here DOES MATTER.  The list is in reverse, so routes lower in the list have higher precedence.
$router = new Phalcon\Mvc\Router();
$router->removeExtraSlashes(true);
$router->add("[/]{0,1}", array('controller' => 'default', 'action' => 'index'))->setName('base');
$router->add("/:controller", array('controller' => 1, 'action' => 'index'))->setName('index-action');
//
//
//$router->add(
//    "/:controller/:action/:params",
//    array(
//        'controller' => 1,
//        'action' => 2,
//        'params' => 3
//    )
//)
//->setName('full')
//->convert('action', function($action) {
//    return lcfirst(Phalcon\Text::camelize($action));
//});
$router->add("/:controller/:action/([\\d]+)/:params", array('controller' => 1, 'action' => 2, 'id' => 3, 'params' => 4))->setName('controller-action-id')->convert('action', function ($action) {
    return lcfirst(Phalcon\Text::camelize($action));
});
$router->add("/(login|logout)", array('controller' => 'default', 'action' => 1))->setName('default-action')->convert('action', function ($action) {
    return lcfirst(Phalcon\Text::camelize($action));
});
$router->add('/flush[/]?{id}', array('controller' => 'default', 'action' => 'flush'));
return $router;
Esempio n. 12
0
<?php

echo Phalcon\Text::endsWith("Hello", "llo");
// true
echo Phalcon\Text::endsWith("Hello", "LLO");
// false
echo Phalcon\Text::endsWith("Hello", "LLO", false);
// true
Esempio n. 13
0
<?php

echo Phalcon\Text::increment("a");
// "a_1"
echo Phalcon\Text::increment("a_1");
// "a_2"
Esempio n. 14
0
<?php

echo Phalcon\Text::camelize('coco_bongo');
//CocoBongo
Esempio n. 15
0
<?php

/*
 * Define custom routes. File gets included in the router service definition.
 */
$router = new \Phalcon\Mvc\Router();
//Remove trailing slashes automatically
$router->removeExtraSlashes(true);
$router->add('/([a-zA-Z\\-]+)/([a-zA-Z\\-]+)/:params', array('controller' => 1, 'action' => 2, 'params' => 3))->convert('action', function ($action) {
    return Phalcon\Text::camelize($action);
});
$router->add('/signup', array('namespace' => 'Talon\\Controllers', 'controller' => 'session', 'action' => 'signup'))->setName('session-signup');
$router->add('/login', array('namespace' => 'Talon\\Controllers', 'controller' => 'session', 'action' => 'login'))->setName('session-login');
$router->add('/forgot-password', array('namespace' => 'Talon\\Controllers', 'controller' => 'session', 'action' => 'forgotPassword'))->setName('session-forgotPassword');
$router->add('/reset-password/{code}/{email}', array('controller' => 'users_control', 'action' => 'resetPassword'))->setName('session-resetPassword');
$router->add('/confirm/{code}/{email}', array('controller' => 'users_control', 'action' => 'confirmEmail'))->setName('users_control-confirmEmail');
$router->add('/resend-confirmation/{email}', array('controller' => 'users_control', 'action' => 'resendConfirmation'))->setName('users_control-resendConfirmation');
return $router;
Esempio n. 16
0
<?php

echo Phalcon\Text::startsWith("Hello", "He");
// true
echo Phalcon\Text::startsWith("Hello", "he");
// false
echo Phalcon\Text::startsWith("Hello", "he", false);
// true
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <title><?php 
echo Phalcon\Text::upper($title);
?>
</title>
        <link rel="stylesheet" href="/css/style.css">
        <script src="/js/jquery.js"></script>
        <script src="/js/angular.min.js"></script>
        <script src="/js/index.js"></script>
        <script src="/js/main.js"></script>
    </head>
    <body>
        <header>
            <div class="company"><img src="/img/nahuasuan.png" /> 哪划算网络有限公司</div>
            <div class="user">
                <span>欢迎您:<span class="username"><?php 
echo $user;
?>
</span><a href="javascript:chpasswd()">修改密码</a><a href="/backend/login/logout">退出</a></span>
            </div>
        </header>
        <div class="container">
            <div class="menu">
                <div class="menu">
                    <?php