Exemple #1
0
 public function onBootstrap(MvcEvent $e)
 {
     $sm = $e->getApplication()->getServiceManager();
     $gem = $e->getApplication()->getEventManager();
     // Definiendo ServiceFactory aca, para inyectar MVCEvent
     $sm->setFactory('JavaScript\\Service\\StoreScript', function ($sm) use($e) {
         return new \JavaScript\Service\StoreScript($e);
     })->setAlias('storeScript', 'JavaScript\\Service\\StoreScript');
     // Definiendo Event Render
     $gem->attach(MvcEvent::EVENT_RENDER, function (MvcEvent $e) {
         flog('eventRender');
         $sm = $e->getApplication()->getServiceManager();
         $view = $sm->get('ViewRenderer');
         $store = $sm->get('storeScript')->getStore();
         $params = ['baseHost' => $view->base_path("/")] + $store;
         $view->headScript()->appendScript("window.Global=" . json_encode($params, JSON_FORCE_OBJECT));
     }, 100);
     /*
             $e->getApplication()->getEventManager()->getSharedManager()->attach(
                 'Zend\Mvc\Controller\AbstractActionController', MvcEvent::EVENT_DISPATCH, $callback , 100
             );
     
             $e->getApplication()->getEventManager()->getSharedManager()->attach(
                 'Zend\Mvc\Application', MvcEvent::EVENT_DISPATCH_ERROR, $callback , 100
             );*/
 }
Exemple #2
0
 public function indexAction(\ZfrMailChimp\Client\MailChimpClient $mc = null)
 {
     flog('indexAction');
     // https://github.com/zf-fr/zfr-mailchimp-module
     // Cliente MailChip --------------------------------------------------------------
     $mc = $this->getServiceLocator()->get('ZfrMailChimp\\Client\\MailChimpClient');
     // Campania existente ------------------------------------------------------------
     //$idCampagnExist = '35b41b9a9e';
     //$campaig = $mc->getCampaigns(array('id'=>$idCampagnExist));
     //var_dump($campaig);
     // Creando campania --------------------------------------------------------------
     $apiKey = $this->getServiceLocator()->get('config')['zfr_mailchimp']['key'];
     $listIdExist = 'b529ef0a83';
     $opts['list_id'] = $listIdExist;
     $opts['subject'] = 'mi asunto de prueba';
     $opts['from_email'] = '*****@*****.**';
     $opts['from_name'] = 'JRODEV SAC';
     $opts['tracking'] = array('opens' => true, 'html_clicks' => true, 'text_clicks' => true);
     // $opts['analytics'] = array('google'=>'goo_analytics_key');
     $opts['title'] = 'Titulo de prueba';
     $content = array('html' => 'Mi contenido <b>html</b> *|UNSUB|* mensaje', 'text' => 'texto de prueba *|UNSUB|*');
     /* 
     // Usando Template:
     $content = array(
         'html_main'       => 'some pretty html content',
         'html_sidecolumn' => 'this goes in a side column',
         'html_header'     => 'this gets placed in the header',
         'html_footer'     => 'the footer with an *|UNSUB|* message', 
         'text'            => 'text content text content *|UNSUB|*'
     );
     $opts['template_id'] = "1";
     */
     $idCamp = $mc->campaignCreate('regular', $opts, $content);
     if ($mc->errorCode) {
         echo "\n\t no se puede crear campania!";
         echo "\n\t errorCode=" . $mc->errorCode;
         echo "\n\t errorMessage=" . $mc->errorMessage . "\n";
     } else {
         echo "\n\t id nueva campania:" . $idCamp . "\n";
     }
     // Suscribiendo correos ------------------------------------------------------
     $batch = array();
     $batch['email'] = array('email' => '*****@*****.**');
     $batch['email'] = array('email' => '*****@*****.**');
     $batch['email'] = array('email' => '*****@*****.**');
     /* ... more ...*/
     $mc->batchSubscribe($apiKey, $listIdExist, $batch);
     // Send Campania --------------------------------------------------------------
     $mc->sendCampaign($listIdExist, $idCamp);
     $storeScript = $this->getServiceLocator()->get('storeScript');
     $storeScript->setStore('fooIndex', ['item' => 2, 'item2' => array(1, 2)]);
     $this->layout()->setTemplate("layout/layout");
     return new ViewModel();
 }
Exemple #3
0
#!/usr/bin/php
<?php 
while ($line = trim(fgets(STDIN))) {
    flog("GOT[[[" . $line . "]]]\n");
    $myArray = json_decode($line, true);
    flog(print_r($myArray, true));
    // flog("=== Decoded ===");
    // flog(print_r(json_last_error()));
    // flog(print_r($line));
    // flog(print_r($myArray));
    print "l\n";
    $line = trim(fgets(STDIN));
    flog("NEXT LINE GOT[[[" . $line . "]]]\n");
    // flog(print_r($myArray['moves'], true));
    //var_dump ($line);
    // $move = getMove($myArray['moves']);
    // flog($move);
    // print $move . "\n";
}
function flog($message)
{
    error_log($message . "\n", 3, "/tmp/phperror");
}
function getMove($moves)
{
    return array_pop($moves) == 'l' ? 'a' : 'l';
    //return 'l';
}
Exemple #4
0
<?php

require "../firelogger.php";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    flog("Got POST request!", $_POST);
    ?>
    <b>Hello World! #<?php 
    echo $_POST["counter"];
    ?>
</b>
<?php 
    exit;
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>FireLogger AJAX test</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
</head>
<body>
    <h1>FireLogger AJAX test</h1>
  
<?php 
$code = <<<'EOD'
flog("Hello from main HTML!");
EOD;
echo "<pre>{$code}</pre>";
eval($code);
?>
  
Exemple #5
0
function eastOrWest($world)
{
    $firstFilled = [];
    $map = $world['board']['map'];
    foreach ($map as $col => $m) {
        foreach ($m as $row => $l) {
            if ($l == 'F') {
                $firstFilled = [$row, $col];
                break 2;
            }
        }
    }
    if (empty($firstFilled)) {
        return 'S';
    }
    $pos = $world['current_unit']['position'];
    flog($pos, "Current Unit Pos");
    flog($firstFilled, "First Filled Pos");
    if ($pos[0] > $firstFilled[0]) {
        return 'E';
    } else {
        if ($pos[0] < $firstFilled[0]) {
            return 'W';
        } else {
            return 'S';
        }
    }
}