Exemplo n.º 1
0
 public function clickRecordEditBtn($i = 1)
 {
     $this->waitForList();
     find_element_ok(".result tbody tr:nth-child({$i}) input.record-edit-btn")->click();
     wait_for('.crud-edit');
     wait_for('div[id^=record-div]');
     wait_for_tinymce();
     wait();
 }
function forwardCall($numberToCall)
{
    global $callerID;
    say("Calling.");
    // transfer the call to the number we passed in using the caller ID we set
    transfer("tel:+" . $numberToCall, array("callerID" => $callerID, "playvalue" => "http://themes.stumpnet.net/Jeopardy%20(Think%20Song).mp3", "terminator" => "#", "onTimeout" => "timeoutFCN"));
    // at this point, the call has ended
    wait(500);
    say("Call ended.");
    wait(500);
}
 /**
  * Block execution until a command has finished been projected/dispatched
  * @param \SmoothPhp\Contracts\CommandBus\Command[]|\SmoothPhp\Contracts\CommandBus\Command $commands
  * @param int $timeout Timeout 8 seconds
  */
 function wait($commands, $timeout = 8)
 {
     if (config('app.env') == 'testing') {
         return;
     }
     if (!is_array($commands)) {
         return wait([$commands], $timeout);
     }
     $limit = time() + $timeout;
     foreach ($commands as $command) {
         while (!Cache::has((string) $command)) {
             usleep(1000);
             if (time() > $limit) {
                 return;
             }
         }
     }
 }
Exemplo n.º 4
0
function f2($url)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
    $json = curl_exec($ch);
    curl_close($ch);
    $ans = json_decode($json, true);
    $x = 0;
    foreach ($ans["sample"] as $key => $values) {
        say($ans["sample"][$x]["data"]);
        wait(500);
        $x++;
    }
}
Exemplo n.º 5
0
<?php

for ($i = 0; $i < 3; $i++) {
    $pid = pcntl_fork();
    if ($pid < 0) {
        die("fork failed");
    } elseif ($pid > 0) {
        //echo "parent process \n";
    } else {
        echo "child process {$i} is born. \n";
        switch ($i) {
            case 0:
                wait();
                break;
            case 1:
                wait();
                break;
            case 2:
                sleep(1);
                fire();
                break;
        }
    }
}
while (pcntl_waitpid(0, $status) != -1) {
    $status = pcntl_wexitstatus($status);
    echo "Child {$status} completed\n";
}
function wait()
{
    $event = new SyncEvent("UniqueName");
Exemplo n.º 6
0
/**
* Trackt den User und zeichnet die Bewegungen auf
*
* @param    string
* @param    integer
* @return   void
* @since    2001-02-18
* @since    Bastian Pöttner <*****@*****.**>
* @author   Thorsten Rinne <*****@*****.**>
* @author   Matteo Scaramuccia <*****@*****.**>
*/
function Tracking($action, $id = 0)
{
    global $db, $PMF_CONF, $sid;
    if (isset($PMF_CONF["tracking"])) {
        if (isset($_GET["sid"])) {
            $sid = $_GET["sid"];
        }
        if (isset($_COOKIE['pmf_sid'])) {
            $sid = $_COOKIE['pmf_sid'];
        }
        if ($action == "old_session") {
            unset($sid);
        }
        if (!isset($sid)) {
            $sid = $db->nextID(SQLPREFIX . "faqsessions", "sid");
            // HACK: be sure that pmf_sid cookie contains the current $sid
            if (isset($_COOKIE["pmf_sid"]) && (int) $_COOKIE['pmf_sid'] != $sid) {
                setcookie('pmf_sid', $sid, time() + 3600);
            }
            $db->query("INSERT INTO " . SQLPREFIX . "faqsessions (sid, ip, time) VALUES (" . $sid . ", '" . $_SERVER["REMOTE_ADDR"] . "', " . time() . ")");
        }
        $fp = @fopen("./data/tracking" . date("dmY"), "a+b");
        if ($fp) {
            $flanz = "0";
            while (!flock($fp, LOCK_EX) && $flanz < 6) {
                wait(500);
                $flanz++;
            }
            if ($flanz >= 6) {
                fclose($fp);
            } elseif (!empty($_SERVER["HTTP_REFERER"]) || $action == "new_session") {
                if (!isset($_SERVER["HTTP_REFERER"])) {
                    $_SERVER["HTTP_REFERER"] = "";
                }
                if (!isset($_SERVER["QUERY_STRING"])) {
                    $_SERVER["QUERY_STRING"] = "";
                }
                fputs($fp, $sid . ";" . str_replace(";", ",", $action) . ";" . $id . ";" . $_SERVER["REMOTE_ADDR"] . ";" . str_replace(";", ",", $_SERVER["QUERY_STRING"]) . ";" . str_replace(";", ",", $_SERVER["HTTP_REFERER"]) . ";" . str_replace(";", ",", urldecode($_SERVER["HTTP_USER_AGENT"])) . ";" . time() . ";\n");
                flock($fp, LOCK_UN);
                fclose($fp);
            }
        }
    }
}
Exemplo n.º 7
0
        $event = ask("", array("choices" => "1,2,3,4,5,6,7,8,9,0"));
        if ($event->name == 'choice') {
            $inchar = $event->value;
        }
        // read back each character of user input
        say($inchar);
        // if the user entered the incorrect character then we're done.
        if ($inchar != $simon[$i]) {
            $win = null;
            say("Sorry, that's not right.  goodbye.");
            hangup();
            break;
        }
        $i++;
    }
    // while
    // if the user won that round then see if we need to continue
    if ($win == true) {
        say("Good Job!");
        wait(3);
        if (count(simon) > 20) {
            say("You beat simon!");
            hangup();
        } else {
            say("Next round");
        }
        // if
    }
    // if
}
// while
Exemplo n.º 8
0
<?php

