Cant acces cms : application error / can not write last accessed file

hi all,

i need some help please

i was saving a layout into a template then the cms hang

i had this message : there is an application error / can not write last accessed file

i managed to get back to the cms by deleting some lines in the template php file in xibo cms

but not i have only a blank page when i click on template, this is the lines i erased from the template php :

///////////////////////////////

/**
* Adds a template
* @return
*/
function AddTemplate()
{
// Check the token
if (!Kit::CheckToken())
trigger_error(__(‘Sorry the form has expired. Please refresh.’), E_USER_ERROR);

    $db =& $this->db;
    $user =& $this->user;
    $response = new ResponseManager();

    $template = Kit::GetParam('template', _POST, _STRING);
    $tags = Kit::GetParam('tags', _POST, _STRING);
    $description = Kit::GetParam('description', _POST, _STRING);
    $templateLayoutId = Kit::GetParam('layoutid', _POST, _INT);
    
    // Copy the layout and adjust the values of the new layout
    $layoutObject = new Layout();

    if (!$layoutId = $layoutObject->Copy($templateLayoutId, $template, $description, $user->userid, true))
        trigger_error($layoutObject->GetErrorMessage(), E_USER_ERROR);

    // Tag it with the template tag
    $layoutObject->tag('template', $layoutId);
    
    $response->SetFormSubmitResponse('Template Added.');
    $response->Respond();
}

function Edit() {
    // Check the token
    if (!Kit::CheckToken())
        trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
    
    $response       = new ResponseManager();

    $layoutid       = Kit::GetParam('layoutid', _POST, _INT);
    $layout         = Kit::GetParam('layout', _POST, _STRING);
    $description    = Kit::GetParam('description', _POST, _STRING);
    $retired        = Kit::GetParam('retired', _POST, _INT, 0);
    $userid         = Kit::GetParam('userid', _SESSION, _INT);
    $tags = 'template';
    
    // Add this layout
    $layoutObject = new Layout();

    if (!$layoutObject->Edit($layoutid, $layout, $description, $tags, $userid, $retired))
        trigger_error($layoutObject->GetErrorMessage(), E_USER_ERROR);

    $response->SetFormSubmitResponse(__('Template Details Changed.'));
    $response->Respond();
}

/**
 * Deletes a template
 * @return
 */
function DeleteTemplate()
{
    // Check the token
    if (!Kit::CheckToken())
        trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
    
    $db =& $this->db;
    $user =& $this->user;
    $response = new ResponseManager();

    $templateId = Kit::GetParam('templateId', _POST, _INT);

    if ($templateId == 0)
        trigger_error(__('No template selected'), E_USER_ERROR);

    // Is this user allowed to delete this template?
    $auth = $this->user->TemplateAuth($templateId, true);
    
    if (!$auth->del)
        trigger_error(__('Access denied'), E_USER_ERROR);

    // Use the data class
    $template = new Layout();

    // Delete the template
    if (!$template->Delete($templateId))
        trigger_error($template->GetErrorMessage(), E_USER_ERROR);

    $response->SetFormSubmitResponse(__('The Template has been Deleted'));
    $response->Respond();
}

/**
 * Shows the form to delete a template
 */
public function DeleteTemplateForm()
{
    $response = new ResponseManager();
    
    $templateId = Kit::GetParam('layoutid', _GET, _INT);

    $auth = $this->user->TemplateAuth($templateId, true);
    if (!$auth->del)
        trigger_error(__('You do not have permissions to delete this template'), E_USER_ERROR);
    
    Theme::Set('form_id', 'DeleteForm');
    Theme::Set('form_action', 'index.php?p=template&q=DeleteTemplate');
    Theme::Set('form_meta', '<input type="hidden" name="templateId" value="' . $templateId . '">');
    Theme::Set('form_fields', array(
        FormManager::AddMessage(__('Are you sure you want to delete this template?'))
        ));

    $form = Theme::RenderReturn('form_render');
    
    $response->SetFormRequestResponse($form, __('Delete Template'), '300px', '200px');
    $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('Template', 'Delete') . '")');
    $response->AddButton(__('No'), 'XiboDialogClose()');
    $response->AddButton(__('Yes'), '$("#DeleteForm").submit()');
    $response->Respond();
}
 
 /**
 * Get a list of group names for a layout
 * @param <type> $layoutId
 * @return <type>
 */
private function GroupsForTemplate($campaignId)
{
    $db =& $this->db;

    $SQL = '';
    $SQL .= 'SELECT `group`.Group ';
    $SQL .= '  FROM `group` ';
    $SQL .= '   INNER JOIN lkcampaigngroup ';
    $SQL .= '   ON `group`.GroupID = lkcampaigngroup.GroupID ';
    $SQL .= ' WHERE lkcampaigngroup.CampaignID = %d ';

    $SQL = sprintf($SQL, $campaignId);

    if (!$results = $db->query($SQL))
    {
        trigger_error($db->error());
        trigger_error(__('Unable to get group information for template'), E_USER_ERROR);
    }

    $groups = '';

    while ($row = $db->get_assoc_row($results))
    {
        $groups .= $row['Group'] . ', ';
    }

    $groups = trim($groups);
    $groups = trim($groups, ',');

    return $groups;
}

}
?>

thx a lot guys if you can help me that would be kind

best regards

You definitely shouldn’t edit parts of the CMS code. That will only make whatever the original problem was worse.

If it’s saying it can’t write a file then I would be looking at filesystem permissions on the CMS library and it’s sub folders as a first step.