Wordpress PHP-exec header problem - wordpress

I am trying to integrate one of my websites with facebook connect.
I have developed the code and it works as expected.
I want to integrate the code into a wordpress page utilizing the php-exec plugin to parse php.
When i do as can be seen at gua.com/testing it simply does not work. Seemingly the session etc is registered but it simply displays the connect box again..
Any ideas?
Thanks

Does your code use global variables? Php-exec works using eval() and eval() has different rules for globals.
But I've got more ideas...
There are a few different versions of the facebook connect api, but all of the ones I've used used also required a lump of javascript to be included in the site, I don't see that on your page. Make sure it isn't needed.
If that's not the problem, try including the facebook lib in wp-config.php, then call it from php-exec. I'm not really sure if that'll work or not but it's worth a shot.

Related

How can I pull a Wordpress header and footer into Laravel views?

Before I get to the question, let me say that I saw a similar question here with a fairly detailed response:
https://wordpress.stackexchange.com/questions/115211/loading-wordpress-stuff-on-laravel-site
And it was the closest thing I have found on the web to what I'm looking for, but the potential solution looked like it might end up being so laborious as to not be worth the time. Here is my situation:
I develop and maintain a small custom SaaS program that typically functions on a subdomain of a client site (say, software.client.com). The latest version of the code was rewritten using Laravel and there were a lot of gains associated with that. In the past, when the program was basically procedural spaghetti, if we had a client with a Wordpress site on their primary domain, we ran some atrocious (by best-practices standards) hack-around code to pull the Wordpress header and footer onto the pages of my program - sitting, of course, outside the CMS - while modifying meta tags and doing a number of other things. It wasn't pretty but it worked.
Now I'm in a situation where I'd like to solve the same problem - that is, to at least pull the Wordpress headers and footers onto some of the Laravel subdomain views - but nothing I have found on the web so far has enabled me to make much progress in that direction. I have found a lot of tutorials explaining how to integrate Laravel and Wordpress, or use one for frontend and the other for backend, etc., but nothing yet about the specific type of integration I'm talking about.
What I have tried so far is implementing some of the code I've used elsewhere into various parts of the Laravel codebase. Most of the recent experiments have been in public/index.php and in Controller methods. Laravel will allow me to get as far as including the Wordpress config, but if I attempt to go any further I cause a 500 error. Here's an example snippet that actually attempts to do more than I need, but I can't even get past wp_init(). Imagine the following code in a Laravel Controller method. The first two lines are OK, but:
public function index() {
define('WP_USE_THEMES', false);
require '/path_to/wp-config.php';
$wp->init(); // from here on, 500 errors occur
$wp->parse_request();
$wp->query_posts();
$wp->register_globals();
// And then, at some point, I would call and modify get_header()
(I didn't really expect this to work from the Controller, but it doesn't work from anywhere else in the codebase I've tried either.) This is not a situation where I want to hand off control from Laravel to Wordpress for these URLs (I need Laravel functions / DB queries and more flexibility, and I know I could just do that hand-off through public/index.php and routes.php if it would solve the problem). And for these intallations, I don't need to grab posts or other items from Wordpress. I would just like to find a way to pull the header and footer into these views directly from Wordpress while maintaining control of the views in Laravel. If I can't, among other things, the design team will end up rebuilding headers and footers for every program install on a Wordpress client (for the time being) and they will have to make changes in at least two places when things are modified or updated.
If we have to, we will find a way to live with that until the next program version rollout, but if I can build a solution in what my superiors will deem a reasonable amount of time, we would all be happier. I hope that I have just missed something simple somewhere and I will be embarrassed to find out that I could have solved this in less time than it took to explain the problem. Thank you for any and all helpful responses and potential solutions.
You're not going to be able to cleanly merge the two codebases together. That would cause a disaster.
The complexity of the solution depends on the complexity the information you need to share. The simplest solution possible would be to write something custom to WordPress that builds a document with no body data and just supplies a token, like {!! $body !!}. Then, in Laravel, you can do an HTTP request to localhost to fetch this tokenized content. Store the result in a memory cache and use Blade to render the final view.
Essentially, my suggestion boils down to: Create a Blade layout with WordPress.
There's a thousand different ways to do this, and all of them are wrong.

Does anybody know of a Wordpress plugin that produces a PDF locally?

The function of the plugin is to print the page contents as a PDF.
I can find a bunch that connect to an external service in a popup to generate the PDF, but I can't seem to find one that produces the PDF on the server where the PDF needs to be generated.
The reason I don't want to use these external services is because of branding, and because most of them have advertising. If it wasn't for this, I wouldn't mind using these plugins either.
I'm OK with paying money if the plugin is good enough.
P.S. On an unrelated note, Wordpress' plugin search sucks :( I can't filter by version number, compatibility, etc.
I've found this http://www.investintech.com/resources/blog/archives/167-top-10-handy-wordpress-pdf-plugins.html
Should help you find what you need.
I already tried Print Friendly, and I think it could work in your situation.

Integrate OsTicket into Drupal 7

Our main web page is Drupal and we would like to use Osticket as our issue tracking system, but there is a problem with Osticket: anybody can create new tickets.
We can protect this by .htaccess, but we don't want do that; we would like to make this protect by Drupal: only authenticated users should access the Osticket page.
Is there a way to achieve this?
Found a solution here:
http://osticket.com/forum/discussion/9910/integrate-with-drupal-7
Here is the relevant part:
Preamble
It just so happens I was doing some off-again on-again work with integrating this into Drupal.
If you're just interested in ensuring a user is logged you're right, you need bootstrap.inc and you're right you end up with useless blank pages.
Solution
I've yet to get to properly documenting, so try this and let me know if I missed something and I'll have another look, however the following should sort the issue:
Duplicate Function Names
osTicket uses db_query() and (I think) db_close() rename the functions to something like db_ost_query() and you'll be fine. (Note I put the 'ost' in the middle to help future find/replace) I can't remember whether all occurrences of the function needed renaming for it to work, but its probably a good idea to do it.
Location of the bootstrap
The bootstrap has all manner of issues if called from outside the root Drupal directory, I gave up finding an answer to this and just kept an file in the root that osticket would include.
Headers, Headers everywhere
Bootstrap seems to like sending additional headers out so you'd want to include your file in an appropriate location (i.e. one of the .inc files). I think this solved everything.
Disclaimer
Of course, remember this will break on any updates and any mods you add you'd have to take this into account. If I've remembered rightly this will get bootstrap up and running and you can run is_user_logged_in() and show or redirect the page.
Further Concerns
I actually had a greater goal in mind in my meddling and so I don't remember whether everything was perfectly cosy after this addition.
I do remember having further issues with headers being sent and when fully bootstrapping the system session usage interfering with ostickets sessions - I think this occurred later though and shouldn't be an issue for you.
An Alternative Solution
When googling, many people suggested simply creating a module and having it iframe the contents inside it, this might be a good enough solution for what you want and would require a whole lot less messing around with ostickets code.

Migating from CakePHP to Drupal, functionality question

(I've posted this on the drupal forum too btw)
I'm converting the company websites to use Drupal, or at least trying to check that its going to be the best way forward. I have a background in PHP development, and I'm currently using the CakePHP framwork. I've built this site (not my design) and I can see how to replicate most of the functionality using Drupal, most likely using the CCK module.
http://preview.tinyurl.com/yk6u8mt
As you can see from the homepage:
A user chooses a country.
The country is passed using an ajax call to a script that decides which phone is best based on 'in country' network coverage.
A div is shown recommending the visitor the best phone for that country.
I'm wondering how to go about this in Drupal, I'm definitely not after a step by step guide, I just want to know if this kind of thing is possible with Drupal, and what approach to use.
If someone can help that would be superb. Thanks.
Okay, so you've got a path you're defining in hook_menu, which is where your form is being presented - or else you've got it set up as a webform in a node, that could work too.
Either way, in your form you're going to be using AHAH - check out http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#ahah and http://drupal.org/node/348475 .
Basically, you're going to define another path in hook_menu that's of type MENU_CALLBACK, and which will receive the country as input, and then will return the div that you'll display on the screen.
One core example of AHAH that may be useful to you is where you're entering a password and it lets you know if the password is secure enough - check that out.
Edit: There's also some good examples at http://drupal.org/project/examples.
I would look into using CCK and views. you can set up filters for the views. If filters don't work, you have the ability to include php code. I have also successfully added jquery code in the header of a view through which I was then able to have my view filtered by what is typed in a text box.
Coming from CakePHP using Drupal is a pain in the a** - even more for developers.
It's application structure might be designed to ease extensibility but this only means you have a system to enable your own plugins and themes.
While modules are basically the M+C-part the themes are the V-part of an MVC-application. The problem is that this seperation is not very strict in Drupal - in fact you have to break it sometimes in order to make things work (e.g. you have to include a theme_mymodule_myfunction() into your module as default output which you then can override with your theme using mytheme_mymodule_myfunction() ) And don't even bother looking for classes ( see http://drupal.org/node/547518 ).
Also there is no real link from a module to a theme. On many occations this is a good thing as you can switch modules and themes seperatly without creating a problem. For application builders coming from CakePHP (or any other framework) you often feel a lack of "wholesomeness" - you create parts for a base software and have to live with it's drawbacks.
IMHO I wouldn't recommend this step. Drupal is fine if you have to manage a website and might add a few modules to add neccessary value (image gallery etc.) but I definetly don't recommend it as a base for a customized web-app.

dashcode and external rss feeds

I was wonder if anyone can help me with this. I've been looking everywhere for this information, but I want to make a web application using dascode rss. I know that you can't link external sources. Does anyone know a way I can get around it. From what I understand a little php can get around this, but I'm unsure where to look.
OK, first thing no PHP. Dashcode is limited to HTML, CSS and JavaScript. Although having said that there are a whole range of system calls that cna be made using the functionality provided by various parts of the x-cde system.
Second yes you can link to external sources such as other web sites, api on say Twitter, google etc. RSS feeds and so on, not sure where you got the idea to the contrary.
If you want to learn how to do a Dashcode RSS then open up Dashcode, start a new project, either web based or Dsashboard based and choose the RSS project. This will give you an out of the box template to add you own information and then see how it works. Then customise it.
In the above i am assuming Snow Leopard and the latest Dashcode/X-code but it will still gove you most of what you want on earlier version.

Resources