/*
 * Copyright (c) 2009 - 2015 Tropo, now part of Cisco
 * Released under the MIT license. See the file LICENSE
 * for the complete license
 */
// A demo of using SSML to influence pronounciation
// and pacing of Lewis Carroll's famous poem full of
// nonsense words.
say("<speak>Welcome to Lewis Carroll's <phoneme alphabet='ipa' ph='dʒæbərwɔki'>Jabberwock</phoneme></speak>.", array('voice' => 'Vanessa'));
say("Here is the poem with detailed speech control.", array('voice' => 'Vanessa'));
say("<speak><p><s><phoneme alphabet='ipa' ph='twʌz'>Twas</phoneme> <phoneme alphabet='ipa' ph='brɪlɪg'>brillig</phoneme>, and the <phoneme alphabet='ipa' ph='slaɪði'>slithy</phoneme> toves Did <phoneme alphabet='ipa' ph='dʒaɪjʊər'>gyre</phoneme> and <phoneme alphabet='ipa' ph='dʒɪmbəl'>gimble</phoneme> in the wabe:</s> <s>All mimsy were the <phoneme alphabet='ipa' ph='boʊroʊgoʊvz'>borogoves</phoneme>,   And the mome raths <phoneme alphabet='ipa' ph='aʊtgreɪb'>outgrabe</phoneme>.</s></p>  <p><s>Beware the <phoneme alphabet='ipa' ph='dʒæbərwɔk'>Jabberwock</phoneme>, my son! The jaws that bite, the claws that catch!</s> <s>Beware the <phoneme alphabet='ipa' ph='dʒub dʒub'>Jubjub</phoneme> bird, and shun The frumious Bandersnatch!</s></p>  <p><s>He took his <phoneme alphabet='ipa' ph='ˈvɔrpʊl'>vorpal</phoneme> sword in hand:   Long time the manxome foe he sought -- So rested he by the Tumtum tree,   And stood awhile in thought.</s></p>  <p><s>And, as in uffish thought he stood,   The <phoneme alphabet='ipa' ph='dʒæbərwɔk'>Jabberwock</phoneme>, with eyes of flame, Came whiffling through the tulgey wood,   And burbled as it came!</s></p>  <p><s><prosody duration='1s'>One, two! One, two!</prosody> And through and through The <phoneme alphabet='ipa' ph='ˈvɔrpʊl'>vorpal</phoneme> blade went snicker-snack!</s> <s>He left it dead, and with its head   He went galumphing back.</s></p>  <p><s>And, has thou slain the <phoneme alphabet='ipa' ph='dʒæbərwɔk'>Jabberwock</phoneme>?</s> <s>Come to my arms, my <phoneme alphabet='ipa' ph='bimɪʃ'>beamish</phoneme> boy!</s> <s>O <phoneme alphabet='ipa' ph='fræbdʒɛs'>frabjous</phoneme> day! <emphasis level='strong'><phoneme alphabet='ipa' ph='kæˈlu'>Callooh</phoneme>! <phoneme alphabet='ipa' ph='ˈkæleɪ'>Callay</phoneme>!</emphasis> He chortled in his joy.</s></p> <p><s><phoneme alphabet='ipa' ph='twʌz'>Twas</phoneme> <phoneme alphabet='ipa' ph='brɪlɪg'>brillig</phoneme>, and the <phoneme alphabet='ipa' ph='slaɪði'>slithy</phoneme> toves Did <phoneme alphabet='ipa' ph='dʒaɪjʊər'>gyre</phoneme> and <phoneme alphabet='ipa' ph='dʒɪmbəl'>gimble</phoneme> in the wabe:</s> <s>All mimsy were the <phoneme alphabet='ipa' ph='boʊroʊgoʊvz'>borogoves</phoneme>,   And the mome raths <phoneme alphabet='ipa' ph='aʊtgreɪb'>outgrabe</phoneme>.</s></p></speak>", array('voice' => 'Victor'));
wait(2000);
say("And now, just the same text without any attempt to control output.", array('voice' => 'Vanessa'));
say("Twas brillig, and the slithy toves   Did gyre and gimble in the wabe: All mimsy were the borogoves,   And the mome raths outgrabe.   Beware the Jabberwock, my son!   The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun   The frumious Bandersnatch!  He took his vorpal sword in hand:   Long time the manxome foe he sought -- So rested he by the Tumtum tree,   And stood awhile in thought.  And, as in uffish thought he stood,   The Jabberwock, with eyes of flame, Came whiffling through the tulgey wood,   And burbled as it came!  One, two! One, two! And through and through   The vorpal blade went snicker-snack! He left it dead, and with its head   He went galumphing back.  And, has thou slain the Jabberwock?   Come to my arms, my beamish boy! O frabjous day! Callooh! Callay!   He chortled in his joy.   Twas brillig, and the slithy toves   Did gyre and gimble in the wabe; All mimsy were the borogoves,   And the mome raths outgrabe.", array('voice' => 'Victor'));
wait(2000);
say('thanks! Goodbye.', array('voice' => 'Vanessa'));
Exemplo n.º 9
0
 protected function logout()
 {
     find_element('#operation .buttons a[href]')->click();
     wait();
 }
