CNCat 3.1 / User manual

© "CN-Software" Ltd. 2002-2007
cncat@cn-software.com
www.cn-software.com

Plugins

Installing a plugin

To install a plugin one should copy its file to /admin/plugins/ folder; the plugin name will appear at the plugins' list in the administrative interface.

Example of a plugin is located at /sample/plugins/ folder.

Creation of a plugin

Note: Any text editor can be used for a plugin creation.

Below is an example of a plugin, which displayes links sorted by the administrator's vote:

  1. <?php
  2. /* PLUGIN: This is title of example plugin; */
  3. chdir("..");
  4. $ADLINK="../";
  5. /* Authorization */
  6. include "./auth.php";
  7. /* Administrative interface - upper part of the page */
  8. include "./_top.php";
  9. /* Main form */
  10. ?>
  11. <table align=center cellspacing=1 cellpadding=6 border=0><form action=example.php method=get>
  12. <th colspan=2 background=../../cat/tablebg.gif>Plugin example</th></tr>
  13. <tr><td>Minimum moderator vote<td><input type=text name=min value='8'></td></tr>
  14. <tr><td>Maximum moderator vote<td><input type=text name=max value='10'></td></tr>
  15. <tr><td colspan=2 align=right><input type=submit value='Show'></td></tr>
  16. </form></table>
  17. <?php
  18. /* Result */
  19. if (isset($_GET["max"]))
  20. {
  21. $max=intval($_GET["max"]);
  22. $min=intval($_GET["min"]);
  23. $r=mysql_query("SELECT url FROM ".$db["prefix"]."main WHERE moder_vote<=".$max." AND moder_vote>='".$min."' LIMIT 1000;") or die(mysql_error());
  24. while ($a=mysql_fetch_array($r))
  25. print "<a href='".$a["url"]."'>".$a["url"]."</a><br>\n";
  26. }
  27. /* Administrative interface - bottom part of the page */
  28. include "./_bottom.php";
  29. ?>


Back | Manual index | Next