varisoft simple accounts

•October 30, 2007 • Leave a Comment

New interface is complete, marketting is the way for it now :)

Not my field of expertise i tell ya :D

WPF, WCF

•October 24, 2007 • Leave a Comment

eh??

PHP MySQL Class

•October 19, 2007 • 1 Comment

Here you go :)
As normal feel free to use but mail me where you do :)

You will have to add your details to the global variables to connect of course :)

<?
/**
 * Class:sql
 * + Handles all the sql queries.
 * --------
 * @author MDalke
 * @copyright 2007 MDalke
 * @todo + Constants from constants class.
 *       + Proper Labeling of what everything does
 */
class sql {
 var $conn_id;
 var $result;
 var $record;
 var $db = array();
 var $host;
 var $user;
 var $pass;
 var $dbname;
 var $constant;
 var $debugStack = array();
 /**
     * void sql
     * + Class Construct (PHP4)
  * -----------------
  * @param string $host
  * @param string $user
  * @param string $pass
  * @param string $dbname
  * @return sql
  */
 function sql($host=null,$user=null,$pass=null,$dbname=null){
  $this->__construct($host=null,$user=null,$pass=null,$dbname=null);
 }
    /**
     * void __construct
     * + Class Construct fix for PHP5
  * -----------------
     * @param string $host
     * @param string $user
     * @param string $pass
     * @param string $dbname
     * @return __construct
     */
 function __construct($host=null,$user=null,$pass=null,$dbname=null) {
  $this->host = ($host)?$host:$this->host;
  $this->user = ($user)?$user:$this->user;
  $this->pass = ($pass)?$pass:$this->pass;
  $this->dbname = ($dbname)?$dbname:$this->dbname;
 }
 
 /**
  * void connect
  *  + Connects to the mysql
  * -----------------
  * @return void
  */
 function connect() {
        // + Using the getconst function to get the required details
        // + Needed:
        //    + Host (The DB Host)
        //    + User (The DB User)
        //    + Pass (The DB pass)
        //    + Dbname (The DB Name)
       
  $this->host = $dbhost;
  $this->user = $dbuser;
  $this->pass = $dbpasswd;
  $this->dbname = $dbname;
        // + Opens the connection to the DB
  mysql_connect($this->host,$this->user,$this->pass);
  // + Selects the required database or dies.
  @mysql_select_db($this->dbname) or die("Unable to select database");
 }
 /**
  * string query
  * + Executes the query to the MYSQL.
  * -----------------
  * @param string $query_string
  * @return string $result
  */
 function query($query_string) {
  $this->result = mysql_query($query_string);
  return $this->result;
 }
 /**
  * array fetch_array
  * + Creates an array of results
  * -----------------
  * @param string $query_id
  * @return array $record
  */
 function fetch_array($query_id) {
  $this->record = mysql_fetch_array($query_id,MYSQL_ASSOC);
  return $this->record;
 }
 /**
  * int num_rows
  * + Gets number of results
  * -----------------
  * @param string $query_id
  * @return int
  */
 function num_rows($query_id) {
  return ($query_id) ? mysql_num_rows($query_id) : 0;
 }
   
 /**
  * int num_fields
  * + Gets number of fields in the results
  * -----------------
  * @param string $query_id
  * @return int
  */ 
 function num_fields($query_id) {
  return ($query_id) ? mysql_num_fields($query_id) : 0;
 }
 /**
  * void free_result
  * + Frees the result set.
  * -----------------
  * @param string $query_id
  * @return void
  */
 function free_result($query_id) {
  return mysql_free_result($query_id);
 }
 /**
  * int affected rows
  * + Get number of affected rows in previous MySQL operation
  * -----------------
  * @return int
  */
 function affected_rows() {
  return mysql_affected_rows($this->conn_id);
 }
 /**
  * boolean close_db
  * + Closes the connection to the DB
  * -----------------
  * @return boolean
  */
 function close_db() {
  if($this->conn_id) {
   return mysql_close($this->conn_id);
  } else {
   return false;
  }
 }
 /**
  * Void debug
  * + Creates a set of debug instructions
  * -----------------
  * @param string $msg
  */
 function debug($msg){
  $this->debugStack .= $msg."<br>\n";
 }
 /**
  * String returnDebug
  * + Returns the debugstack.
  * -----------------
  * @return string $debugStack
  */
 function returnDebug(){
  return $this->debugStack;
 }
}
?>

PHP Support Class (For a commerce site)

•October 19, 2007 • 2 Comments

This is my take on a php support class. Enjoy its not truely complete but it can be finished with a little time :)

