Example #1
0
function changeBlogLogo($blogid, $file)
{
    $context = Model_Context::getInstance();
    $skin = new Skin($context->getProperty('skin.skin'));
    requireModel('blog.attachment');
    if (($attachment = addAttachment($blogid, -1, $file)) === false) {
        return false;
    }
    if (strncmp($attachment['mime'], 'image/', 6) != 0) {
        deleteAttachment($blogid, -1, $attachment['name']);
        return false;
    }
    if (Setting::setBlogSettingGlobal('logo', $attachment['name'])) {
        deleteAttachment($blogid, -1, $context->getProperty('blog.logo'));
        $skin->purgeCache();
        return true;
    }
    return false;
}
Example #2
0
function api_update_attaches_with_replace($entryId)
{
    $pool = DBModel::getInstance();
    $pool->reset('Attachments');
    $pool->setQualifier('blogid', 'eq', getBlogId());
    $pool->setQualifier('parent', 'eq', 0);
    $newFiles = $pool->getAll('name,label');
    if ($newFiles) {
        foreach ($newFiles as $newfile) {
            $newfile['label'] = Utils_Unicode::lessenAsEncoding($newfile['label'], 64);
            $pool->reset('Attachments');
            $pool->setQualifier('blogid', 'eq', getBlogId());
            $pool->setQualifier('parent', 'eq', $entryId);
            $pool->setQualifier('label', 'eq', $newfile['label'], true);
            $oldFile = $pool->getCell('name');
            if (!is_null($oldFile)) {
                deleteAttachment(getBlogId(), $entryId, $oldFile);
            }
        }
    }
    api_update_attaches($entryId);
}
Example #3
0
<?php

