BLAG Ramblings of a crazy old fool

14Feb/120

XHR Load Cross Site Forgery

Javascript Code

Or, How Sano Managed To Defeat The Evil Browser with Javascript Black Magic.

One of the things Sano and I both end up dealing with is Javascript. Over the years we've come to understand it and maybe even hate it a little less (the advent of jQuery really brought that around, especially when dealing with AJAX or anything REST-related). Every once in a while, one of us comes up with a solution that is either completely brilliant, or absolutely retarded.

This is one of those.

if (Request.Headers["Origin"] != null)
{
  Response.AddHeader("Access-Control-Allow-Origin", Request.Headers["Origin"]);
}

Response.AppendHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
14Feb/120

Squeeze easiest upgrade ever? Perhaps.

debian

So I finally got around to upgrading my Linode. It's been...840 days since I last did that. Whoops. Turns out there were a few hundred security updates, and I was pretty far behind on Apache, and PHP versions. I also accidentally upgraded MySQL during the process...didn't mean to do that. Would have been nice if I had gotten the chance to do a full export before hand. However, it was Linode that saved my bacon today! I realized that with my track record, doing a system upgrade was one of the more dangerous things I could try. So, rather abitiously, I set out to make it happen. But before I did that, I took a Linode backup snapshot. You know, just in case. As it turns out, the folks at Linode were ahead of the game, and provided an excellent guide to upgrading to Squeeze. About the only problem I had was with MySQL after the upgrade was complete, but an apt-get install mysql took care of that.

But perhaps a bit of backstory is needed. I've started working recently on a framework to rapidly build and deploy social-oriented web applications.  It's still a work in progress, like many of my other projects, but it certainly made my life a bit easier. I was able to adapt the platform from its current implementation on Fitness Tracker, and take a design/idea in my head, prototype, and build it in less than an hour. Now granted the core of the application still isn't built, but all the basics are there; Analytics and tracking, theming/templating, and SSO/Facebook integration. It's not as polished as I want it of course, I'd like to implement a lot more in the way of object-oriented programming, but it is coming along. I'm hoping someday to have it available to go from prototype to beta testing in less than a day.

After I added the new site to the framework, I started to think about how I wanted to structure the data for this particular application. At some point I'd like to have an integrated database that could scale to fit all my applications/ideas, but for the moment it's just not there yet. But as I started to build out the schema in MySQL, I realized it just wouldn't cut it. I've been working a lot recently with MongoDB and JSON data formats, so my mind is still kind of stuck in that mode. But it was pretty apparent, even for the small scope of my project, that a flat row structure like MySQL just wouldn't be scalable enough to do what I want. So I decided to add mongo to my server to play around and see if that would do more of what I want. But unfortunately for me, I didn't have PECL, so I couldn't use the MongoPHP driver. Hence, the PHP upgrade, and then the Debian upgrade.

There were a few tense moments during the upgrade when I dithered on whether to use the new config files or see if the old ones would still work (in the end the old ones won out), and then the suprise MySQL upgrade that I didn't seem to have a choice on. But now I'm at 5.1 and everything seems to be working after a few REPAIRs, so I guess in the end you could call it a win.

Work still continues on the eminence online roll-out; working on building in news feed scraping for content generation, and then integrating that with WordPress. It's proving...difficult.

At the end of the day though, I still don't have MongoDB installed, nor have I made any progress on the DB schema for myCollections...but I still feel like I accomplished something. I guess that's all that counts!