Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $finstrip = $_POST["finstrip"];
- $nick = $_POST["nick"];
- $profit = $_POST["profit"];
- $err=0;
- if (strlen($finstrip) < 300 ){
- $err=2;
- };
- if (strlen($nick) == 0 ){
- $err=3;
- };
- if (strlen($profit) == 0 ){
- $err=4;
- };
- if ($err==0) {
- require_once('../wp-load.php' );
- $result = count_users();
- //$maxnum = $result['total_users'];
- $maxnum = $result['avail_roles']['author'];
- $user_id = 1;
- if ($maxnum >= 1) {
- $user_name = "user_".$maxnum;
- $random_password = wp_generate_password($length=10, $include_standard_special_chars=false);
- $user_id = wp_create_user($user_name, $random_password);
- } else {
- $err=1;
- };
- };
- if ($err==0) {
- $title = "$nick: $profit";
- $story = $finstrip;
- // timezone + 4 hours
- $date=time()+60*60*4;
- $new_post = array(
- 'post_title' => $title,
- 'post_content' => $story,
- 'post_status' => 'publish',
- 'post_date' => date('Y-m-d H:i:s', $date),
- 'post_author' => $user_id,
- 'post_type' => 'post',
- 'post_category' => array(0)
- );
- $post_id = wp_insert_post($new_post);
- // check if some error occurred
- if ($post_id == 0) {
- $err=1;
- };
- };
- if ($err==0){
- //$text="Финстрип добавлен в очередь на модерацию";
- $text="<h1>Финстрип добавлен</h1>";
- };
- if ($err==1) {
- $text='<h3><font color="red">Ошибка wordpress при добавлении финстрипа</font></h3>';
- };
- if ($err==2) {
- $text='<h3><font color="red">Отчет финстрипа содержит менее 300 символов</font></h3>';
- };
- if ($err==3) {
- $text='<h3><font color="red">Не указан ник/имя</font></h3>';
- };
- if ($err==4) {
- $text='<h3><font color="red">Не указана общая сумма финстрипа</font></h3>';
- };
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>Finstrip.Org</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- </head>
- <body>
- <br/>
- <center><? echo $text; ?></center>
- <br/>
- <?
- if ($err == 0) {
- echo "<br/>\n";
- echo '<table align="center" width="20%"><tr><td>'."\n";
- echo "Данные для редактирования финстрипа:\n";
- echo "<b>User:</b> ".$user_name."<br/>\n";
- echo "<b>Password:</b> ".$random_password."<br/>\n";
- echo "</td></tr></table>\n";
- echo "<br/><br/><br/>\n";
- };
- ?>
- <center><a href="/">на главную</a> | <a href="javascript:goBack()">назад</a></center>
- <br/>
- <script>
- function goBack() {
- history.go(-1);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement