cakephp facebook component include paths on linux - linux

I have a website on cakephp 1.3, with facebook integration. On my localhost(with windows os) it works fine, but on real hosting(with linux os) it gives this error Fatal error: Class 'Facebook' not found in /home/username/public_html/app/plugins/facebook/libs/f_b.php on line 22.
This is f_b.php
App::import('Vendor', 'Facebook.facebook/src/facebook');
App::import('Lib', 'Facebook.FacebookInfo');
class FB {
/**
* Facebook Api
*/
public static $Facebook = null;
public function __construct() {
if (empty(self::$Facebook)) {
self::$Facebook = new Facebook(FacebookInfo::getConfig()); } // 22 line
}
so, apparently it can not load Vender, I think there is a problem with paths, though this does not work either App::import('Vendor', 'Facebook.facebook'.DS.'src'.DS.'facebook');
f_b.php located in plugins/facebook/libs/ folder and this Facebook.php vendor is located in plugins/facebook/vendors/facebook/src folder
Thanks

Finally I found the solution of my problem, in order to work both on windows and linux it is necessary write like this
App::import('Vendor', 'Facebook.Facebook', array('file' => 'facebook/src/Facebook.php' ));
Here, are couple of example for that - Vendor examples

I’d say your paths don’t look right (why is there a dot?).
When I’ve used plugins with CakePHP, I’ve had to enable them by un-commenting the Plugins::loadAll() line in app/config/bootstrap.php. This will then make my library available in my CakePHP application.

Related

Loaded SWF's wont preform their functions in air

Back for some help! So I am making an AIR application that loads SWF's into a container to be viewed by the user. However when I load the files into their containers, the SWF's that are loaded are unable to execute their own code. IE press an invisible button on the loaded SWF and it changes colour. I tried to google solutions for this since Security.allowDomain("*"); is throwing this error in flash. However from what I have read, AIR doesn't allow loaded swfs to execute code for some security reason but im not 100% sure on that either.
SecurityError: Error #3207: Application-sandbox content cannot access this feature.
at flash.system::Security$/allowDomain()
at BugFree()[D:\Desktop\BugFree\BugFree.as:72]
Without the Allow domain it throws this security error when attempting to click the invisible button.
*** Security Sandbox Violation ***
SecurityDomain 'file:///D:/Desktop/Rewritten Tester/TechDemoSwordNew.swf'
tried to access incompatible context 'app:/BugFree.swf'
*** Security Sandbox Violation ***
SecurityDomain 'file:///D:/Desktop/Rewritten Tester/TechDemoSwordNew.swf'
tried to access incompatible context 'app:/BugFree.swf'
SecurityError: Error #2047: Security sandbox violation: parent:
file:///D:/Desktop/Rewritten Tester/TechDemoSwordNew.swf cannot access
app:/BugFree.swf.
at flash.display::DisplayObject/get parent()
at TechDemoSwordNew_fla::Button_Play_21/onButtonPress()
This only shows in the Animate output bar. When I publish it, with application with runtime embeded, and open the exe it throws no errors but the invisible button still doesnt work.
Here is the code for the swf being loaded.
btnButton.addEventListener(MouseEvent.CLICK, onButtonPress, false, 0, true);
function onButtonPress(event:MouseEvent):void
{
MovieClip(parent).play();
}
stop();
This is timeline code within the button since that is how the game company who put my item in game did it. I originally submitted it with it all done in classes but that is besides the point. When the button is pressed the loaded SWF should play and then stop. But I get the above mentioned Sandbox violation.
The code used to load the SWF is below
public function WeaponLoad()
{
if(FileMenu.WeaponFileTxt.text != "")
{
LoadWeapon(FileMenu.WeaponFile.nativePath);
}
else if(FileMenu.WeaponFileTxt.text == "")
{
Character.mcChar.weapon.removeChildAt(0);
Character.mcChar.weaponOff.removeChildAt(0);
}
}
public function LoadWeapon(strFilePath: String)
{
WeaponLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, CompleteWeaponLoad);
WeaponLoader.load(new URLRequest(strFilePath), new LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain)));
}
public function CompleteWeaponLoad(e: Event)
{
var WeaponClass: Class;
if (MiscMenu.WeaponSelect.MainClick.currentFrame != 3)
{
try
{
trace("WeaponOff");
WeaponClass = WeaponLoader.contentLoaderInfo.applicationDomain.getDefinition(FileMenu.WeaponLinkTxt.text) as Class;
this.Character.mcChar.weapon.removeChildAt(0);
this.Character.mcChar.weaponOff.removeChildAt(0);
this.Character.mcChar.weapon.addChild(new(WeaponClass)());
}
catch (err: Error)
{
trace("Either the weapon class doesnt exist or it is wrong");
this.Character.mcChar.weapon.removeChildAt(0);
this.Character.mcChar.weaponOff.removeChildAt(0);
}
}
else if (MiscMenu.WeaponSelect.MainClick.currentFrame == 3)
{
try
{
WeaponClass = WeaponLoader.contentLoaderInfo.applicationDomain.getDefinition(FileMenu.WeaponLinkTxt.text) as Class;
this.Character.mcChar.weapon.removeChildAt(0);
this.Character.mcChar.weaponOff.removeChildAt(0);
this.Character.mcChar.weapon.addChild(new(WeaponClass)());
this.Character.mcChar.weaponOff.addChild(new(WeaponClass)());
}
catch (err: Error)
{
trace("Either the weapon class doesnt exist or it is wrong");
this.Character.mcChar.weapon.removeChildAt(0);
this.Character.mcChar.weaponOff.removeChildAt(0);
}
}
}
Any help would be apreciated since I have no idea how to change any security sandbox settings within the publish settings since it is greyed out for me. Like I said I tried googling it but I couldn't seem to come up with any answers. Also worth noting is im a self taught novice and I do not know a lot of things in regards to AS3. I know my codes could be cleaner and I plan to clean it up and properly reduce memory consumption once I have the base program up and running. Thank you for the help!
It seems that you're not setting the application domain properly. Here is the code included in as3 documentation:
var loader:Loader = new Loader();
var url:URLRequest = new URLRequest("[file path].swf");
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
loader.load(url, loaderContext);
Use it in your LoadWeapon function.
In the meantime try not to use Uppercase letters for starting variables and method names. In ActionScript names starting with Uppercase represent Class names. It will widely improve readability of your code.
Can't you bundle your swfs with the AIR app and use File class to load them? If you want to use classes from the swfs, maybe consider making swc library?

