plug_usermanager.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. if (!class_exists("plug_usermanager")) {
  3. class plug_usermanager {
  4. function plug_usermanager($ns) {
  5. $this->title = __("plug_usermanager","dagsopt");
  6. $this->pluginname = $ns->pluginname;
  7. $this->file = $ns->file;
  8. $this->ns = $ns;
  9. }
  10. function start() {
  11. // register_setting("section", "demo-file", array(&this,"handle_file_upload"));
  12. }
  13. function handle_file_upload($option)
  14. {
  15. if(!empty($_FILES["demo-file"]["tmp_name"]))
  16. {
  17. $urls = wp_handle_upload($_FILES["demo-file"], array('test_form' => FALSE));
  18. $temp = $urls["url"];
  19. return $temp;
  20. }
  21. return $option;
  22. }
  23. function help(){
  24. ?>
  25. plug_usermanager
  26. <?php
  27. }
  28. function Option($pre){
  29. $nonce = $_REQUEST['_wpnonce'];
  30. if ( ! wp_verify_nonce( $nonce, 'filen-nonce' ) ) {
  31. // This nonce is not valid.
  32. die( __( 'Security check', 'textdomain' ) );
  33. } else {
  34. // The nonce was valid.
  35. // Do stuff here.
  36. if(isset($_FILES) && !empty($_FILES)){
  37. if($_FILES['filen']){
  38. $upload = wp_upload_dir();
  39. $upload_dir = $upload['basedir'];
  40. $upload_dir = $upload_dir . '/assets';
  41. move_uploaded_file($_FILES['filen']['tmp_name'], $upload_dir."/users.csv");
  42. }
  43. }
  44. }
  45. }
  46. /*<input id="link_image" value="test">
  47. <img src="" id="background_image">
  48. <a id="upload_image_button" href="#"><?php _e('Set image', 'dagsopt'); ?></a>
  49. */
  50. function admin_line($pre){
  51. ?>
  52. <?php
  53. $nonce = wp_create_nonce( 'filen-nonce' );
  54. $upload = wp_upload_dir();
  55. $upload_dir = $upload['basedir'];
  56. $upload_dir = $upload_dir . '/assets';
  57. $data = file_get_contents($upload_dir."/users.csv");
  58. ?>
  59. <textarea><?php echo($data); ?></textarea>
  60. <input type="file" name="filen">
  61. <input type="hidden" name="_wpnonce" value="<?php echo $nonce ?>">
  62. <?php
  63. }
  64. }
  65. global $plug_usermanager;
  66. $plug_usermanager = new plug_usermanager($this);
  67. $this->dagsopt['plug_usermanager'] = $plug_usermanager;
  68. }