require 'php/sql/' . substr($class, 2) . '.sql.php'; } } } } spl_autoload_register('class_loader'); /*| error and exception handling |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|*/ ErrorHandler::setAsHandler($cfg['error_level']); ErrorHandler::setShowErrors($cfg['error_show']); ErrorHandler::setMaxArgumentLength($cfg['error_max_arg_length']); ErrorHandler::setMailSettings($cfg['error_mail'], $cfg['error_mail_subject'], $cfg['error_mail_to'], $cfg['error_mail_from']); ErrorHandler::setLogSettings($cfg['error_log'], $cfg['error_log_type'], $cfg['error_log_destination']); ErrorHandler::setFirebugSettings($cfg['error_firebug'], $cfg['error_firebug_collapse']); /*| database |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|*/ try { DB::construct($cfg['db']['engine']); DB::connect($cfg['db']['host'], $cfg['db']['username'], $cfg['db']['password'], $cfg['db']['port']); DB::selectDB($cfg['db']['database']); DB::setPrefix($cfg['db']['table_prefix']); // i always unset the db password once it is not needed unset($cfg['db']['password']); } catch (DBError $e) { trigger_error("Database Connection Error: " . $e->getMessage()); echo "Database Connection Error. Reload the page to try again."; exit; } /*| template engine |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|*/ Session::init($cfg['guid']); TemplateEngine::init($cfg['dwoo_template_directory'], $cfg['dwoo_compiled_directory'], $cfg['dwoo_cache_directory']); /*| magic quotes |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|*/ if (get_magic_quotes_gpc()) {
function getSettings($p_mailbox) { global $g_use_database; global $g_voicemail_conf_path; global $g_db_host, $g_db_name, $g_db_user, $g_db_pass; if ($g_use_database == true) { // Authenticate with Database $my_db = new DB(); $my_db->construct($g_db_host, $g_db_name, $g_db_user, $g_db_pass); $my_db->connect(); $my_db->select(); $sql = "SELECT uniqueid,password,fullname,email,saycid,envelope,sendvoicemail,'delete' AS deleteafteremail FROM voicemail WHERE mailbox='{$p_mailbox}';"; //if ($g_debug) echo("SQL: $sql<br />\n"); $result = $my_db->query($sql); if ($result) { if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); $temp['FullName'] = $row['fullname']; $temp['Password'] = $row['password']; $temp['SayCallerId'] = $row['saycid']; $temp['Envelope'] = $row['envelope']; $temp['Email'] = $row['email']; $temp['SendToEmail'] = $row['sendvoicemail']; $temp['DeleteAfterEmail'] = $row['deleteafteremail']; } mysql_free_result($result); } $my_db->disconnect(); } else { // cat the voicemail.conf file, grep for mailbox $cmd = "cat " . $g_voicemail_conf_path . " | grep " . $p_mailbox; $last_line = exec($cmd, $retvalue); // parse out the info - 1001 => 1001,Chris Carey,chris@chriscarey.com list($mailbox, $everything_else) = split('=>', $last_line); list($password, $name, $email) = split(",", $everything_else); // Settings from voicemail.conf $temp['FullName'] = $name; $temp['Password'] = $password; $temp['SayCallerId'] = "true"; $temp['Envelope'] = "true"; $temp['Email'] = $email; $temp['SendToEmail'] = "true"; $temp['DeleteAfterEmail'] = "true"; } return $temp; }
break; case "versioncheck": $latest_version = doCheckVersion($client_version); $json_version = array('version' => $latest_version); print json_encode($json_version); exit; break; default: $fail = array('OK' => 0, 'ERROR' => 'Bad Request'); print json_encode($fail); exit; break; } // Prep Database $my_db = new DB(); $my_db->construct($g_db_host, $g_db_name, $g_db_user, $g_db_pass); $my_db->connect(); $my_db->select(); if ($sql) { $result = $my_db->query($sql); if ($result) { $json_array = array(); $result_array = array(); // add a time stamp to this array //$dtz = new DateTimeZone(); //$offset = tdz.getOffset(); $seconds = date_offset_get(new DateTime()); $offset = $seconds / 3600; array_push($json_array, array('stamp' => time(), 'offset' => $offset)); // push all the results down into a json string while ($row = mysql_fetch_array($result)) {