Exemplo n.º 10
0
        case 'pgsql':
            $query[] = "VACUUM ANALYZE;";
            break;
    }
    print '<p class="center">';
    if (isset($query)) {
        while ($each_query = each($query)) {
            $result = $db->query($each_query[1]);
            print "|&nbsp;\n";
            if (!$result) {
                print "<p class=\"error\"><strong>Error:</strong> " . $db->error() . "</p>\n";
                print "<p>Query:</p>\n";
                print "<pre>" . $each_query[1] . "</pre>\n";
                die;
            }
            wait(250);
        }
    }
    print "</p>\n";
    print '<p class="center">The database was updated successfully.</p>';
    print '<p class="center"><a href="../index.php">phpMyFAQ</a></p>';
    print '<p class="center">Please remove the backup (*.php.bak and *.bak.php) files located in the directory inc/.</p>';
    if (@unlink(basename($_SERVER["PHP_SELF"]))) {
        print "<p class=\"center\">This file was deleted automatically.</p>\n";
    } else {
        print "<p class=\"center\">Please delete this file manually.</p>\n";
    }
}
?>
<p class="center"><?php 
print COPYRIGHT;
Exemplo n.º 11
0
 * @package   Benchmark
 * @author    Sebastian Bergmann <*****@*****.**>
 * @copyright 2002-2005 Sebastian Bergmann <*****@*****.**>
 * @license   http://www.php.net/license/3_0.txt The PHP License, Version 3.0
 * @version   CVS: $Id: timer_example.php 268884 2008-11-12 20:57:49Z clockwerx $
 * @link      http://pear.php.net/package/Benchmark
 */
require '../library/Timer.php';
/**
 * Wait
 *
 * @param int $amount Amount to wait
 *
 * @return void
 */
