duda_mobile's People
duda_mobile's Issues
cPanel error due to addHtaccess function
[2014-04-16 15:49:36 -0500] warn [cpanel] Unable to run [Cpanel::Fileman::api2_listfiles(2/8)]; (Operation `ne': no method found,
left argument in overloaded package JSON::XS::Boolean,
right argument has no overloaded magic at /usr/local/cpanel/Cpanel/Fileman.pm line 507, <$inputfd> line 8.
) at /usr/local/cpanel/Cpanel/Api2/Exec.pm line 121
Cpanel::Api2::Exec::api2_exec('Fileman', 'listfiles', HASH(0x38e0dd0), HASH(0x3892500)) called at cpanel line 1302
This function works better:
function addHtaccess($htaccess,$dirs){
global $cpanel;
$mDomain = "m." . $domain;
$htaccess = preg_replace('//', $mDomain, $htaccess);
$extracontent="#duda_mobile_section_start\r\n".$htaccess."\r\n#duda_mobile_section_end\r\n";
foreach($dirs as $dir){
$htaccessexists=false;
$apiresult = $cpanel->api2( 'Fileman', 'listfiles', array('dir'=>$dir, 'types' => 'file', 'showdotfiles' => 1 ) );
foreach($apiresult['cpanelresult']['data'] as $scan){
if($scan['file']=='.htaccess'){
$htaccessexists=true;
$apiresult = $cpanel->api2( 'Fileman', 'viewfile', array('dir'=>$dir,'file'=>'.htaccess') );
if($apiresult['cpanelresult']['data'][0]['fileinfo']=='empty' || substr($apiresult['cpanelresult']['data'][0]['contents'],0,7)=='<iframe') {
$content='';
} else {
$content=$apiresult['cpanelresult']['data'][0]['contents'];
}
if(strpos($content,'duda_mobile_section')===false) {
$newcontent=$extracontent.$content;
} else {
$newcontent=$content;
}
if(!$htaccessexists) {
$newcontent=$extracontent;
}
$cpanel->api1( 'Fileman', 'fmsavefile', array(0=>$dir,1=>'.htaccess',2=>$newcontent) );
}
}
}
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.