Title: CCount Custom ID's
Version: 1.0
Author: DC
Demo: None
Download: None
Website: http://www.clickcraft.net
Short description:
This mod will allow you to also add custom ID's as well as the stock scripts auto generated sequential ID's. I always felt that the abillity to add ones own custom ID's was a good one, so I created this little mod.
*************************************/
Lets Begin Our Mod, make sure you save a back up of the orig script incase any errors are made ...
Open index.php in your editor.
This should be txt based DO NOT USE anything like MS Word.
Look for the add function. as this is the func we will be modifying
function add() and replace the block of code that should look like this.
Code: Select all
$previd = file_get_contents($settings['idfile']);
$previd = trim($previd);
$previd++;
$fp = @fopen($settings['idfile'],'w') or error('Can\'t write to the IDs file ('.$settings['idfile'].')! Make sure PHP scripts have permission to write to this file (CHMOD it to 666 on LINUX machines!)');
flock($fp, LOCK_EX);
fputs($fp,$previd);
flock($fp, LOCK_UN);
fclose($fp);
Code: Select all
///////////////////////////////////////////////////
//DC Custom ID Mod 1.0 ...
///////////////////////////////////////////////////
$cust_id = trim(strip_tags($_POST['cust_id']));
if (preg_match("/[^0-9]/", $cust_id)) {
error('Custom ID must be numeric ...');
}
$lines = file($settings['logfile']);
foreach ($lines as $thisline) {
$my_line = explode('%%',$thisline);
$previd = rtrim($my_line[0]);
if ($cust_id != ''){
if (preg_match("/$cust_id/", $previd)){
error('Custom ID already exists ...');
}
}
}
if ($cust_id == ''){
$previd = trim($previd);
$previd++;
}else{
$previd = $cust_id;
}
///////////////////////////////////////////////////
Code: Select all
<tr>
<td>Start counting from:<sup>1</sup></td>
<td><input type="text" name="count" value="0" size="6"></td>
</tr>
Code: Select all
<tr>
<td>Custom ID:</td>
<td><input type="text" name="cust_id" value="" size="6" maxlength="6"> Leave blank for auto generated ID's ...</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td>Start counting from:<sup>1</sup></td>
<td><input type="text" name="count" value="0" size="6"></td>
</tr>
Enjoy, DC