示例#1
0
文件: Gear.php 项目: romartyn/cogear
 /**
  * Show messages window
  * 
  * @param string $content
  * @param string $title
  * @param string $class
  * @param int $type 
  */
 public function show($content = NULL, $title = NULL, $class = 'info', $type = NULL)
 {
     $tpl = new Template($this->template);
     $tpl->title = $title or t('Info');
     $tpl->content = $content;
     $tpl->class = $class;
     $tpl->type = $type ? $type : self::INFO;
     prepend('content', $tpl->render());
 }
示例#2
0
 /**
  * Prepare menues
  */
 public function prepare(){
     $cogear = getInstance();
     $menu = new Menu('admin.sidebar');
     $root = Url::gear('admin');
     $menu->{$root} = icon('dashboard','fugue').t('Dashboard');
     $menu->{$root.'gears'} = icon('gear','fugue').t('Gears');
     $menu->{$root.'theme'} = icon('layout').t('Theme');
     $menu->{$root.'site'} = icon('toolbox','fugue').t('Site');
     $menu->{$root.'site/clear_cache'} = icon('bin').t('Clear cache');
     prepend('sidebar',$menu->render('Admin_Menu.sidebar_menu'));
     css($this->folder.'/css/menu.css');
     $menu = new Menu('admin.top');
     Template::bindGlobal('top_menu',$menu);
 }
示例#3
0
    $output = "# en_US translation of BoxBilling Application\n";
    $output .= sprintf("# Copyright %s BoxBilling <*****@*****.**>\n", '2011 - ' . date('Y'));
    $output .= "#\n";
    $output .= "#, fuzzy\n";
    $output .= "msgid \"\"\n";
    $output .= "msgstr \"\"\n";
    $output .= "\"Project-Id-Version: 4\\n\"\n";
    $output .= "\"POT-Creation-Date: " . date("Y-m-d H:iO") . "\\n\"\n";
    $output .= "\"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\\n\"\n";
    $output .= "\"Last-Translator: BoxBilling TM <*****@*****.**>\\n\"\n";
    $output .= "\"Language-Team: BoxBilling TM <*****@*****.**>\\n\"\n";
    $output .= "\"MIME-Version: 1.0\\n\"\n";
    $output .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
    $output .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
    $output .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n\n";
    return $output;
}
function prepend($string, $filename)
{
    $context = stream_context_create();
    $fp = fopen($filename, 'r', 1, $context);
    $tmpname = md5($string);
    file_put_contents($tmpname, $string);
    file_put_contents($tmpname, $fp, FILE_APPEND);
    fclose($fp);
    unlink($filename);
    rename($tmpname, $filename);
}
require_once dirname(__FILE__) . '/../src/bb-load.php';
prepend(_writeHeader(), BB_PATH_LANGS . '/messages.pot');
示例#4
0
/**
 * Gets an array of slices of size `$size` from an array.
 * ```php
 * $pairs = slices(2);
 * $pairs([1, 2, 3, 4, 5]); // [[1, 2], [3, 4], [5]]
 * $pairs("Hello World"); // ['He', 'll', 'o ', 'Wo', 'rl', 'd']
 * slices(5, [1, 2]); // [[1, 2]]
 * slices(3, []) // []
 * slices(3, '') // ''
 * ```
 *
 * @signature Number -> [a] -> [[a]]
 * @signature Number -> String -> [String]
 * @param  int $size
 * @param  array $list
 * @return array
 */
function slices()
{
    $slices = function ($size, $list) {
        if (empty($list)) {
            return is_string($list) ? '' : [];
        }
        if (length($list) <= $size) {
            return [$list];
        }
        return prepend(take($size, $list), slices($size, remove($size, $list)));
    };
    return apply(curry($slices), func_get_args());
}
示例#5
0
 /**
  * @param mixed $x
  *
  * @return Collection
  */
 public function prepend($x)
 {
     return new self(prepend($x, $this->xs));
 }
示例#6
0
function prepends($prefix, $prop = null)
{
    if ($prop === null) {
        return function ($object) use($prefix) {
            return prepend($prefix, $object);
        };
    } else {
        return function ($object) use($prefix, $prop) {
            @($object[$prop] = prepend($prefix, @$object[$prop]));
            return $object;
        };
    }
}
function runDosScript($textToInsert, $conn, $key)
{
    //duplicate Html and create index.php file
    runScript($textToInsert, $conn, $key);
    $script = '<?php require_once "../php/DataBaseHandling.php"; $conn=openConnection();';
    $script .= '$ip=$_SERVER["REMOTE_ADDR"];';
    $script .= '$key = "' . $key . '";';
    $script .= '$link="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $result = checkForDuplicateSessions($conn,$ip,$link);
    if(!$result){
        if($_COOKIE["geoData"]){
		// A "geoData" cookie has been previously set by the script, so we will use it
		
		// Always escape any user input, including cookies:
		list($city,$countryName,$countryAbbrev) = explode("|",mysqli_real_escape_string($conn ,strip_tags($_COOKIE["geoData"])));
	   }
        else{
            // Making an API call to Hostip:
            $json = json_decode(file_get_contents("http://geoip.nekudo.com/api/' . "{$ip}" . '/en/full"));

            $city = $json->city->names->en;

            $countryName = $json->country->names->en;

            $countryAbbrev = $json->country->iso_code;

            // Setting a cookie with the data, which is set to expire in a month:
            setcookie("geoData",$city."|".$countryName."|".$countryAbbrev."|".time()+60*60*24*30);
        }
	    // In case the Hostip API fails:
        if (!$countryName){
            $countryName="UNKNOWN";
            $countryAbbrev="XX";
            $city="(Unknown City?)";
        }
        addSessionToDatabase($conn,$ip,$city,$countryName,$countryAbbrev,$link);
    
    }
    else{
        // If the visitor is already online, just update the dt value of the row:
        updateSessionFromDatabase($conn,$ip,$link);
    }

    // Removing entries not updated in the last 10 minutes:
    deleteSessionFromDatabase($conn);?>';
    //get to the correct directory
    changeToKeyPath($key);
    //add script to index.php itself
    prepend($script, "index.php");
}