Thứ Tư, 31 tháng 7, 2013

Chuyển biến Jquery thành Json và save file + php



download
http://www.mediafire.com/?sptrqocto870cg8

Thứ Ba, 30 tháng 7, 2013

Jquery AJAX Save to file

$('a#exportPage').on('click',function(){
var contentMap = {};
$('[id^="appendHeading"]').each(function(){
    contentMap[this.id] = $(this).text();
});
for(id in contentMap)
    $("#PrintIds").append("ObjectID:" + id + "Content:" + contentMap[id]);

$.ajax({
  url: "post.php",
  type: "post",
  data: { 
      objectID: id,
      content: contentMap[id]
      },
      success: function(){
      alert("success");
  },
  error:function(){
      alert("failure");
  }   
 }); 
});
 
And this PHP:

<?php
if ($_POST['objectID'] || $_POST['content']) {
$myFile = "test.css";
$stringData = $_POST['objectID'] || $_POST['content'];
file_put_contents($myFile,$stringData);
}
?>

Thứ Ba, 23 tháng 7, 2013

Lấy url hiện tại



function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

Thứ Hai, 1 tháng 7, 2013

List Function in file

 



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
    input[type="text"]{
        width:400px;
    }
    textarea{
        width:400px;
        height:400px;
    }
</style>
</head>

<body>

<form>
    <div>Url: <input type="text" name="url"  value="<?php echo $_GET["url"] ; ?>"/></div>
    <div>list: <textarea name="list"><?php echo $_GET["list"] ; ?></textarea></div>
    <div><input type="submit" /></div>
</form>
<?php

if($_GET["url"]){
    $string_file=str_replace(" ","",$_GET["url"]);
    echo "<h3>".$string_file."</h3>";  
    $data_f=get_defined_functions_in_file($string_file);
    for($i=0;$i<sizeof($data_f);$i++){
        echo "<div>".$data_f[$i]."</div>";
    }
}
if($_GET["list"]){
    $array_l=explode(",",str_replace(" ","",$_GET["list"]));
    for($j=0;$j<sizeof($array_l);$j++){
        $string_file=$array_l[$j];
        echo "<h3>".$string_file."</h3>";  
        $data_f=get_defined_functions_in_file($string_file);
        for($i=0;$i<sizeof($data_f);$i++){
            echo "<div>".$data_f[$i]."</div>";
        }
    }
}
function get_defined_functions_in_file($file) {
    $source = file_get_contents($file);
    $tokens = token_get_all($source);

    $functions = array();
    $nextStringIsFunc = false;
    $inClass = false;
    $bracesCount = 0;

    foreach($tokens as $token) {
        switch($token[0]) {
            case T_CLASS:
                $inClass = true;
                break;
            case T_FUNCTION:
                if(!$inClass) $nextStringIsFunc = true;
                break;

            case T_STRING:
                if($nextStringIsFunc) {
                    $nextStringIsFunc = false;
                    $functions[] = $token[1];
                }
                break;

            // Anonymous functions
            case '(':
            case ';':
                $nextStringIsFunc = false;
                break;

            // Exclude Classes
            case '{':
                if($inClass) $bracesCount++;
                break;

            case '}':
                if($inClass) {
                    $bracesCount--;
                    if($bracesCount === 0) $inClass = false;
                }
                break;
        }
    }

    return $functions;
}
 ?>
</body>
</html>