function wait($amount)
{
    for ($i = 0; $i < $amount; $i++) {
        for ($i = 0; $i < 100; $i++) {
        }
    }
}
// Pass the param "true" to constructor to automatically display the results
$timer = new Benchmark_Timer();
$timer->start();
wait(10);
$timer->setMarker('Mark1');
echo "Elapsed time between Start and Mark1: " . $timer->timeElapsed('Start', 'Mark1') . "\n";
wait(50);
$timer->stop();
$timer->display();
Exemplo n.º 12
0
    // Wait for the process to finish
    // Read the data from the channel, and then unserialize it into
    // a PHP object that can be returned
    $output = unserialize(socket_read($proc[1], 4096));
    socket_close($proc[1]);
    return $output;
}
//
// Usage Example
//
$thread = async(function () {
    // Note that variables can be passed through with the "use" construct
    // (ie. $thread = async(function() use($local_var) { ...
    sleep(2);
    // to show that we really are running asynchronously
    echo "Hello from Child Thread!\n";
    return array('hello', 'world!');
});
echo "Hello from Main Thread\n";
$output = wait($thread);
print_r($output);
// Prints:
//
// Hello from Main Thread
// (and then 2 seconds later)
// Hello from Child Thread
// Array
// (
//     [0] => hello
//     [1] => world!
// )
Exemplo n.º 13
0
<?php

