I have already added CDN to my phpfox social network.
My first server is almost full.
Now I have add another another cdn. It is also working fine.
But The problem is, the contents are being delivered/saved one time in first cdn server, Again to second cdn server.
Now I want to save contents in second cdn server.
If I remove key of first cdn then The contents are missing all image,video, and other files of first server.
I want to run two cdn servers but The contents will be saved only second cdn's .
Following are codes: Please edit it.
/home/horjecom/public_html/include/setting/cdn.sett.php
<?php
/**
* [PHPFOX_HEADER]
*
* #copyright [PHPFOX_COPYRIGHT]
* #author natio
* #package PhpFox
* #version $Id: cdn.sett.php.new 3956 2012-03-01 12:28:26Z Raymond_Benc $
*/
defined('PHPFOX') or exit('NO DICE!');
$aServers = array(
array(
'upload' => 'http://1.mydomain.com/',
'file' => 'http://1.mydomain.com/file/',
'key' => '123'
),
array(
'upload' => 'http://2.mydomain.com/',
'file' => 'http://2.mydomain.com/file/',
'key' => '1234'
)
);
?>
Please edit it, Whereby I can use multi keys cdn and contents will be saved to last added cdn server (key)
I see you are using phpFox cdn. phpFox cdn allows you add many servers. But when users are adding the new content, you can't control which server will be stored. It gets random a server. There is no solution if the server is full (with default code).
You should remove your real keys here, if someone know your keys, they can get/add/delete your files on your servers. Key is for verify, each cdn server, you can use a different key.
Related
There are some 3rd party Wordpress plugins that do not support automatic updates. So, if you have v1.0 of a plugin already installed and you try to install a new version (e.g. v1.1), you will end up getting the message:
Destination folder already exists. /home/.../.../...
This leaves two options, neither of which i'd like to use: Uninstall & re-install the plugin, or manually upload the new files via FTP.
In /wp-admin/includes/class-wp-upgrader.php line 428 I see this code:
public function install_package( $args = array() ) {
global $wp_filesystem, $wp_theme_directories;
$defaults = array(
'source' => '', // Please always pass this
'destination' => '', // and this
'clear_destination' => false,
'clear_working' => false,
'abort_if_destination_exists' => true,
'hook_extra' => array()
);
$args = wp_parse_args($args, $defaults);
...
Is it possible to add a line to my theme's functions.php file to re-declare 'clear_destination' as true, and thereby forcing Wordpress to overwrite plugin files when I upload them?
Thanks
I kept digging and think I found a solution. If I create a custom plugin I can re-declare the options by using the 'upgrader_package_options' filter:
function override_plugins( $options ) {
$options['clear_destination'] = true;
$options['abort_if_destination_exists'] = false;
return $options;
}
add_filter( 'upgrader_package_options', 'override_plugins' );
No, that's not possible. You would need to edit the core files.
However you could install a plugin on the relevant site(s) that would take care of the problem for you: http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/
Or you could incorporate an updater framework within your plugin, which makes it possible to serve updates from private repos(eg not WP): https://github.com/afragen/github-updater
Alternatively, you could use something like WPPusher, which can automatically update the plugin whenever an update is pushed to Github / BitBucket. I personally use this plugin for testing dev versions of plugins I'm building.
In addition to Phill Healey's answer, an alternative service to WPPusher dedicated to Wordpress Developement is WP Package Editor (WP2E)
The Package Installer overwrite plugin source and log installations into a panel to monitor script versions, upgrades and status.
I am currently working on a site which is on smarty based.The name of the site is http://example.com
I built a new folder in the root path and installed droupon (which is a component of drupal for buying or creating any deal) on the folder.The site url is http://example.com/coupon
Now I want to integrate or merge this two sites.So that when a registered user access example.com then he can access the example.com/coupon with his session user id.
But this is the problem.
Is this really possible to pass data from smarty based site (example.com) to drupal site example.com/coupon ?
Please help me.
I would write at module in Drupal that looks at $_SESSION and creates and/or login the user at the Drupal-site. Perhaps the rules module can do that work, but you will probably need to implement a rules-hook to grab the relevant session data as input to the rules component.
Here are a few lines of code that do some of the work but you need to implement hook_menu aswell to register an entrypoint for the integration.
//register user
$passwd = user_password();
$edit = array(
'name' => $_SESSION['username'],
'pass' => $passwd,
'mail' => $_SESSION['email'],
'init' => $_SESSION['email'],
'status' => 1,
'access' => REQUEST_TIME,
);
$uu = drupal_anonymous_user();
$u = user_save($uu, $edit);
//Login
global $user;
$user = user_load($u->uid);
$login_array = array ('name' => $username);
user_login_finalize($login_array);
However, Im not sure this is the best way to go about it. Sharing data in the same session-namespace between 2 different applications will probably lead to errors on both sides. Is it not better to implement the whole site in Drupal from the beginning?
I am modifying a website on wordpress (codex) and I would like to import all the .doc files (about 200) from the old website and make them into posts on the wordpress website.
Any ideas how to do this bulk import or is the only way to copy and paste each one, which will take a long time.
There Is a way to do this - but as far as I know - it is not easy ..
I struggled with it one time - but could achieve it in the end .
The reason is that a WORD *.doc is a complicated format , and even simple Copy&Paste can make problems (as it actually copies also formatting)
You need to use the COM interface in php , turn the DOC to a TXT file or a string , and then create the post with wp_insert_post( $my_post );
so - opening the DOC . (you need to loop for bulk )
$filename="file.doc";
$TXTfilename = $filename . ".txt";
$word = new COM("word.application") or die("Unable to instantiate Word object");
$word->Documents->Open($filename);
$word->Documents[1]->SaveAs($TXTfilename ,2);// '2' for txt format
$word->Documents[1]->Close(false);
$word->Quit();
$word->Release();
$word = NULL;
unset($word);
$my_doc_string = file_get_contents($TXTfilename); //write file
unlink($TXTfilename);
Then, either read a txt file , or if in the same function use the $my_doc_string directly.. :
$title_p = 'mypost no'.$i;
$my_post = array(
'post_title' => $title_p,
'post_content' => $my_doc_string,
'post_status' => 'publish',
'post_author' => 1
);
$post_id = wp_insert_post( $my_post );
wp_insert_post( $my_post );
NOTE : the COM interface , as far as I know , Is available only on the WINDOWS vesion of PHP , and you will also need to have MS WORD installed ...
some more reading for you :
http://php.net/manual/en/book.com.php
http://docstore.mik.ua/orelly/webprog/php/ch15_03.htm
http://www.gsdesign.ro/blog/extracting-text-from-word-documents-in-php-with-com-objects/
EDIT I -
After reading your question again - if you have an OLD website - why do you need the DOC files ? you might be able to do that with an HTML PARSER (if the OLD website has the same content as the DOCs - but in HTML)
EDIT II - unbelievably - today I have stumbled into this plugin, it might be of some help although I did not tried it .
http://wordpress.org/extend/plugins/auto-poster/screenshots/
l downloaded a plugin https://wordpress.org/plugins/mammoth-docx-converter/ that is able to import word documents into wordpress editor for publishing. Format mapping is not 100% but does the basic stuff. All i need to do now is to be able to populate metadata in association with that particular document (custom post) upon import using particular key words from the post Content to asynchronously populate the meta boxes. I am also trying to generate excerpts automatically from a particular paragraph (second paragraph) of the document.I read about wp all import plugin and find it quite close to what i want but cant really figure out how word documents can be imported at the same time automating the operations stated above. I was able to come up with an XML file from source using WRX specification leveraging exported Content from my Website and then uploading again for test purposes but that is not what i really want to achieve. Is there anyway wp all import plugin can be customized to do what i want?
I also find your php approach quite suitable and might be more appropriate for what i need it to do and my goal. Important for me is an automated import of the word document as a post keeping the formatting intact and and then asynchronously populating associated meta data automatically. Do you have any recommendations based on the above php COM Code?
I'm developing a Wordpress plugin that requires updates, although the plugin version is being checked from my server. There are several plugins that I have developed which use the exact same server to check for new versions. The problem I'm experiencing is that when all the plugins require an update and I click View Details, one of the plugins will show details of the update (version, description, and etc), but the other plugins won't show any information. After some debugging I can see that the server is returning data for sure.
My question is, how can I apply the plugins_api filter multiple times without it conflicting with the other plugins?
Your observation is right. It is not obvious. Even the book of Brad and Ozh (Plugin development ed. Wrox) includes an error in the example on page 267 in the chapter "make your own API repository".
Like you, I spent (lost) time to find the issue with a two plugins in alternate API...
The solution:
Remember that that first parameter in the WP filter is the original value passed to the filter.
So to concatenate the filters (listed by plugins using alternate api)... the first line must be:
function xiliw_altapi_information( $false, $action, $args ) {
$plugin_slug = plugin_basename( __FILE__ );
// Check if this plugins API is about this plugin
if( $args->slug != $plugin_slug ) {
return $false; // var to conserve the value of previous filter of plugins list in alternate api. fixes book error not val false
}
// POST data to send to your API
$args = array(
'action' => 'plugin_information',
'plugin_name' => $plugin_slug,
'version' => $transient->checked[$plugin_slug],
'registration' => $this->registration
);//../..
By doing this test, each time the list of hooks is called, only one - the concerned plugin - gives the right answer to display the information for the splash window.
If I have time, I probably will publish soon a more complete article about a class to manage this alternate powerful API and how to add it to a -private- plugin.
I'm trying to import nodes from my forum to drupal 7. Not in bulk, but one by one so that news posts can be created and referenced back to the forum. The kicker is that I'm wanting to bring image attachments across as well...
So far, using the code example here http://drupal.org/node/889058#comment-3709802 things mostly work: Nodes are created, but the images don't go through any validation or processing.
I'd like the attached images to be validated against the rules defined in the content type. in particular the style associated with my image field which resizes them to 600x600.
So, instead of simply creating the nodes programatically with my own form, i decided to modify a "new" node using hook_node_prepare and using the existing form to create new content (based on passed in url args). This works really well and a create form is presented pre-filled with all my data. including the image! very cute.
I expected that i could then hit preview or save and all the validation and resizing would happen to my image, but instead i get the error:
"The file used in the Image field may not be referenced."
The reason for this is that my file doesn't have an entry in the file_usage table.. *le sigh*
so, how do i get to all the nice validation and processing which happens when i manually choose a file to upload? like resizing, an entry in the file_usage table.
The ajax upload function does it, but i can't find the code which is called to do this anywhere in the api.
What file upload / validation functions does Drupal call which i'm not doing?
Anybody have any experience with the file/image api for Drupal 7 who can help me out?
For getting the usage entry (in essence, checking out a file to a specific module so that it doesn't get deleted while its in use) look up the Drupal function 'file_usage_add()'
For validating incoming images, I got this example from user.module (if you're comfortable with PHP, you can always look at the core to see how something is done the 'Drupal way'):
function user_validate_picture(&$form, &$form_state) {
// If required, validate the uploaded picture.
$validators = array(
'file_validate_is_image' => array(),
'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),
'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024),
);
// Save the file as a temporary file.
$file = file_save_upload('picture_upload', $validators);
if ($file === FALSE) {
form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array('%directory' => variable_get('user_picture_path', 'pictures'))));
}
elseif ($file !== NULL) {
$form_state['values']['picture_upload'] = $file;
}
}
That function is added to the $form['#validate'] array like so:
$form['#validate'][] = 'user_validate_picture'