/// Copyright (c) 2004-2016, Needlworks  / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
require ROOT . '/library/preprocessor.php';
importlib("model.blog.attachment");
requireStrictRoute();
if (!empty($_GET['name']) && deleteAttachment($blogid, $suri['id'], $_GET['name'])) {
    Respond::ResultPage(0);
} else {
    Respond::ResultPage(-1);
}
$of->Value = getItemTemplateContents('testplan_template', $of->InstanceName, $args->notes);
// Checks on testplan name, and testplan name<=>testplan id
if ($args->do_action == "do_create" || $args->do_action == "do_update") {
    $gui->testplan_name = $args->testplan_name;
    $name_exists = $tproject_mgr->check_tplan_name_existence($args->tproject_id, $args->testplan_name);
    $name_id_rel_ok = isset($gui->tplans[$args->tplan_id]) && $gui->tplans[$args->tplan_id]['name'] == $args->testplan_name;
}
// interface changes to be able to do not loose CF values if some problem arise on User Interface
$gui->cfields = $tplan_mgr->html_table_of_custom_field_inputs($args->tplan_id, $args->tproject_id, 'design', '', $_REQUEST);
switch ($args->do_action) {
    case 'fileUpload':
        fileUploadManagement($db, $args->tplan_id, $args->fileTitle, $tplan_mgr->getAttachmentTableName());
        getItemData($tplan_mgr, $gui, $of, $args->tplan_id, true);
        break;
    case 'deleteFile':
        deleteAttachment($db, $args->file_id);
        getItemData($tplan_mgr, $gui, $of, $args->tplan_id, true);
        break;
    case 'edit':
        getItemData($tplan_mgr, $gui, $of, $args->tplan_id);
        break;
    case 'do_delete':
        $tplanInfo = $tplan_mgr->get_by_id($args->tplan_id);
        if ($tplanInfo) {
            $tplan_mgr->delete($args->tplan_id);
            logAuditEvent(TLS("audit_testplan_deleted", $args->tproject_name, $tplanInfo['name']), "DELETE", $args->tplan_id, "testplan");
        }
        //unset the session test plan if it is deleted
        if (isset($_SESSION['testplanID']) && ($_SESSION['testplanID'] = $args->tplan_id)) {
            $_SESSION['testplanID'] = 0;
            $_SESSION['testplanName'] = null;
Example #5
0
     douserssync($kunena_db, $option);
     break;
 case "syncusers":
     syncusers($kunena_db, $option);
     break;
 case "browseImages":
     browseUploaded($kunena_db, $option, 1);
     break;
 case "browseFiles":
     browseUploaded($kunena_db, $option, 0);
     break;
 case "deleteImage":
     deleteAttachment(JRequest::getInt('id', 0), JURI::base() . "index.php?option={$option}&task=browseImages", 'COM_KUNENA_IMGDELETED');
     break;
 case "deleteFile":
     deleteAttachment(JRequest::getInt('id', 0), JURI::base() . "index.php?option={$option}&task=browseFiles", 'COM_KUNENA_FILEDELETED');
     break;
 case "showAdministration":
     showAdministration($option);
     break;
 case "saveorder":
     orderForum();
     break;
 case 'recount':
     CKunenaTools::reCountUserPosts();
     CKunenaTools::reCountBoards();
     // Also reset the name info stored with messages
     //CKunenaTools::updateNameInfo();
     while (@ob_end_clean()) {
     }
     $kunena_app->redirect(JURI::base() . 'index.php?option=com_kunena', JText::_('COM_KUNENA_RECOUNTFORUMS_DONE'));
Example #6
0
/** 
 * delete one test execution from database (include child data and relations)
 * 
 * @param resource &$db reference to database handler
 * @param datatype $execution_id
 * 
 * @return boolean result of delete
 * 
 * @TODO delete attachments FROM DISK when are saved on Filesystem
 * @TODO run SQL as transaction if database engine allows 
 **/
function delete_execution(&$db, $exec_id)
{
    $tables = tlObjectWithDB::getDBTables(array('executions', 'execution_bugs', 'cfield_execution_values', 'execution_tcsteps', 'attachments'));
    $sid = intval($exec_id);
    // Attachments NEED special processing.
    $dummy = " SELECT id FROM {$tables['attachments']} " . " WHERE fk_table = 'executions' AND fk_id = {$sid}";
    $rs = $db->fetchRowsIntoMap($dummy, 'id');
    if (!is_null($rs)) {
        foreach ($rs as $fik => $v) {
            deleteAttachment($db, $fik, false);
        }
    }
    // order is CRITIC, because is DELETING ORDER => ATTENTION to Foreing Keys
    $sql = array();
    $sql[] = "DELETE FROM {$tables['execution_bugs']} WHERE execution_id = {$sid}";
    $sql[] = "DELETE FROM {$tables['cfield_execution_values']} WHERE execution_id = {$sid}";
    $sql[] = "DELETE FROM {$tables['execution_tcsteps']} WHERE execution_id = {$sid}";
    // This delete HAS TO BE THE LATEST, because is the PARENT
    $ldx = count($sql);
    $sql[$ldx] = "DELETE FROM {$tables['executions']} WHERE id = {$sid}";
    foreach ($sql as $the_stm) {
        $result = $db->exec_query($the_stm);
        if (!$result) {
            break;
        }
    }
    return $result;
}
Example #7
0
 * @link 		    http://www.testlink.org
 *
 */
require_once "../../config.inc.php";
require_once "../../cfg/reports.cfg.php";
require_once "print.inc.php";
require_once "common.php";
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$tree_mgr = new tree($db);
$args = init_args();
$gui = new stdClass();
$gui->goback_url = !is_null($args->goback_url) ? $args->goback_url : '';
$gui->page_title = '';
if ($args->deleteAttachmentID > 0) {
    deleteAttachment($db, $args->deleteAttachmentID);
}
// Struture defined in printDocument.php
$printingOptions = array('toc' => 0, 'body' => 1, 'summary' => 1, 'header' => 0, 'headerNumbering' => 0, 'passfail' => 0, 'author' => 1, 'notes' => 1, 'requirement' => 1, 'keyword' => 1, 'cfields' => 1, 'displayVersion' => 1, 'displayDates' => 1, 'docType' => SINGLE_TESTCASE, 'importance' => 1);
$level = 0;
$tplanID = 0;
$prefix = null;
$text2print = '';
$text2print .= renderHTMLHeader($gui->page_title, $_SESSION['basehref'], SINGLE_TESTCASE, array('gui/javascript/testlink_library.js'));
$text2print .= renderExecutionForPrinting($db, $_SESSION['basehref'], $args->id, $_SESSION['currentUser']);
echo $text2print;
/*
  function: init_args
  args:
  
  returns: 
 /**
  *
  */
 function deleteFile(&$argsObj)
 {
     deleteAttachment($this->db, $argsObj->file_id);
     return $this->initGuiObjForAttachmentOperations($argsObj);
 }
Example #9
0
function deleteAttachments($blogid, $parent)
{
    $attachments = getAttachments($blogid, $parent);
    foreach ($attachments as $attachment) {
        deleteAttachment($blogid, $parent, $attachment['name']);
    }
}
Example #10
0
             $echoAnswer = "Текстовые данные обновлены!";
             break;
         case 1:
             $echoAnswer = "Произошла ошибка во время передачи файла!";
             break;
         case 2:
             $echoAnswer = "Не получилось обновить информацию в БД!";
             break;
         case 3:
             $echoAnswer = "Не удалось подключиться к БД!";
             break;
     }
 } else {
     if (isset($_POST['deleteAttachment'])) {
         $attachmentId = intval($_POST['attachmentId']);
         $answer = deleteAttachment($attachmentId);
         switch ($answer) {
             case 0:
                 $echoAnswer = "Файл игры успешно удален!";
                 break;
             case 1:
                 $echoAnswer = "Не удалось удалить файл ./attachments/" . $attachmentId . " !";
                 break;
             case 2:
                 $echoAnswer = "Не получилось удалить информацию из БД!";
                 break;
             case 3:
                 $echoAnswer = "Не удалось подключиться к БД!";
                 break;
         }
     }
Example #11
0
 /**
  * Copy one uploaded file to his destination and insert an entry in the database
  * @access    private
  * @return    boolean   TRUE if OK
  */
 function uploadFile($IdPost, $IdTopic, $name, $size, $type, $src_file, $inline = DEFAULT_INLINE)
 {
     global $MAX_FILE_SIZE;
     global $mimetypes, $mimetype_default;
     global $insert_base;
     settype($size, 'integer');
     $this->errno = 0;
     # Check temporary file
     # --------------------
     if (empty($src_file) || strcasecmp($src_file, 'none') == 0) {
         $this->errno = NO_FILE;
         return false;
     }
     # Check size
     # ----------
     if ($size == 0) {
         $this->errno = FILE_EMPTY;
         return false;
     } else {
         $fsize = filesize($src_file);
     }
     if ($size != $fsize) {
         $this->errno = ERR_FILE;
         return FALSE;
     }
     if ($size > $MAX_FILE_SIZE) {
         $this->errno = FILE_TOO_BIG;
         return FALSE;
     }
     # Check name
     # ----------
     if (empty($name)) {
         $this->errno = NO_FILE;
         return false;
     }
     $name = preg_replace('#[/\\\\:\\*\\?"<>|]#i', '_', rawurldecode($name));
     # Check type and extension
     # ------------------------
     load_mimetypes();
     $suffix = strtoLower(substr(strrchr($name, '.'), 1));
     if (isset($mimetypes[$suffix])) {
         $type = $mimetypes[$suffix];
     } elseif (empty($type) || $type == 'application/octet-stream') {
         $type = $mimetype_default;
     }
     if (!$this->isAllowedFile($name, $type)) {
         $this->errno = INVALID_FILE_TYPE;
         return FALSE;
     }
     # Find the path to upload directory
     # -------------------------------------------
     global $DOCUMENTROOT;
     $rep = $DOCUMENTROOT;
     settype($log_filename, "string");
     if ($insert_base == true) {
         # insert attachment reference in database
         # ---------------------------------------
         $id = insertAttachment($this->apli, $IdPost, $IdTopic, $this->IdForum, $name, $this->upload_dir, $inline, $size, $type);
         if ($id <= 0) {
             $this->errno = DB_ERROR;
             return FALSE;
         }
         # copy temporary file to the upload directory
         # -------------------------------------------
         $dest_file = $rep . $this->upload_dir . "{$id}." . $this->apli . ".{$name}";
         $copyfunc = function_exists('move_uploaded_file') ? 'move_uploaded_file' : 'copy';
         if (!$copyfunc($src_file, $dest_file)) {
             deleteAttachment($this->apli, $IdPost, $rep . $this->upload_dir, $id, $name);
             $this->errno = COPY_ERROR;
             return FALSE;
         }
         @chmod($dest_file, 0766);
         $log_filename = $dest_file;
     } else {
         if ($this->apli == "minisite") {
             # copy temporary file to the upload directory
             # -------------------------------------------
             global $rep_upload_minisite;
             $copyfunc = function_exists('move_uploaded_file') ? 'move_uploaded_file' : 'copy';
             if (!$copyfunc($src_file, $rep . $rep_upload_minisite . $name)) {
                 $this->errno = COPY_ERROR;
                 return FALSE;
             }
             @chmod($rep . $rep_upload_minisite . $name, 0766);
             $log_filename = $rep . $rep_upload_minisite . $name;
         } elseif ($this->apli == "editeur") {
             # copy temporary file to the upload directory
             # -------------------------------------------
             global $rep_upload_editeur;
             $copyfunc = function_exists('move_uploaded_file') ? 'move_uploaded_file' : 'copy';
             if (!$copyfunc($src_file, $rep . $rep_upload_editeur . $name)) {
                 $this->errno = COPY_ERROR;
                 return FALSE;
             }
             @chmod($rep . $rep_upload_editeur . $name, 0766);
             $log_filename = $rep . $rep_upload_editeur . $name;
         } else {
             return FALSE;
         }
     }
     Ecr_Log("security", "Upload File(s) : " . getip(), $log_filename);
     return TRUE;
 }
Example #12
0
function api_update_attaches_with_replace($entryId)
{
    global $database;
    $newFiles = POD::queryAll("SELECT name, label FROM {$database['prefix']}Attachments WHERE blogid=" . getBlogId() . " AND parent=0");
    if ($newFiles) {
        foreach ($newFiles as $newfile) {
            $newfile['label'] = POD::escapeString(UTF8::lessenAsEncoding($newfile['label'], 64));
            $oldFile = POD::queryCell("SELECT name FROM {$database['prefix']}Attachments WHERE blogid=" . getBlogId() . " AND parent={$entryId} AND label='{$newfile['label']}'");
            if (!is_null($oldFile)) {
                deleteAttachment(getBlogId(), $entryId, $oldFile);
            }
        }
    }
    api_update_attaches($entryId);
}