Wordpress MU admin plugin, how to apply to new blogs? - plugins

I am trying to create a Wordpress MU admin plugin, that will insert some JavaScript code into every admin page that my users see.
I created my own plugin, and activated using the "Activate Plugin Site wide" link.
I have been testing with the following code, which works on existing blogs.
add_action("admin_footer", 'testAdminFooterHook', 5);
function testAdminFooterHook()
{
echo "<script language='javascript' >\n";
echo "alert('test admin_footer hook')";
echo "</script >\n";
}
However, if I create a new user and a new blog, and then log in -- the plugin does not fire.
Am I approaching this wrong? How can I create an admin plugin that will fire for every future user created and every future blog created? I'm running Wordpress MU 2.8.4.

Ok, I'll answer my own question.
I just had to put the php file in the /wp-content/mu-plugins directory.
It now fires for on every admin page, including ones new users and new blogs. Although, you do have to put a php file in the /wp-content/mu-plugins directory - putting a your plugin code inside a folder does not work.

Related

Scrapy: Redirecting to a confirmation page with a captcha

How can I stop redirecting from a target url to another url which is a confirmation page of a website with a captcha?
Here is my code below:
yield scrapy.Request(meta={'handle_httpstatus_list': [302], 'dont_redirect': True, 'redirect_enabled':False},url=url, callback=self.profileCategoryPages)
Now it redirects me to another web page from a web page. I don't know why it is happening. It did not happen when I ran it for the first time, but when I ran for the second time, and ran it again and again, all I got is that it is redirect to another web page.
Tagget page:
http://www.profilecanada.com/browse_by_category.cfm/
Redirected to this page:
http://www.profilecanada.com/confirmReqPage.cfm
Thank you for your help!
I think the reason that I am blocked is that I don't a delay value when requesting pages from a website. Also, I created the spider as a stand alone scraper program, thus, there is not settings.py that gonna be available to modify. What I did is this:
Create a scraper as a projecy by running:
scrapy startproject
Added my previously created program scraper to the spider folder which is inside my newly created project
Modiy the settings.py:
DOWNLOAD_DELAY = ,
CONCURRENT_REQUESTS = 20,
CONCURRENT_REQUESTS_PER_DOMAIN = 1,
DOWNLOAD_TIMEOUT = 30
Now it works!

Add new category and custom page into Site Administration menu

