示例#1
0
function normal_sign($uid, $tieba)
{
    $setting = get_setting($uid);
    $url = "http://tieba.baidu.com/mo/m?kw={$tieba[unicode_name]}";
    $get_url = curl_get($url, $uid);
    if (!$get_url) {
        return array(1, '无法打开贴吧首页', 0);
    }
    $get_url = wrap_text($get_url);
    preg_match('/<ahref="([^"]*?)">签到<\\/a>/', $get_url, $matches);
    if (isset($matches[1])) {
        $s = str_replace('&amp;', '&', $matches[1]);
        $sign_url = 'http://tieba.baidu.com' . $s;
        $get_sign = curl_get($sign_url, $uid, $setting['use_bdbowser']);
        $done++;
        if (!$get_sign) {
            return array(1, '签到错误,可能已经签到成功,稍后重试', 0);
        }
        $get_sign = wrap_text($get_sign);
        preg_match('/<spanclass="light">签到成功,经验值上升<spanclass="light">(\\d+)<\\/span>/', $get_sign, $matches);
        if ($matches[1]) {
            return array(2, "签到成功,经验值+{$matches[1]}", $matches[1]);
        } else {
            return array(1, '签到错误,可能已经签到成功,稍后重试', 0);
        }
    } else {
        preg_match('/<span>已签到<\\/span>/', $get_url, $matches);
        if ($matches[0]) {
            return array(2, '此前已成功签到', 0);
        } else {
            return array(-1, '找不到签到链接,稍后重试', 0);
        }
    }
}
示例#2
0
function _get_liked_tieba($cookie)
{
    $pn = 0;
    $kw_name = array();
    while (true) {
        $pn++;
        $mylikeurl = "http://tieba.baidu.com/f/like/mylike?&pn={$pn}";
        $ch = curl_init($mylikeurl);
        curl_setopt($ch, CURLOPT_URL, $mylikeurl);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_COOKIE, $cookie);
        $result = curl_exec($ch);
        curl_close($ch);
        $result = wrap_text($result);
        $pre_reg = '/<tr><td>.*?<ahref="\\/f\\?kw=.*?"title="(.*?)"/';
        preg_match_all($pre_reg, $result, $matches);
        $count = 0;
        foreach ($matches[1] as $key => $value) {
            $uname = urlencode($value);
            $_uname = preg_quote($value);
            preg_match('/ForumManager\\.undo_like\\(\'([0-9]+)\',\'' . preg_quote($uname) . '\'/i', $result, $fid);
            $kw_name[] = array('name' => mb_convert_encoding($value, 'utf-8', 'gbk'), 'uname' => $uname, 'fid' => $fid[1]);
            $count++;
        }
        if ($count == 0) {
            break;
        }
    }
    return $kw_name;
}
示例#3
0
function _get_liked_tieba($cookie)
{
    $pn = 0;
    $kw_name = array();
    $retry = 0;
    while (true) {
        $pn++;
        $mylikeurl = "http://tieba.baidu.com/f/like/mylike?&pn={$pn}";
        $result = kk_fetch_url($mylikeurl, 0, '', $cookie);
        $result = wrap_text($result);
        $pre_reg = '/<tr><td>.*?<ahref="\\/f\\?kw=.*?"title="(.*?)"/';
        preg_match_all($pre_reg, $result, $matches);
        $count = 0;
        foreach ($matches[1] as $key => $value) {
            $uname = urlencode($value);
            $_uname = preg_quote($value);
            preg_match('/balvid="([0-9]+)"/i', $result, $fid);
            $kw_name[] = array('name' => mb_convert_encoding($value, 'utf-8', 'gbk'), 'uname' => $uname, 'fid' => $fid[1]);
            $count++;
        }
        if ($count == 0) {
            if ($retry >= 2) {
                break;
            }
            $retry++;
            $pn--;
            continue;
        }
        $retry = 0;
    }
    return $kw_name;
}
示例#4
0
function text_stamp($image, $fontsize, $angle, $x, $y, $fontfile, $string, $width, $max_height, $text_color)
{
    $first = true;
    while ($first || $dimensions[1] - $dimensions[7] > $max_height || $first) {
        $text = wrap_text($fontsize, $angle, $fontfile, $string, $width);
        $dimensions = imagettfbbox($fontsize, $angle, $fontfile, $text);
        $fontsize--;
        $first = false;
    }
    imagettftext($image, $fontsize, $angle, $x, $y, $text_color, $fontfile, $text);
}
示例#5
0
$t->diag('excerpt_text()');
$t->is(excerpt_text('', 'foo', 5), '', 'text_excerpt() return an empty string if argument is empty');
$t->is(excerpt_text('foo', '', 5), '', 'text_excerpt() return an empty string if phrase is empty');
$t->is(excerpt_text("This is a beautiful morning", "beautiful", 5), "...is a beautiful morn...", 'text_excerpt() creates an excerpt of a text');
$t->is(excerpt_text("This is a beautiful morning", "this", 5), "This is a...", 'text_excerpt() creates an excerpt of a text');
$t->is(excerpt_text("This is a beautiful morning", "morning", 5), "...iful morning", 'text_excerpt() creates an excerpt of a text');
$t->is(excerpt_text("This is a beautiful morning", "morning", 5, '...', true), "... morning", 'text_excerpt() takes a fifth argument allowing excerpt on whitespace');
$t->is(excerpt_text("This is a beautiful morning", "beautiful", 5, '...', true), "... a beautiful ...", 'text_excerpt() takes a fifth argument allowing excerpt on whitespace');
$t->is(excerpt_text("This is a beautiful morning", "This", 5, '...', true), "This is ...", 'text_excerpt() takes a fifth argument allowing excerpt on whitespace');
$t->is(excerpt_text("This is a beautiful morning", "day"), '', 'text_excerpt() does nothing if the search string is not in input');
// wrap_text()
$t->diag('wrap_text()');
$line = 'This is a very long line to be wrapped...';
$t->is(wrap_text($line), "This is a very long line to be wrapped...\n", 'wrap_text() wraps long lines with a default of 80');
$t->is(wrap_text($line, 10), "This is a\nvery long\nline to be\nwrapped...\n", 'wrap_text() takes a line length as its second argument');
$t->is(wrap_text($line, 5), "This\nis a\nvery\nlong\nline\nto be\nwrapped...\n", 'wrap_text() takes a line length as its second argument');
// simple_format_text()
$t->diag('simple_format_text()');
$t->is(simple_format_text("crazy\r\n cross\r platform linebreaks"), "<p>crazy\n<br /> cross\n<br /> platform linebreaks</p>", 'text_simple_format() replaces \\n by <br />');
$t->is(simple_format_text("A paragraph\n\nand another one!"), "<p>A paragraph</p>\n\n<p>and another one!</p>", 'text_simple_format() replaces \\n\\n by <p>');
$t->is(simple_format_text("A paragraph\n With a newline"), "<p>A paragraph\n<br /> With a newline</p>", 'text_simple_format() wrap all string with <p>');
// text_strip_links()
$t->diag('text_strip_links()');
$t->is(strip_links_text("<a href='almost'>on my mind</a>"), "on my mind", 'text_strip_links() strips all links in input');
// auto_link_text()
$t->diag('auto_link_text()');
$email_raw = '*****@*****.**';
$email_result = '<a href="mailto:' . $email_raw . '">' . $email_raw . '</a>';
$link_raw = 'http://www.google.com';
$link_result = '<a href="' . $link_raw . '">' . $link_raw . '</a>';
$link2_raw = 'www.google.com';
示例#6
0
    <div class="digitalObject">
      <div class="digitalObjectRep">
        <?php 
        if (isset($link)) {
            ?>
          <?php 
            echo link_to(image_tag($representation->getFullPath()), $link);
            ?>
        <?php 
        } else {
            ?>
          <?php 
            echo image_tag($representation->getFullPath());
            ?>
        <?php 
        }
        ?>
      </div>
      <div class="digitalObjectDesc">
        <?php 
        echo wrap_text($resource->name, 18);
        ?>
      </div>
    </div>

  <?php 
    }
    ?>

<?php 
}
    <div style="width: 100px; text-align: center"/>

      <?php 
        if (isset($link)) {
            ?>
        <?php 
            echo link_to(image_tag($representation->getFullPath()), $link);
            ?>
      <?php 
        } else {
            ?>
        <?php 
            echo image_tag($representation->getFullPath());
            ?>
      <?php 
        }
        ?>

      <?php 
        echo wrap_text($digitalObject->name, 15);
        ?>

    </div>

  <?php 
    }
    ?>

<?php 
}
<?php 
echo $sw_blog_post->getTitle();
?>
 

<?php 
echo __('label_email_name', null, 'swBlogPosts');
echo $sw_blog_comment->getName();
?>
 
<?php 
echo __('label_email_email', null, 'swBlogPosts');
echo $sw_blog_comment->getEmail();
?>
 
<?php 
echo __('label_email_url', null, 'swBlogPosts');
echo $sw_blog_comment->getUrl();
?>
 
<?php 
echo __('label_email_message', null, 'swBlogPosts');
?>
 

<?php 
echo wrap_text($sw_blog_comment->getMessage(), 65);
?>

<?php 
echo __('message_email_footer', null, 'swBlogPosts');