<?php

# PHP_SELF: 但前正在执行脚本的文件名,与document root相关
# QUERY_STRING: 查询(query)的字符串
$cachefile = "cache".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
# ^
function start_caching() # |
{ # |
//Use the global $cachefile variable # |
global $cachefile; # -->---->--+ //There is a random string to the end of the $_GET Query String to
//prevent IE from caching the Ajax request. The below line removes the random portion
//of the query so we can cache the page properly in php
if(stripos($cachefile, "&rand=")==true)
$cachefile = substr($cachefile,,stripos($cachefile, "&rand=")); if (file_exists($cachefile))
{
// the page has been cached from an earlier request
// output the contents of the cache file
include($cachefile);
// exit the script, so that the rest isnt executed
exit;
}
else
ob_start();
} function get_application($dot_desktop_array,$submenu,$app_name)
{
for($i = ;$i<count($dot_desktop_array[$submenu]["apps"]);$i++)
{
if($dot_desktop_array[$submenu]["apps"][$i]["Name"]==$app_name)
return $dot_desktop_array[$submenu]["apps"][$i];
}
return NULL;
} function end_caching()
{
//Use the global $cachefile variable
global $cachefile; //Disable Caching on Description Page
// open the cache file "cache/home.html" for writing
$fp = fopen($cachefile, 'w');
// save the contents of output buffer to the file
fwrite($fp, ob_get_contents());
// close the file
fclose($fp);
// Send the output to the browser
ob_end_flush();
} function get_submenu($dot_desktop_array,$submenu_name)
{
# foreach 循环
# $k: 表示数组的下标
# $v: 表示k下标对应的数组值
foreach ($dot_desktop_array as $k => $v)
{
for($j = ;$j<count($v["apps"]);$j++)
{
$current_entry = $v["apps"][$j]; # 如果当前的记录类型是目录,并且当前分类和给定名字一样,那么返回该对象
if($current_entry["Type"]=="directory" && $current_entry["Category"] == $submenu_name)
return $current_entry;
}
}
return NULL;
} function read_desktop_file()
{
# 检查json.txt是否存在,并且json.txt文件长度不为0
if(file_exists("json.txt") == true && filesize("json.txt") != )
{
# 打开并读取文件
$handle = fopen("json.txt", "rb");
$contents = fread($handle,filesize("json.txt"));
fclose($handle); # 接受一个JSON格式的字符串并且把它转换为PHP变量,
# 返回解析后的json对象
return json_decode($contents,true);
}
else
return null;
} ?>

Texas Instruments matrix-gui-2.0 hacking -- helper_functions.php的更多相关文章

  1. Texas Instruments matrix-gui-2.0 hacking -- app_description.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  2. Texas Instruments matrix-gui-2.0 hacking -- submenu.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  3. Texas Instruments matrix-gui-2.0 hacking -- run_script.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  4. Texas Instruments matrix-gui-2.0 hacking -- index.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  5. Texas Instruments matrix-gui-2.0 hacking -- menubar.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  6. Texas Instruments matrix-gui-2.0 hacking -- generate.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  7. Texas Instruments matrix-gui-2.0 hacking -- execute_command.sh

    #!/bin/sh #Copyright (C) Texas Instruments Incorporated - http://www.ti.com/ # # # Redistribution an ...

  8. 【LeetCode每天一题】Set Matrix Zeroes(设置0矩阵)

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Exampl ...

  9. Texas Instruments matrix-gui-2.0 hacking -- json.txt

    { "main_menu": { "apps": [ { "Name":"Profiling", ", &qu ...

随机推荐

  1. JSON序列化反序列化

    JSON(全称为JavaScript Object Notation) 是一种轻量级的数据交换格式.它是基于JavaScript语法标准的一个子集. JSON采用完全独立于语言的文本格式,可以很容易在 ...

  2. XML_CPP_资料_libxml2库函数详解

    http://blog.csdn.net/hanchaoman/article/details/42557195 许多事物符合80/20法则,libxml中也是20%的函数提供了80%的功能.下面的列 ...

  3. 03_ExeZZ.cpp

    1.静态加载 DLL : #pragma comment(lib, "DllZZ.lib") __declspec(dllimport) void __stdcall AA(); ...

  4. jsonp跨域远离

    http://blog.csdn.net/sky_beyond/article/details/54096275 function ajax( obj ){ // 默认参数 由于 jsonp 原理是 ...

  5. 模块commonjs AMD UMD

    commonjs是用在服务器端的,同步的,如nodejs amd, cmd是用在浏览器端的,异步的,如requirejs和seajs 其中,amd先提出,cmd是根据commonjs和amd基础上提出 ...

  6. windows 网络共享传送文件超慢

    这可是无线局域网,竟然只有 200K/s. 调查经过: 1) 问题是单向的, B->A 没有问题, A->B就出事 2) 只发生在 Windows网络共享, A上装了apache测试, A ...

  7. Ubuntu 16.04下docker ce的安装

    卸载版本的docker sudo apt-get remove docker docker-engine docker.io 安装可选内核模块 从 Ubuntu 14.04 开始,一部分内核模块移到了 ...

  8. 2月9日 Time and Date(Ruby基础) \n 2月10日 ,使用Proc,block对象化。

    20.1Time类 ,Data类 Time.now或者Time.new:获取当前时间. 相关Method: year, month, hour, min ,sec, wday: 一周中的第几天,返回整 ...

  9. 『cs231n』注意力模型

    RNN实现文本标注: 弊端是图像信息只在初始化时有用到 Soft Attention模型: 每一层具有三个输入:隐藏状态 + 注意力特征向量 + 词向量 每一层具有两个输出:新的位置分布(指示下一次‘ ...

  10. hdu-4678-sg

    Mine Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...