Less PHP (http://leafo.net/lessphp/docs/) has a great method
function autoCompileLess($inputFile, $outputFile) {
// load the cache
$cacheFile = $inputFile.".cache";
if (file_exists($cacheFile)) {
$cache = unserialize(file_get_contents($cacheFile));
} else {
$cache = $inputFile;
}
$less = new lessc;
$newCache = $less->cachedCompile($cache);
if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
file_put_contents($cacheFile, serialize($newCache));
file_put_contents($outputFile, $newCache['compiled']);
}
}
autoCompileLess('myfile.less', 'myfile.css');
Is there any option to do same thing with http://leafo.net/scssphp/, for SASS? I can't find alternative to cachedCompile() with scssphp.
Related
I have updated the app.ini file but somewhere someone wrote this code to have used cache. How can I clear the cache?
static $configuration;
if (!$configuration) {
if (Zend_Registry::isRegistered("configuration")) {
$configuration = Zend_Registry::get("configuration");
}
else {
$cache = self::getCache();
if (!$configuration = $cache->load("configuration")) {
$configuration = new Zend_Config_Ini(APPLICATION_PATH . "/config/app.ini", APPLICATION_ENVIRONMENT);
$cache->save($configuration, "configuration");
}
Zend_Registry::set("configuration", $configuration);
}
}
I use codeigniter 3.0.6 query string like
index.php?d=directoryt&c=controller
index.php?d=directory&c=controller&m=function
How ever having two get methods for directory and controller is a bit long.
Question Is there any way to modify the protected function
_set_routing() function using a MY_Router.php to get it so it will pick up the directory and controller by using one query only like example below.
index.php?route=directory/controller
// If need to get function
index.php?route=directory/controller&m=function
What have tried so far
<?php
class MY_Router extends CI_Router {
protected function _set_routing()
{
// Load the routes.php file. It would be great if we could
// skip this for enable_query_strings = TRUE, but then
// default_controller would be empty ...
if (file_exists(APPPATH.'config/routes.php'))
{
include(APPPATH.'config/routes.php');
}
if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}
// Validate & get reserved routes
if (isset($route) && is_array($route))
{
isset($route['default_controller']) && $this->default_controller = $route['default_controller'];
isset($route['translate_uri_dashes']) && $this->translate_uri_dashes = $route['translate_uri_dashes'];
unset($route['default_controller'], $route['translate_uri_dashes']);
$this->routes = $route;
}
// Are query strings enabled in the config file? Normally CI doesn't utilize query strings
// since URI segments are more search-engine friendly, but they can optionally be used.
// If this feature is enabled, we will gather the directory/class/method a little differently
if ($this->enable_query_strings)
{
// If the directory is set at this time, it means an override exists, so skip the checks
if ( ! isset($this->directory))
{
$_route = isset($_GET['route']) ? trim($_GET['route'], " \t\n\r\0\x0B/") : '';
if ($_route !== '')
{
echo $_route;
$this->uri->filter_uri($_route);
$this->set_directory($_route);
}
}
// Routing rules don't apply to query strings and we don't need to detect
// directories, so we're done here
return;
}
// Is there anything to parse?
if ($this->uri->uri_string !== '')
{
$this->_parse_routes();
}
else
{
$this->_set_default_controller();
}
}
}
config.php
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
// Modifyed in MY_Router.php
$config['route'] = 'route';
I have it working
<?php
class MY_Router extends CI_Router {
protected function _set_routing() {
if (file_exists(APPPATH.'config/routes.php'))
{
include(APPPATH.'config/routes.php');
}
if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}
// Validate & get reserved routes
if (isset($route) && is_array($route))
{
isset($route['default_controller']) && $this->default_controller = $route['default_controller'];
isset($route['translate_uri_dashes']) && $this->translate_uri_dashes = $route['translate_uri_dashes'];
unset($route['default_controller'], $route['translate_uri_dashes']);
$this->routes = $route;
}
if ($this->enable_query_strings) {
if ( ! isset($this->directory))
{
$route = isset($_GET['route']) ? trim($_GET['route'], " \t\n\r\0\x0B/") : '';
if ($route !== '')
{
$part = explode('/', $route);
$this->uri->filter_uri($part[0]);
$this->set_directory($part[0]);
if ( ! empty($part[1])) {
$this->uri->filter_uri($part[1]);
$this->set_class($part[1]);
// Testing function atm
if ( ! empty($_GET['function']))
{
$this->uri->filter_uri($_GET['function']);
$this->set_method($_GET['function']);
}
$this->uri->rsegments = array(
1 => $this->class,
2 => $this->method
);
}
} else {
$this->_set_default_controller();
}
}
// Routing rules don't apply to query strings and we don't need to detect
// directories, so we're done here
return;
}
// Is there anything to parse?
if ($this->uri->uri_string !== '')
{
$this->_parse_routes();
}
else
{
$this->_set_default_controller();
}
}
}
im trying to convert an android code into java using netbeans as IDE.
all the other conversion is done. a single line is still remaining because i don't know what equivalent function can be use here.
public BufferedImage[] SeprateText(BufferedImage newb3)
{
Color clr1,clr2,clr3,clr4;
for(int iht=0;iht<newb3.getHeight()-1;iht++)
{
if(chk==false)
{
clr1 = new Color(newb3.getRGB(0, iht));
if(clr1==Color.RED)
{
chk=true;
}
}
clr2 = new Color(newb3.getRGB(5, iht));
clr3 = new Color(newb3.getRGB(5, iht));
if(chk && ( clr2 == Color.BLACK || clr3 ==Color.WHITE ))
{
if(!sind)
{
sind=true;
index[count]=iht;
}
location[count]++;
clr4 = new Color(newb3.getRGB(0, iht+1));
if(clr4==Color.RED)
{
chk=false;
endloc[count]=iht;
barray[count] = Bitmap.create(newb3,0,index[count],
newb3.getWidth(),location[count]);
// this is the line. i dont know what function of bufferedImage can replace it
count++;
sind=false;
}
}
}
}
Hi I've already installed the CometChat, but I'm facing the following error:
Call to undefined function mcrypt_decrypt() in /home/vagrant/changeglobe/public/cometchat/integration.php on line 89
I'm using Homestead with Nginx for Laravel. I have read at many places that I need to enable mycrypt, but did not found any correct. Please let me know about this issue if you know. Thank you.
Try replacing the getUserID() function in /cometchat/integration.php file with the code below:
function getUserID() {
$userid = 0;
if (!empty($_SESSION['basedata']) && $_SESSION['basedata'] != 'null') {
$_REQUEST['basedata'] = $_SESSION['basedata'];
}
if (!empty($_REQUEST['basedata'])) {
if (function_exists('mcrypt_encrypt') && defined('ENCRYPT_USERID') && ENCRYPT_USERID == '1') {
$key = "";
if( defined('KEY_A') && defined('KEY_B') && defined('KEY_C') ){
$key = KEY_A.KEY_B.KEY_C;
}
$uid = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode(rawurldecode($_REQUEST['basedata'])), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
if (intval($uid) > 0) {
$userid = $uid;
}
} else {
$userid = $_REQUEST['basedata'];
}
}
if (!empty($_COOKIE['laravel_session'])) {
$session= cookie_decrypt($_COOKIE['laravel_session']);
$data = file_get_contents(dirname(dirname(dirname(__FILE__))).'/storage/framework/sessions/'.$session);
if (!empty($data)) {
$k = explode(';i:',$data);
$m = explode(';s:',$k[1]);
$userid = $m[0];
}
}
$userid = intval($userid);
return $userid;
}
If you are still facing issues please create a support ticket https://my.cometchat.com/tickets and our team will assist you.
here is my folder
index.php
smartyhere
-Smarty.class.php
admin
-index.php
-users.php
in index.php -> $smarty->display('index.tpl');
in admin/index.php -> $smarty->display('adminindex.tpl');
got error Smarty error: unable to read resource: "adminindex.tpl"
any idea ?
thx
try to understand code
which urlencode is doing path
<?php
print_r($file);
if (isset($file)) {
$var = explode("-", $file);
print_r($var);
$prefix = $var[0];
$script = $var[1];
} else {
$file = "c-home1";
$prefix = "c";
$script = "home";
$modid = 0;
}
if ($script=="") {
$script="prod_list";
}
/*
* following code finds out the modules from suffix
* and find out the script name
*/
switch ($prefix) {
case "c":
$module = "content";
break;
case "m":
$module = "myaccount";
break;
default:
$module = "content";
break;
}
$smarty->assign("module",$module);
/*
* following code finds out the modules from suffix and
* find out the script name
*/
$include_script .= $module."/".$script.".php";
if (file_exists($include_script)) {
include_once $include_script;
} else {
include_once "content/error.php";
}
if ($script!='home') {
if ($script == 'termsandcondition') {
$smarty->display("content/termsandcondition.tpl");
} else {
$smarty->display("template.tpl");
}
} else {
$smarty->display("template_home.tpl");
$smarty->assign("msg", $msg);
$smarty->assign("msglogin", $msglogin);
}