<?php
##############################################################
##In-portal                                     ##
##############################################################
##                   In-portal                     ##
##             Intechnic Corporation               ##
##          All Rights Reserved, 1998-2002            ##
##                                           ##
## No portion of this code may be copied, reproduced or  ##
##    otherwise redistributed without proper written     ##
##   consent of Intechnic Corporation.  Violation will      ##
##    result in revocation of the license and support    ##
##  privileges along maximum prosecution allowed by law. ##
##############################################################
//$pathtoroot="";
if(!strlen($pathtoroot))
{
  $path=dirname(realpath($_SERVER['SCRIPT_FILENAME']));
  if(strlen($path))
  {
    /* determine the OS type for path parsing */
    $pos = strpos($path,":");
    if ($pos === false)
    {
      $gOS_TYPE="unix";
      $pathchar = "/";
    }
    else
    {
      $gOS_TYPE="win";
      $pathchar="\\";
    }
    $p = $path.$pathchar;
    /*Start looking for the root flag file */
    while(!strlen($pathtoroot) && strlen($p))
    {
      $sub = substr($p,strlen($pathchar)*-1);
      if($sub==$pathchar)
      {
        $filename = $p."root.flg";
      }
      else
        $filename = $p.$pathchar."root.flg";
      if(file_exists($filename))
      {
        $pathtoroot = $p;
      }
      else
      {
        $parent = realpath($p.$pathchar."..".$pathchar);
   if($parent!=$p)
   {
     $p = $parent;
   }
   else
     $p = "";
      }
    }
    if(!strlen($pathtoroot))
      $pathtoroot = ".".$pathchar;
  }
  else
  {
    $pathtoroot = ".".$pathchar;
  }
}

$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
  $pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;

require_once($pathtoroot."kernel/startup.php");

//echo "<pre>"; print_r($_POST); echo "</pre>";

$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");

$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
    $admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
$browseURL = $adminURL."/browse";

//admin only util

$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
//require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/browse/toolbar.php");

//Set Section
$section = 'in-portal:sendmail'; 

//Set Environment Variable
$envar = "env=" . BuildEnv(); 

$objListToolBar = new clsToolBar();

$objListToolBar->Set("section",$section);
$objListToolBar->Set("load_menu_func","");
$objListToolBar->Set("CheckClass","");
  
$listImages = array();
                    //$img, $alt, $link, $onMouseOver, $onMouseOut, $onClick

$objListToolBar->Add("select", "la_ToolTip_SendEmail","#","swap('select','toolbar/tool_select_f2.gif');",
                    "swap('select', 'toolbar/tool_select.gif');",
                     "SendMail();",
                     $imagesURL."/toolbar/tool_select.gif");

$objListToolBar->Add("cancel", "la_ToolTip_Stop","#","swap('cancel','toolbar/tool_stop_f2.gif');",
                     "swap('cancel', 'toolbar/tool_stop.gif');","window.close();",
                     $imagesURL."/toolbar/tool_stop.gif");


int_header($objListToolBar);
if(count(explode(",",$recip_ids))>1)
{
    $action = "email_multi_send";
}
else
  $action = "email_single_send";
if ($addr_list != '' || $addr_list != null) {
	$addresses = implode(",",$addr_list);  
}
?>

<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<form ID="sendmail" name="sendmail" action="<?php echo $adminURL."/email/do_send.php?env=".BuildEnv(); ?>" enctype="multipart/form-data" method=POST>   
  <INPUT TYPE="HIDDEN" NAME="EmailState" VALUE="<?php echo $action; ?>">
  <?php int_subsection_title(admin_language("la_tab_General")); ?>

  <tr <?php int_table_color(); ?>> 
    <td valign="top"><span class="text"><?php echo admin_language("la_prompt_To"); ?></span></td>
    <td> 

    <SPAN CLASS="text"><?php echo implode("; ", $reciplist); ?></SPAN>
      <input type="hidden" name="sendto" class="text" value="<?php echo $recip_ids; ?>">
      <INPUT TYPE="HIDDEN" NAME="sendaddrs" VALUE="<?php echo $addresses; ?>">
    </td>
    <td><span ID="valTo" class="validation_error"><?php echo admin_language("la_val_RequiredField"); ?></span></td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><span class="text"><?php echo admin_language("la_prompt_Subject"); ?></span></td>
    <td> 
      <input type="text" name="subject" class="text" size="60" value="<?php echo ""; ?>">
    </td>
    <td><span ID="valSubject" class="validation_error"><?php echo admin_language("la_val_RequiredField"); ?></span></td>
  </tr>

  <tr <?php int_table_color(); ?>> 
    <td valign="top"><span class="text"><?php echo admin_language("la_prompt_Attatchment"); ?></span></td>
    <td> 
      <input type="file" name="attatchment" class="text" size="60">
    </td>
    <td></td>
  </tr>

  <?php int_subsection_title(admin_language("la_tab_Message")); ?>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><span class="text"><?php echo admin_language("la_prompt_html_version"); ?></span>
   		<br />
         <a href="#">
         <img src="<?php echo $rootURL; ?>admin/icons/icon24_link_editor.gif" style="cursor:hand" border="0"
   ONCLICK="document.forms[0].elements[0].checked=true; OpenEditor('&section=<?php echo $section; ?>','sendmail','messageHTML');">
         </a>    
    
    </td>
    <td valign="top" COLSPAN=2>
         <textarea name="messageHTML" id="messageHTML" rows="5" cols="60">Type your Message Here</textarea>
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><span class="text"><?php echo admin_language("la_prompt_text_version"); ?></span></td>
    <td valign="top" COLSPAN=2>
         <textarea name="messageTEXT" id="messageTEXT" rows="5" cols="60">Type your Message Here</textarea>
    </td>
  </tr>
  
</FORM>
</TABLE>
<script language="JavaScript">
	InitValidation();
</script>
<?php int_footer(); ?>