Exemplo n.º 1
0
 private static function getVariables()
 {
     ObjectCache::getInstance();
     $site = Site::getInstance();
     define('GUEST_ROLE_ID', (int) $site->getGuestRoleID()->getValue());
     define('SITE_EMAIL', $site->getEmail());
     define('SITE_TITLE', $site->getTitle());
     date_default_timezone_set($site->getTimeZone());
     if ($site->isInMaintenanceMode()) {
         if (!PermissionEngine::getInstance()->currentUserCanDo('bypasssMaintenanceMode')) {
             return;
         }
     }
     $blockEngine = BlockEngine::getInstance();
     $user = CurrentUser::getUserSession();
     $hookEngine = HookEngine::getInstance();
     $router = Router::getInstance();
     $hookEngine->runAction('addStaticRoutes');
     $moduleInCharge = $router->whichModuleHandlesRequest();
     $response = self::getResponse($moduleInCharge);
     http_response_code($response->getResponseCode());
     $headers = $response->getHeaders();
     foreach ($headers as $header => $value) {
         header($header . ": " . $value, true);
     }
     define('PAGE_TYPE', $response->getPageType());
     $blocks = $blockEngine->getBlocks($site->getTheme(), PAGE_TYPE, $user->getRoleID());
     if ($blocks === null) {
         $blocks = array();
     }
     self::render($site, $response, $blocks);
 }
Exemplo n.º 2
0
 public function run()
 {
     if (!isset($this->cronToken)) {
         return;
     }
     if ($this->cronToken === "") {
         return;
     }
     if ($this->cronToken !== Config::getInstance()->getCronToken()) {
         return;
     }
     $database = Database::getInstance();
     if (!$database->isConnected()) {
         return;
     }
     $site = Site::getInstance();
     if (!$site->doesCronNeedToRun()) {
         return;
     }
     if ($site->isCronRunning()) {
         return;
     }
     $site->setCronRunning(true);
     $site->setLastCronRun(new DateTime());
     $hookEngine = HookEngine::getInstance();
     $hookEngine->runAction('cronRun');
     $logger = Logger::getInstance();
     $logger->logIt(new LogEntry(1, logEntryType::info, "Cron ran.", 0, new DateTime()));
     $site->setCronRunning(false);
 }
Exemplo n.º 3
0
 /**
  * Converts a filesystem path to a URL if possible.
  *
  * @param string $path
  */
 public static function path2url($path)
 {
     // see if the root path exists in $path
     if (strpos($path, Site::getInstance()->getRoot()) === FALSE) {
         return null;
     }
     $img = str_replace(Site::getInstance()->getRoot(), self::getBase(), $path);
     return str_replace("pub/", '', $img);
 }
 function approveAction()
 {
     $user = $this->getRequest()->getParam('user');
     $cashout = Cashout_Models_Cashout::getUsersLastPendingCashout($user);
     if ($cashout != null) {
         $cashout->completionDate = date('Y-m-d');
         $cashout->approve();
         $user = User_Models_User::getUser($user);
         $pay[$user->paymentEmail] = $cashout->amount;
         //now send the payment to the user
         $paymentGateway = Site::getInstance(Site::getResource('payment_gateway'));
         $paymentGateway->pay($pay);
     }
     $this->getResponse()->setRedirect('/cashout/admin/requests');
 }
Exemplo n.º 5
0
 public function __construct($id, $entryDate, $dateRecorded, $name, $description, $breed, $sex, $fixed, $age, $color, $commonName, $shelter)
 {
     $this->id = $id;
     $this->entryDate = $entryDate;
     $this->dateRecorded = $dateRecorded;
     $this->name = $name;
     $this->description = $description;
     $this->breed = $breed;
     $this->sex = $sex;
     $this->fixed = $fixed;
     $this->age = $age;
     $this->color = $color;
     $this->commonName = $commonName;
     $this->shelter = $shelter;
     $this->image = Site::getInstance()->getUploadPath() . "/{$this->id}.jpg";
 }
 /**
  * Run the scrapers.
  */
 public function scrape()
 {
     // TODO: This should be read from the ``shelter_pages'' table
     $mhsDog = new MhsDogScraper("http://montanapets.org/mhs/residentdog.html");
     $mhsCat = new MhsCatScraper("http://montanapets.org/mhs/residentcat.html");
     $packer = new Packer();
     $packer->pack($mhsDog->scrape());
     $packer->pack($mhsCat->scrape());
     $loader = new Loader($packer->getPackedPets());
     $loader->checkActive();
     $loader->load();
     // temporary fix for the slashes in some breeds
     // @todo: this should be done in the scraper
     $db = new Database(Site::getInstance()->getDbConf());
     $db->execute("update animals set breed = replace(breed, '/', '-')");
 }