How are directory listings generated with ratpack?

I've just started looking at Ratpack, and my initial use case to as a simple development server. It seems quite trivial to get it to serve a directory of static files (in Groovy), I paraphrase this article:
#!/usr/bin/env groovy
#Grab('io.ratpack:ratpack-groovy:1.5.1')
import static ratpack.groovy.Groovy.ratpack
ratpack {
handlers {
files { dir "static" index }
}
}
I see there's an option to define an index page (for example, index.html), but this is static. I'd like it to serve a dynamic directory listing, as Apache can. I'd hoped this would simply require enabling a option, but I cannot find any indication such a thing exists.
I can't help feeling I have missed something. Can anyone point me in the right direction?
There's no built in directory listing feature. You would have to implement your own.

Default config.xml?

On this page of the documentation, at the bottom, it says:
You can find full examples of Sphinx-4 configuration file in sources. For example, check the file
sphinx4/src/apps/edu/cmu/sphinx/demo/transcriber/config.xml
Well, I looked, and there is no config.xml in that directory, and there is no such file in any of the other folders inside of demo either.
So where can one find a default config file to use to get started with?
If I just do Configuration configuration = new Configuration();, would that be good enough to start with?
I recently found out that what you suggest is not enough. Take a look at the latest code on the Github repository. There is a default.config.xml file at https://github.com/cmusphinx/sphinx4/tree/master/sphinx4-core/src/main/resources/edu/cmu/sphinx/api, and the path to it is set in the Context class in package edu.cmu.sphinx.api:
public Context(Configuration config)
throws IOException, MalformedURLException
{
this("../sphinx4/sphinx4-core/src/main/resources/edu/cmu/sphinx/api/default.config.xml", config);
}

