本文整理汇总了PHP中dol_delete_file函数的典型用法代码示例。如果您正苦于以下问题:PHP dol_delete_file函数的具体用法?PHP dol_delete_file怎么用?PHP dol_delete_file使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dol_delete_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Delete a project from database
* @param user User
* @param notrigger Disable triggers
* @return int <0 if KO, 0 if not possible, >0 if OK
*/
function delete($user, $notrigger=0)
{
global $langs,$conf;
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0;
$this->db->begin();
if (! $error)
{
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0)
{
$this->error='ErrorFailToDeleteLinkedContact';
//$error++;
$this->db->rollback();
return 0;
}
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task";
$sql.= " WHERE fk_projet=".$this->id;
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet";
$sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
// We remove directory
$projectref = dol_sanitizeFileName($this->ref);
if ($conf->projet->dir_output)
{
$dir = $conf->projet->dir_output . "/" . $projectref ;
$file = $conf->projet->dir_output . "/" . $projectref . "/" . $projectref . ".pdf";
if (file_exists($file))
{
//project_delete_preview($this->db, $this->id, $this->ref);
if (!dol_delete_file($file))
{
$this->error='ErrorFailToDeleteFile';
$this->db->rollback();
return 0;
}
}
if (file_exists($dir))
{
$res=@dol_delete_dir($dir);
if (! $res)
{
$this->error='ErrorFailToDeleteDir';
$this->db->rollback();
return 0;
}
}
}
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('PROJECT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
dol_syslog("Project::delete sql=".$sql, LOG_DEBUG);
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog("Project::delete ".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
}
示例2: preg_match
preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=$reg[1];
}
if ($id || $ref)
{
//print 'Fetch '.$id.' or '.$ref.'<br>';
$result=$object_instance->fetch($id,$ref);
//print $result.'<br>';
if ($result == 0) // Not found but no error
{
// Clean of orphelins directories are done into repair.php
print '<tr><td colspan="2">';
print 'Delete orphelins file '.$file['fullname'].'<br>';
if (GETPOST('purge') == 2)
{
dol_delete_file($file['fullname'],1,1,1);
dol_delete_dir(dirname($file['fullname']),1);
}
print "</td></tr>";
}
else if ($result < 0) print 'Error in '.get_class($object_instance).'.fetch of id'.$id.' ref='.$ref.', result='.$result.'<br>';
}
}
}
}
}
print '</table>';
示例3: dol_print_error
if (GETPOST('confirm') == 'yes') {
$langs->load("other");
if ($section) {
$result = $ecmdir->fetch($section);
if (!($result > 0)) {
dol_print_error($db, $ecmdir->error);
exit;
}
$relativepath = $ecmdir->getRelativePath();
} else {
$relativepath = '';
}
$upload_dir = $conf->ecm->dir_output . ($relativepath ? '/' . $relativepath : '');
$file = $upload_dir . "/" . GETPOST('urlfile');
// Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
$ret = dol_delete_file($file);
if ($ret) {
setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
} else {
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
}
$result = $ecmdir->changeNbOfFiles('-');
clearstatcache();
}
$action = 'file_manager';
}
// Remove directory
if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') {
$result = $ecmdir->delete($user);
setEventMessage($langs->trans("ECMSectionWasRemoved", $ecmdir->label));
clearstatcache();
示例4: validate
//.........这里部分代码省略.........
}
}
if ($num) {
$this->update_price(1);
// Validate
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture';
$sql .= " SET facnumber='" . $num . "', fk_statut = 1, fk_user_valid = " . $user->id . ", date_valid = '" . $this->db->idate($now) . "'";
if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
$sql .= ', datef=' . $this->db->idate($this->date);
$sql .= ', date_lim_reglement=' . $this->db->idate($this->date_lim_reglement);
}
$sql .= ' WHERE rowid = ' . $this->id;
dol_syslog(get_class($this) . "::validate sql=" . $sql);
$resql = $this->db->query($sql);
if (!$resql) {
dol_syslog(get_class($this) . "::validate Echec update - 10 - sql=" . $sql, LOG_ERR);
dol_print_error($this->db);
$error++;
}
// On verifie si la facture etait une provisoire
if (!$error && preg_match('/^[\\(]?PROV/i', $this->ref)) {
// La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne
}
if (!$error) {
// Define third party as a customer
$result = $this->client->set_as_client();
// Si active on decremente le produit principal et ses composants a la validation de facture
if ($this->type != 3 && $result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL) {
require_once DOL_DOCUMENT_ROOT . "/product/stock/class/mouvementstock.class.php";
$langs->load("agenda");
// Loop on each line
$cpt = count($this->lines);
for ($i = 0; $i < $cpt; $i++) {
if ($this->lines[$i]->fk_product > 0) {
$mouvP = new MouvementStock($this->db);
// We decrease stock for product
if ($this->type == 2) {
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num));
} else {
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num));
}
if ($result < 0) {
$error++;
}
}
}
}
}
if (!$error) {
$this->oldref = '';
// Rename directory if dir was a temporary ref
if (preg_match('/^[\\(]?PROV/i', $this->ref)) {
// On renomme repertoire facture ($this->ref = ancienne ref, $num = nouvelle ref)
// afin de ne pas perdre les fichiers attaches
$facref = dol_sanitizeFileName($this->ref);
$snumfa = dol_sanitizeFileName($num);
$dirsource = $conf->facture->dir_output . '/' . $facref;
$dirdest = $conf->facture->dir_output . '/' . $snumfa;
if (file_exists($dirsource)) {
dol_syslog(get_class($this) . "::validate rename dir " . $dirsource . " into " . $dirdest);
if (@rename($dirsource, $dirdest)) {
$this->oldref = $facref;
dol_syslog("Rename ok");
// Suppression ancien fichier PDF dans nouveau rep
dol_delete_file($conf->facture->dir_output . '/' . $snumfa . '/' . $facref . '.*');
}
}
}
}
// Set new ref and define current statut
if (!$error) {
$this->ref = $num;
$this->facnumber = $num;
$this->statut = 1;
$this->date_validation = $now;
}
// Trigger calls
if (!$error) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('BILL_VALIDATE', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
} else {
$error++;
}
if (!$error) {
$this->db->commit();
return 1;
} else {
$this->db->rollback();
$this->error = $this->db->lasterror();
return -1;
}
}
示例5: delete
//.........这里部分代码省略.........
$error++;
dol_syslog(get_class($this) . "::delete error deleteExtraFields " . $this->error, LOG_ERR);
}
}
if (!$error) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {
$error++;
}
}
if (!$error) {
// If invoice was converted into a discount not yet consumed, we remove discount
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'societe_remise_except';
$sql .= ' WHERE fk_facture_source = ' . $rowid;
$sql .= ' AND fk_facture_line IS NULL';
$resql = $this->db->query($sql);
// If invoice has consumned discounts
$this->fetch_lines();
$list_rowid_det = array();
foreach ($this->lines as $key => $invoiceline) {
$list_rowid_det[] = $invoiceline->rowid;
}
// Consumned discounts are freed
if (count($list_rowid_det)) {
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except';
$sql .= ' SET fk_facture = NULL, fk_facture_line = NULL';
$sql .= ' WHERE fk_facture_line IN (' . join(',', $list_rowid_det) . ')';
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->error() . " sql=" . $sql;
$this->db->rollback();
return -5;
}
}
// If we decrement stock on invoice validation, we increment
if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) {
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php';
$langs->load("agenda");
$num = count($this->lines);
for ($i = 0; $i < $num; $i++) {
if ($this->lines[$i]->fk_product > 0) {
$mouvP = new MouvementStock($this->db);
$mouvP->origin =& $this;
// We decrease stock for product
if ($this->type == self::TYPE_CREDIT_NOTE) {
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref));
} else {
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr", $this->ref));
}
// we use 0 for price, to not change the weighted average value
}
}
}
// Delete invoice line
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE fk_facture = ' . $rowid;
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
if ($this->db->query($sql) && $this->delete_linked_contact()) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facture WHERE rowid = ' . $rowid;
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
// On efface le repertoire de pdf provisoire
$ref = dol_sanitizeFileName($this->ref);
if ($conf->facture->dir_output && !empty($this->ref)) {
$dir = $conf->facture->dir_output . "/" . $ref;
$file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf";
if (file_exists($file)) {
$ret = dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = $langs->trans("ErrorCanNotDeleteFile", $file);
$this->db->rollback();
return 0;
}
}
if (file_exists($dir)) {
if (!dol_delete_dir_recursive($dir)) {
$this->error = $langs->trans("ErrorCanNotDeleteDir", $dir);
$this->db->rollback();
return 0;
}
}
}
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror() . " sql=" . $sql;
$this->db->rollback();
return -6;
}
} else {
$this->error = $this->db->lasterror() . " sql=" . $sql;
$this->db->rollback();
return -4;
}
} else {
$this->db->rollback();
return -2;
}
}
示例6: delete
/**
* Delete an order
*
* @param User $user Object user
* @return int <0 if KO, >0 if OK
*/
function delete($user = '')
{
global $langs, $conf;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$error = 0;
// Call trigger
$result = $this->call_trigger('ORDER_SUPPLIER_DELETE', $user);
if ($result < 0) {
$this->errors[] = 'ErrorWhenRunningTrigger';
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
return -1;
}
// End call triggers
$this->db->begin();
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet WHERE fk_commande =" . $this->id;
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "commande_fournisseur WHERE rowid =" . $this->id;
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
if ($resql = $this->db->query($sql)) {
if ($this->db->affected_rows($resql) < 1) {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}
} else {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}
// Remove extrafields
if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$result = $this->deleteExtraFields();
if ($result < 0) {
$this->error = 'FailToDeleteExtraFields';
$this->errors[] = 'FailToDeleteExtraFields';
$error++;
dol_syslog(get_class($this) . "::delete error -4 " . $this->error, LOG_ERR);
}
}
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {
$this->error = 'FailToDeleteObjectLinked';
$this->errors[] = 'FailToDeleteObjectLinked';
$error++;
}
if (!$error) {
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->fournisseur->commande->dir_output) {
$dir = $conf->fournisseur->commande->dir_output . "/" . $ref;
$file = $dir . "/" . $ref . ".pdf";
if (file_exists($file)) {
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = 'ErrorFailToDeleteFile';
$this->errors[] = 'ErrorFailToDeleteFile';
$error++;
}
}
if (file_exists($dir)) {
$res = @dol_delete_dir_recursive($dir);
if (!$res) {
$this->error = 'ErrorFailToDeleteDir';
$this->errors[] = 'ErrorFailToDeleteDir';
$error++;
}
}
}
}
if (!$error) {
dol_syslog(get_class($this) . "::delete {$this->id} by {$user->id}", LOG_DEBUG);
$this->db->commit();
return 1;
} else {
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
$this->db->rollback();
return -$error;
}
}
示例7: commande_pdf_create
$result = commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'));
if ($result <= 0) {
dol_print_error($db, $result);
exit;
} else {
Header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc'));
exit;
}
}
// Remove file in doc form
if ($action == 'remove_file') {
if ($object->fetch($id)) {
require_once DOL_DOCUMENT_ROOT . "/lib/files.lib.php";
$upload_dir = $conf->commande->dir_output;
$file = $upload_dir . '/' . $_GET['file'];
dol_delete_file($file);
$mesg = '<div class="ok">' . $langs->trans("FileWasRemoved") . '</div>';
}
}
/*
* Add file in email form
*/
if ($_POST['addfile']) {
require_once DOL_DOCUMENT_ROOT . "/lib/files.lib.php";
// Set tmp user directory TODO Use a dedicated directory for temp mails files
$vardir = $conf->user->dir_output . "/" . $user->id;
$upload_dir_tmp = $vardir . '/temp';
$mesg = dol_add_file_process($upload_dir_tmp, 0, 0);
$action = 'presend';
}
/*
示例8: supplier_order_delete_preview
/**
* Delete preview files, pour le cas de regeneration de commande
* @param $db data base object
* @param $comfournid id de la commande a effacer
* @param $comfournref reference de la commande si besoin
* @return int
*/
function supplier_order_delete_preview($db, $comfournid, $comfournref='')
{
global $langs,$conf;
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (!$comfournref)
{
$comfourn = new CommandeFournisseur($db,"",$comfournid);
$comfourn->fetch($comfournid);
$comfournref = $comfourn->ref;
$soc = new Societe($db);
$soc->fetch($comfourn->socid);
}
if ($conf->fournisseur->dir_output.'/commande')
{
$suppordref = dol_sanitizeFileName($comfournref);
$dir = $conf->fournisseur->dir_output . "/" . $suppordref ;
$file = $dir . "/" . $suppordref . ".pdf.png";
$multiple = $file . ".";
if ( file_exists( $file ) && is_writable( $file ) )
{
if ( ! dol_delete_file($file,1) )
{
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
return 0;
}
}
else
{
for ($i = 0; $i < 20; $i++)
{
$preview = $multiple.$i;
if ( file_exists( $preview ) && is_writable( $preview ) )
{
if ( ! dol_delete_file($preview,1) )
{
$this->error=$langs->trans("ErrorFailedToOpenFile",$preview);
return 0;
}
}
}
}
}
return 1;
}
示例9: valid
/**
* Validate an order
* @param user Utilisateur qui valide
*/
function valid($user)
{
global $langs,$conf;
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0;
dol_syslog("CommandeFournisseur::Valid");
$result = 0;
if ($user->rights->fournisseur->commande->valider)
{
$this->db->begin();
// Definition du nom de modele de numerotation de commande
$soc = new Societe($this->db);
$soc->fetch($this->fourn_id);
// Check if object has a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
$num = $this->getNextNumRef($soc);
}
else
{
$num = $this->ref;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " SET ref='".$num."'";
$sql.= ", fk_statut = 1";
$sql.= ", date_valid=".$this->db->idate(mktime());
$sql.= ", fk_user_valid = ".$user->id;
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND fk_statut = 0";
$resql=$this->db->query($sql);
if (! $resql)
{
dol_syslog("CommandeFournisseur::valid() Echec update - 10 - sql=".$sql, LOG_ERR);
dol_print_error($this->db);
$error++;
}
if (! $error)
{
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
// On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref)
// afin de ne pas perdre les fichiers attaches
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->fournisseur->dir_output.'/commande/'.$oldref;
$dirdest = $conf->fournisseur->dir_output.'/commande/'.$newref;
if (file_exists($dirsource))
{
dol_syslog("CommandeFournisseur::valid() rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest))
{
dol_syslog("Rename ok");
// Suppression ancien fichier PDF dans nouveau rep
dol_delete_file($dirdest.'/'.$oldref.'.*');
}
}
}
}
if (! $error)
{
$result = 1;
$this->log($user, 1, time()); // Statut 1
$this->ref = $num;
}
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
dol_syslog("CommandeFournisseur::valid ".$this->error, LOG_ERR);
$this->db->rollback();
$this->error=$this->db->lasterror();
return -1;
//.........这里部分代码省略.........
示例10: dol_sanitizeFileName
}
}
}
}
}
// Delete
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->fetch($id))
{
$object->fetch_thirdparty();
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,'FILE_DELETE',$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
}
}
/*
* View
*/
llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
$html = new Form($db);
if ($id > 0 || ! empty($ref))
{
示例11: dol_dir_list
$filesarray = dol_dir_list($dolibarr_main_data_root, "all", 0, '', 'install\\.lock$');
}
}
if ($choice == 'logfile') {
$filesarray[] = array('fullname' => $filelog, 'type' => 'file');
}
$count = 0;
if (count($filesarray)) {
foreach ($filesarray as $key => $value) {
//print "x ".$filesarray[$key]['fullname']."<br>\n";
if ($filesarray[$key]['type'] == 'dir') {
$count += dol_delete_dir_recursive($filesarray[$key]['fullname']);
} elseif ($filesarray[$key]['type'] == 'file') {
// If (file that is not logfile) or (if logfile with option logfile)
if ($filesarray[$key]['fullname'] != $filelog || $choice == 'logfile') {
$count += dol_delete_file($filesarray[$key]['fullname']);
}
}
}
// Update cachenbofdoc
if (!empty($conf->ecm->enabled) && $choice == 'allfiles') {
require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmdirectory.class.php';
$ecmdirstatic = new EcmDirectory($db);
$result = $ecmdirstatic->refreshcachenboffile(1);
}
}
if ($count) {
$mesg = $langs->trans("PurgeNDirectoriesDeleted", $count);
} else {
$mesg = $langs->trans("PurgeNothingToDelete");
}
示例12: octdec
@chmod($file, octdec($conf->global->MAIN_UMASK));
}
} else {
$mesg = '<div class="error">' . $langs->trans('NoPDFAvailableForChecked') . '</div>';
}
} else {
$mesg = '<div class="error">' . $langs->trans('InvoiceNotChecked') . '</div>';
}
}
// Remove file
if ($action == 'remove_file') {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$langs->load("other");
$upload_dir = $diroutputpdf;
$file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, '');
if ($ret) {
setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
} else {
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
}
$action = '';
}
/*
* View
*/
$form = new Form($db);
$formfile = new FormFile($db);
if (GETPOST('courrier') == 1) {
$title = $langs->trans("BillsByPrintOK");
} else {
示例13: propale_delete_preview
/**
* Delete preview files
* @param db objet base de donnee
* @param propalid id de la propal a effacer
* @param propalref reference de la propal si besoin
*/
function propale_delete_preview($db, $propalid, $propalref = '')
{
global $langs, $conf;
require_once DOL_DOCUMENT_ROOT . "/lib/files.lib.php";
if (!$propalref) {
$propal = new Propal($db, "", $propalid);
$propal->fetch($propalid);
$propalref = $propal->ref;
}
if ($conf->propale->dir_output) {
$propalref = dol_sanitizeFileName($propalref);
$dir = $conf->propale->dir_output . "/" . $propalref;
$file = $dir . "/" . $propalref . ".pdf.png";
$multiple = $file . ".";
if (file_exists($file) && is_writable($file)) {
if (!dol_delete_file($file, 1)) {
$this->error = $langs->trans("ErrorFailedToOpenFile", $file);
return 0;
}
} else {
for ($i = 0; $i < 20; $i++) {
$preview = $multiple . $i;
if (file_exists($preview) && is_writable($preview)) {
if (!unlink($preview)) {
$this->error = $langs->trans("ErrorFailedToOpenFile", $preview);
return 0;
}
}
}
}
}
return 1;
}
示例14: build_exportfile
//.........这里部分代码省略.........
$resql = $this->db->query($sql);
if ($resql) {
// Note: Output of sql request is encoded in $conf->file->character_set_client
while ($obj = $this->db->fetch_object($resql)) {
$qualified = true;
// 'eid','startdate','duration','enddate','title','summary','category','email','url','desc','author'
$event = array();
$event['uid'] = 'dolibarragenda-' . $this->db->database_name . '-' . $obj->id . "@" . $_SERVER["SERVER_NAME"];
$event['type'] = $type;
//$datestart=$obj->datea?$obj->datea:$obj->datep;
//$dateend=$obj->datea2?$obj->datea2:$obj->datep2;
//$duration=$obj->durationa?$obj->durationa:$obj->durationp;
$datestart = $this->db->jdate($obj->datep);
//print $datestart.'x'; exit;
$dateend = $this->db->jdate($obj->datep2);
$duration = $obj->durationp;
$event['summary'] = $langs->convToOutputCharset($obj->label . ($obj->socname ? " (" . $obj->socname . ")" : ""));
$event['desc'] = $langs->convToOutputCharset($obj->note);
$event['startdate'] = $datestart;
$event['duration'] = $duration;
// Not required with type 'journal'
$event['enddate'] = $dateend;
// Not required with type 'journal'
$event['author'] = $obj->firstname . ($obj->name ? " " . $obj->name : "");
$event['priority'] = $obj->priority;
$event['fulldayevent'] = $obj->fulldayevent;
$event['location'] = $langs->convToOutputCharset($obj->location);
$event['transparency'] = 'TRANSPARENT';
// OPAQUE (busy) or TRANSPARENT (not busy)
$event['category'] = $langs->convToOutputCharset($obj->libelle);
// libelle type action
$urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', $dolibarr_main_url_root);
$url = $urlwithouturlroot . DOL_URL_ROOT . '/comm/action/fiche.php?id=' . $obj->id;
$event['url'] = $url;
$event['created'] = $this->db->jdate($obj->datec);
$event['modified'] = $this->db->jdate($obj->datem);
if ($qualified && $datestart) {
$eventarray[$datestart] = $event;
}
}
} else {
$this->error = $this->db->lasterror();
dol_syslog("ActionComm::build_exportfile " . $this->db->lasterror(), LOG_ERR);
return -1;
}
$langs->load("agenda");
// Define title and desc
$more = '';
if ($login) {
$more = $langs->transnoentities("User") . ' ' . $langs->convToOutputCharset($login);
}
if ($logina) {
$more = $langs->transnoentities("ActionsAskedBy") . ' ' . $langs->convToOutputCharset($logina);
}
if ($logint) {
$more = $langs->transnoentities("ActionsToDoBy") . ' ' . $langs->convToOutputCharset($logint);
}
if ($logind) {
$more = $langs->transnoentities("ActionsDoneBy") . ' ' . $langs->convToOutputCharset($logind);
}
if ($more) {
$title = $langs->convToOutputCharset('Dolibarr actions ' . $mysoc->name) . ' - ' . $more;
$desc = $more;
$desc .= $langs->convToOutputCharset(' (' . $mysoc->name . ' - built by Dolibarr)');
} else {
$title = $langs->convToOutputCharset('Dolibarr actions ' . $mysoc->name);
$desc = $langs->transnoentities('ListOfActions');
$desc .= $langs->convToOutputCharset(' (' . $mysoc->name . ' - built by Dolibarr)');
}
// Create temp file
$outputfiletmp = tempnam($conf->agenda->dir_temp, 'tmp');
// Temporary file (allow call of function by different threads
@chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK));
// Write file
if ($format == 'vcal') {
$result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
}
if ($format == 'ical') {
$result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
}
if ($format == 'rss') {
$result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp);
}
if ($result >= 0) {
if (rename($outputfiletmp, $outputfile)) {
$result = 1;
} else {
dol_syslog("ActionComm::build_exportfile failed to rename " . $outputfiletmp . " to " . $outputfile, LOG_ERR);
dol_delete_file($outputfiletmp, 0, 1);
$result = -1;
}
} else {
dol_syslog("ActionComm::build_exportfile build_xxxfile function fails to for format=" . $format . " outputfiletmp=" . $outputfile, LOG_ERR);
dol_delete_file($outputfiletmp, 0, 1);
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToCreateFile", $outputfile);
}
}
return $result;
}
示例15: fclose
// Close file
if ($compression == 'none') {
fclose($handle);
}
if ($compression == 'gz') {
gzclose($handle);
}
if ($compression == 'bz') {
bzclose($handle);
}
if ($ok && preg_match('/^-- MySql/i', $errormsg)) {
$errormsg = '';
} else {
// Renommer fichier sortie en fichier erreur
//print "$outputfile -> $outputerror";
@dol_delete_file($outputerror, 1);
@rename($outputfile, $outputerror);
// Si safe_mode on et command hors du parametre exec, on a un fichier out vide donc errormsg vide
if (!$errormsg) {
$langs->load("errors");
$errormsg = $langs->trans("ErrorFailedToRunExternalCommand");
}
}
}
// Fin execution commande
}
if ($what == 'mysqlnobin') {
$outputdir = $conf->admin->dir_output . '/backup';
$outputfile = $outputdir . '/' . $file;
$outputfiletemp = $outputfile . '-TMP.sql';
// for compression format, we add extension