If u wish to use it feel free to but credit me and send me a mail telling me where you are using it :)

You will need my take on a mysql class also posted on my blog or make your own and edit the code.
Plus where you see the constants bit either make your own constants class or fill it in with your own constants.

<?
/**
 * Class:support
 * + Handles the support section of the website.
 * --------
 * @author mdalke
 * @copyright 2007 mdalke
 * @todo + Constants from constants class.
 *       + Add class to add a ticket
 *       + Security
 *       + Add Stuff :P
 *       + Proper Labeling of what everything does
 */
class support{
 // + Generally Needed variables
 var $db;
 var $constants;
 var $debugStack = array();
 // + Table Variables
 var $support_table;
 var $userstbl;
 var $managerstbl;
 var $base_cat_tbl;
 var $base_topics_tbl;
 var $assignedtbl;
 // + Knowledge Base Items
 var $title;
 var $content;
 var $subject;
 var $sub_subject;
 var $priority;
 var $assigned;
 var $user_id;
 /**
  * Void support
  * + Construct (PHP4)
  * -----------------
  * @param string $title
  * @param string $content
  * @param int $subject
  * @param int $sub_subject
  * @param int $priority
  * @param int $assigned
  * @param int $user_id
  * @param string $support_table
  * @return support
  */
 function support($title=null,$content=null,$subject=null,$sub_subject=null,$priority=null,$assigned=null,$user_id=null,$support_table=null){
  $this->__construct($title,$content,$subject,$sub_subject,$priority,$assigned,$user_id,$support_table);
 }
 /**
  * Void __construct
  * + Construct (PHP5 Fix)
  * -----------------
  * @param string $title
  * @param string $content
  * @param int $subject
  * @param int $sub_subject
  * @param int $priority
  * @param int $assigned
  * @param int $user_id
  * @param string $support_table
  * @return __construct
  */ 
 function __construct($title=null,$content=null,$subject=null,$sub_subject=null,$priority=null,$assigned=null,$user_id=null,$support_table=null){
  if(!$this->db = new sql()){
   throw new Exception("Error opening class sql");
  }
  $this->debug("Opened SQL Class");
  if(!$this->constants = new constants()){
   throw new Exception("Error opening class constants");
  }
  $this->debug("Opened Constants");
  $this->title = ($title)?$title:$this->title;
  $this->content = ($content)?$content:$this->content;
  $this->subject = ($subject)?$subject:$this->subject;
  $this->sub_subject = ($sub_subject)?$sub_subject:$this->sub_subject;
  $this->priority = ($priority)?$priority:$this->priority;
  $this->assigned = ($assigned)?$assigned:$this->assigned;
  $this->user_id = ($user_id)?$user_id:$this->user_id;
  $this->support_table = ($support_table)?$support_table:$this->support_table;
  $this->debug("Constructed Variables");
  $this->base_topics_tbl = $this->constants->getconst("kb_topics_tbl");
  $this->managerstbl = $this->constants->getconst("managers_tbl");
  $this->userstbl = $this->constants->getconst("users_tbl");
  $this->assignedtbl = $this->constants->getconst("assigned_tbl");
  $this->base_cat_tbl = $this->constants->getconst("kb_cat_tbl");
  $this->debug("Added Some Constants");
 }
 function view_kb_topic($id){
  $sql = "SELECT * FROM '".$this->base_topics_tbl."' WHERE id='".$id."'";
  $query = $this->db->query($sql);
  if(!$base = $this->db->fetch_array($query)){
   throw new Exception("Error Fetching The Knowledge Base Item ".mysql_error()."<br>".$sqlb);
  }
  $this->debug("Retrived the Knowledge Base Topic");
  return $base;
 }
 function view_kb_cats($id){
  $sql = "SELECT * FROM '".$this->base_cat_tbl."' WHERE id='".$id."'";
  $query = $this->db->query($sql);
  if(!$base = $this->db->fetch_array($query)){
   throw new Exception("Error Fetching The Knowledge Base Catergory ".mysql_error()."<br>".$sqlb);
  }
  $this->debug("Retrieved the Knowledge Base Category");
  return $base;
 }
 function view_kb_cat_from_topic($id){
  $sql = "SELECT * FROM '".$this->base_topics_tbl."'
          INNER JOIN '".$this->base_cat_tbl."'
          ON '".$this->base_topics_tbl."'.cid='".$this->base_cat_tbl."'.id";
  $query = $this->db->query($sql);
  if(!$base = $this->db->fetch_array($query)){
   throw new Exception("Error getting the knowledge base item in query ".mysql_error()."<br>".$sqlb);
  }
  $this->debug("Retrieved the Category from the Topic");
  return $base;
 }
 function assign_manager($tid){
  $sql = "SELECT * FROM '".$this->managerstbl."'
          INNER JOIN '".$this->usertbl."'
          ON '".$this->managerstbl."'.user_id='".$this->usertbl."'.user_id";
  $query = $this->db->query($sql);
  if(!$max = $this->db->num_rows($query)){
   throw new Exception("Error Executive Query ".mysql_error()."<br>".$sqlb);
  }
        $this->debug("Accessed the managers table");
  
        $figure = rand(0,$max);
        $this->debug("Created a random figure from the managers id");
  while($base = mysql_fetch_array($query)){
   if($base["id"] == $figure){
    $sqlb = "INSERT INTO '".$this->assignedtbl."'
           (tid,mid)
           VALUES('".$tid."','".$base["id"]."')";
    if(!$sql_q = mysql_query($sqlb)){
     throw new Exception("Error with Assigning A Manager: ".mysql_error()."<br>".$sqlb);
    }else{
     $this->debug("Assigned manager to topic");
     return true;
    }
   }
  }
 }
 function get_manager_info($mid){
  $sql = "SELECT * FROM '".$this->managerstbl."'
          INNER JOIN '".$this->usertbl."'
          ON '".$this->managerstbl."'.user_id='".$this->usertbl."'.user_id
          WHERE '".$this->managerstbl."'.mid = '".$mid."'";
  $query = $this->db->query($sql);
  if(!$base = $this->db->fetch_array($query)){
   throw new Exception("Error Getting Manager's Info".mysql_error()."<br>".$sqlb);
  }
        $this->debug("Retrived The Managers Information");
  return $base;
 }
 function add_ticket($title,$content,$subject,$sub_subject,$priority,$assigned,$user_id){
  $this->title = stripslashes($title);
  $this->content = stripslashes($content);
  $this->subject = $subject;
  $this->sub_subject = $sub_subject;
  $this->priority = $priority;
  $this->assigned = $assigned;
  $this->user_id = $user_id;
  $this->debug("Assigned Values For Ticket");
  $this->support_table = $this->constants->getconst("kb_topics_tbl");
        $this->debug("Support Table Assigned From Constants");
  $sql = "INSERT INTO '".$this->support_table."'
   (title,content,subject,sub_subject,priority,assigned,user_id)
   VALUES('".$this->title."','".$this->content."','".$this->subject."','".$this->sub_subject."',
   '".$this->priority."','".$this->assigned."','".$this->user_id."')";
  if(!$sql_q = mysql_query($sql)){
   throw new Exception("Error with Adding A Ticket: ".mysql_error()."<br>".$sql);
  }else{
   $this->debug("Inserted Ticket into DB");
   return true;
  }
 }
 /**
  * Void debug
  * + Creates a set of debug instructions
  * -----------------
  * @param string $msg
  */
 function debug($msg){
  $this->debugStack .= $msg."<br>\n";
 }
 /**
  * String returnDebug
  * + Returns the debugstack.
  * -----------------
  * @return string $debugStack
  */
 function returnDebug(){
  return $this->debugStack;
 }
}
?>