Exemplo n.º 7
0
 public static function start()
 {
     $sessionProvider = Config::getInstance()->getSessionProvider();
     $sessionProvider = str_replace(".", "", $sessionProvider);
     $sessionProviderFile = EDUCASK_ROOT . '/core/providers/sessions/' . $sessionProvider . '.php';
     if (!is_readable($sessionProviderFile)) {
         return;
     }
     require_once $sessionProviderFile;
     if (!class_exists($sessionProvider)) {
         return;
     }
     $implementations = class_implements($sessionProvider);
     if (!in_array('ISession', $implementations)) {
         return;
     }
     if (!in_array('SessionHandlerInterface', $implementations)) {
         return;
     }
     session_set_save_handler(new $sessionProvider());
     session_name("educask");
     session_start();
     if (!isset($_SESSION['lastSessionGenerationTime'])) {
         $_SESSION['lastSessionGenerationTime'] = time();
         return;
     }
     $maxSessionAgeAgo = (int) Site::getInstance()->getMaxSessionIdAge()->getValue();
     $maxSessionIdAge = time() - $maxSessionAgeAgo;
     if ($_SESSION['lastSessionGenerationTime'] > $maxSessionIdAge) {
         return;
     }
     $randomPerformSessionIdRegeneration = rand(0, 1000) % 6 === 0;
     if (!$randomPerformSessionIdRegeneration) {
         return;
     }
     session_regenerate_id(true);
     $_SESSION['lastSessionGenerationTime'] = time();
 }
Exemplo n.º 8
0
 private function buildMinifiedCSS()
 {
     $siteObject = Site::getInstance();
     $minifiedSoFar = "";
     $themesCssFiles = glob(EDUCASK_ROOT . "/site/themes/{$siteObject->getTheme()}/css/*.css");
     foreach ($themesCssFiles as $cssFile) {
         if (!is_readable($cssFile)) {
             continue;
         }
         $rawFile = file_get_contents($cssFile);
         $rawFile = $this->minifyCssString($rawFile);
         $minifiedSoFar .= $rawFile;
     }
     $minifiedSoFar .= $this->getOtherCssFiles();
     $minifiedSoFar .= $this->getRawCss();
     $objectCache = ObjectCache::getInstance();
     $objectCache->setObject('minifiedCSS', $minifiedSoFar, true);
     $response = Response::fiveHundred();
     $response->setRawContent($minifiedSoFar);
     $response->setHeader('Content-Type', "text/css");
     $response->setResponseCode(200);
     return $response;
 }
 function indexAction()
 {
     $session = new Zend_Session_Namespace('user');
     $form = new Fund_Models_Forms_Fund();
     $minimum = Site::getResource('fund_minimum');
     $maximum = Site::getResource('fund_maximum');
     if ($this->getRequest()->isPost() && $form->isValid($_POST)) {
         $fund = Fund_Models_FundAccount::getUsersLastFundAccount('pending');
         if ($fund == NULL) {
             $args = array('ownerID' => $session->user->accountID, 'startDate' => date('Y-m-d'), 'status' => 'pending', 'amount' => $form->getValue('amount'));
             $fund = new Fund_Models_FundAccount($args);
         }
         $fund->amount = $form->getValue('amount');
         $fund->save();
         $session->user->lastFundTransaction = $fund;
         //display pay button
         $paymentGateway = Site::getInstance(Site::getResource('payment_gateway'));
         $paymentGateway->returnUrl = 'http://www.project.supersaid.net/fund/complete';
         $paymentGateway->cancelUrl = 'http://www.project.supersaid.net/fund/cancel';
         $this->view->form = $paymentGateway->getForm($fund);
     } else {
         $this->view->form = $form;
     }
 }
 public function view($params = NULL)
 {
     // valid categories to search
     $categories = array("common_name_id" => "Common Name", "breed" => "Breed", "sex" => "Sex", "shelter_id" => "Shelter");
     $v = new View("animal_index");
     $v->title = "Browse";
     $v->showBrowser = true;
     $animalModel = new AnimalModel();
     // common name browser
     $commonModel = new CommonNameModel();
     $v->commonNames = $commonModel->getAll();
     // breed browser
     $breedModel = new BreedModel();
     $v->breeds = $breedModel->getAll();
     // shelter browser
     $shelterModel = new ShelterModel();
     $v->shelters = $shelterModel->getAll();
     $v->animals = array();
     // default page
     if (!$params) {
         $v->animals = $animalModel->getLatestAnimals(Site::getInstance()->getNumAnimals());
         return $v->render();
     }
     // check params
     if (!isset($categories[$params[0]])) {
         $e = new NotFoundError("Invalid criteria");
         return $e->serve();
     }
     // sanitize the params
     for ($i = 0; $i < count($params); $i++) {
         $params[$i] = filter_var($params[$i], FILTER_SANITIZE_STRING);
     }
     $v->title = "Browsing by {$categories[$params[0]]}";
     $v->animals = $animalModel->getByCategory($params[0], $params[1]);
     $v->render();
 }
