function main() { global $g_conf; $ret = array('code' => 0, 'value' => ''); if (!isset($_GET['key'])) { $ret['code'] = 1; $ret['value'] = "miss `key`"; return $ret; } $key = $_GET['key']; $j_v = get_local($key); if ($j_v === false) { $ret['code'] = 2; $ret = "get fail"; return $ret; } else { if ($j_v === null) { $ret['code'] = 3; $ret['value'] = "no data"; return $ret; } else { $_j = @json_decode($j_v, true); if ($_j === false) { $ret['code'] = 2; $ret['value'] = "not valid json data"; } else { $ret['value'] = $_j; } return $ret; } } }
define('DOING_AJAX', true); //if (!defined('WP_ADMIN')) { // define('WP_ADMIN', true); //} require_once get_root_path() . 'wp-load.php'; require_once get_root_path() . 'wp-admin/includes/file.php'; require_once get_root_path() . 'wp-admin/includes/media.php'; require_once get_root_path() . 'wp-admin/includes/image.php'; /** Allow for cross-domain requests (from the frontend). */ send_origin_headers(); $data = array(); if (isset($_REQUEST['nonce']) && check_ajax_referer('ajax_nonce', 'nonce', false)) { if (isset($_POST['action']) && $_POST['action'] == 'delete' && isset($_POST['file'])) { $file = $_POST['file']; $data = array('result' => true); $local_file = get_local($file); //get all image attachments $attachments = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment')); //loop through the array if (!empty($attachments)) { foreach ($attachments as $attachment) { $attach_file = strtolower(basename($attachment->guid)); $my_local_file = strtolower(basename($local_file)); if ($attach_file == $my_local_file) { wp_delete_attachment($attachment->ID); } // Update the post into the database // wp_update_post( array( // 'ID' => $attachment->ID, // 'post_parent' => 0 // )
$local['error_fr'] = 'Le répertoire \''.$path.'\' n\'existe pas.'; $context['error'] .= '<p>'.get_local('error')."</p>\n"; // list directories and files separately } else { // offers to change the avatar if(Surfer::is_logged()) { $local['label_en'] = 'To check or change your avatar, go to the '.Skin::build_link('users/select_avatar.php', 'avatar selection page', 'shortcut').'.'; $local['label_fr'] = 'Pour vérifier ou changer votre avatar, allez à la page de '.Skin::build_link('users/select_avatar.php', 'sélection d\'avatar', 'shortcut').'.'; $context['text'] .= '<p>'.get_local('label').'</p>'."\n"; } $local['label_en'] = 'This is the list of available avatars on this system.'; $local['label_fr'] = 'Voici la liste des avatars disponibles sur ce système.'; $context['text'] .= '<p>'.get_local('label').'</p>'."\n"; // build the lists while($item = readdir($dir)) { // skip some files if($item == '.' || $item == '..') continue; if(@is_dir($actual_item)) continue; // consider only images if(!preg_match('/(\.gif|\.jpeg|\.jpg|\.png)$/i', $item)) continue; // display the image
function addpage($pagedef, $menu_id) { $ret = null; $parent = $pagedef['parent']; $parentid = 0; $test = get_page_by_path($parent); if (!empty($test)) { $parentid = $test->ID; } // try to find if this page already exists $pid = getPageID($parent, $pagedef['url'], $pagedef['title']); // create the post $post = array(); $post['ID'] = $pid; $post['menu_order'] = $pagedef['order']; $post['post_name'] = $pagedef['url']; if (empty($post['post_name'])) { $post['post_name'] = null; } $post['post_title'] = $pagedef['title']; $post['post_status'] = 'publish'; $post['post_parent'] = $parentid; $post['comment_status'] = 'closed'; // set the default content $content = $pagedef['content']; if ($content != '') { /* we check if the content is pointing to a local file */ if (strpos($content, '/') === 0) { $cpath = get_local(plugins_url($content, __FILE__)); $t = file_get_contents($cpath); $m = new Mustache_Engine(); /* we need to call this function so the $bapi_all_options gets populated */ bapi_wp_site_options(); $wrapper = getbapisolutiondata(); $string = $m->render($t, $wrapper); } else { /* if not is pointing to a json object */ $jsonContent = file_get_contents($content); if ($jsonContent != FALSE) { $jsonObjContent = json_decode($jsonContent); $string = $jsonObjContent->result[0]->DocText; } else { $string = ''; } } $string = str_replace("\t", '', $string); // remove tabs $string = str_replace("\n", '', $string); // remove new lines $string = str_replace("\r", '', $string); // remove carriage returns $post['post_content'] = $string; //utf8_encode($string); } else { $post['post_content'] = ''; } $post['post_type'] = 'page'; $action = "Added"; if ($pid == 0) { $pid = wp_insert_post($post, $error); } else { $action = "Edited"; wp_update_post($post); } add_post_meta($pid, 'bapi_page_id', $pagedef['intid'], true); update_post_meta($pid, "_wp_page_template", $pagedef['template']); $miid = 0; $addtomenu = $pagedef['addtomenu'] == 'true'; if ($addtomenu && !doesNavMenuExist($pid)) { $miid = addtonav($pid, $menu_id, $post, $parent, $ret); } if ($post['post_title'] == 'Home') { update_option('page_on_front', $pid); update_option('show_on_front', 'page'); } if ($post['post_title'] == 'Blog') { update_option('page_for_posts', $pid); } return array('action' => $action, 'post_title' => $post['post_title'], 'post_id' => $pid, 'miid' => $miid, 'menu_id' => $menu_id, 'add_to_nav' => $ret); }
} else { unlink($file->getRealPath()); } } rmdir($dir); } } if (rmdirr('included/browser/css/redmond/images')) { $local['label_en'] = 'suppressing of old jqueryui pictures'; $local['label_fr'] = 'suppression des anciennes images jquery-ui'; echo get_local('label') . "<br />\n"; } if (rmdirr('included/tinymce')) { $local['label_en'] = 'suppress of old tinymce'; $local['label_fr'] = 'suppression de l\'ancienne version de tinymce'; echo get_local('label') . "<br />\n"; } // files to fetch, from root path $copy = array(); $copy[] = 'control/htaccess/basic/.htaccess'; $copy[] = 'control/htaccess/options/.htaccess'; $copy[] = 'included/browser/css/redmond/jquery-ui-1.10.3.custom.min.css'; $copy[] = 'included/browser/js_header/readme.md'; $copy[] = 'included/browser/js_endpage/aa-jquery-1.10.1.min.js'; $copy[] = 'included/browser/js_endpage/autogrow.min.js'; $copy[] = 'included/browser/js_endpage/file.txt'; $copy[] = 'included/browser/js_endpage/imagesloaded.pkgd.min.js'; $copy[] = 'included/browser/js_endpage/jquery-migrate-1.2.1.js'; $copy[] = 'included/browser/js_endpage/jquery-ui-1.10.3.custom.min.js'; $copy[] = 'included/browser/js_endpage/jquery.json.min.js'; $copy[] = 'included/browser/js_endpage/jquery.livetwitter.js';
continue; } // remove it if (Safe::unlink($context['path_to_root'] . $file)) { $local['error_en'] = $file . ' has been removed'; $local['error_fr'] = $file . ' a été supprimé'; echo get_local('error') . "<br />\n"; } // next one $count += 1; Safe::set_time_limit(30); } // basic reporting $local['label_en'] = 'files have been deleted'; $local['label_fr'] = 'fichiers ont été supprimés'; echo $count . ' ' . get_local('label') . "<br />\n"; /** * Delete a file, or a folder and its contents (recursive algorithm) * */ if (!is_callable(rmdirr)) { function rmdirr($dir) { global $context; $dir = $context['path_to_root'] . $dir; // Sanity check if (!file_exists($dir)) { return false; } $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);