First One

•October 19, 2007 • Leave a Comment

This is my first blog :)

Well today is work day.

I think i should start and explain what i do for a living ey. Well today i am a computer programmer, tommorrow i might be a web designer, the day after this i might be a pure buisness man. I like to keep myself busy :)

Anyone my current project is Varisoft a software and web design company.

I am currently programming a very simple accounts program for them to sell.

I just wrote these lines for your information.

Dim dayOfYear As Integer, wkNumber As Integer
Dim compensation As Integer = 0
Dim oneDate As String
Dim firstDayDate As Date
dayOfYear = inDate.DayOfYear
oneDate = "1/1/" & inDate.Year.ToString
firstDayDate = DateAndTime.DateValue(oneDate)

Anyways its looking very nice i will upload a few screen shots for you to browse on.
Also if u want any information on the purchase of this program you can send me a email or a message :)

Can i just boast and say this program is gonna blow the market for accounts programs appart for ease. I designed this especially for those who don’t generally have the time, computer knowledge or effort to use a complicated program. Also its designed so i can change it for a customer if they need to. I am real excited about this :) .

Anyway SS :)

Varisoft Simple Accounts SS1Varisoft SS 2

I am gonna be developing the interface over the day.

But anyways onto other things. Its Friday!!

Hello world!

•October 19, 2007 • Leave a Comment

Welcome to my blog.

I am interesting i tell thee.