本文整理汇总了PHP中dol_osencode函数的典型用法代码示例。如果您正苦于以下问题:PHP dol_osencode函数的具体用法?PHP dol_osencode怎么用?PHP dol_osencode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dol_osencode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkLoginPassEntity
/**
* Return a login if login/pass was successfull
*
* @param string $usertotest Login value to test
* @param string $passwordtotest Password value to test
* @param string $entitytotest Instance of data we must check
* @param array $authmode Array list of selected authentication mode array('http', 'dolibarr', 'xxx'...)
* @return string Login or ''
*/
function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode)
{
global $conf, $langs;
//global $dolauthmode; // To return authentication finally used
// Check parameters
if ($entitytotest == '') {
$entitytotest = 1;
}
dol_syslog("checkLoginPassEntity usertotest=" . $usertotest . " entitytotest=" . $entitytotest . " authmode=" . join(',', $authmode));
$login = '';
// Validation of login/pass/entity with standard modules
if (empty($login)) {
$test = true;
foreach ($authmode as $mode) {
if ($test && $mode && !$login) {
// Validation of login/pass/entity for mode $mode
$mode = trim($mode);
$authfile = 'functions_' . $mode . '.php';
$fullauthfile = '';
$dirlogin = array_merge(array("/core/login"), (array) $conf->modules_parts['login']);
foreach ($dirlogin as $reldir) {
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
// Check if file found (do not use dol_is_file to avoid loading files.lib.php)
if (is_file($newdir . '/' . $authfile)) {
$fullauthfile = $newdir . '/' . $authfile;
}
}
$result = false;
if ($fullauthfile) {
$result = (include_once $fullauthfile);
}
if ($fullauthfile && $result) {
// Call function to check user/password
$function = 'check_user_password_' . $mode;
$login = call_user_func($function, $usertotest, $passwordtotest, $entitytotest);
if ($login) {
$test = false;
// To stop once at first login success
$conf->authmode = $mode;
// This properties is defined only when logged to say what mode was successfully used
$dol_tz = GETPOST('tz');
$dol_dst = GETPOST('dst');
$dol_screenwidth = GETPOST('screenwidth');
$dol_screenheight = GETPOST('screenheight');
}
} else {
dol_syslog("Authentification ko - failed to load file '" . $authfile . "'", LOG_ERR);
sleep(1);
$langs->load('main');
$langs->load('other');
$_SESSION["dol_loginmesg"] = $langs->trans("ErrorFailedToLoadLoginFileForMode", $mode);
}
}
}
}
return $login;
}
示例2: getTriggersList
/**
* Return list of triggers. Function used by admin page htdoc/admin/triggers.
* List is sorted by trigger filename so by priority to run.
*
* @return array Array list of triggers
*/
function getTriggersList()
{
global $conf, $langs;
$files = array();
$fullpath = array();
$relpath = array();
$iscoreorexternal = array();
$modules = array();
$orders = array();
$i = 0;
$dirtriggers = array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']);
foreach ($dirtriggers as $reldir) {
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
//print "xx".$dir;exit;
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
if (!is_dir($newdir)) {
continue;
}
$handle = opendir($newdir);
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (is_readable($newdir . '/' . $file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\\.class\\.php/', $file, $reg)) {
$part1 = $reg[1];
$part2 = $reg[2];
$part3 = $reg[3];
$modName = 'Interface' . ucfirst($reg[3]);
//print "file=$file"; print "modName=$modName"; exit;
if (in_array($modName, $modules)) {
$langs->load("errors");
print '<div class="error">' . $langs->trans("Error") . ' : ' . $langs->trans("ErrorDuplicateTrigger", $modName, "/htdocs/core/triggers/") . '</div>';
} else {
include_once $newdir . '/' . $file;
}
$files[$i] = $file;
$fullpath[$i] = $dir . '/' . $file;
$relpath[$i] = preg_replace('/^\\//', '', $reldir) . '/' . $file;
$iscoreorexternal[$i] = $reldir == '/core/triggers/' ? 'internal' : 'external';
$modules[$i] = $modName;
$orders[$i] = $part1 . '_' . $part2 . '_' . $part3;
// Set sort criteria value
$i++;
}
}
closedir($handle);
}
}
asort($orders);
$triggers = array();
$j = 0;
// Loop on each trigger
foreach ($orders as $key => $value) {
$modName = $modules[$key];
if (empty($modName)) {
continue;
}
if (!class_exists($modName)) {
print 'Error: A trigger file was found but its class "' . $modName . '" was not found.' . "<br>\n";
continue;
}
$objMod = new $modName($this->db);
// Define disabledbyname and disabledbymodule
$disabledbyname = 0;
$disabledbymodule = 1;
$module = '';
// Check if trigger file is disabled by name
if (preg_match('/NORUN$/i', $files[$key])) {
$disabledbyname = 1;
}
// Check if trigger file is for a particular module
if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\\.class\\.php/i', $files[$key], $reg)) {
$module = preg_replace('/^mod/i', '', $reg[2]);
$constparam = 'MAIN_MODULE_' . strtoupper($module);
if (strtolower($reg[2]) == 'all') {
$disabledbymodule = 0;
} else {
if (empty($conf->global->{$constparam})) {
$disabledbymodule = 2;
}
}
}
// We set info of modules
$triggers[$j]['picto'] = $objMod->picto ? img_object('', $objMod->picto) : img_object('', 'generic');
$triggers[$j]['file'] = $files[$key];
$triggers[$j]['fullpath'] = $fullpath[$key];
$triggers[$j]['relpath'] = $relpath[$key];
$triggers[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
$triggers[$j]['version'] = $objMod->getVersion();
$triggers[$j]['status'] = img_picto($langs->trans("Active"), 'tick');
if ($disabledbyname > 0 || $disabledbymodule > 1) {
$triggers[$j]['status'] = " ";
}
$text = '<b>' . $langs->trans("Description") . ':</b><br>';
$text .= $objMod->getDesc() . '<br>';
//.........这里部分代码省略.........
示例3: add_photo_web
/**
* Deplace fichier recupere sur internet (utilise pour interface avec OSC)
*
* @param string $sdir Repertoire destination finale
* @param string $file url de l'image
* @param int $idprod Product id where store the image
* @return void
*/
function add_photo_web($sdir, $file, $idprod)
{
$dir = $sdir . '/' . get_exdir($idprod, 2) . $idprod . "/";
$dir .= "photos/";
$dir_osencoded = dol_osencode($dir);
if (!file_exists($dir_osencoded)) {
dol_syslog("Product Create " . $dir);
dol_mkdir($dir);
}
if (file_exists($dir_osencoded)) {
// Cree fichier en taille vignette
// TODO A faire
// Cree fichier en taille origine
$content = @file_get_contents($file);
if ($content) {
$nom = basename($file);
$im = fopen(dol_osencode($dir . $nom), 'wb');
fwrite($im, $content);
fclose($im);
}
}
}
示例4: dol_print_error
// This test is to avoid error images when image is not available (for example thumbs).
if (! dol_is_file($original_file))
{
$original_file=DOL_DOCUMENT_ROOT.'/theme/common/nophoto.jpg';
/*$error='Error: File '.$_GET["file"].' does not exists or filesystems permissions are not allowed';
dol_print_error(0,$error);
print $error;
exit;*/
}
// Les drois sont ok et fichier trouve
if ($type)
{
header('Content-Disposition: inline; filename="'.basename($original_file).'"');
header('Content-type: '.$type);
}
else
{
header('Content-Disposition: inline; filename="'.basename($original_file).'"');
header('Content-type: image/png');
}
$original_file_osencoded=dol_osencode($original_file);
readfile($original_file_osencoded);
}
if (is_object($db)) $db->close();
?>
示例5: load_arrays
/**
* Load an exportable dataset
*
* @param User $user Object user making export
* @param string $filter Load a particular dataset only
* @return int <0 if KO, >0 if OK
*/
function load_arrays($user, $filter = '')
{
global $langs, $conf, $mysoc;
dol_syslog(get_class($this) . "::load_arrays user=" . $user->id . " filter=" . $filter);
$var = true;
$i = 0;
// Define list of modules directories into modulesdir
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
$modulesdir = dolGetModulesDirs();
foreach ($modulesdir as $dir) {
// Search available exports
$handle = @opendir(dol_osencode($dir));
if (is_resource($handle)) {
// Search module files
while (($file = readdir($handle)) !== false) {
if (is_readable($dir . $file) && preg_match("/^(mod.*)\\.class\\.php\$/i", $file, $reg)) {
$modulename = $reg[1];
// Defined if module is enabled
$enabled = true;
$part = strtolower(preg_replace('/^mod/i', '', $modulename));
if ($part == 'propale') {
$part = 'propal';
}
if (empty($conf->{$part}->enabled)) {
$enabled = false;
}
if ($enabled) {
// Chargement de la classe
$file = $dir . $modulename . ".class.php";
$classname = $modulename;
require_once $file;
$module = new $classname($this->db);
if (isset($module->export_code) && is_array($module->export_code)) {
foreach ($module->export_code as $r => $value) {
//print $i.'-'.$filter.'-'.$modulename.'-'.join(',',$module->export_code).'<br>';
if ($filter && $filter != $module->export_code[$r]) {
continue;
}
// Test if condition to show are ok
if (!empty($module->export_enabled[$r]) && !verifCond($module->export_enabled[$r])) {
continue;
}
// Test if permissions are ok
$bool = true;
foreach ($module->export_permission[$r] as $val) {
$perm = $val;
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
if (!empty($perm[2])) {
$bool = $user->rights->{$perm}[0]->{$perm}[1]->{$perm}[2];
} else {
$bool = $user->rights->{$perm}[0]->{$perm}[1];
}
if ($perm[0] == 'user' && $user->admin) {
$bool = true;
}
if (!$bool) {
break;
}
}
//print $bool." $perm[0]"."<br>";
// Permissions ok
// if ($bool)
// {
// Charge fichier lang en rapport
$langtoload = $module->getLangFilesArray();
if (is_array($langtoload)) {
foreach ($langtoload as $key) {
$langs->load($key);
}
}
// Module
$this->array_export_module[$i] = $module;
// Permission
$this->array_export_perms[$i] = $bool;
// Icon
$this->array_export_icon[$i] = isset($module->export_icon[$r]) ? $module->export_icon[$r] : $module->picto;
// Code du dataset export
$this->array_export_code[$i] = $module->export_code[$r];
// Libelle du dataset export
$this->array_export_label[$i] = $module->getExportDatasetLabel($r);
// Tableau des champ a exporter (cle=champ, valeur=libelle)
$this->array_export_fields[$i] = $module->export_fields_array[$r];
// Tableau des champs a filtrer (cle=champ, valeur1=type de donnees) on verifie que le module a des filtres
$this->array_export_TypeFields[$i] = isset($module->export_TypeFields_array[$r]) ? $module->export_TypeFields_array[$r] : '';
// Tableau des entites a exporter (cle=champ, valeur=entite)
$this->array_export_entities[$i] = $module->export_entities_array[$r];
// Tableau des entites qui requiert abandon du DISTINCT (cle=entite, valeur=champ id child records)
$this->array_export_dependencies[$i] = !empty($module->export_dependencies_array[$r]) ? $module->export_dependencies_array[$r] : '';
// Tableau des operations speciales sur champ
$this->array_export_special[$i] = !empty($module->export_special_array[$r]) ? $module->export_special_array[$r] : '';
// Requete sql du dataset
$this->array_export_sql_start[$i] = $module->export_sql_start[$r];
$this->array_export_sql_end[$i] = $module->export_sql_end[$r];
//.........这里部分代码省略.........
示例6: _encode_file
/**
* Read a file on disk and return encoded content for emails (mode = 'mail')
*
* @param string $sourcefile Path to file to encode
* @return int <0 if KO, encoded string if OK
*/
function _encode_file($sourcefile)
{
$newsourcefile = dol_osencode($sourcefile);
if (is_readable($newsourcefile)) {
$contents = file_get_contents($newsourcefile);
// Need PHP 4.3
$encoded = chunk_split(base64_encode($contents), 76, $this->eol);
// 76 max is defined into http://tools.ietf.org/html/rfc2047
return $encoded;
} else {
$this->error = "Error: Can't read file '" . $sourcefile . "' into _encode_file";
dol_syslog("CMailFile::encode_file: " . $this->error, LOG_ERR);
return -1;
}
}
示例7: getImageProduct
/**
* Return path of a catergory image
*
* @param int $idCat Id of Category
* @return string Image path
*/
public static function getImageProduct($idProd, $thumb = false)
{
global $conf, $db;
$extName = "_small";
$extImgTarget = ".jpg";
$outDir = "pos";
$maxWidth = 90;
$maxHeight = 90;
$quality = 50;
if ($idProd > 0) {
$objProd = new Product($db);
$objProd->fetch($idProd);
$pdir = get_exdir($idProd, 2) . $idProd . "/photos/";
$dir = $conf->product->multidir_output[$objProd->entity] . '/' . $pdir;
foreach ($objProd->liste_photos($dir, 1) as $key => $obj) {
$filename = $dir . $obj['photo'];
$filethumbs = $dir . $outDir . '/' . $obj['photo'];
$fileName = preg_replace('/(\\.gif|\\.jpeg|\\.jpg|\\.png|\\.bmp)$/i', '', $filethumbs);
$fileName = basename($fileName);
$imgThumbName = $dir . $outDir . '/' . $fileName . $extName . $extImgTarget;
$file_osencoded = $imgThumbName;
if (!file_exists($file_osencoded)) {
$file_osencoded = dol_osencode($filename);
if (file_exists($file_osencoded)) {
require_once DOL_DOCUMENT_ROOT . "/core/lib/images.lib.php";
vignette($filename, $maxWidth, $maxHeight, $extName, $quality, $outDir, 2);
}
}
if (!$thumb) {
$filename = $obj['photo'];
} else {
$filename = $outDir . '/' . $fileName . $extName . $extImgTarget;
}
$realpath = DOL_URL_ROOT . '/viewimage.php?modulepart=product&entity=' . $objProd->entity . '&file=' . urlencode($pdir . $filename);
}
if (!$realpath) {
$realpath = DOL_URL_ROOT . '/viewimage.php?modulepart=product&file=' . urlencode('noimage.jpg');
}
return $realpath;
}
}
示例8: get_image_size
/**
* Load size of image file
*
* @param string $file Path to file
* @return void
*/
function get_image_size($file)
{
$file_osencoded = dol_osencode($file);
$infoImg = getimagesize($file_osencoded);
// Get information on image
$this->imgWidth = $infoImg[0];
// Largeur de l'image
$this->imgHeight = $infoImg[1];
// Hauteur de l'image
}
示例9: complete_elementList_with_modules
/**
* Add external modules to list of contact element
*
* @param array $elementList elementList
* @return int 1
*/
function complete_elementList_with_modules(&$elementList)
{
global $db, $modules, $conf, $langs;
// Search modules
$filename = array();
$modules = array();
$orders = array();
$categ = array();
$dirmod = array();
$i = 0;
// is a sequencer of modules found
$j = 0;
// j is module number. Automatically affected if module number not defined.
$modulesdir = dolGetModulesDirs();
foreach ($modulesdir as $dir) {
// Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>";
dol_syslog("Scan directory " . $dir . " for modules");
$handle = @opendir(dol_osencode($dir));
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
//print "$i ".$file."\n<br>";
if (is_readable($dir . $file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
$modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName) {
include_once $dir . $file;
$objMod = new $modName($db);
if ($objMod->numero > 0) {
$j = $objMod->numero;
} else {
$j = 1000 + $i;
}
$modulequalified = 1;
// We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_' . strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && !$conf->global->{$const_name}) {
$modulequalified = 0;
}
if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && !$conf->global->{$const_name}) {
$modulequalified = 0;
}
//If module is not activated disqualified
if (empty($conf->global->{$const_name})) {
$modulequalified = 0;
}
if ($modulequalified) {
// Load languages files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
foreach ($objMod->langfiles as $langfile) {
$langs->load($langfile);
}
}
$modules[$i] = $objMod;
$filename[$i] = $modName;
$orders[$i] = $objMod->family . "_" . $j;
// Tri par famille puis numero module
//print "x".$modName." ".$orders[$i]."\n<br>";
if (isset($categ[$objMod->special])) {
$categ[$objMod->special]++;
} else {
$categ[$objMod->special] = 1;
}
$dirmod[$i] = $dirroot;
if (!empty($objMod->module_parts['contactelement'])) {
$elementList[$objMod->name] = $langs->trans($objMod->name);
//exit;
}
$j++;
$i++;
} else {
dol_syslog("Module " . get_class($objMod) . " not qualified");
}
}
}
}
closedir($handle);
} else {
dol_syslog("htdocs/admin/modules.php: Failed to open directory " . $dir . ". See permission and open_basedir option.", LOG_WARNING);
}
}
return 1;
}
示例10: complete_dictionnary_with_modules
/**
* Add external modules to list of dictionnaries
*
* @param array &$taborder Taborder
* @param array &$tabname Tabname
* @param array &$tablib Tablib
* @param array &$tabsql Tabsql
* @param array &$tabsqlsort Tabsqlsort
* @param array &$tabfield Tabfield
* @param array &$tabfieldvalue Tabfieldvalue
* @param array &$tabfieldinsert Tabfieldinsert
* @param array &$tabrowid Tabrowid
* @param array &$tabcond Tabcond
* @param array &$tabhelp Tabhelp
* @return int 1
*/
function complete_dictionnary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp)
{
global $db, $modules, $conf, $langs;
// Search modules
$filename = array();
$modules = array();
$orders = array();
$categ = array();
$dirmod = array();
$modulesdir = array();
$i = 0;
// is a sequencer of modules found
$j = 0;
// j is module number. Automatically affected if module number not defined.
foreach ($conf->file->dol_document_root as $type => $dirroot) {
$modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/';
$handle = @opendir($dirroot);
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (is_dir($dirroot . '/' . $file) && substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS' && $file != 'includes') {
if (is_dir($dirroot . '/' . $file . '/core/modules/')) {
$modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/';
}
}
}
closedir($handle);
}
}
//var_dump($modulesdir);
foreach ($modulesdir as $dir) {
// Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>";
dol_syslog("Scan directory " . $dir . " for modules");
$handle = @opendir(dol_osencode($dir));
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
//print "$i ".$file."\n<br>";
if (is_readable($dir . $file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
$modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName) {
include_once $dir . $file;
$objMod = new $modName($db);
if ($objMod->numero > 0) {
$j = $objMod->numero;
} else {
$j = 1000 + $i;
}
$modulequalified = 1;
// We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_' . strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && !$conf->global->{$const_name}) {
$modulequalified = 0;
}
if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && !$conf->global->{$const_name}) {
$modulequalified = 0;
}
if ($modulequalified) {
// Load languages files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
foreach ($objMod->langfiles as $langfile) {
$langs->load($langfile);
}
}
$modules[$i] = $objMod;
$filename[$i] = $modName;
$orders[$i] = $objMod->family . "_" . $j;
// Tri par famille puis numero module
//print "x".$modName." ".$orders[$i]."\n<br>";
if (isset($categ[$objMod->special])) {
$categ[$objMod->special]++;
} else {
$categ[$objMod->special] = 1;
}
$dirmod[$i] = $dirroot;
// Complete arrays
//&$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond
//$objMod
if (!empty($objMod->dictionnaries)) {
//var_dump($objMod->dictionnaries['tabname']);
$taborder[] = 0;
foreach ($objMod->dictionnaries['tabname'] as $val) {
$taborder[] = count($tabname) + 1;
$tabname[] = $val;
}
//.........这里部分代码省略.........
示例11: add_thumb
/**
* Build thumb
*
* @param string $file Path file in UTF8 to original file to create thumbs from.
* @return void
*/
function add_thumb($file)
{
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
// This define also $maxwidthsmall, $quality, ...
$file_osencoded = dol_osencode($file);
if (file_exists($file_osencoded)) {
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
vignette($file_osencoded, $maxwidthsmall, $maxheightsmall, '_small', $quality);
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
vignette($file_osencoded, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}
示例12: dol_compress_file
/**
* Compress a file
*
* @param string $inputfile Source file name
* @param string $outputfile Target file name
* @param string $mode 'gz' or 'bz' or 'zip'
* @return int <0 if KO, >0 if OK
*/
function dol_compress_file($inputfile, $outputfile, $mode = "gz")
{
$foundhandler = 0;
try {
$data = implode("", file(dol_osencode($inputfile)));
if ($mode == 'gz') {
$foundhandler = 1;
$compressdata = gzencode($data, 9);
} elseif ($mode == 'bz') {
$foundhandler = 1;
$compressdata = bzcompress($data, 9);
} elseif ($mode == 'zip') {
if (defined('ODTPHP_PATHTOPCLZIP')) {
$foundhandler = 1;
include_once ODTPHP_PATHTOPCLZIP . '/pclzip.lib.php';
$archive = new PclZip($outputfile);
$archive->add($inputfile, PCLZIP_OPT_REMOVE_PATH, dirname($inputfile));
//$archive->add($inputfile);
return 1;
}
}
if ($foundhandler) {
$fp = fopen($outputfile, "w");
fwrite($fp, $compressdata);
fclose($fp);
return 1;
} else {
dol_syslog("Try to zip with format " . $mode . " with no handler for this format", LOG_ERR);
return -2;
}
} catch (Exception $e) {
global $langs, $errormsg;
$langs->load("errors");
dol_syslog("Failed to open file " . $outputfile, LOG_ERR);
$errormsg = $langs->trans("ErrorFailedToWriteInDir");
return -1;
}
}
示例13: while
$obj = 'facture';
}
if (empty($conf->{$module}->enabled)) {
$enabled = false;
}
if ($enabled) {
/*
* If exists, load the API class for enable module
*
* Search files named api_<object>.class.php into /htdocs/<module>/class directory
*
* @todo : take care of externals module!
* @todo : use getElementProperties() function ?
*/
$dir_part = DOL_DOCUMENT_ROOT . '/' . $part . '/class/';
$handle_part = @opendir(dol_osencode($dir_part));
if (is_resource($handle_part)) {
while (($file_searched = readdir($handle_part)) !== false) {
if (is_readable($dir_part . $file_searched) && preg_match("/^(api_.*)\\.class\\.php\$/i", $file_searched, $reg)) {
$classname = $reg[1];
$classname = str_replace('Api_', '', ucwords($reg[1])) . 'Api';
$classname = ucfirst($classname);
require_once $dir_part . $file_searched;
if (class_exists($classname)) {
dol_syslog("Found API classname=" . $classname);
$api->r->addAPIClass($classname, '');
$listofapis[] = array('classname' => $classname, 'fullpath' => $file_searched);
}
}
}
}
示例14: dol_delete_dir_recursive
/**
* Remove a directory $dir and its subdirectories
* @param dir Dir to delete
* @param count Counter to count nb of deleted elements
* @param nophperrors Disable all PHP output errors
* @return int Number of files and directory removed
*/
function dol_delete_dir_recursive($dir,$count=0,$nophperrors=0)
{
dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir,LOG_DEBUG);
if (dol_is_dir($dir))
{
$dir_osencoded=dol_osencode($dir);
if ($handle = opendir("$dir_osencoded"))
{
while (false !== ($item = readdir($handle)))
{
if (! utf8_check($item)) $item=utf8_encode($item); // should be useless
if ($item != "." && $item != "..")
{
if (is_dir(dol_osencode("$dir/$item")))
{
$count=dol_delete_dir_recursive("$dir/$item",$count,$nophperrors);
}
else
{
dol_delete_file("$dir/$item",1,$nophperrors);
$count++;
//echo " removing $dir/$item<br>\n";
}
}
}
closedir($handle);
dol_delete_dir($dir,$nophperrors);
$count++;
//echo "removing $dir<br>\n";
}
}
//echo "return=".$count;
return $count;
}
示例15: getLabelFromNumber
/**
* Return full text translated to language label for a key. Store key-label in a cache.
* This function need module "numberwords" to be installed. If not it will return
* same number (this module is not provided by default as it use non GPL source code).
*
* @param int $number Number to encode in full text
* @param int $isamount 1=It's an amount, 0=it's just a number
* @return string Label translated in UTF8 (but without entities)
* 10 if setDefaultLang was en_US => ten
* 123 if setDefaultLang was fr_FR => cent vingt trois
*/
function getLabelFromNumber($number, $isamount = 0)
{
global $conf;
$newnumber = $number;
$dirsubstitutions = array_merge(array(), $conf->modules_parts['substitutions']);
foreach ($dirsubstitutions as $reldir) {
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
// Check if directory exists
if (!is_dir($newdir)) {
continue;
}
// We must not use dol_is_dir here, function may not be loaded
$fonc = 'numberwords';
if (file_exists($newdir . '/functions_' . $fonc . '.lib.php')) {
include_once $newdir . '/functions_' . $fonc . '.lib.php';
$newnumber = numberwords_getLabelFromNumber($this, $number, $isamount);
break;
}
}
return $newnumber;
}