How do you clear this error with using HaxePunk in FlashDevelop?

I have tried researching this and using pre-made templates, but to no avail. I just want to get a real basic HaxePunk project working with FlashDevelop, with making Flash games in mind. Going back to real basic tutorials and such, this is my code:
import com.haxepunk.Engine;
import com.haxepunk.HXP;
class Main extends Engine
{
/*override public function init()
{
#if debug
HXP.console.enable();
#end
//HXP.scene = new MainScene();
}*/
public static function main() { new Main(); }
}
I'm not sure whether to compile this as a Flash Player project or an NME project (I'm really new to this). If I try to compile it as a Flash Player project, I get this error at runtime:
TypeError: Error #2007: Parameter type must be non-null.
at flash.events::EventDispatcher/addEventListener()
at flash.display::Stage/addEventListener()
at com.haxepunk.utils::Input$/enable()
at com.haxepunk::Engine/onStage()
at com.haxepunk::Engine()
at Main()
at Main$/main()
at boot_0b9a/init()
at flash::Boot/start()
at boot_0b9a()
If I try to compile it as an NME project, I get this error at compile time:
Error: You must have a "project.xml" file or specify another valid project file
when using the 'build' command
I'm not finding a whole lot of information about this. What would likely be wrong here? Thanks.
You have to make an OpenFL project, not a flash one, this is because HaxePunk uses OpenFL for rendering.
To get flashdevelop work with an HaxePunk project this is what I usually do:
Create a new blank openfl project in FlashDevelop
Create a haxepunk project the commandline (it should be 'haxepunk new name')
Substitute files from the haxepunk project into the flashdevelop one
"Fix what's wrong"
Number 4 is usually a matter of renaming files, iirc in the haxepunk project files has a different name from the one in the flashdevelop one so you'll have to change it

Autoloading a class in Symfony 2.1

I'm porting a Symfony 1.2 project to Symfony 2.x. I'm currently running the latest 2.1.0-dev release.
From my old project I have a class called Tools which has some simple functions for things like munging arrays into strings and generating slugs from strings. I'd like to use this class in my new project but I'm unclear how to use this class outside of a bundle.
I've looked at various answers here which recommend changing app/autoload.php but my autoload.php looks different to the ones in the answers, maybe something has changed here between 2.0 and 2.1.
I'd like to keep my class in my src or app directories as they're under source control. My vendors directory isn't as I'm using composer to take care of that.
Any advice would be appreciated here.
Another way is to use the /app/config/autoload.php:
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
$loader = require __DIR__.'/../vendor/autoload.php';
$loader->add( 'YOURNAMESPACE', __DIR__.'/../vendor/YOURVENDOR/src' );
// intl
if (!function_exists('intl_get_error_code')) {
require_once _DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
$loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
}
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;
Just replace YOURNAMESPACE and YOURVENDOR with your values. Works quite well for me, so far.
You're correct, I stumbled upon the changes in autoload from 2.0 to 2.1. The above code works fine with the latest version, to which I upgraded my project ;-)
For a simple case like this the quickest solution is creating a folder (for example Common) directly under src and put your class in it.
src
-- Common
-- Tools.php
Tools.php contains your class with proper namespace, for example
<?php
namespace Common;
class Tools
{
public static function slugify($string)
{
// ...
}
}
Before calling your function do not forget the use statement
use Common\Tools;
// ...
Tools::slugify('my test string');
If you put your code under src following the proper folder structure and namespace as above, it will work without touching app/autoload.php.

Resources