<?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. package 'orocos-bfl' not found CMake Error at /usr/share/cmake-2.8/Modules/FindPkgConfig.cmake:283 (message):

    #没有数字 sudo apt-get install ros-indigo-bfl

  2. json-rpc和restful

    json-rpc是一种动作 restful 是一种资源 RPC 所谓的远程过程调用 (面向方法) SOA 所谓的面向服务的架构(面向消息) REST 所谓的 Representational stat ...

  3. Python 爬虫-Robots协议

    2017-07-25 21:08:16 一.网络爬虫的规模 二.网络爬虫的限制 • 来源审查:判断User‐Agent进行限制 检查来访HTTP协议头的User‐Agent域,只响应浏览器或友好爬虫的 ...

  4. C# 通过Newtonsoft.Json.dll序列化日期的处理

    Newtonsoft.Json.dll提供了非常好的Json序列化和反序列化方式,但是对日期的处理却让我纠结了很久.首先定义类如下: public class Student{ public int ...

  5. Java线程池队列吃的太饱,撑着了咋整?java 队列过大导致内存溢出

    Java的Executors框架提供的定长线程池内部默认使用LinkedBlockingQueue作为任务的容器,这个队列是没有限定大小的,可以无限向里面submit任务. 当线程池处理的太慢的时候, ...

  6. php json josn_decode()返回的是对像,如何把对像转成数组

    php json josn_decode()返回的是对像,如何把对像转成数组 a.php传值页面,使用 json_encode($array)对数组进行加密码. b.php页面在接收a.php传过来的 ...

  7. python模块——re模块(简单的计算器功能实现_eval版)

    #!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = "loki" # Usage: Make a Diy Calcu ...

  8. Jzzhu and Numbers CodeForces - 449D (高维前缀和,容斥)

    大意: 给定集合a, 求a的按位与和等于0的非空子集数. 首先由容斥可以得到 $ans = \sum \limits_{0\le x <2^{20}} (-1)^{\alpha} f_x$, 其 ...

  9. 『PyTorch』第十六弹_hook技术

    由于pytorch会自动舍弃图计算的中间结果,所以想要获取这些数值就需要使用钩子函数. 钩子函数包括Variable的钩子和nn.Module钩子,用法相似. 一.register_hook impo ...

  10. 『cs231n』作业1选讲_通过代码理解KNN&交叉验证&SVM

    通过K近邻算法探究numpy向量运算提速 茴香豆的“茴”字有... ... 使用三种计算图片距离的方式实现K近邻算法: 1.最为基础的双循环 2.利用numpy的broadca机制实现单循环 3.利用 ...