I'm trying to add a new feature into site administration menu of moodle as part of a project that I am working on. Right now our customer only needs to integrate OnePay gateway into moodle. But in the future, they may require integration of other payment gateways (like PayPal) as well. So I need to create a category just for website administrators to input different types of payment. A new category should be somewhere in the "Advanced Features" menu (something like in the following screenshots)
Where to add new category
Example for onepay integration
With "Settings" page is a page that site administrator to input all necessary payment information (including customer's card number, access code, etc.). Right now I'm testing with using two of my testing pages for domestic and international payments.
Here is my code in file /lang/en/admin.php:
$string['payment'] = 'Payment';
$string['onepay'] = 'OnePay';
$string['test_onepay_domestic'] = 'Test Domestic Payment using OnePay';
$string['test_onepay_international'] = 'Test International Payment using OnePay';
In admin_custom directory, I created a path like this /payment/onepay/test/ and add 2 my testing pages into it. In folder /payment/, I added a file named menu.php. Here is my code in it.
<?php
$ADMIN->add('advancedfeatures', new admin_category('payment', get_string('payment', 'admin')));
$ADMIN->add('payment', new admin_category('payment', get_string('onepay', 'admin')));
//$domestic = new admin_settingpage('onepay', new lang_string('test_onepay_domestic', 'admin'), new moodle_url("/admin_custom/payment/onepay/test/domestic/index.php"));
//$international = new admin_settingpage('onepay', new lang_string('test_onepay_international', 'admin'), new moodle_url("/admin_custom/payment/onepay/test/international/index.php"));
$domestic = new admin_externalpage('test_onepay_domestic', get_string('test_onepay_domestic'), "$CFG->wwwroot/admin_custom/payment/onepay/test/domestic/index.php");
$international = new admin_externalpage('test_onepay_international', get_string('test_onepay_international'), "$CFG->wwwroot/admin_custom/payment/onepay/test/international/index.php");
$ADMIN->add('onepay', $domestic);
$ADMIN->add('onepay', $international);
I have attempted to include file menu.php in both files
/admin/settings/top.php
/admin/settings/server.php
But none of these works. Can anyone please tell me what should I do to get this works? Thank you very much. I really appreciate that.
Moodle doesn't have any sort of plugin type called 'payment', so by creating a hierarchy starting '/payment', you're already at odds with the way that Moodle works (as shown by needing to edit core files in order to add language strings and menu items).
I would recommend that you start again by creating an admin tool or a local plugin. Both of these types can have their own language strings and can add entries to the site admin menu (have a look at the settings.php inside any of the standard admin tool plugins or, for local plugins, an additional option is to create a local_MYPLUGIN_extend_settings_navigation() function). If you want to support multiple payment options, then your plugin could define a new subplugin type for each of the payment options.

how do i add this php script to my .html page

<?php
// check for minimum PHP version
if (version_compare(PHP_VERSION, '5.3.7', '<')) {
exit('Sorry, this script does not run on a PHP version smaller than 5.3.7 !');
} else if (version_compare(PHP_VERSION, '5.5.0', '<')) {
// if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php
// (this library adds the PHP 5.5 password hashing functions to older versions of PHP)
require_once('libraries/password_compatibility_library.php');
}
// include the config
require_once('config/config.php');
// include the to-be-used language, english by default. feel free to translate your project and include something else
require_once('translations/en.php');
// include the PHPMailer library
require_once('libraries/PHPMailer.php');
// load the login class
require_once('classes/Login.php');
// create a login object. when this object is created, it will do all login/logout stuff automatically
// so this single line handles the entire login process.
$login = new Login();
// ... ask if we are logged in here:
if ($login->isUserLoggedIn() == true) {
// the user is logged in. you can do whatever you want here.
// for demonstration purposes, we simply show the "you are logged in" view.
include("views/index1.php");
} else {
// the user is not logged in. you can do whatever you want here.
// for demonstration purposes, we simply show the "you are not logged in" view.
include("views/not_logged_in.php");
}
I am trying to add this .php log in script to a HTML webpage. Me and a buddy managed to get a database together along with .php log in script we have downloaded. Our database works with our our .php allowing new users to sing up and log in. Also has email verification with SMTP. Ebery thing works fine but our issue is that when people would go to the log in page it is just a white page with a username and password box. We would like to take our web template and use that as our log in back ground (so that it wouuld be the same background as rest of site.) we just want our log in pages,registration, and all our other .php files to match our site.
Its just ugly having a plain white screen with 1 box for username and 1 box for password and a submit button. thanks.
I was also told .css would help. My whole site is using a style.css file to give the HTML pages there look. Is there any way to make that work for the .php pages too? again, thanks.
You can include HTML outside of the <?php and ?> tags. Use the HTML to style your page to your liking.

Publishing a story using Facebook open graph

I am currently trying to run through the publish open graph story for iOS tutorial on the Facebook website.
https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/publish-open-graph-story/
I'm getting lost at step 2 - Set up your back end server. I have set up a Heroku account just like it says and I go through the set up tutorial on the Heroku site. It all seems fine. I save the code listed in step 2 in a new file I created called opengraphobject.php (I have no idea if this was the right thing to do?).
After that it says "Once you've uploaded the dynamic object creation code, test a sample object using the Object Debugger. Enter a URL into the debugger, for example:"
https://fbsdkog.herokuapp.com/repeater.php?fb:app_id=233936543368280
&og:type=fb_sample_scrumps:meal
&og:title=Pizza
&og:description="Pizza"
&og:image=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fimages%2Fdevsite%2Fattachment_blank.png
&body=Pizza
I have no idea what I'm supposed to do at this point. My action is called beats and the object is called boss. How do I generate a url like this for my own action?
I can't move onto stop 3 till I move past this because it's very similar.
The page opengraphobject.php should contain the sample code provided in that step.
So when you are done setting it up you point to your url in the debugger to test
https://YOUR.herokuapp.com/opengraphobject.php?fb:app_id=YOUR_APP_ID
&og:type=fb_sample_scrumps:meal
&og:title=Pizza
&og:description="Pizza"
&og:image=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fimages%2Fdevsite%2Fattachment_blank.png
&body=Pizza

Cannot log in to admin after upgrade

I need some help troubleshooting.
I've just upgraded my 1.3 site to 2.0 (with the intent of going on to 2.1). I get the actual page running, content is read from DB etc, but I cannot log in to the admin panel!
Just to make sure I didn't forget the password I did
<?php echo sha1('password' . 'salt'); ?>
Taking the salt from the DB, and the output is the same as is stored in the DB. But still I cannot log in. The log in prompt just reloads, no error message or anything. Any ideas?
I've also tried clearing cache/sessions/etc, and even a different browser to no affect.
Crossposted from the PyroCMS forum: https://www.pyrocms.com/forums/topics/view/19323
OK, since there doesn't seem to be any good suggestions found either here or on the PyroCMS forums and my site is very small content wise I decided to just wipe everything and do a clean install of the latest build instead.
Not a very good solution for future reference, but it will have to do.
From my checklist (it's been a while since I had this happen to me):
If you didn't get an incorrect password error, it may well be you were just being redirected back to the login page before the details were even checked. You can run into issues with enabling the 'Remove index.php from URL' in .htaccess - in /system/cms/config/config.php try changing
$config['index_page'] = 'index.php';
to $config['index_page'] = '';
or (as you've hinted):
clear the contents of default_ci_sessions table
clear the cookies for the domain (a quicker way is to just open a new Google Incognito window which won't have any cookies).
Also - you can initiate a password reset for the admin password using the ordinary user login form if you or someone else does ever forget it (don't though).