Beispiel #1
0
function createimg($sid, $headers = true, $w = 0, $h = 0)
{
    global $setctl, $cfg;
    $sent = false;
    $f2 = new file2($sid);
    $fdesc = new filedesc($f2->fname);
    if ($f2->fexists && $fdesc->found) {
        $nh = $nw = 0;
        if ($setctl->get('albumresize')) {
            if (imgcoords($w, $h, $f2->fullpath, $nw, $nh) && function_exists('imagecreatetruecolor') && function_exists('imagecopyresampled')) {
                if ($imagesize = @getimagesize($f2->fullpath)) {
                    $w = $imagesize[0];
                    $h = $imagesize[1];
                    $image_p = imagecreatetruecolor($nw, $nh);
                    if (is_resource($image_p)) {
                        switch ($fdesc->extension) {
                            case 'gif':
                                if (function_exists('imagecreatefromgif') && function_exists('imagegif')) {
                                    $image = @imagecreatefromgif($f2->fullpath);
                                    if ($image) {
                                        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $nw, $nh, $w, $h);
                                        imgsend($f2, $fdesc, false, $headers);
                                        imagegif($image_p);
                                        $sent = true;
                                    }
                                }
                                break;
                            case 'png':
                                if (function_exists('imagecreatefrompng') && function_exists('imagepng')) {
                                    $image = @imagecreatefrompng($f2->fullpath);
                                    if ($image) {
                                        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $nw, $nh, $w, $h);
                                        imgsend($f2, $fdesc, false, $headers);
                                        imagepng($image_p);
                                        $sent = true;
                                    }
                                }
                                break;
                            case 'jpg':
                                if (function_exists('imagecreatefromjpeg') && function_exists('imagejpeg')) {
                                    $image = @imagecreatefromjpeg($f2->fullpath);
                                    if ($image) {
                                        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $nw, $nh, $w, $h);
                                        imgsend($f2, $fdesc, false, $headers);
                                        imagejpeg($image_p, null, $cfg['jpeg-quality']);
                                        $sent = true;
                                    }
                                }
                                break;
                        }
                    }
                }
            }
        }
        if (!$sent) {
            imgsend($f2, $fdesc, true);
        }
    }
}
Beispiel #2
0
function id3v2image($sid, $send = true, $headers = true)
{
    $f2 = new file2($sid, true);
    if ($f2->ifexists()) {
        $info = get_file_info($f2->fullpath, true);
        if (isset($info['id3v2']['APIC'][0]) && is_array($info['id3v2']['APIC'][0])) {
            $fdesc = new filedesc();
            $apic = $info['id3v2']['APIC'][0];
            if (isset($apic['mime']) && isset($apic['data'])) {
                $fdesc->mime = $apic['mime'];
                $name = 'cover';
                $mimex = explode('/', $fdesc->mime);
                if (count($mimex) == 2) {
                    $name .= '.' . $mimex[1];
                }
                if ($send) {
                    if ($headers) {
                        imgsend($f2, $fdesc, false, true, $name);
                    }
                    echo $apic['data'];
                } else {
                    return true;
                }
            }
        }
    }
    return false;
}
Beispiel #3
0
$xmlobj = simplexml_load_string($poststr, 'SimpleXMLElement', LIBXML_NOCDATA);
$xmlArr = json_decode(json_encode($xmlobj), true);
if ($xmlArr['MsgType'] == 'text') {
    $title = '感谢您关注我公司微招聘官方平台。';
    $description = '在这里,您可以更全面的了解到我公司的详情情况,实时掌握我公司的最新招聘信息。';
    $picurl = "http://www.toptophr.com/" . $doc['firmpic'] . "";
    $url = "http://www.toptophr.com/company/index.php?id=" . $doc['wxuid'] . "&style=wap";
    echo imgsend($title, $description, $picurl, $url);
}
//如果第一次关注微信号
if ($xmlArr['MsgType'] == 'event') {
    $title = '感谢您关注我公司微招聘官方平台。';
    $description = '在这里,您可以更全面的了解到我公司的详情情况,实时掌握我公司的最新招聘信息。';
    $picurl = "http://www.toptophr.com/" . $doc['firmpic'] . "";
    $url = "http://www.toptophr.com/company/index.php?id=" . $doc['wxuid'] . "&style=wap";
    echo imgsend($title, $description, $picurl, $url);
}
//发送文本消息
function send($reply)
{
    global $xmlArr;
    $str = "<xml>\n\t\t\t\t\t<ToUserName><![CDATA[" . $xmlArr['FromUserName'] . "]]></ToUserName>\n\t\t\t\t\t<FromUserName><![CDATA[" . $xmlArr['ToUserName'] . "]]></FromUserName>\n\t\t\t\t\t<CreateTime>" . $xmlArr['createTime'] . "</CreateTime>\n\t\t\t\t\t<MsgType><![CDATA[text]]></MsgType>\n\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t</xml>";
    return $result = sprintf($str, $reply);
}
function imgsend($title, $description, $picurl, $turl)
{
    global $xmlArr;
    $str = "<xml>\n\t\t\t\t\t<ToUserName><![CDATA[" . $xmlArr['FromUserName'] . "]]></ToUserName>\n\t\t\t\t\t<FromUserName><![CDATA[" . $xmlArr['ToUserName'] . "]]></FromUserName>\n\t\t\t\t\t<CreateTime>" . $xmlArr['CreateTime'] . "</CreateTime>\n\t\t\t\t\t<MsgType><![CDATA[news]]></MsgType>\n\t\t\t\t\t<ArticleCount>1</ArticleCount>\n\t\t\t\t\t<Articles>\n\t\t\t\t\t<item>\n\t\t\t\t\t<Title><![CDATA[%s]]></Title> \n\t\t\t\t\t<Description><![CDATA[%s]]></Description>\n\t\t\t\t\t<PicUrl><![CDATA[%s]]></PicUrl>\n\t\t\t\t\t<Url><![CDATA[%s]]></Url>\n\t\t\t\t\t</item>\n\t\t\t\t\t</Articles>\n\t\t\t\t</xml>";
    $result = sprintf($str, $title, $description, $picurl, $turl);
    return $result;
}