Advertisement
Guest User

Untitled

a guest
Sep 20th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. <?
  2.  
  3. $finstrip = $_POST["finstrip"];
  4. $nick = $_POST["nick"];
  5. $profit = $_POST["profit"];
  6.  
  7. $err=0;
  8. if (strlen($finstrip) < 300 ){
  9. $err=2;
  10. };
  11. if (strlen($nick) == 0 ){
  12. $err=3;
  13. };
  14. if (strlen($profit) == 0 ){
  15. $err=4;
  16. };
  17.  
  18. if ($err==0) {
  19. require_once('../wp-load.php' );
  20.  
  21. $result = count_users();
  22. //$maxnum = $result['total_users'];
  23. $maxnum = $result['avail_roles']['author'];
  24. $user_id = 1;
  25. if ($maxnum >= 1) {
  26. $user_name = "user_".$maxnum;
  27. $random_password = wp_generate_password($length=10, $include_standard_special_chars=false);
  28. $user_id = wp_create_user($user_name, $random_password);
  29. } else {
  30. $err=1;
  31. };
  32. };
  33.  
  34. if ($err==0) {
  35. $title = "$nick: $profit";
  36. $story = $finstrip;
  37.  
  38. // timezone + 4 hours
  39. $date=time()+60*60*4;
  40.  
  41. $new_post = array(
  42. 'post_title' => $title,
  43. 'post_content' => $story,
  44. 'post_status' => 'publish',
  45. 'post_date' => date('Y-m-d H:i:s', $date),
  46. 'post_author' => $user_id,
  47. 'post_type' => 'post',
  48. 'post_category' => array(0)
  49. );
  50. $post_id = wp_insert_post($new_post);
  51.  
  52. // check if some error occurred
  53. if ($post_id == 0) {
  54. $err=1;
  55. };
  56.  
  57. };
  58.  
  59.  
  60.  
  61. if ($err==0){
  62. //$text="Финстрип добавлен в очередь на модерацию";
  63. $text="<h1>Финстрип добавлен</h1>";
  64. };
  65. if ($err==1) {
  66. $text='<h3><font color="red">Ошибка wordpress при добавлении финстрипа</font></h3>';
  67. };
  68. if ($err==2) {
  69. $text='<h3><font color="red">Отчет финстрипа содержит менее 300 символов</font></h3>';
  70. };
  71. if ($err==3) {
  72. $text='<h3><font color="red">Не указан ник/имя</font></h3>';
  73. };
  74. if ($err==4) {
  75. $text='<h3><font color="red">Не указана общая сумма финстрипа</font></h3>';
  76. };
  77.  
  78.  
  79. ?>
  80. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  81. <html>
  82. <head>
  83. <title>Finstrip.Org</title>
  84. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  85. </head>
  86. <body>
  87.  
  88. <br/>
  89. <center><? echo $text; ?></center>
  90. <br/>
  91. <?
  92. if ($err == 0) {
  93. echo "<br/>\n";
  94. echo '<table align="center" width="20%"><tr><td>'."\n";
  95. echo "Данные для редактирования финстрипа:\n";
  96. echo "<b>User:</b> ".$user_name."<br/>\n";
  97. echo "<b>Password:</b> ".$random_password."<br/>\n";
  98. echo "</td></tr></table>\n";
  99. echo "<br/><br/><br/>\n";
  100. };
  101. ?>
  102. <center><a href="/">на главную</a> | <a href="javascript:goBack()">назад</a></center>
  103. <br/>
  104.  
  105.  
  106. <script>
  107. function goBack() {
  108. history.go(-1);
  109. }
  110. </script>
  111. </body>
  112. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement