Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Append to Article Body

Here's the code to insert some bit of text to the end of your article body. For the Textpattern plugin.

var obj = document.getElementById('body');
obj.value = obj.value+"SOME TEXT";

Set a Field Equal to Something

A basic code sample for tcm_write_macros. It sets a custom field to a value
/* also - custom-1, custom-2, custom-3, custom-4, custom-5, etc for custom fields. */
var obj = document.getElementById('custom-3');
obj.value = "VALUE";

Textpattern - display log by hostname


<html>
<head>
<link href="/textpattern/textpattern.css" rel="Stylesheet" type="text/css" />
</head>
<body>
<?php
require_once("textpattern/config.php");
mysql_connect($txpcfg['host'], $txpcfg['user'], $txpcfg['pass']) or die(mysql_error());
mysql_select_db($txpcfg['db']) or die(mysql_error());

// Quote variable to make safe
function quote_smart($value)
{
   // Stripslashes
   if (get_magic_quotes_gpc()) {
       $value = stripslashes($value);
   }
   // Quote if not a number or a numeric string
   if (!is_numeric($value)) {
       $value = mysql_real_escape_string($value);
   }
   return $value;
}
$sql = "SELECT * FROM " .$txpcfg['table_prefix'] ."txp_log WHERE host LIKE '%" .quote_smart($_GET['host']) ."%' ORDER BY 'time' DESC LIMIT 0, 30 ";
$result = mysql_query($sql) or die(mysql_error());
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" id=\"list\" align=\"center\">";
echo "<tr><td><b>Time</b></td><td><b>host</b></td><td><b>page</b></td></tr>";
while($row = mysql_fetch_array($result))
{
 echo "<tr><td>".$row['time']."</td><td>".$row['host']."</td><td>".$row['page']."</td></tr>";
}
echo "</table>";
?>
</body></html>


« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS