Beispiel #1
0
 /**
  * @param int $timeout The timeout in milliseconds after which the promise will resolve
  * @throws \DomainException On invalid timeout value
  */
 public function __construct($timeout)
 {
     $timeout = (int) $timeout;
     if ($timeout < 1) {
         throw new \DomainException("Pause timeout must be greater than or equal to 1 millisecond");
     }
     once(function () {
         $this->resolve();
     }, $timeout);
 }
 public function createApplication()
 {
     $pimple = new \Pimple();
     $dependencies = array('beforeTokenChecker' => $pimple->protect(function () {
     }));
     require SPIKA_ROOT . '/etc/app.php';
     $mailer = $this->getMockBuilder('\\Silex\\Provider\\SwiftmailerServiceProvider')->setMethods(array('send'))->disableOriginalConstructor()->getMock();
     $mailer->expects(once())->method('send')->with(isInstanceOf('Swift_Message'));
     $app['mailer'] = $mailer;
     return $app;
 }
Beispiel #3
0
    curl_close($ch);
    $little = stripos($content, '一般全文 start');
    $content = substr($content, $little);
    $last = stripos($content, '一般全文 end');
    $content = substr($content, 0, $last);
    $content = str_replace("\n", "", $content);
    $content = str_replace("\r", "", $content);
    preg_match("/<div class=\"artical-content-read\">(.*?)<span id=\"editor_baidu/", $content, $arr);
    return $arr[1];
}
$newsurl = "http://voice.hupu.com/soccer/newslist";
$newsarr = caiji($newsurl);
$newnewsarr = array();
$i = 0;
foreach ($newsarr as $key => $value) {
    $content = str_replace("div", "p", once($value['link']));
    //虎扑的图片是禁止外站调用的,所以你要把图片下载到本地
    preg_match("/src=\"(.*?)((.jpg)|(.png)|(.jpeg))(.*?)\"/", $content, $img);
    $imgstr = file_get_contents($img[1] . $img[2]);
    $dir = "./Yourdir/";
    if (!file_exists($dir)) {
        mkdir($dir);
    }
    $tempdir = $dir . date("Ymdhis") . "_" . rand(10000, 99999) . $img[2];
    //下载图片并保持到本地---END
    file_put_contents($tempdir, $imgstr);
    $tempdir = substr($tempdir, 1);
    $newnewsarr[$i]['content'] = preg_replace("/src=\"(.*?)\"/", "src='http://www.yoursite.com{$tempdir}'", $content);
    $newnewsarr[$i]['title'] = $value['title'];
    $i++;
}
Beispiel #4
0
/**
 * Create an artificial timeout for any Promise instance
 *
 * If the timeout expires prior to promise resolution the returned
 * promise is failed.
 *
 * @param \Amp\Promise $promise The promise to which the timeout applies
 * @param int $msTimeout The timeout in milliseconds
 * @return \Amp\Promise
 */
function timeout(Promise $promise, $msTimeout)
{
    $resolved = false;
    $promisor = new Deferred();
    $watcherId = once(function () use($promisor, &$resolved) {
        $resolved = true;
        $promisor->fail(new TimeoutException("Promise resolution timed out"));
    }, $msTimeout);
    $promise->when(function ($error = null, $result = null) use($promisor, $watcherId, &$resolved) {
        if ($resolved) {
            return;
        }
        $resolved = true;
        cancel($watcherId);
        if ($error) {
            $promisor->fail($error);
        } else {
            $promisor->succeed($result);
        }
    });
    return $promisor->promise();
}
Beispiel #5
0
				<h5>YYUC开发管理中心登录</h5>
				<div class="corner tl"></div>
				<div class="corner tr"></div>
			</div>
			<?php 
if (hold('logerr')) {
    ?>
			<div class="messages">
				<div id="message-error" class="message message-error">
					<div class="image">
						<img src="/@system/mg/icons/error.png" alt="Error" height="32" />
					</div>
					<div class="text">
						<h6></h6>
						<span><?php 
    echo once('logerr');
    ?>
</span>
					</div>
					<div class="dismiss">
						<a href="#message-error"></a>
					</div>
				</div>
			</div>
			<?php 
}
?>
			<div class="inner">
				<form action="" method="post">
				<div class="form">
					<!-- fields -->
<div style="max-width:600px; background-color:darkGrey; color:white">'
	<?php 
echo lang('email_resend_detail');
?>
</div>

<?php 
require -once('invitation.php');
?>