Prechádzať zdrojové kódy

added roundcube driver for vesta reset api

Serghey Rodin 13 rokov pred
rodič
commit
44829483b6
1 zmenil súbory, kde vykonal 54 pridanie a 0 odobranie
  1. 54 0
      install/0.9.7/rhel/roundcube-driver.php

+ 54 - 0
install/0.9.7/rhel/roundcube-driver.php

@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * Vesta Control Panel Password Driver
+ *
+ * @version 1.0
+ * @author Serghey Rodin <skid@vestacp.com>
+ */
+
+class rcube_vesta_password
+{
+    function save($curpass, $passwd)
+    {
+        $rcmail = rcmail::get_instance();
+        $vesta_host = $rcmail->config->get('password_vesta_host');
+
+        if (empty($vesta_host))
+        {
+            $vesta_host = 'localhost';
+        }
+
+        $vesta_port = $rcmail->config->get('password_vesta_port');
+        if (empty($vesta_port))
+        {
+            $vesta_port = '8083';
+        }
+
+        $request  = 'email='.$_SESSION['username'].'&';
+        $request .= 'password='.$curpass.'&';
+        $request .= 'new='.$passwd.'&';
+
+
+        $context = stream_context_create(array(
+            'http' => array(
+                'method' => 'POST',
+                'header' => 'Content-Type: application/x-www-form-urlencoded' . PHP_EOL,
+                'content' => $request,
+            ),
+        ));
+
+        $result = file_get_contents(
+            $file = "https://".$vesta_host.":".$vesta_port."/reset/mail/?",
+            $use_include_path = false,
+            $context);
+
+        if ($result == 'ok'){
+            return PASSWORD_SUCCESS;
+        }
+        else {
+            return PASSWORD_ERROR;
+        }
+
+    }
+}