Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by MrFish

  1. var object = document.createElement("object");object.setAttribute("width", 519);object.setAttribute("height", 292);object.setAttribute("id", "video"); var mparam = document.createElement("param");mparam.setAttribute("name", "movie");mparam.setAttribute("value", flashUrl); var fsparam = document.createElement("param");fsparam.setAttribute("name", "allowFullScreen");fsparam.setAttribute("value", "true"); var asaparam = document.createElement("param");asaparam.setAttribute("name", "allowscriptaccess");asaparam.setAttribute("value", "always"); var embed = document.createElement("embed");embed.setAttribute("src", flashUrl);embed.setAttribute("type", "application/x-shockwave-flash");embed.setAttribute("width", "519");embed.setAttribute("height", "292");embed.setAttribute("allowscriptaccess", "always");embed.setAttribute("allowsfullscreen", "true"); object.appendChild(mparam);object.appendChild(fsparam);object.appendChild(asaparam);*** object.appendChild(embed); $("#video").remove();$("#video_main")[0].appendChild(object); This code works in all browsers except for IE8 and lower. It's stopping at the line I marked with three asterisks ( object.appendChild(embed) ). It gives me this error without any other explanation- I don't know why it can't append embed elements. I also tried object.innerHTML += embed.outerHTML but that had an undescrive runtime error. http://www.price-homes.com/Home
  2. MrFish

    Running IF ELSE

    Looks like I need to create a mysql procedure to do this. I will just do something else in php instead.
  3. MrFish

    Running IF ELSE

    Semi-Solved I am trying to follow the MySQL site but I can't get this to work- IF EXISTS (SELECT * FROM information_table.COLUMNS WHERE TABLE_NAME='db_name' AND TABLE_NAME='communityCustomFeatures' AND COLUMN_NAME='ccf_id');BEGIN;ALTER TABLE `communityCustomFeatures` ADD `ccf_id` ) FIRST;ELSE;ALTER TABLE `communityCustomFeatures` MODIFY `ccf_id` ) FIRST;END IF; It turns up this error- ------------------ IF EXISTS ( SELECT * FROM information_table.COLUMNSWHERE TABLE_NAME = 'db_name'AND TABLE_NAME = 'communityCustomFeatures'AND COLUMN_NAME = 'ccf_id' ); MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS (SELECT * FROM information_table.COLUMNS WHERE TABLE_NAME='db_name' AN' at line 1 ------------------- I cannot figure out why.
  4. Yes that worked. I wouldn't have guessed with $Class being a string and all. Thanks.
  5. I'm doing some tests now. How would I do this if possible? Trying to avoid eval. <?php class A { function __toString(){return "A";} } $Class = A; $Instance = new $Class($parameters = NULL); echo "No Error";?>
  6. Try getting the session id. session_id();Add it to an active viewers table with the video code viewed and the session id used to view that video.If you find a match then it was viewed by that user.Clear this once a day or it will stack up. There may be a more elegant solution.
  7. I'm trying to write an sql parsing tool for specific purposes. I'm going to run all the sql statements through mysql but any create statement needs to update the table if there are new fields. So it doubles as an alter statement. The problem I'm having is a simple one but I'm wonder how this could be possible in PHP. Each statement I parse out will be called a Command and extend the SQLCommand super class. I'm going to determine what command it's using by looping through each word of a command, adding it to a string where I try to match it to an associative array. class SQLCommand { private $sql; private $executables; //String private $command; private $table; //String[] private $flags; private $parameterSets; function SQLCommand($str) { $this->sql = str; } function getExecutables() { return $this->executables; } } class SQLCreate extends SQLCommand { } CREATE TABLE IF NOT EXISTS `builders` ( `bld_id` int(11) NOT NULL AUTO_INCREMENT, `bld_name` varchar(30) NOT NULL, `bld_brandLogo_med` mediumint(9) NOT NULL, `bld_brandLogo_sm` mediumint(9) NOT NULL, `bld_reportingName` varchar(75) NOT NULL, `bld_defaultLeadsEmail` varchar(100) NOT NULL, `bld_copyLeadsEmail` varchar(100) NOT NULL, `bld_builderWebsite` varchar(255) NOT NULL, `bld_LeadsPerMessage` enum('All','1') NOT NULL, PRIMARY KEY (`bld_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; This would look for "CREATE" then "CREATE TABLE" (where it will make a match). I could create a long if-else or switch to choose what Command to pass back but here is what I'd like to do- function parseCommands() { $commandRegex = "|([^;]+)|"; preg_match_all($commandRegex, $this->sql, $matches); foreach($matches[1] as $match) { $this->commands[] = self::SQLCommandFactory($match); } } .... public static function SQLCommandFactory($commandSQL) { $knownCommands = array( "CREATE TABLE" => &SQLCreate; ); print_r($knownCommands); return NULL; } Is this possible? So I can eventually do $CommandCls &= $knownCommands[$commandStr];$Command = new *$CommandCls($commandStr); My pointers might be off. Haven't had much practice with them.
  8. I'm to add a functionality to an already existing batch upload script on a site. I don't want to rewrite what already exists. I want to have a file input above the original form that lets you select multiple files. When you select them it add each of those files to an individual upload in the form. This lets the person change the name and category of the file individually. How can I do this?
  9. I'm writing a script to push out config file updates to a number of sites. In the configuration some site specific information shouldn't change like db username and passwords. Here is a sample- <?php // #Mobile Sniffer ... // ~Mobile Sniffer // #Constants // #host define("HOST", ""); // ~host // #user define("USER", ""); // ~user // #pass define("PASS", ""); // ~pass // #db define("DB", ""); // ~db // #wysiwyg define("WYSIWYG", false); // ~wysiwyg // #paths ... // ~paths // #Courtesy Connect mysql_connect(HOST, USER, PASS) or die(mysql_error()); mysql_select_db(DB) or die(mysql_error()); // ~Courtesy Connect // #Dependencies Load require_once(__BASEADMINPATH__."bin/loaddependencies.php"); // ~Dependencies Load?> So to do what I'm thinking I've split everything into chunks. A chunk starts with # followed by the name of the chunk and ends with ~ followed by the name of the chunk. Some chunks are nested- they don't have to be but I'd like to organize it better. You can see the problem with a regex that looks like this- |\/\/ #(.*)([\w\W\d\s]+)\/\/ ~(.*)|U This would pull this chunk- // #Constants// #hostdefine("HOST", "");// ~host So what I'd like to be able to do is something like this- |\/\/ #(.*)([\w\W\d\s]+)\/\/ ~$1|U Where the regex would use the first match as an identifier for the closing tag ($1). But I can't find any examples of this. Is it possible?
  10. Ok I think I found the solution myself. PanelOS extends Object which handles events. function Object(){}Object.eventListeners = null;Object.prototype.constructor = function(){this.eventListeners = [];}Object.prototype.dispatchEvent = function(evtName){for(var i = 0; i < this.eventListeners.length; i++){ var Evt = this.eventListeners[i]; if(Evt.name == evtName) Evt.callback();}}Object.prototype.addEventListener(nm, callback){var Evt = new Event();Evt.name = nm;Evt.callback = callback;this.eventListeners.push(Evt);return Evt;}function Event(){this.name = "Undefined";this.callback = function(){};} PanelOS dispatches events. The events with that name run the callback. /** #include <object.js>****/function PanelOS(){}PanelOS.prototype = new Object();PanelOS.prototype.BootLoader = null;PanelOS.prototype.ScriptLoader = null;PanelOS.prototype.StyleLoader = null;PanelOS.prototype.errors = null;PanelOS.prototype.warnings = null;PanelOS.prototype.messages = null;PanelOS.prototype.logs = null;PanelOS.prototype.constructor = function(){}PanelOS.prototype.loadScript = function(src){var head = document.getElementById("head");if(head != null){}else{ this.logError}}PanelOS.prototype.logError(str){var Lg = new Log();Lg.type = "error";Lg.message = str;this.errors.push(Lg);this.logs.push(Lg);this.dispatchEvent("error");}PanelOS.prototype.logWarning(str){var Lg = new Log();Lg.type = "warning";Lg.message = str;this.warnings.push(str);this.logs.push(Lg);this.dispatchEvent("warning");}PanelOS.prototype.logMessage(str){var Lg = new Log();Lg.type = "message";Lg.message = str;this.messages.push(str);this.logs.push(Lg);this.dispatchEvent("message");} Is that how everyone else would have done it?
  11. Here is my situation. I have a javascript class I'm calling PanelOS (managing panels and such in an application). I want it to log errors, warnings, and messages. I have three methods to do this: logError, logWarning, logMessage. When these are used I want it to create a Log object and push it to these arrays and also call an onerror, onwarning, and onmessage event. I want all of theses events to call onlog as well. With this I will have any kind of view that is using it (lets say a black screen with white text for starters) be able to use the onerror event without overwriting the onerror method from calling onlog. This is my first time using prototype so if it looks funny that's why. function PanelOS(){}PanelOS.prototype.errors = null;PanelOS.prototype.warnings = null;PanelOS.prototype.messages = null;PanelOS.prototype.constructor = function(){}PanelOS.prototype.loadScript = function(src){var head = document.getElementById("head");if(head != null){}else{ this.logError("document head does not exist");}}PanelOS.prototype.logError(str){var Lg = new Log();Lg.type = "error";Lg.message = str;this.onerror(Lg);this.errors.push(Lg);}PanelOS.prototype.logWarning(str){var Lg = new Log();Lg.type = "error";Lg.message = str;this.onwarning(Lg);this.warnings.push(str);}PanelOS.prototype.logMessage(str){var Lg = new Log();Lg.type = "message";Lg.message = str;this.onmessage(lg);this.messages.push(str);}// EventsPanelOS.prototype.onerror = function(Lg){this.onlog(Lg);}PanelOS.prototype.onwarning = function(Lg){this.onlog(Lg);}PanelOS.prototype.onmessage = function(Lg){this.onlog(Lg);}PanelOS.prototype.onlog = function(Lg){} // Helper Objects function Log(){this.type = "Undefined";this.message = "Undefined";} So is there a way I can use the method in many 3rd party scripts without overwriting each other or the original? I could make something like an addEventListener to this but I'm not sure how I would do that.
  12. I have a feeling the answer to this is no (for security reasons) but I'd like to use references in a script I'm writing. I have a JSON object of key-value settings and a set of objects that will take these settings. I would like to be able to update the object and the setting object at the same time without needing to recursively rebuild the setting object every time a value is updated. Here is my example code- settings:{"fields":{ "sort": { "value":1, "fields": { "sort_options": { "value": [ { "name": { "value":"test" }, "sort": { "value":"inv_id" }, "sort_direction": { "value":"DESC" } } ] } } }, "pagination": { "value":0 "fields": { "limit":10 } }}} For each of the fields you see (like "sort" and "pagination") in these setting will become an object. Each setting is also sent to a view object that prints an input type to it's parent dom object (like a checkbox or text field). When the field is set and not null then it's sub-fields become visible. So you can see the recursion here. These settings need to be saved to a text file and read in the same format. You can see how it could be convenient to reference that value or any of these fields to the same variable the model is using. Any ideas?
  13. I haven't used either of these. I will look into them both.Thanks
  14. At my company we maintain around 400 sites. These sites are built with a custom CMS. Each site has it's own directory in /var/www/vhosts and it's own admin directory and admin files. This makes updating impractical. Even if we push an update out to all of these sites the admin frequently changes and this would probably break the majority of the sites. I'm trying to come up with a solution to this be redirecting all requests to the admin directory to /var/www/base_admin which hosts all of admin files. This would making updating easy and force all future sites to be compatible with all other new site (we won't go back and fix any, that would require too much). This is working well on one server but we have 4. We would need to setup this root admin system on all of our servers and any update would have to be pushed out to it. Is there any way to have all the servers pointing to one location on one server that would still be quick and effective? Every page request requires at least one or more files from the admin (classes and such). If not what would be the best way of updating these automatically? I'm a Unix newbie but I'm familiar with things like rsync. Would this be the best method?
  15. I am trying to include files outside of the include scope. Currently the sites on the server I'm working on are setup in these directories /var/www/vhosts/{site_name}/{available_include_area} I want to redirect all requests from /var/www/vhosts/{site_name}/httpdocs/admin/(request_uri} to /var/www/base_admin/{request_uri} I'm doing this by dropping an .htaccess file in each of the sites admin directory. I thought I could just change ownership to the apache user but I get this error: I've tried google and looking through my php.ini and httpd.conf files but couldn't find anything i thought would do the trick. Anyone know what I could use?Side note- I thought about creating Symlinks for each site but I don't want to have to do that for each. Would that work though?
  16. I didn't want any commas in the number. This should work. Thanks
  17. In other words. document is a variable in window. It can be access like any other object variable MyObject.myVariable.doSomething() All of windows variables are also treated like global variables. So you are always in the scope of window. MyObject = { ... };// In the global/window scope// These are both validwindow.MyObject;MyObject; Using window before any variable is redundant but it would be courteous to other developers as they could see instantly where the variable you're using is coming from instead going back through your script to find the origin. But for variables like document (where most people remember) it doesn't really matter.
  18. I'm trying to parse a string to see if it's a valid real number. The first issue I've run into is with java the \w flag returns a digit. A work around I'm using for integers is just \D which does work but now I've got the check for digits and a single decimal point (if exists) // Trying to parse if string is an interger or real number// Should find any non-numeric charactersvar invalidCharacters = "[\\w]";var reg = new RegExp(invalidCharacters);reg.exec(400); // Finds "4" Could anyone shed light on this?
  19. I was able to get it working for now by passing the session id in the url to the page I need admin access. This works for my situation but it would be nice to know why I'm having this problem.
  20. In the IFP directory Array( [lifetime] => 0 [path] => / [domain] => [secure] => [httponly] =>) in the IFP/admin/ directory Array( [lifetime] => 0 [path] => / [domain] => [secure] => [httponly] =>) a var_dump of my sessions (I'm logged out) In the IFP dir array(4) { ["adminId"]=> string(1) "2" ["loggedin"]=> bool(true) ["adminPass"]=> string(9) "***hidden***" ["action"]=> string(4) "edit" } In the IFP/admin dir NULL var_dump of the cookies in the IFP dir array(3) { ["PHPSESSID"]=> string(26) "b2n67ubavlvro10dj7if9sjjv3" ["adminId"]=> string(1) "2" ["adminPass"]=> string(9) "***hidden***" } in the IFP/admin dir array(3) { ["PHPSESSID"]=> string(26) "9bq4ht9rv197l0pno1rsehcc16" ["adminId"]=> string(1) "2" ["adminPass"]=> string(9) "***hidden***" } The PHPSESSID are different. Could that have something to do with it?
  21. I have a site with a directory called IFP. In the IFP/admin/ directory the administrators login and should be able to go back to the IFP while keeping their administrative identity. For some reason settings sessions or cookies in the admin directory doesn't register in the previews IFP directory. Any ideas why that might be?
  22. Well I'm still looking into it. I'll post an update on what I come up with if anyone is still interested.
  23. Hello W3C, I've been doing web stuff for a while and a little spoiled since I haven't had to mess with MVC much. I'm writing a large javascript app that would be nice to have some kind of programming paradigm. Right now I'm just having trouble finding how to implement a controller that wouldn't just get in the way. I've written a basic test file tree viewer trying to find a way to add a controller to it. In the end I just set the controller of the model the ul or li object since it already has all the ui events like onclick. But I would still need to set the controller methods on the file inside the view where it creates the dom tree (see link). I'm also having trouble imagining a situation where it would be more convenient to have the view go through the controller or poll the controller with/for information. So lets say I want my file manager to run in a pane in my app. But there will also be a time where I want it to come up in a popup where clicking the folders and files will react differently with the model and view then the one in the pane. I guess this is where the controller comes in? Instead of having 2 slightly altered model classes or 2 slightly altered view classes I have 2 slightly altered controller classes that interacts with the ui events differently? Anyway Here is my attempt where I wasn't able to figure out how I should build my controller. http://jsbin.com/oso...javascript,live
  24. Solved The answer is simply to use $DOM->saveHTML() instead of $DOM->saveXML() Simple enough. Thanks for your help
  • Create New...