Author Archive

iframe下JS跨域的方法

一般情况下,浏览器是禁止JS跨域操作的,这对于iframe调用其他域名下的页面一样是禁止的,在iframe里如果我们想操作父级或子级页面里的dom对象就不行了,如何解决呢?    浏览器虽然会禁止js跨域访问页面中的对象,但对于iframe的层级关系引用并没有做限制,即parent仍然可用;该方案就是利用了2层内嵌 iframe、使用第二级iframe中的页面与parent.parent的页面是同域名的关系,从而避免跨域问题实现两个页面间相关数据的传递,本质上就是利用parent.parent实现对父父页面中js的回调!   (continue reading…)

Linux下wget下载整个FTP目录(含子目录)

Linux下可以使用以下命令,下载远端FTP目录下所有的文件,递归所有子目录。对服务器迁移很有用。 (continue reading…)


xCode5.0使用iOS6.1SDK及模拟器 转

最近项目中,介于测试人员提出的问题,有些情况只在ios6的设备上才能显现,而本机的xcode已升级到最新的5.0,这可如何是好呢,在网上搜索了一番,找到如下方法解决此问题: (continue reading…)


使用Nginx的proxy_cache缓存功能取代Squid – 转载

 Nginx从0.7.48版本开始,支持了类似Squid的缓存功能。这个缓存是把URL及相关组合当作Key,用md5编码哈希后保存在硬盘上,所以它可以支持任意URL链接,同时也支持404/301/302这样的非200状态码。虽然目前官方的Nginx Web缓存服务只能为指定URL或状态码设置过期时间,不支持类似Squid的PURGE指令,手动清除指定缓存页面,但是,通过一个第三方的Nginx模块,可以清除指定URL的缓存。
(continue reading…)


php使用curl上传文件post提交

$post_data = array("fax_file"=>'@'.$r_file, "aa"=>'bb'); //文件绝对路径,前面要加@,表明是文件上传.

function uploadByCURL($post_data,$post_url){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $post_url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HEADER, 0);
    $result = curl_exec($curl);
    curl_close($curl);
    return $result;
}

LC_ALL错误

/*
Starting ftp server: proftpd – unable to set LC_ALL: No such file or directory
– Fatal: unable to load module ‘mod_lang.c’: Operation not permitted
failed!
*/
解决办法:
/*
export LC_CTYPE=C
export LC_MESSAGES=C
export LC_ALL=C
*/



Unique Code

session_start();

echo $_SESSION['temparray'][] = generateCode();

var_dump($_SESSION['temparray']);

function generateCode(){
    $code = strtoupper(substr(md5(crypt(uniqid(microtime()))), -5));
    if(is_numeric($code)||in_array($code, $_SESSION['temparray'])){
        return generateCode();
    }
    return $code;
}

Working with multiple PHP versions on MAC OS-X

Today I had to update a project that was developed using WordPress and PHP 5.3. Today I have PHP 5.4 installed on my machine and this newer version abandoned some old features, and you have some Fatal errors like Call-time pass-by-reference has been removed. The solution was go back to PHP 5.3 and do the updates on my the project, because the production server is with PHP 5.3 too. (continue reading…)


typo3 imagemagick pdf pages

//test
        $picConf = array();
        $picConf['image.']['file'] = t3lib_extMgm::extPath($this->extKey).'pi1/test1.pdf';
        if(!is_file($picConf['image.']['file'])){
            $picConf['image.']['file'] = "";
        }
        $theImgCode = '';
        if(is_file($picConf['image.']['file'])){
            $picConf['image.']['file.']['maxW'] = $this->conf['maxW'] ? $this->conf['maxW'] : 300;
            $picConf['image.']['file.']['maxH'] = $this->conf['maxH'] ? $this->conf['maxH'] : 600;
            $picConf['image.']['file.']['frame'] = 1;
            $picConf['image.']['altText'] = '';
            $picConf['image.']['titleText'] = '';
            $content .= $this->cObj->IMAGE($picConf['image.']);
        }

        //S1
        $document = new Imagick($picConf['image.']['file']);
        echo $document->getNumberImages();
        //S2
        $img_info = exec(t3lib_div::imageMagickCommand('identify', $cur_path));
        //echo .*\.pdf[3]

Or global: $GLOBALS[‘TYPO3_CONF_VARS’][‘GFX’][‘im_noFramePrepended’]

1 Comment more...

Copyright © 1996-2010 Add Lives. All rights reserved.
iDream theme by Templates Next | Powered by WordPress