Tagged: php RSS

  • chetanweb 12:58 pm on February 14, 2010 Permalink | Reply
    Tags: highlighter, php, postphp   

    Post PHP Codes to wordpress using plugin PostPHP 

    Here is simple wordpress plug-in for posting PHP Scripts in WordPress post called PostPHP.
    Download : http://wordpress.org/extend/plugins/post-php/

    I made this plug in for my personal use on chetanweb.com.Today I thought to make it public.

    How to use it ??

    Just add you php code in between tags <php></php> as you use HTML tags .

    Example :

    <php><?php

    echo “Hello,World!”;

    ?>

    </php>


    Will Get


    <?php

    echo "Hello,World!";

    ?>


    That’s It :D

     
    • Никита 2:02 am on February 15, 2010 Permalink | Reply

      можно сказать, это исключение :) из правил

    • Shashank amin 10:19 am on February 19, 2010 Permalink | Reply

      Oh great buddy ;)

    • Nikotinka 11:43 am on March 3, 2010 Permalink | Reply

      Хотелось бы видеть надпись to be continied

    • Cialis 2:20 am on March 10, 2010 Permalink | Reply

      XoAVjX Excellent article, I will take note. Many thanks for the story!

  • chetanweb 11:45 am on February 6, 2010 Permalink | Reply
    Tags: php   

    Publish a post on your WordPress blog using PHP + cURL 

    I think I should name my blog “Web Bot source codes”  :P Lolz , today I will be posting something similar called WPBot – Wordpress bot. The PHP code which will publish a post on your post using cURL.This PHP is dependent on class file class.XMLHttpRequest.php ( You can get it here ).You can use this function for various things like publishing of scores , news , jokes etc on your blog . Use cron job method of automated things as used in Twitter Bot.

    Source Code


    <?php
    include("class.XMLHttpRequest.php");
    //URL of the wordpress blog
    $link="http://localhost/chetanim/newwp/";

    //Logins
    $username="admin";
    $password="admin";
    //Title and body
    $title=time();
    $body="Hello ! World";

    //Common setting 
    $setting=array();
    $setting['User-Agent']="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.17) Gecko/2009122116 Firefox/3.0.17 GTB5";
    $setting['Login-File']="wp-login.php";
    $setting['Accept']="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
    $setting['Accept-Language']="en-us,en;q=0.5";
    $setting['Accept-Charset']="ISO-8859-1,utf-8;q=0.7,*;q=0.7";
    $setting['Content-Type']="application/x-www-form-urlencoded; charset=UTF-8";
    $setting['Reffer']="{$link}wp-login.php?redirect_to=http%3A%2F%2Flocalhost%2Fchetanim%2Fnewwp%2Fwp-admin%2F";

    //Getting logged in to the blog and getting cookies in var

    $req=new XMLHttpRequest();
    $req->open("POST","{$link}{$setting['Login-File']}");
    $req->setRequestHeader("Host","localhost");
    $req->setRequestHeader("User-Agent",$setting['User-Agent']);
    $req->setRequestHeader("Accept",$setting['Accept']);
    $req->setRequestHeader("Accept-Language",$setting['Accept-Language']);
    $req->setRequestHeader("Accept-Encoding","gzip,deflate");
    $req->setRequestHeader("Accept-Charset",$setting['Accept-Charset']);
    $req->setRequestHeader("Referer",$setting['Reffer']);
    $req->send("log=".urlencode($username)."&pwd=".urlencode($password)."&wp-submit=Log+In&redirect_to=".urlencode($link)."wp-admin%2F&testcookie=1&");

    $responseText=$req->responseText;
    $cookie=$req->getResponseHeader('Set-Cookie');
    $req->close();

    //Cleaning and arranging cookie properly
    $cookie=explode(";",$cookie);
    $cookie_part1=explode(", ",$cookie[1]);
    $cookie_part1=$cookie_part1[1];
    $cookie_part2=str_replace("httponly, ","",$cookie[3]);
    $cookie_part3=str_replace("httponly, ","",$cookie[5]);
    $cookie=str_replace(" ",'',$cookie_part1.";".$cookie_part2.";".$cookie_part3.";");

    //Posting the topic
    $req=new XMLHttpRequest();
    $req->open("POST","{$link}wp-admin/post.php");
    $req->setRequestHeader("Host","localhost");
    $req->setRequestHeader("User-Agent",$setting['User-Agent']);
    $req->setRequestHeader("Accept",$setting['Accept']);
    $req->setRequestHeader("Accept-Language",$setting['Accept-Language']);
    $req->setRequestHeader("Accept-Encoding","gzip,deflate");
    $req->setRequestHeader("Accept-Charset",$setting['Accept-Charset']);
    $req->setRequestHeader("Content-Type",$setting['Content-Type']);
    $req->setRequestHeader("X-Requested-With","XMLHttpRequest");
    $req->setRequestHeader("Referer","{$link}wp-admin/");
    $req->setRequestHeader("Cookie",$cookie);       
    $request="post_title=".urlencode($title)."&content=".rawurlencode($body)."&tags_input=&action=post-quickpress-publish&quickpress_post_ID=0&_wpnonce=647ecf8dea&_wp_http_referer="    .urlencode($link."/wp-admin")."&";
    $req->send($request);
    $responseText=$req->responseText;
    preg_match('/<a href="(.*)">View post<\/a>/',$responseText,$postlink);

    //The link of the post
    $postlink=$postlink[1];

    echo $postlink;

    ?>

    Do Report Bugs and comment your new ideas or creativity over here.

    Regards,

    Chetan Mendhe

     
Get Adobe Flash playerPlugin by wpburn.com wordpress themes
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
esc
cancel