Exemplo n.º 11
0
 public function setFile($name)
 {
     $this->file = Site::getInstance()->getAppRoot() . "/views/{$name}.php";
 }
Exemplo n.º 12
0
 public function __construct()
 {
     $this->db = new Database(Site::getInstance()->getDbConf());
 }
Exemplo n.º 13
0
<?php

require dirname(dirname(__FILE__)) . "/app/lib/Site.php";
Site::getInstance();
// bootstrap the application
$router = new Router();
$router->delegate();
Exemplo n.º 14
0
    <link href="<?php 
echo Url::route2url("animal/feed");
?>
" rel="self" />
    <link href="<?php 
echo Url::getBase();
?>
" />
    <updated><!-- TODO: Last scrape date --></updated>
    <author>
        <name><?php 
echo Site::getInstance()->getName();
?>
</name>
        <email><?php 
echo Site::getInstance()->getEmail();
?>
</email>
    </author>

    <?php 
foreach ($animals as $animal) {
    ?>
        <entry>
            <link href="<?php 
    $url = Url::route2url("animal/view/{$animal->getId()}");
    echo $url;
    ?>
"/>
            <id><?php 
    echo $url;
Exemplo n.º 15
0
 /**
  * Saves a remote image to the local disk.
  *
  * @param string $impoundNum Impound # for finding the image
  * @param int    $id         Animal ID from the animals table
  */
 private function saveImage($impoundNum, $id)
 {
     $url = "http://montanapets.org/mhs/pictures/{$impoundNum}.jpg";
     $jpg = file_get_contents($url);
     if ($jpg) {
         file_put_contents(Site::getInstance()->getUploadPath() . "/{$id}.jpg", $jpg);
     }
 }
Exemplo n.º 16
0
">
    <link href="<?php 
echo Url::getBase();
?>
/css/screen.css" rel="stylesheet" media="screen">
</head>
<body>
    <div id="header">
        <div id="header_inner">
            <h1>
                <a href="<?php 
echo Url::getBase();
?>
">
                    <?php 
echo Site::getInstance()->getName();
?>
                </a>
            </h1>

            <ul id="nav">
                <li><a href="<?php 
echo Url::getBase();
?>
">Home</a></li>
                <li><a href="<?php 
echo Url::route2url("browse");
?>
">Browse</a></li>
                <li><a href="<?php 
echo Url::route2url("animal/feed");