<?php 

 ini_set('display_errors', 1);
 ini_set('display_startup_errors', 1);
 error_reporting(E_ALL);

function loadconf() {
 global $shm_memory;
 $shm_key=fileinode("../bin/pandabot.php");
 $shm = shm_attach($shm_key, $shm_memory);
 
 $channelInfoNew=shm_get_var($shm, 4);
 echo "<table style='font-size: 12px;'>";
 echo "
   <tr>
    <th style='text-align: left; border-bottom-style: solid; border-width: 1px;'>&nbsp;source<a href='javascript:sortchannels(\"sortchannels\", \"cmd\");' title='A-Z' style='color:white; text-decoration: none;'>&nbsp;&nbsp;↑️</a><a href='#' title='Z-A' style='color:gray; text-decoration: none;'>↓&nbsp;&nbsp;</a></th>
    <th style='text-align: left; border-bottom-style: solid; border-width: 1px;'>type<a href='#' title='up' style='color:white; text-decoration: none;'>&nbsp;&nbsp;↑️</a><a href='#' title='down' style='color:gray; text-decoration: none;'>↓&nbsp;&nbsp;</a></th>
    <th style='text-align: left; border-bottom-style: solid; border-width: 1px;'>status<a href='#' title='up' style='color:white; text-decoration: none;'>&nbsp;&nbsp;↑️</a><a href='#' title='down' style='color:gray; text-decoration: none;'>↓&nbsp;&nbsp;</a></th>
	<th style='text-align: left; border-bottom-style: solid; border-width: 1px;'>targets</th>
	<th style='text-align: left;'>&nbsp;</th>
	<th style='text-align: left;'>&nbsp;</th>
  </tr>
 ";
 
 foreach(array_keys($channelInfoNew) as $channelInfoKey) {
  if ($channelInfoNew[$channelInfoKey]["mode"] != "a") {
   echo "<tr><td><b><a style='color: #9e6108; text-decoration:none;' href='javascript:editchannel(".$channelInfoKey.");'>".substr($channelInfoNew[$channelInfoKey]["name"],0,50)."</b></a></td>";
   if ($channelInfoNew[$channelInfoKey]["status"]=="nook") { 
   $chanstatus="<p style='color:red; display: inline;' title='".$channelInfoNew[$channelInfoKey]['info']."'>&#10060;</p>"; 
   } else $chanstatus="<p style='color: #71fe04; display: inline; text-align: center;'><b>&nbsp;&#10003;</b></p>";

   echo "<td>".$channelInfoNew[$channelInfoKey]["typemapping"]."</td><td>".$chanstatus."</td>";
   if (!array_key_exists("-1", $channelInfoNew[$channelInfoKey]["to"])) {
	$tooltiptitle=""; 
	$c=1;
	foreach (array_keys($channelInfoNew[$channelInfoKey]["to"]) as $t) {
	 $tooltiptitle.=$c.". ".$channelInfoNew[$channelInfoKey]["to"][$t]["name"]."\n";
	 $c++;
	} // foreach (array_keys($channelInfoNew[$channelInfoKey]["to"]) as $t) 
	 echo "<td style='border: 1px; border-style: dotted;' title='".$tooltiptitle."'><a style='color: #b8bfba; text-decoration:none;' href='javascript:editchannel(".$channelInfoKey.");'>".count($channelInfoNew[$channelInfoKey]["to"])." to channel(s)</a></td>";
   } else {
	echo "<td style='color: #222224;'>no to channels</td>";
   } // if (!array_key_exists("-1", $channelInfoNew[$channelInfoKey]["to"]))
  if ($channelInfoNew[$channelInfoKey]["autosync"] != -1) {echo "<td style='font-size: 15px;' title='brummm'>&#128663;</td>"; } else echo "<td>&nbsp;</td>";
 
 echo "<td><a href='#' title='up' style='color:white; text-decoration: none;'>&nbsp;&nbsp;↑️</a>&nbsp;&nbsp;<a href='#' title='down' style='color:gray; text-decoration: none;'>↓&nbsp;&nbsp;</a></td>";   
 
   echo "</tr>";
  } // if ($channelInfoNew[$channelInfoKey]["mode"] =! "a") 
 } // foreach(array_keys($channelInfoNew) as $channelInfoKey)
 echo "
   <tr>
    <td style='text-align: left;'><a href='#' title='add' style='text-decoration: none;'>&nbsp;&nbsp;&nbsp;➕</a></th>
    <td style='text-align: left;'>&nbsp;</th>
    <td style='text-align: left;'>&nbsp;</th>
	<td style='text-align: left;'>&nbsp;</th>
	<td style='text-align: left;'>&nbsp;</th>
	<td style='text-align: left;'>&nbsp;</th>
  </tr>
 ";
 echo "</table>";
} // function end 

?>