// PREFERRED
$d = __DIR__;
$mutex = array();
foreach (range(1, 3) as $i) {
    $mutex[] = "{$d}/mutex/banana.{$i}";
}
wait($mutex, 'run');
function wait($mutex, $cb)
{
    while (true) {
        foreach ((array) $mutex as $s) {
            $fp = fopen($s, 'c');
            if (flock($fp, LOCK_EX | LOCK_NB)) {
                $ret = call_user_func($cb);
                flock($fp, LOCK_UN);
                fclose($fp);
                return $ret;
            }
            fclose($fp);
        }
        usleep(mt_rand(1000, 100000));
    }
}
function run()
{
    $pid = getmypid();
    $date = date('Y-m-d H:i:s');
    echo "[{$date}] {$pid} running...", PHP_EOL;
    usleep(500000);
Exemplo n.º 14
0
<?php

set_time_limit(0);
header('Cache-Control: no-cache');
header('Content-Type: text/javascript');
require_once 'init.php';
$game_id = $_GET['game'];
$move_num = $_GET['moveNum'];
$game = gameData($_SESSION['member_id'], $game_id, false);
if ($game) {
    $i = 0;
    while ($i < 8) {
        $rs = wait($_SESSION['member_id'], $game_id, $move_num);
        if ($rs) {
            $game = gameData($_SESSION['member_id'], $game_id, false);
            $rs['stat'] = $game['status'];
            break;
        } else {
            $game = gameData($_SESSION['member_id'], $game_id, false);
            if ($game['status'] == 'tie' || $game['status'] == 'won') {
                $game['stat'] = $game['status'];
                echo json_encode($game);
                exit;
            }
        }
        time_sleep_until(time() + 5);
        $i++;
    }
    if (!$rs) {
        $rs['stat'] = 'not_found';
    }
Exemplo n.º 15
0
<?php

answer();
// Have to ask an initial question and wait for a response
// Otherwise it will run through to the hangup();
ask("Hello there! What would you like to know about? Say cats, dogs, or fish.", array("choices" => "cats(cat, cats, feline), dogs(dog, dogs, big dogs), fish(fish)", "repeat" => 3, "timeout" => 30, "onEvent" => create_function('$event', 'if ($event->name == "badChoice") say( "I\'m sorry, I didn\'t quite understand. Say cats, dogs, or fish."); 
                  if ($event->name == "timeout") say( "Are you sure that you don\'t want to know about cats, dogs OR fish?!"); 
                  if ($event->name == "choice") 
                  { 
                      if ($event->value == "cats") 
                      { 
                        say( "Cats like to eat, sleep, lather, rinse, repeat." ); 
                      } 
                      if ($event->value == "dogs") 
                      { 
                        say( "Dogs like tearing up your most prized possessions." ); 
                      } 
                      if ($event->value == "fish") 
                      { 
                        say( "Fish like to swim in circles - it keeps the water circulating." ); 
                      } 

                      // make their choice available outside of the array 
                      define(choice, $event->value); 

                  }')));
wait(3000);
say("You probably already knew that about " . choice . " though, right?");
wait(8000);
say("Sure buddy, sure. Adios.");
hangup();
Exemplo n.º 16
0
<?php

namespace Testing\Spec\Suite;

describe("Google", function () {
    it("finds the Google logo", function () {
        browser()->visit('http://www.google.fr');
        expect(element('#hplogo'))->not->toBeAnInstanceOf('Testing\\Spec\\Api\\ElementNotFound');
    });
    it("finds Kahlan in the search result", function () {
        browser()->visit('http://www.google.fr');
        page()->fillField('q', 'Unit/BDD PHP Test Framework for Freedom, Truth, and Justice');
        page()->pressButton('btnG');
        wait(page())->toContain('Kahlan');
    });
}, 10);
Exemplo n.º 17
0
}
// see http://www.webhostingtalk.com/showthread.php?t=1043707
// http://www.webdeveloper.com/forum/showthread.php?208676-Remote-site-loading-time
print "STARTING " . date('Y-m-d H:i:s') . "\n";
$mtime = explode(" ", microtime());
$tstart = $mtime[1] + $mtime[0];
$pg_cnt = 0;
$e_cnt = 0;
$collection = $modx->getIterator('modResource', $c);
foreach ($collection as $obj) {
    $url = $modx->makeUrl($obj->get('id'), '', '', 'full');
    if (!$url) {
        print 'ERROR empty URL for page ' . $obj->get('id') . "\n";
        continue;
    }
    if (!($loadtime = request_url($url))) {
        print 'ERROR requesting ' . $url . "\n";
        $e_cnt++;
    } else {
        print $url . ' Load Time: ' . $loadtime . "s\n";
        $pg_cnt++;
    }
    wait($params['sleep']);
}
$totalTime = $tend - $tstart;
$totalTime = sprintf("%2.4f s", $totalTime);
print "COMPLETE " . date('Y-m-d H:i:s') . "\n";
print "Total Time " . $totalTime . "s\n";
// seconds
print "Total pages: " . $pg_cnt . "\n";
print "Total errors: " . $e_cnt . "\n";
Exemplo n.º 18
0
 while ($each_query = each($query)) {
     $result = @$db->query($each_query[1]);
     print "| ";
     if (!$result) {
         print "\n<div class=\"error\">\n";
         print "<p><strong>Error:</strong> Please install your version of phpMyFAQ once again or send us a <a href=\"http://bugs.phpmyfaq.de\" target=\"_blank\">bug report</a>.</p>";
         print "<p><strong>DB error:</strong> " . $db->error() . "</p>\n";
         print "<div style=\"text-align: left;\"><p>Query:\n";
         print "<pre>" . PMF_htmlentities($each_query[1]) . "</pre></p></div>\n";
         print "</div>";
         db_uninstall();
         cleanInstallation();
         HTMLFooter();
         die;
     }
     wait(25);
     $count++;
     if (!($count % 10)) {
         @ob_flush();
         flush();
     }
 }
 @ob_flush();
 flush();
 // add admin account and rights
 $admin = new PMF_User();
 $admin->createUser('admin', $password, 1);
 $admin->setStatus('protected');
 $adminData = array('display_name' => $realname, 'email' => $email);
 $admin->setUserData($adminData);
 $adminID = $admin->getUserId();
Exemplo n.º 19
0
)"><option>-- Seleccione --</option><?php 
            echo $nombre[0];
            ?>
</select> </td><td   width="50%" class='titulos2'> 
			<div id="<?php 
            echo $nombre[1];
            ?>
Div"></div></td>
  			</tr> </table>
			<div  id="waitDiv<?php 
            echo $_GET['con'] + 1;
            ?>
"></div><?php 
        }
    } else {
        $nombre = wait($db, $_GET['padre']);
        if ($nombre[1] == Null) {
            // echo $_GET['padre'];
            ?>
<input type="hidden" name="exp_entre" value="<?php 
            echo $_GET['padre'];
            ?>
">
<input type="hidden" name="exp_caja" value="<?php 
            echo $_GET['padre'];
            ?>
"><?php 
        } else {
            ?>
 <table cellpadding="0" cellspacing="0"  width="100%"><TR><TD class='titulos2' width="50%"><?php 
            echo $nombre[1];