diff --git a/.htaccess b/.htaccess
new file mode 100755
index 0000000..ef60688
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,7 @@
+#If you're working with a server which doesn't seem to display errors and you don't
+#have access to httpd.conf and you have a good reason to develop remotely instead of
+#locally, you may have luck with uploading this configuration file to the server
+
+php_flag display_errors on
+php_flag display_startup_errors on
+php_value error_reporting 2047
\ No newline at end of file
diff --git a/browser/AC_OETags.js b/browser/AC_OETags.js
new file mode 100755
index 0000000..157eb21
--- /dev/null
+++ b/browser/AC_OETags.js
@@ -0,0 +1,269 @@
+// Flash Player Version Detection - Rev 1.5
+// Detect Client Browser type
+// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
+var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
+var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
+var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
+
+function ControlVersion()
+{
+ var version;
+ var axo;
+ var e;
+
+ // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
+
+ try {
+ // version will be set for 7.X or greater players
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 6.X players only
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
+
+ // installed player is some revision of 6.0
+ // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
+ // so we have to be careful.
+
+ // default to the first public version
+ version = "WIN 6,0,21,0";
+
+ // throws if AllowScripAccess does not exist (introduced in 6.0r47)
+ axo.AllowScriptAccess = "always";
+
+ // safe to call for 6.0r47 or greater
+ version = axo.GetVariable("$version");
+
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 4.X or 5.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 3.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = "WIN 3,0,18,0";
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 2.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ version = "WIN 2,0,0,11";
+ } catch (e) {
+ version = -1;
+ }
+ }
+
+ return version;
+}
+
+// JavaScript helper required to detect Flash Player PlugIn version information
+function GetSwfVer(){
+ // NS/Opera version >= 3 check for Flash plugin in plugin array
+ var flashVer = -1;
+
+ if (navigator.plugins != null && navigator.plugins.length > 0) {
+ if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
+ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+ var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+ var descArray = flashDescription.split(" ");
+ var tempArrayMajor = descArray[2].split(".");
+ var versionMajor = tempArrayMajor[0];
+ var versionMinor = tempArrayMajor[1];
+ if ( descArray[3] != "" ) {
+ tempArrayMinor = descArray[3].split("r");
+ } else {
+ tempArrayMinor = descArray[4].split("r");
+ }
+ var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
+ var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
+ }
+ }
+ // MSN/WebTV 2.6 supports Flash 4
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
+ // WebTV 2.5 supports Flash 3
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
+ // older WebTV supports Flash 2
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
+ else if ( isIE && isWin && !isOpera ) {
+ flashVer = ControlVersion();
+ }
+ return flashVer;
+}
+
+// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
+function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
+{
+ versionStr = GetSwfVer();
+ if (versionStr == -1 ) {
+ return false;
+ } else if (versionStr != 0) {
+ if(isIE && isWin && !isOpera) {
+ // Given "WIN 2,0,0,11"
+ tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
+ tempString = tempArray[1]; // "2,0,0,11"
+ versionArray = tempString.split(","); // ['2', '0', '0', '11']
+ } else {
+ versionArray = versionStr.split(".");
+ }
+ var versionMajor = versionArray[0];
+ var versionMinor = versionArray[1];
+ var versionRevision = versionArray[2];
+
+ // is the major.revision >= requested major.revision AND the minor version >= requested minor
+ if (versionMajor > parseFloat(reqMajorVer)) {
+ return true;
+ } else if (versionMajor == parseFloat(reqMajorVer)) {
+ if (versionMinor > parseFloat(reqMinorVer))
+ return true;
+ else if (versionMinor == parseFloat(reqMinorVer)) {
+ if (versionRevision >= parseFloat(reqRevision))
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
+function AC_AddExtension(src, ext)
+{
+ if (src.indexOf('?') != -1)
+ return src.replace(/\?/, ext+'?');
+ else
+ return src + ext;
+}
+
+function AC_Generateobj(objAttrs, params, embedAttrs)
+{
+ var str = '';
+ if (isIE && isWin && !isOpera)
+ {
+ str += ' ';
+ str += '> ';
+ } else {
+ str += ' ';
+ }
+
+ document.write(str);
+}
+
+function AC_FL_RunContent(){
+ var ret =
+ AC_GetArgs
+ ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
+ , "application/x-shockwave-flash"
+ );
+ AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
+}
+
+function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
+ var ret = new Object();
+ ret.embedAttrs = new Object();
+ ret.params = new Object();
+ ret.objAttrs = new Object();
+ for (var i=0; i < args.length; i=i+2){
+ var currArg = args[i].toLowerCase();
+
+ switch (currArg){
+ case "classid":
+ break;
+ case "pluginspage":
+ ret.embedAttrs[args[i]] = args[i+1];
+ break;
+ case "src":
+ case "movie":
+ args[i+1] = AC_AddExtension(args[i+1], ext);
+ ret.embedAttrs["src"] = args[i+1];
+ ret.params[srcParamName] = args[i+1];
+ break;
+ case "onafterupdate":
+ case "onbeforeupdate":
+ case "onblur":
+ case "oncellchange":
+ case "onclick":
+ case "ondblClick":
+ case "ondrag":
+ case "ondragend":
+ case "ondragenter":
+ case "ondragleave":
+ case "ondragover":
+ case "ondrop":
+ case "onfinish":
+ case "onfocus":
+ case "onhelp":
+ case "onmousedown":
+ case "onmouseup":
+ case "onmouseover":
+ case "onmousemove":
+ case "onmouseout":
+ case "onkeypress":
+ case "onkeydown":
+ case "onkeyup":
+ case "onload":
+ case "onlosecapture":
+ case "onpropertychange":
+ case "onreadystatechange":
+ case "onrowsdelete":
+ case "onrowenter":
+ case "onrowexit":
+ case "onrowsinserted":
+ case "onstart":
+ case "onscroll":
+ case "onbeforeeditfocus":
+ case "onactivate":
+ case "onbeforedeactivate":
+ case "ondeactivate":
+ case "type":
+ case "codebase":
+ case "id":
+ ret.objAttrs[args[i]] = args[i+1];
+ break;
+ case "width":
+ case "height":
+ case "align":
+ case "vspace":
+ case "hspace":
+ case "class":
+ case "title":
+ case "accesskey":
+ case "name":
+ case "tabindex":
+ ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
+ break;
+ default:
+ ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
+ }
+ }
+ ret.objAttrs["classid"] = classid;
+ if (mimeType) ret.embedAttrs["type"] = mimeType;
+ return ret;
+}
+
+
diff --git a/browser/history.js b/browser/history.js
new file mode 100755
index 0000000..ea5a8a7
--- /dev/null
+++ b/browser/history.js
@@ -0,0 +1,48 @@
+// $Revision$
+// Vars
+Vars = function(qStr) {
+ this.numVars = 0;
+ if(qStr != null) {
+ var nameValue, name;
+ var pairs = qStr.split('&');
+ var pairLen = pairs.length;
+ for(var i = 0; i < pairLen; i++) {
+ var pair = pairs[i];
+ if( (pair.indexOf('=')!= -1) && (pair.length > 3) ) {
+ var nameValue = pair.split('=');
+ var name = nameValue[0];
+ var value = nameValue[1];
+ if(this[name] == null && name.length > 0 && value.length > 0) {
+ this[name] = value;
+ this.numVars++;
+ }
+ }
+ }
+ }
+}
+Vars.prototype.toString = function(pre) {
+ var result = '';
+ if(pre == null) { pre = ''; }
+ for(var i in this) {
+ if(this[i] != null && typeof(this[i]) != 'object' && typeof(this[i]) != 'function' && i != 'numVars') {
+ result += pre + i + '=' + this[i] + '&';
+ }
+ }
+ if(result.length > 0) result = result.substr(0, result.length-1);
+ return result;
+}
+function getSearch(wRef) {
+ var searchStr = '';
+ if(wRef.location.search.length > 1) {
+ searchStr = new String(wRef.location.search);
+ searchStr = searchStr.substring(1, searchStr.length);
+ }
+ return searchStr;
+}
+var lc_id = Math.floor(Math.random() * 100000).toString(16);
+if (this != top)
+{
+ top.Vars = Vars;
+ top.getSearch = getSearch;
+ top.lc_id = lc_id;
+}
diff --git a/browser/history.swf b/browser/history.swf
new file mode 100755
index 0000000..e6e03ec
--- /dev/null
+++ b/browser/history.swf
Binary files differ
diff --git a/browser/index.html b/browser/index.html
new file mode 100755
index 0000000..b2772c6
--- /dev/null
+++ b/browser/index.html
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/playerProductInstall.swf b/browser/playerProductInstall.swf
new file mode 100755
index 0000000..bdc3437
--- /dev/null
+++ b/browser/playerProductInstall.swf
Binary files differ
diff --git a/browser/servicebrowser.mxml b/browser/servicebrowser.mxml
new file mode 100755
index 0000000..c96ef50
--- /dev/null
+++ b/browser/servicebrowser.mxml
@@ -0,0 +1,223 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0)
+ {
+ methodLinks.dataProvider = links;
+ methodLinks.selectedIndex = 0;
+ currentMethod = methods[links[0].data];
+ currentMethodName = links[0].data;
+ currentState = "testService";
+ }
+ }
+
+ function sendRequest()
+ {
+ time = getTimer();
+ currentMethodName = methodLinks.dataProvider[methodLinks.selectedIndex].data;
+ sro.source = currentService.data.split('/').join('.').split('\\').join('.') + currentService.label;
+ sro[currentMethodName].send.apply(null, getArgs());
+ }
+
+ function getArgs()
+ {
+ var parsedArgs:Array = new Array();
+ if(arg is Array)
+ {
+ for(var i:int = 0; i < arg.length; i++)
+ {
+ try
+ {
+ var text = arg[i].text;
+ if(text.indexOf('{') == -1 &&
+ text.indexOf('[') == -1 &&
+ text.indexOf('"') == -1 &&
+ text.indexOf("'") == -1)
+ {
+ var val = parseInt(text);
+ if(isNaN(val))
+ {
+ text = '"' + text + '"';
+ }
+ }
+ parsedArgs.push(JSON.decode(text));
+ }
+ catch(e:*)
+ {
+
+ }
+ }
+ }
+ return parsedArgs;
+ }
+
+ function onResult(event)
+ {
+ currentState = "testMethod";
+ resultsText.text = ObjectUtil.toString(event.result);
+ infoText.text = "Query took: " + (getTimer() - time) + " ms";
+
+ if((event.result is Array && event.result[0] is Object) ||
+ (event.result is ArrayCollection && event.result.getItemAt(0) is Object))
+ {
+ var keys = new Array();
+ for(var i in event.result[0])
+ {
+ keys.push(new DataGridColumn(i));
+ }
+ resultsDg.columns = keys;
+ resultsDg.dataProvider = event.result;
+ }
+ else
+ {
+ resultsDg.columns = new Array();
+ resultsDg.dataProvider = new Array();
+ }
+ output.selectedIndex = 0;
+ }
+
+ function onFault(event)
+ {
+ currentState = "testMethod";
+ resultsText.text = ObjectUtil.toString(event.fault);
+ infoText.text = "Query took: " + (getTimer() - time) + " ms";
+ resultsDg.dataProvider = new Array();
+ output.selectedIndex = 0;
+ }
+
+ function enableLinks()
+ {
+ for(var i=0; i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/servicebrowser.swf b/browser/servicebrowser.swf
new file mode 100755
index 0000000..533cb98
--- /dev/null
+++ b/browser/servicebrowser.swf
Binary files differ
diff --git a/browser/services-config.xml b/browser/services-config.xml
new file mode 100755
index 0000000..61975f6
--- /dev/null
+++ b/browser/services-config.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+ *
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gateway.php b/gateway.php
new file mode 100755
index 0000000..1c3a284
--- /dev/null
+++ b/gateway.php
@@ -0,0 +1,155 @@
+ phpCharset. When using nusoap,
+ soapclient->soap_defencoding will be initialized with phpCharset.
+
+ The following settings are recommended (try the first setting appropriate for
+ your language, if it doesn't work try the second):
+
+ * English:
+
+ $gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" );
+
+ * Western european languages (French, Spanish, German, etc.):
+
+ $gateway->setCharsetHandler( "iconv", "ISO-8859-1", "ISO-8859-1" );
+ $gateway->setCharsetHandler( "utf8_decode", "ISO-8859-1", "ISO-8859-1" );
+
+ * Eastern european languages (Russian and other slavic languages):
+
+ $gateway->setcharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" );
+ $gateway->setCharsetHandler( "iconv", "your codepage", "your codepage" );
+
+ * Oriental languages (Chinese, japanese, korean):
+
+ $gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" );
+ $gateway->setCharsetHandler( "iconv", "big5", "big5" );
+ $gateway->setCharsetHandler( "iconv", "CP950", "CP950" );
+ $gateway->setCharsetHandler( "iconv", "Shift_JIS", "Shift_JIS" );
+ $gateway->setCharsetHandler( "iconv", "CP932", "CP932" );
+ $gateway->setCharsetHandler( "iconv", "CP949", "CP949" );
+
+ * Other languages:
+
+ $gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" );
+
+ See all the possible codepages for iconv here:
+
+ http://www.gnu.org/software/libiconv/
+
+ iconv is included by default in php5, but not in php4 although most
+ hosts have it installed. utf8_decode is of some use for Western European languages,
+ but please remember that it won't work with settings other than ISO-8859-1.
+ The other methods also require seldom-used extensions but were included
+ just in case your particular host only supports them.
+
+ - setWebServiceHandler(string handler)
+ Handler can be one of:
+ - php5 (that is, PHP5 SoapClient)
+ - pear
+ - nusoap
+ This is used for webservices when working with http:// service names in
+ new Service(). For php5 and pear, you will need to have it installed on your
+ server. For nusoap, you need nusoap.php instead in ./lib relative to this file.
+
+ If you have PHP5 and the SOAP extension installed it is highly recommended that
+ you use it as it is _much_ faster than NuSOAP or PEAR::SOAP
+
+ Things you may want to disable for production environments:
+
+ - disableStandalonePlayer()
+ Disables the standalone player by filtering out its User-Agent string
+
+ - disableServiceDescription()
+ Disable service description from Macromedia's service browser
+
+ - disableTrace()
+ Disables remote tracing
+
+ - disableDebug()
+ Stops debug info from being sent (independant of remote trace setting)
+
+ */
+
+ //You can set this constant appropriately to disable traces and debugging headers
+ //You will also have the constant available in your classes, for changing
+ //the mysql server info for example
+ define("PRODUCTION_SERVER", false);
+
+ //Include things that need to be global, for integrating with other frameworks
+ include "globals.php";
+
+ //Include framework
+ include "core/amf/app/Gateway.php";
+
+ $gateway = new Gateway();
+
+ //Set where the services classes are loaded from, *with trailing slash*
+ //$servicesPath defined in globals.php
+ $gateway->setClassPath($servicesPath);
+
+ //Set where class mappings are loaded from (ie: for VOs)
+ //$voPath defined in globals.php
+ $gateway->setClassMappingsPath($voPath);
+
+ //Read above large note for explanation of charset handling
+ //The main contributor (Patrick Mineault) is French,
+ //so don't be afraid if he forgot to turn off iconv by default!
+ $gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" );
+ //$gateway->setCharsetHandler("utf8_decode", "ISO-8859-1", "ISO-8859-1");
+
+ //Error types that will be rooted to the NetConnection debugger
+ $gateway->setErrorHandling(E_ALL ^ E_NOTICE);
+
+ if(PRODUCTION_SERVER)
+ {
+ //Disable profiling, remote tracing, and service browser
+ $gateway->disableDebug();
+ }
+
+ //If you are running into low-level issues with corrupt messages and
+ //the like, you can add $gateway->logIncomingMessages('path/to/incoming/messages/');
+ //and $gateway->logOutgoingMessages('path/to/outgoing/messages/'); here
+ $gateway->logIncomingMessages('/usr/web/logs/amf/');
+ $gateway->logOutgoingMessages('/usr/web/logs/amf/');
+
+ //Explicitly disable the native extension if it is installed
+ //$gateway->disableNativeExtension();
+
+ //Enable gzip compression of output if zlib is available,
+ //beyond a certain byte size threshold
+ $gateway->enableGzipCompression(25*1024);
+
+ //Service now
+ $gateway->service();
+
+?>
diff --git a/globals.php b/globals.php
new file mode 100755
index 0000000..2ec1ade
--- /dev/null
+++ b/globals.php
@@ -0,0 +1,27 @@
+
diff --git a/json.php b/json.php
new file mode 100755
index 0000000..3aeeecf
--- /dev/null
+++ b/json.php
@@ -0,0 +1,16 @@
+setBaseClassPath($servicesPath);
+
+ $gateway->service();
+?>
\ No newline at end of file
diff --git a/phpinfo.php b/phpinfo.php
new file mode 100755
index 0000000..d2b25e4
--- /dev/null
+++ b/phpinfo.php
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/services/amfphp/DiscoveryService.php b/services/amfphp/DiscoveryService.php
new file mode 100755
index 0000000..4e13333
--- /dev/null
+++ b/services/amfphp/DiscoveryService.php
@@ -0,0 +1,148 @@
+_omit = array();
+ $this->_path = dirname(dirname(realpath(__FILE__))) . '/';
+ $services = $this->_listServices();
+ //Now sort on key
+ ksort($services);
+ $out = array();
+ foreach($services as $key => $val)
+ {
+ if($key == "zzz_default")
+ {
+ foreach($val as $key2 => $val2)
+ {
+ $out[] = array("label" => $val2[0], "data" => $val2[1]);
+ }
+ }
+ else
+ {
+ $children = array();
+ foreach($val as $key2 => $val2)
+ {
+ $children[] = array("label" => $val2[0], "data" => $val2[1]);
+ }
+ $out[] = array("label" => $key, "children" => $children, "open" => true);
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Describe a service and all its methods
+ * @param $data An object containing 'label' and 'data' keys
+ */
+ function describeService($data)
+ {
+ $className = $data['label'];
+ //Sanitize path
+ $path = str_replace('..', '', $data['data']);
+ //Generate the method table from this info
+ $this->_path = dirname(dirname(realpath(__FILE__))) . DIRECTORY_SEPARATOR;
+
+ $methodTable = MethodTable::create($this->_path . $path . $className . '.php', NULL, $classComment);
+ return array($methodTable, $classComment);
+ }
+
+ function _listServices($dir = "", $suffix = "")
+ {
+ if($dir == "")
+ {
+ $dir = $this->_path;
+ }
+ $services = array();
+ if(in_array($suffix, $this->_omit)){ return; }
+ if ($handle = opendir($dir . $suffix))
+ {
+ while (false !== ($file = readdir($handle)))
+ {
+ chdir(dirname(__FILE__));
+ if ($file != "." && $file != "..")
+ {
+ if(is_file($dir . $suffix . $file))
+ {
+ if(strpos($file, '.methodTable') !== FALSE)
+ {
+ continue;
+ }
+ $index = strrpos($file, '.');
+ $before = substr($file, 0, $index);
+ $after = substr($file, $index + 1);
+
+ if($after == 'php')
+ {
+ $loc = "zzz_default";
+ if($suffix != "")
+ {
+ $loc = str_replace(DIRECTORY_SEPARATOR,'.', substr($suffix, 0, -1));
+ }
+
+ if($services[$loc] == NULL)
+ {
+ $services[$loc] = array();
+ }
+ $services[$loc][] = array($before, $suffix);
+ //array_push($this->_classes, $before);
+ }
+
+ }
+ elseif(is_dir($dir . $suffix . $file))
+ {
+ $insideDir = $this->_listServices($dir, $suffix . $file . DIRECTORY_SEPARATOR);
+ if(is_array($insideDir))
+ {
+ $services = $services + $insideDir;
+ }
+ }
+ }
+ }
+ }else{
+ //echo("error");
+ }
+ closedir($handle);
+ return $services;
+ }
+
+ function listTemplates()
+ {
+ $templates = array();
+ if ($handle = opendir('templates'))
+ {
+ while (false !== ($file = readdir($handle)))
+ {
+ //chdir(dirname(__FILE__));
+ if ($file != "." && $file != "..")
+ {
+ if(is_file('./templates/' . $file))
+ {
+ $index = strrpos($file, '.');
+ $before = substr($file, 0, $index);
+ $after = substr($file, $index + 1);
+
+ if($after == 'php')
+ {
+ $templates[] = $before;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ trigger_error("Could not open templates dir");
+ }
+ return $templates;
+ }
+}
\ No newline at end of file
diff --git a/services/place_services_here.txt b/services/place_services_here.txt
new file mode 100755
index 0000000..126ef01
--- /dev/null
+++ b/services/place_services_here.txt
@@ -0,0 +1 @@
+Place services here...
\ No newline at end of file
diff --git a/services/tuve.inc b/services/tuve.inc
new file mode 100755
index 0000000..24526ee
--- /dev/null
+++ b/services/tuve.inc
@@ -0,0 +1,9 @@
+
+Define('DATABASE_SERVER', 'ivorytower.ubixonline.com');
+Define('DATABASE_USERNAME', 'tuve');
+Define('DATABASE_PASSWORD', '5558585');
+Define('DATABASE_NAME', 'tuve');
+
+include("/usr/web/sites/tuve.tv/include/funcs.inc");
+
+?>
diff --git a/services/tuve.php b/services/tuve.php
new file mode 100755
index 0000000..f6351ca
--- /dev/null
+++ b/services/tuve.php
@@ -0,0 +1,298 @@
+mysqli = new mysqli(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME);
+ # Check MySQL connection
+ if (mysqli_connect_errno()) {
+ # Dont use die (Fatal Error), return useful info to the client
+ trigger_error("AMFPHP Remoting 'sample' class could not connect: " . mysqli_connect_error());
+ }
+ }
+
+ /* Function For TUplayer */
+ function pVid($vid) {
+ if ($vid == 0)
+ $query = "SELECT file,count,artist,title,vid FROM videos WHERE rating < 4 AND mType = 1 AND length < 610 ORDER BY rand() LIMIT 1";
+ else
+ $query = "SELECT file,count,artist,title,vid FROM videos WHERE vid = $vid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ $nCount = $return_array[0]['count'] + 1;
+ $query = "UPDATE videos SET count = $nCount WHERE vid = $vid";
+ $this->mysqli->query($query);
+ return($return_array);
+
+ }
+ function sendFB($data) {
+ // To send HTML mail, the Content-type header must be set
+ $headers = 'MIME-Version: 1.0' . "\r\n";
+ $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
+ $headers .= 'From: TUve Feedback ' . "\r\n";
+
+ mail("Christopher Olsen ,Mark Iuzzolino ",$data['subject'] . " - " . $data['username'],$data['message'],$headers);
+ }
+
+ function getVideo($data) {
+ $query = "SELECT * FROM videos WHERE vid = $data";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+
+ function getArtists($data) {
+ $sKey = $data['skey'];
+ $uid = $data['uid'];
+
+ if ($data['gid'] == 1)
+ $query = "SELECT artist,aid FROM artists WHERE artist LIKE \"%$sKey%\" ORDER BY artist";
+ else
+ $query = "SELECT artist,aid FROM artists WHERE artist LIKE \"%$sKey%\" AND oid = $uid ORDER BY artist";
+
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+
+ function getUsers($data) {
+ if ($data['gid'] == 1)
+ $query = "SELECT username,uid FROM users ORDER BY username";
+ else
+ $query = "SELECT username,uid FROM users WHERE uid = " . $data['uid'];
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+
+ }
+
+ function getVideos($data) {
+ $sKey = $data['skey'];
+ $uid = $data['uid'];
+ if ($data['gid'] == 1)
+ $query = "SELECT artist,title,vid FROM videos WHERE artist LIKE \"%$sKey%\" OR title LIKE \"%$sKey%\" AND status = 0 ORDER BY artist,title";
+ else
+ $query = "SELECT artist,title,vid FROM videos WHERE oid = $uid AND (artist LIKE \"%$sKey%\" OR title LIKE \"%$sKey%\") status = 0 ORDER BY artist,title";
+
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query [%query] error: " . $errno);
+ }
+
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+
+ function getChans() {
+ $query = "SELECT channel FROM channels";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database [$query] query error: " . $errno);
+ }
+
+ if ($result->num_rows == 0) {
+ $return_array[] = array('channel' => '#General');
+ }
+ else {
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ }
+
+ return($return_array);
+ }
+
+
+ function getInfo($data) {
+ $query = "SELECT thumb,v.artist,title,sbio FROM videos v INNER JOIN artists a ON v.aid = a.aid WHERE vid = $data";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database [$query] query error: " . $errno);
+ }
+
+ if ($result->num_rows == 0) {
+ $return_array[] = array('thumb' => 'UbixCube.swf','artist' => 'Unknown','title' => 'Unknown');
+ }
+ else {
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ }
+
+ return($return_array);
+ }
+
+ function getNextMovie() {
+ $query = "SELECT file,artist,title FROM videos";
+ if (!$result = @$this->mysqli->query($query)) {
+ $errno = $this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+
+ $rn = rand(0,$result->num_rows);
+ for ($i=0;$i < $rn;$i++)
+ $row = $result->fetch_assoc();
+
+ return($row);
+ }
+
+ function findSongs($data) {
+ $skey = $data['skey'];
+ $srating = $data['srating'];
+ $sclass = $data['sclass'];
+ $exclusive = $data['exclusive'];
+ if ($data['inca'] == 2)
+ $mType = " AND mType >= 1";
+ else
+ $mType = " AND mType = 1";
+
+ $query = "SELECT vid,artist,title,length,thumb,genre FROM videos WHERE status = 0 AND (artist like \"%$skey%\" OR title like \"%$skey%\") AND rating <= $srating$mType";
+ if ($sclass != 0)
+ $query .= " AND classification = $sclass";
+ if ($exclusive != 0)
+ $query .= " AND oid = $exclusive";
+
+ $query .= " ORDER BY artist,title";
+
+ if (!$result = @$this->mysqli->query($query)) {
+ $errno = $this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database [$query] query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ if ($row['length'] > 3600)
+ $row['length'] = makeTime($row['length']); //date("H:i:s",$row['length']);
+ else
+ $row['length'] = makeTime($row['length']); date("i:s",$row['length']);
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+ function findSongsVOD($data) {
+ $skey = $data['skey'];
+ $srating = $data['srating'];
+ $sclass = $data['sclass'];
+ $exclusive = $data['exclusive'];
+ if ($data['inca'] == 2)
+ $mType = " AND mType >= 1";
+ else
+ $mType = " AND mType = 1";
+
+ $query = "SELECT vid,artist,title,length,thumb,genre,file FROM videos WHERE (artist like \"%$skey%\" OR title like \"%$skey%\") AND rating <= $srating$mType";
+ if ($sclass != 0)
+ $query .= " AND classification = $sclass";
+ if ($exclusive != 0)
+ $query .= " AND oid = $exclusive";
+
+ $query .= " ORDER BY artist,title";
+
+ if (!$result = @$this->mysqli->query($query)) {
+ $errno = $this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database [$query] query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ if ($row['length'] > 3600)
+ $row['length'] = date("H:i:s",$row['length']);
+ else
+ $row['length'] = date("i:s",$row['length']);
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+ function userAuth($data) {
+ $username = $data['username'];
+ $password = $data['password'];
+ $query = "SELECT uid,username,password,gid,active,profile_image,main_image,lcount FROM users WHERE username LIKE '$username' AND password = '$password'";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+
+ if ($result->num_rows == 0) {
+ $row['active'] = "0"; //return_array[] = array('active' => '0');
+ return($row);
+ }
+
+ $row = $result->fetch_assoc();
+
+ $lcount = $row['lcount'] + 1;
+
+ $query = "UPDATE users SET lcount = $lcount, laston = " . time() . " WHERE uid = " . $row['uid'];
+ $this->mysqli->query($query);
+
+
+ $imIndex = $row['profile_image'];
+ if ($imIndex == 0)
+ $row['my_image'] = $row['main_image'] . "-small.png";
+ else {
+ switch($imIndex) {
+ case 1:
+ $row['my_image'] = "http://www.ubixonline.com/images/sb/none.gif-small.png";
+ case 2:
+ $row['my_image'] = "http://www.ubixonline.com/images/sb/female_icon.png-small.png";
+ case 3:
+ $row['my_image'] = "http://www.ubixonline.com/images/sb/male_icon.png-small.png";
+ }
+ }
+
+ return($row);
+ }
+
+ function getFriends($uid) {
+ $query = "SELECT username,uid FROM friends f INNER JOIN users u ON f.fid = u.uid WHERE oid = $uid ORDER BY username";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+
+ }
+?>
diff --git a/services/tuveAdmin.php b/services/tuveAdmin.php
new file mode 100755
index 0000000..5f40323
--- /dev/null
+++ b/services/tuveAdmin.php
@@ -0,0 +1,837 @@
+mysqli = new mysqli(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME);
+ # Check MySQL connection
+ if (mysqli_connect_errno()) {
+ # Dont use die (Fatal Error), return useful info to the client
+ trigger_error("AMFPHP Remoting 'sample' class could not connect: " . mysqli_connect_error());
+ }
+ }
+
+ function checkNewMail($uid) {
+ $query = "SELECT mid FROM mail WHERE oid = $uid AND folder = 0 AND status = 1 LIMIT 1";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+
+ if ($result->num_rows == 1)
+ return(1);
+ else
+ return(0);
+ }
+
+ function schedVid($data) {
+ $sTime = strtotime($data['sTime']);
+ $cid = $data['cid'];
+ $vid = $data['sVid'];
+ $query = "INSERT INTO schedule (cid,vid,time) VALUES($cid,$vid,$sTime)";
+ $this->mysqli->query($query);
+ $query = "UPDATE channels SET updated = 1 WHERE cid = $cid";
+ $this->mysqli->query($query);
+ }
+
+ function requestBuddy($data) {
+ $rUser = $data['rUser'];
+ $rUID = $data['rUID'];
+ $username = $data['rName'];
+
+ $query = "SELECT uid,notifications,firstname,lastname,email FROM users WHERE username LIKE '$rUser'";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+
+ if ($result->num_rows == 0) {
+ $pdate = time();
+ $query = "INSERT INTO mail (oid,sid,subject,message,date) VALUES($rUID,$rUID,'Friend Request Failed','Friend Request Failed \nNo Such User: $rUser \n\n',$pdate)";
+ $this->mysqli->query($query);
+ }
+ else {
+ $row = $result->fetch_assoc();
+ $uid = $row['uid'];
+ $notifications = $row['notifications'];
+ $fname = $row['firstname'];
+ $lname = $row['lastname'];
+ $email = $row['email'];
+
+ $pdate = time();
+ $message = str_replace("\r"," ",$data['rMessage']);
+ $message .= "Approve Deny \n";
+ $message = $this->mysqli->real_escape_string($message);
+ $query = "INSERT INTO friends (oid,fid) VALUES($rUID,$uid)";
+ $this->mysqli->query($query);
+ $query = "INSERT INTO friends (fid,oid) VALUES($rUID,$uid)";
+ $this->mysqli->query($query);
+ $query = "INSERT INTO mail (oid,sid,subject,message,date) VALUES($uid,$rUID,'New Friend Request From $username','$message',$pdate)";
+ $this->mysqli->query($query);
+ /* Send Message To User */
+ if ($notifications[N_FREQUEST] == 1)
+ send_mail("$fname $lname <$email>","$fname, You have received a new friends. Follow this link http://www.tuve.tv/launch.php to see your new friends request. Sincerely, TUve Support","You have a new friends request from $username","support@tuve.tv","TUve Support");
+ }
+ }
+
+
+ function loadWidget($wid) {
+ $query = "SELECT * FROM widgets WHERE wid = $wid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+ $row = $result->fetch_assoc();
+ $row['ts'] = time();
+ return($row);
+ }
+
+ function deleteVid($vid) {
+ $query = "UPDATE videos SET status = 1 WHERE vid = $vid";
+ $this->mysqli->query($query);
+ }
+
+ function findUsers($data) {
+ $skey = $data['skey'];
+
+ $query = "SELECT username,main_image,profile_image,caption,city,state_prov FROM users WHERE username LIKE '%$skey%'";
+
+ if ($data['gender'] == 1)
+ $query .= " AND gender = 1";
+ else if ($data['gender'] == 2)
+ $query .= " AND gender = 2";
+
+ $syear = 2007 - (18 + $data['sAge']);
+ $eyear = 2007 - (18 + $data['eAge']);
+
+ $query .= " AND (byear <= $syear AND byear >= $eyear)";
+
+
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $imIndex = $row['profile_image'];
+ if ($imIndex == 0)
+ $row['my_image'] = $row['main_image'] . "-small.png";
+ else {
+ switch($imIndex) {
+ case 1:
+ $row['my_image'] = "http://www.ubixonline.com/images/sb/none.gif-small.png";
+ case 2:
+ $row['my_image'] = "http://www.ubixonline.com/images/sb/female_icon.png-small.png";
+ case 3:
+ $row['my_image'] = "http://www.ubixonline.com/images/sb/male_icon.png-small.png";
+ }
+ }
+ $row['location'] = $row['city'] . ", " . $row['state_prov'];
+
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+ function finBroad($file) {
+ $query = "UPDATE videos SET status = 5 WHERE file = '$file.flv'";
+ $this->mysqli->query($query);
+ }
+
+ function addVid($data) {
+ $artist = $data['username'];
+ $title = $data['title'];
+ $file = $data['file'];
+ $oid = $data['uid'];
+ $added = time();
+ $query = "INSERT INTO videos (artist,title,genre,file,rating,classification,oid,count,mType,added,status) VALUES('$artist','$title','Recorded Video','$file.flv',2,6,$oid,0,1,$added,6)";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+
+ }
+
+ function updateMsgFolder($data) {
+ $mid = $data['mid'];
+ $folder = $data['folder'];
+
+ $query = "UPDATE mail SET folder = $folder WHERE mid = $mid";
+ $this->mysqli->query($query);
+ }
+
+ function mailRead($mid) {
+ $query = "UPDATE mail SET status = 2 WHERE mid = $mid";
+ $this->mysqli->query($query);
+ }
+
+ function updatePass($data) {
+ $uid = $data['uid'];
+ $pass = $data['pass'];
+ $query = "UPDATE users SET password = '$pass' WHERE uid = $uid";
+ $this->mysqli->query($query);
+ }
+
+ function approveFriend($data) {
+ $fid = $data['fid'];
+ $oid = $data['oid'];
+ $approved = $data['approved'];
+
+ if ($approved == 0) {
+ $query = "DELETE FROM friends WHERE fid = $fid AND oid = $oid AND approved = 0";
+ $this->mysqli->query($query);
+ $query = "DELETE FROM friends WHERE fid = $oid AND oid = $fid AND approved = 0";
+ $this->mysqli->query($query);
+
+ $pdate = time();
+ $query = "INSERT INTO mail (oid,sid,date,subject,message,folder) VALUES($fid,$oid,$pdate,'Friend Request Denied','This Friend Request Has Been Denied',0)";
+ $this->mysqli->query($query);
+
+ $query = "SELECT firstname,lastname,email FROM users WHERE uid = $fid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+ $row = $result->fetch_assoc();
+ send_mail("$row[firstname] $row[lastname] <$row[email]>","Your request to make $data[username] your friend has been denied","Friend Request Denied","support@tuve.tv","TUve Support");
+
+ }
+ else {
+ $query = "UPDATE friends SET approved = 1 WHERE approved = 0 AND fid = $fid AND oid = $oid";
+ $this->mysqli->query($query);
+ $query = "UPDATE friends SET approved = 1 WHERE approved = 0 AND fid = $oid AND oid = $fid";
+ $this->mysqli->query($query);
+
+ $pdate = time();
+ $query = "INSERT INTO mail (oid,sid,date,subject,message,folder) VALUES($fid,$oid,$pdate,'Friend Request Approved','This Friend Request Has Been Approved',0)";
+ $this->mysqli->query($query);
+
+ $query = "SELECT firstname,lastname,email FROM users WHERE uid = $fid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+ $row = $result->fetch_assoc();
+ send_mail("$row[firstname] $row[lastname] <$row[email]>","Your request to make $data[username] your friend has been approved","Friend Request Approved","support@tuve.tv","TUve Support");
+
+ }
+ }
+
+ function getMail($uid) {
+ $query = "SELECT mid,subject,username,date,message,sid,folder,status FROM mail m INNER JOIN users u ON m.sid = u.uid WHERE m.oid = $uid ORDER BY mid DESC";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $row['date'] = date("m/d/Y g:i A",$row['date']);
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+
+ function getProfile($user) {
+ $query = "SELECT username,uid,gid,bday,bmonth,byear,about_me,caption,main_image,profile_image,gender,city,state_prov,postal_code FROM users WHERE username LIKE '$user'";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+
+ function getUserInfo($uid) {
+ $query = "SELECT username,uid,gid,bday,bmonth,byear,about_me,caption,main_image,profile_image,gender,city,state_prov,postal_code FROM users WHERE uid = $uid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . " query: " . $query);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+ function updateUserInfo($data) {
+ $uid = $data['uid'];
+
+ $caption = $this->mysqli->real_escape_string($data['caption']);
+ $about_me = $this->mysqli->real_escape_string($data['about_me']);
+ $city = $this->mysqli->real_escape_string($data['city']);
+ $state_prov = $this->mysqli->real_escape_string($data['state_prov']);
+ $zip_postal = $this->mysqli->real_escape_string($data['zip_postal']);
+ $gender = $data['gender'];
+ $bday = $data['bday'];
+ $bmonth = $data['bmonth'];
+ $byear = $data['byear'];
+ $profile_image = $data['profile_image'];
+
+ if ($caption == "")
+ $caption = "No Caption Available";
+
+ $query = "UPDATE users SET profile_image = $profile_image";
+
+ if ($caption != "")
+ $query .= ",caption='$caption'";
+
+ if ($about_me != "")
+ $query .= ",about_me='$about_me'";
+
+ if ($city != "")
+ $query .= ",city='$city'";
+
+ if ($sate_prove != "")
+ $query .= ",state_prov='$state_prov'";
+
+ if ($zip_postal != "")
+ $query .= ",zip_postal='$zip_postal'";
+
+ if ($gender > 0)
+ $query .= ",gender = $gender";
+
+ if ($bday > 0)
+ $query .= ",bday = $bday";
+
+ if ($bmonth > 0)
+ $query .= ",bmonth = $bmonth";
+
+ if ($byear > 1900)
+ $query .= ",byear = $byear";
+ $query .= " WHERE uid = $uid";
+ $this->mysqli->query($query);
+ //trigger_error("AMFPHP Remoting database SELECT query error: " . $errno . "Query: $query");
+ }
+
+ /* Authenticates a user into the system */
+ function userAuth($data) {
+ $username = $data['username'];
+ $password = $data['password'];
+ $query = "SELECT username,uid,gid,profile_image,main_image FROM users WHERE username = '$username' AND password = '$password'";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+/*
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+*/
+ $row = $result->fetch_assoc();
+
+ $imIndex = $row['profile_image'];
+ if ($imIndex == 0)
+ $row['my_image'] = $row['main_image'] . "-small.png";
+ else {
+ switch($imIndex) {
+ case 1:
+ $row['my_image'] = "http://www.ubixonline.com/images/sb/none.gif-small.png";
+ case 2:
+ $row['my_image'] = "http://www.ubixonline.com/images/sb/female_icon.png-small.png";
+ case 3:
+ $row['my_image'] = "http://www.ubixonline.com/images/sb/male_icon.png-small.png";
+ }
+ }
+
+ return($row);
+ // return($return_array);
+ }
+
+ function getUsers($data) {
+ if ($data['gid'] == 1)
+ $query = "SELECT username,uid FROM users ORDER BY username";
+ else
+ $query = "SELECT username,uid FROM users WHERE uid = " . $data['uid'];
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+
+ }
+
+ function getVideos($data) {
+ $sKey = $data['skey'];
+ $uid = $data['uid'];
+ if ($data['gid'] == 1)
+ $query = "SELECT artist,title,vid,length FROM videos WHERE (artist LIKE \"%$sKey%\" OR title LIKE \"%$sKey%\") AND status = 0 ORDER BY artist,title";
+ else
+ $query = "SELECT artist,title,vid,length FROM videos WHERE oid = $uid AND (artist LIKE \"%$sKey%\" OR title LIKE \"%$sKey%\") AND status = 0 ORDER BY artist,title";
+
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query [%query] error: " . $errno);
+ }
+
+ while ($row = $result->fetch_assoc()) {
+ $row['length'] = makeTime($row['length']);
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+ function getUserChans($data) {
+ $sKey = $data['skey'];
+ $uid = $data['uid'];
+ if ($data['gid'] == 1)
+ $query = "SELECT channel,cid FROM channels WHERE channel LIKE \"%$sKey%\" ORDER BY channel";
+ else
+ $query = "SELECT channel,cid FROM channels WHERE oid = $uid AND channel LIKE \"%$sKey%\" ORDER BY channel";
+
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query [%query] error: " . $errno);
+ }
+
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+ function getArtists($data) {
+ $sKey = $data['skey'];
+ $uid = $data['uid'];
+
+ if ($data['gid'] == 1)
+ $query = "SELECT artist,aid FROM artists WHERE artist LIKE \"%$sKey%\" ORDER BY artist";
+ else
+ $query = "SELECT artist,aid FROM artists WHERE artist LIKE \"%$sKey%\" AND oid = $uid ORDER BY artist";
+
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+ function getVideo($data) {
+ $query = "SELECT * FROM videos WHERE vid = $data";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ $row = $result->fetch_assoc();
+ return($row);
+ }
+ function getSchedule($data) {
+ $stime = strtotime($data[date]);
+ $etime = $stime + 86400;
+
+ if ($data['con'] > 1) {
+ $query = "DELETE FROM schedule WHERE sid = $data[con]";
+ $this->mysqli->query($query);
+ $query = "UPDATE channels SET updated = 1 WHERE cid = $data[cid]";
+ $this->mysqli->query($query);
+ }
+
+ $query = "SELECT sid,time,artist,title,length FROM schedule s INNER JOIN videos v ON s.vid = v.vid WHERE cid = $data[cid] AND (time >= $stime AND time < $etime) ORDER BY time";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ if ($data['con'] == 1) {
+ $prev['sid'] = 0;
+ $prev['length'] = 0;
+ $prev['time'] = 0;
+ while ($row = $result->fetch_assoc()) {
+ $tm = $row['time'] - ($prev['time'] + $prev['length']);
+ if ($tm > (0 - $row['time']) && $tm < 60) {
+ $row['time'] = $prev['time'] + floor($prev['length']) + 1;
+ $query = "UPDATE schedule SET time = $row[time] WHERE sid = $row[sid]";
+ $this->mysqli->query($query);
+ }
+ $prev['sid'] = $row['sid'];
+ $prev['length'] = $row['length'];
+ $prev['time'] = $row['time'];
+ $row['time'] = date("H:i:s",$row['time']);
+ $row['length'] = makeTime($row['length']);
+ $return_array[] = $row;
+ }
+ }
+ else {
+ while ($row = $result->fetch_assoc()) {
+ $row['time'] = date("H:i:s",$row['time']);
+ $row['length'] = makeTime($row['length']);
+ $return_array[] = $row;
+ }
+ }
+ return($return_array);
+ }
+
+ function getChannel($data) {
+ $query = "SELECT * FROM channels WHERE channel = '$data'";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+
+ $row = $result->fetch_assoc();
+ return($row);
+ }
+
+ function addArtist($data) {
+ $nArtist = $data['artist'];
+ $nOID = $data['oid'];
+
+ $query = "INSERT INTO artists (artist,photo,oid) VALUES(\"$nArtist\",'http://www.ubixonline.com/images/UbixCube.swf',$nOID)";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database INSERT query [$query] error: " . $errno);
+ }
+
+ }
+
+ function getArtist($data) {
+ $query = "SELECT * FROM artists WHERE aid = $data";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+
+ function updateVideo($data) {
+ $nRating = $data['rating'];
+ $nClass = $data['classification'];
+ $nGenre = addslashes($data['genre']);
+ $nTitle = $data['title'];
+ $nLength = $data['length'];
+ $nArtist = $data['artist'];
+ $nThumbFrame = $data['thumbFrame'];
+ $nAID = $data['aid'];
+ $nOID = $data['oid'];
+ $nDescription = addslashes($data['description']);
+
+ $vid = $data['vid'];
+ $query = "UPDATE videos SET rating = $nRating,classification = $nClass,genre = '$nGenre',title = \"$nTitle\",length = '$nLength',artist = \"$nArtist\",thumbFrame = '$nThumbFrame',aid = $nAID,description = \"$nDescription\",oid = $nOID WHERE vid = $vid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database UPDATE query [$query] error: " . $errno);
+ return(0x1);
+ }
+ return(0x0);
+ }
+
+ function updateChannel($data) {
+ $nRating = $data['rating'];
+ $nClass = $data['classification'];
+ $nTopic = $data['topic'];
+ $nOID = $data['oid'];
+ $nRandom = $data['random'];
+ $nQueue = $data['queue'];
+ $nExclusive = $data['exclusive'];
+ $nTime = $data['time'];
+ $nDescription = addslashes($data['description']);
+ $channel = $data['channel'];
+
+ $query = "UPDATE channels SET rating = $nRating,classification = $nClass,topic = \"$nTopic\",oid = $nOID,random = $nRandom,queue = $nQueue,exclusive = $nExclusive,time = $nTime,description = '$nDescription',updated = 1 WHERE channel = '$channel'";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database UPDATE query [$query] error: " . $errno);
+ return(0x1);
+ }
+ return(0x0);
+ }
+
+ function updateArtist($data) {
+ $nPhoto = $data['photo'];
+ $nArtist = $data['artist'];
+ $nBio = addslashes($data['description']);
+ $nOID = $data['oid'];
+ $aid = $data['aid'];
+ $nsBio = substr($nBio,0,252) . "...";
+
+ $query = "UPDATE artists SET artist = \"$nArtist\",photo = \"$nPhoto\",bio = \"$nBio\",oid = $nOID,sbio = \"$nsBio\" WHERE aid = $aid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database UPDATE query [$query] error: " . $errno);
+ return(0x1);
+ }
+ return(0x0);
+ }
+
+
+ function regenThumb($data) {
+ $gentime = $data['time'];
+ $vid = $data['vid'];
+ /*
+ $file = $data['file'];
+ $cmd = "/usr/local/bin/ffmpeg -i \"/usr/web/sites/ubixonline.com/docroot/streams/$file\" -t 0.001 -ss $gentime -vframes 1 -f mjpeg /tmp/1.jpg";
+ #$cmd = "/usr/local/bin/ffmpeg -i '/usr/web/sites/ubixonline.com/docroot/streams/$file' -t 0.001 -ss $gentime -vframes 1 -f mjpeg -s 200x150 /tmp/1.jpg";
+ system($cmd);
+ $cmd = "/bin/mv /tmp/1.jpg \"/usr/web/sites/ubixonline.com/docroot/images/$file.jpg\"";
+ system($cmd);
+ */
+ $fp = fopen("http://monkey.ubixos.com:6969/genthumb.php?data[vid]=$vid&data[gentime]=$gentime","r");
+ $file = fread($fp,1024);
+ $query = "UPDATE videos SET thumbFrame = '$gentime' WHERE vid = $vid";
+ $this->mysqli->query($query);
+
+ return("$file?" . time());
+ }
+
+ function chanReg($data) {
+ // To send HTML mail, the Content-type header must be set
+ $headers = 'MIME-Version: 1.0' . "\r\n";
+ $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
+ $headers .= 'From: TUve Manager ' . "\r\n";
+
+ $message = "Channel: " . $data['channel'] . " \n";
+ $message .= "Description: " . $data['description'] . " \n";
+ $message .= "User: " . $data['username'] . " \n";
+
+ mail("Christopher Olsen ,Mark Iuzzolino ","New Chan Reg",$message,$headers);
+ }
+
+
+
+// Old Stuff Here
+
+ function sendFB($data) {
+ // To send HTML mail, the Content-type header must be set
+ $headers = 'MIME-Version: 1.0' . "\r\n";
+ $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
+ $headers .= 'From: TUve Feedback ' . "\r\n";
+
+ mail("Christopher Olsen ,Mark Iuzzolino ",$data['subject'] . " - " . $data['username'],$data['message'],$headers);
+ }
+
+
+ /* Returns Info */
+ function getInfo($data) {
+ $query = "SELECT thumb,v.artist,title,sbio FROM videos v INNER JOIN artists a ON v.aid = a.aid WHERE vid = $data";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database [$query] query error: " . $errno);
+ }
+
+ if ($result->num_rows == 0) {
+ $row = array('thumb' => 'UbixCube.swf','artist' => 'Unknown','title' => 'Unknown');
+ }
+ else {
+ $row = $result->fetch_assoc();
+ }
+
+ return($row);
+ }
+
+ /* Get Full Video Information */
+ function getFullInfo($vid) {
+ $query = "SELECT thumb,a.artist,title,bio,photo,description FROM videos v INNER JOIN artists a ON v.aid = a.aid WHERE v.vid = $vid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database [$query] query error: " . $errno);
+ }
+
+ if ($result->num_rows == 0) {
+ $query = "SELECT thumb,artist,title,'NA' as bio,'No Description' as description,'/images/UbixCube.swf' AS photo FROM videos WHERE vid = $vid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database [$query] query error: " . $errno);
+ }
+ }
+
+ $row = $result->fetch_assoc();
+ return($row);
+ } /* End getFullInfo */
+
+
+ function getNextMovie() {
+ $query = "SELECT file,artist,title FROM videos";
+ if (!$result = @$this->mysqli->query($query)) {
+ $errno = $this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+
+ $rn = rand(0,$result->num_rows);
+ for ($i=0;$i < $rn;$i++)
+ $row = $result->fetch_assoc();
+
+ return($row);
+ }
+
+ function findSongs($data) {
+
+ $skey = $data['skey'];
+ $srating = $data['srating'];
+ $sclass = $data['sclass'];
+
+ if ($sclass == "0")
+ $query = "SELECT * FROM videos WHERE (artist like \"%$skey%\" OR title like \"%$skey%\") AND rating <= $srating ORDER BY artist";
+ else
+ $query = "SELECT * FROM videos WHERE (artist like \"%$skey%\" OR title like \"%$skey%\") AND rating <= $srating AND class = $sclass ORDER BY artist";
+
+ if (!$result = @$this->mysqli->query($query)) {
+ $errno = $this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database [$query] query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+ function getView($uid) {
+ $query = "SELECT viewXML FROM users WHERE uid = $uid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+ /* Send Mail For TUve */
+ function sendMail($data) {
+ $oid = $data['tid'];
+ $sid = $data['fid'];
+ $from = $data['from'];
+
+ if ($oid == "")
+ $oid = 78;
+ if ($sid == "")
+ $sid = 78;
+
+ $subject = $this->mysqli->real_escape_string($data['subject']);
+ $message = $this->mysqli->real_escape_string($data['message']);
+
+ $pdate = time();
+
+ $query = "INSERT INTO mail (oid,sid,date,subject,message,folder) VALUES($oid,$sid,$pdate,'$subject','$message',0)";
+ if (!$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: [$query] " . $errno);
+ }
+
+ $query = "INSERT INTO mail (oid,sid,date,subject,message,folder) VALUES($sid,$oid,$pdate,'$subject','$message',1)";
+ if (!$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: [$query] " . $errno);
+ }
+
+
+ $query = "SELECT firstname,lastname,email,notifications FROM users WHERE uid = $oid";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: [$query] " . $errno);
+ }
+ $row = $result->fetch_assoc();
+
+ if ($row['notifications'][N_MAIL])
+ send_mail("$row[firstname] $row[lastname] <$row[email]>","You have a new message waiting for you. Message Sender: $from Message Subject: $data[subject] Please follow this link http://www.tuve.tv/ to log into your account. Sincerely, TUve Staff ","New Message On TUve","support@tuve.tv","TUve Support");
+
+ return;
+ } /* End Send Mail for TUve */
+ /* Get Picture */
+ function getPic($data) {
+ $query = "SELECT profile_image,main_image FROM users WHERE username LIKE '$data'";
+
+ if (!$result = @$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+
+ $row = $result->fetch_assoc();
+
+ $imIndex = $row['profile_image'];
+ if ($imIndex == 0)
+ return($row['main_image'] . "-small.png");
+ else {
+ switch($imIndex) {
+ case 1:
+ return("http://www.ubixonline.com/images/sb/none.gif-small.png");
+ case 2:
+ return("http://www.ubixonline.com/images/sb/female_icon.png-small.png");
+ case 3:
+ return("http://www.ubixonline.com/images/sb/male_icon.png-small.png");
+ }
+ }
+ }
+
+ function getChans() {
+ $query = "SELECT channel FROM channels";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database [$query] query error: " . $errno);
+ }
+
+ if ($result->num_rows == 0) {
+ $return_array[] = array('channel' => 'TUv�');
+ }
+ else {
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ }
+ return($return_array);
+ }
+
+ function getFriends($uid) {
+ $query = "SELECT username,uid FROM friends f INNER JOIN users u ON f.fid = u.uid WHERE oid = $uid ORDER BY username";
+ if (!$result=@$this->mysqli->query($query)) {
+ $errno=$this->mysqli->errno;
+ $this->mysqli->close();
+ trigger_error("AMFPHP Remoting database SELECT query error: " . $errno);
+ }
+ while ($row = $result->fetch_assoc()) {
+ $return_array[] = $row;
+ }
+ return($return_array);
+ }
+
+
+ }
+?>
diff --git a/xmlrpc.php b/xmlrpc.php
new file mode 100755
index 0000000..9e9ed33
--- /dev/null
+++ b/xmlrpc.php
@@ -0,0 +1,15 @@
+setBaseClassPath($servicesPath);
+
+ $gateway->service();
+?>
\ No newline at end of file