Announcement

Collapse
No announcement yet.

Launch Windows Editor FROM php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Launch Windows Editor FROM php

    I am building have a quick php module that, when passed a template name, first see if there is a FILE with that name . ".html" and if it finds it will launch an Editor to edit that file.

    IF it does NOT find the file, it will grab the contents from the templates table and write it to disk. Then it will launch editor to edit that file.

    The PLAN is to click a 'button' to load the contents from file back into the template record.

    At this point, being new to php, I am trying to find a way to launch, for example, UltraEd WITH a filename from php. Is this possible?

    If someone has a better approach to what I'm trying to accomplish, I would really appreciate it. Since I prefer to edit template contents, for the most part, from an editor, I hate having to repeatedly copy and paste contents back and forth between the templete edit form and my editor.

    This is what I have so far:
    Code:
    <?php
    // ######################## SET PHP ENVIRONMENT ###########################
    error_reporting(E_ALL & ~E_NOTICE);
    @set_time_limit(0);
    ignore_user_abort(true);
    
    define('TPL_DIR', '/forum/_l/tpl/');
    define('TPL_EXT', 'html');
    
    if (empty($_REQUEST['tpl'])) {exit;}
    	// double output buffering does some weird things, so turn it off in these two cases
    	//$nozip = 1;
    
    // ########################## REQUIRE BACK-END ############################
    require_once('./global.php');
    require_once('./includes/adminfunctions_template.php');
    
    // ######################## CHECK ADMIN PERMISSIONS #######################
    if (!can_administer('canadminstyles'))
    {
    	print_cp_no_permission();
    }
    // #############################################################################
    
      $tmptitle = $_REQUEST['tpl'];
    
    
    /*
      If file doesn't exist, find template, save to filename, then launch editor
    */
    
    
    
    	$tmp = $DB_site->query_first("
    		SELECT template.templateid as templateid
    		FROM " . TABLE_PREFIX . "template AS template
    		WHERE title = '$tmptitle' and styleid = 2
    	");
    
    
    
      $templateid=$tmp['templateid'];
    
      $tplfile = $_SERVER['DOCUMENT_ROOT'] . TPL_DIR . $_REQUEST['tpl'] . "." . TPL_EXT;
    
    	if (file_exists($tplfile)) {
    	    print "The file $filename exists";
    	} else {
    	    print "The file $filename does not exist";
    	}
    
    
    
    
      $template = file_get_contents($tplfile );
     
    	$template_un = $template;
    	$template = compile_template($template);
    
    	$errors = check_template_errors($template);
    	if (!empty($errors))
    	{
       	echo("ERROR");
    	 	exit;
    	}
    
    	$DB_site->query("
    		UPDATE " . TABLE_PREFIX . "template SET
    			template = '" . addslashes($template) . "',
    			template_un = '" . addslashes($template_un) . "',
    			dateline = " . TIMENOW . "
    		WHERE templateid = $templateid
    	");
    
    ?>
    Larry Eitel - Administrator & Webmaster
    NoBlood.org
    Transfusion Alternatives and Blood Management
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X