• דף הבית
    • אינדקס קישורים
    • פוסטים אחרונים
    • משתמשים
    • חיפוש בהגדרות המתקדמות
    • חיפוש גוגל בפורום
    • ניהול המערכת
    • ניהול המערכת - שרת private
    • הרשמה
    • התחברות

    העתקת מערכות שלמות

    מתוזמן נעוץ נעול הועבר טיפים עצות והדגמות מהמשתמשים
    3 פוסטים 2 כותבים 218 צפיות 1 עוקבים
    טוען פוסטים נוספים
    • מהישן לחדש
    • מהחדש לישן
    • הכי הרבה הצבעות
    תגובה
    • תגובה כנושא
    התחברו כדי לפרסם תגובה
    נושא זה נמחק. רק משתמשים עם הרשאות מתאימות יוכלו לצפות בו.
    • ט מנותק
      טנטפון
      נערך לאחרונה על ידי טנטפון

      אחרי שראיתי שיש דבר ניצרך להעתקת מערכות כתבתי קוד הקוד לפניכם השמח לתגובות

      <?php
      set_time_limit(0);
      error_reporting(E_ALL);
      
      function apiGet($url) {
          $ch = curl_init($url);
          curl_setopt_array($ch, [
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_SSL_VERIFYPEER => false,
              CURLOPT_SSL_VERIFYHOST => false,
          ]);
          $res = curl_exec($ch);
          curl_close($ch);
          return json_decode($res, true);
      }
      
      function login($user, $pass) {
          $res = apiGet("https://call2all.co.il/ym/api/Login?path=ivr2:/&username=$user&password=$pass");
          if (!isset($res['responseStatus']) || $res['responseStatus'] !== 'OK') {
              die("שגיאה בהתחברות");
          }
          return $res['token'];
      }
      
      function uploadFile($token, $dstPath, $fileName, $content) {
          $url = "https://call2all.co.il/ym/api/UploadFile?path=$dstPath/$fileName&token=$token";
          $ch = curl_init($url);
          curl_setopt_array($ch, [
              CURLOPT_POST => true,
              CURLOPT_POSTFIELDS => $content,
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_SSL_VERIFYPEER => false,
              CURLOPT_SSL_VERIFYHOST => false,
          ]);
          curl_exec($ch);
          curl_close($ch);
      }
      
      function copyDir($srcToken, $dstToken, $srcPath, $dstPath) {
          $data = apiGet("https://call2all.co.il/ym/api/GetIVR2Dir?path=ivr2:$srcPath/&token=$srcToken");
          if (!isset($data['responseStatus']) || $data['responseStatus'] !== 'OK') return;
      
          foreach ($data['files'] as $file) {
              $content = file_get_contents("https://call2all.co.il/ym/api/DownloadFile?path={$file['what']}&token=$srcToken");
              uploadFile($dstToken, "ivr2:$dstPath", $file['name'], $content);
              echo "הועתק קובץ: {$file['name']}<br>";
              flush();
          }
      
          foreach ($data['dirs'] as $dir) {
              copyDir(
                  $srcToken,
                  $dstToken,
                  trim($srcPath . '/' . $dir['name'], '/'),
                  trim($dstPath . '/' . $dir['name'], '/')
              );
          }
      }
      
      if ($_SERVER['REQUEST_METHOD'] === 'POST') {
      
          $srcUser = $_POST['src_user'];
          $srcPass = $_POST['src_pass'];
          $srcPath = trim($_POST['src_path'], '/');
      
          $dstUser = $_POST['dst_user'];
          $dstPass = $_POST['dst_pass'];
          $dstPath = trim($_POST['dst_path'], '/');
      
          echo "<h3>מתחיל העתקה...</h3>";
      
          $srcToken = login($srcUser, $srcPass);
          $dstToken = login($dstUser, $dstPass);
      
          copyDir($srcToken, $dstToken, $srcPath, $dstPath);
      
          apiGet("https://call2all.co.il/ym/api/Logout?token=$srcToken");
          apiGet("https://call2all.co.il/ym/api/Logout?token=$dstToken");
      
          echo "<h2>ההעתקה הושלמה בהצלחה</h2>";
          exit;
      }
      ?>
      
      <!DOCTYPE html>
      <html lang="he">
      <head>
      <meta charset="UTF-8">
      <title>העתקת מערכת</title>
      </head>
      <body>
      
      <h2>העתקת מערכת</h2>
      
      <form method="post">
      
      מערכת מקור:<br>
      <input type="text" name="src_user" required><br>
      <input type="password" name="src_pass" required><br>
      שלוחה להעתקה (ריק = הכל):<br>
      <input type="text" name="src_path"><br><br>
      
      מערכת יעד:<br>
      <input type="text" name="dst_user" required><br>
      <input type="password" name="dst_pass" required><br>
      שלוחה יעד:<br>
      <input type="text" name="dst_path" required><br><br>
      
      <button type="submit">התחל העתקה</button>
      
      </form>
      
      </body>
      </html>
      
      

      גם בפיטון

      from flask import Flask, request
      import requests
      
      app = Flask(__name__)
      
      def api_get(url):
          r = requests.get(url, verify=False)
          return r.json()
      
      def login(user, password):
          r = api_get(f"https://call2all.co.il/ym/api/Login?path=ivr2:/&username={user}&password={password}")
          if r.get("responseStatus") != "OK":
              raise Exception("Login failed")
          return r["token"]
      
      def upload_file(token, path, name, content):
          requests.post(
              f"https://call2all.co.il/ym/api/UploadFile?path={path}/{name}&token={token}",
              data=content,
              verify=False
          )
      
      def copy_dir(src_token, dst_token, src_path, dst_path):
          data = api_get(f"https://call2all.co.il/ym/api/GetIVR2Dir?path=ivr2:{src_path}/&token={src_token}")
          if data.get("responseStatus") != "OK":
              return ""
      
          out = ""
      
          for f in data["files"]:
              content = requests.get(
                  f"https://call2all.co.il/ym/api/DownloadFile?path={f['what']}&token={src_token}",
                  verify=False
              ).content
              upload_file(dst_token, f"ivr2:{dst_path}", f["name"], content)
              out += f"הועתק קובץ: {f['name']}<br>"
      
          for d in data["dirs"]:
              out += copy_dir(
                  src_token,
                  dst_token,
                  f"{src_path}/{d['name']}".strip("/"),
                  f"{dst_path}/{d['name']}".strip("/")
              )
      
          return out
      
      @app.route("/", methods=["GET", "POST"])
      def index():
          if request.method == "POST":
              src_user = request.form["src_user"]
              src_pass = request.form["src_pass"]
              src_path = request.form["src_path"].strip("/")
      
              dst_user = request.form["dst_user"]
              dst_pass = request.form["dst_pass"]
              dst_path = request.form["dst_path"].strip("/")
      
              try:
                  src_token = login(src_user, src_pass)
                  dst_token = login(dst_user, dst_pass)
                  result = copy_dir(src_token, dst_token, src_path, dst_path)
                  api_get(f"https://call2all.co.il/ym/api/Logout?token={src_token}")
                  api_get(f"https://call2all.co.il/ym/api/Logout?token={dst_token}")
                  return "<h2>העתקה הושלמה</h2>" + result
              except Exception as e:
                  return "שגיאה"
      
          return """
          <html><body>
          <h2>העתקת מערכת</h2>
          <form method="post">
          <h3>מערכת מקור</h3>
          מספר מערכת:<br><input name="src_user"><br>
          סיסמה:<br><input type="password" name="src_pass"><br>
          שלוחה (ריק = הכל):<br><input name="src_path"><br><br>
      
          <h3>מערכת יעד</h3>
          מספר מערכת:<br><input name="dst_user"><br>
          סיסמה:<br><input type="password" name="dst_pass"><br>
          שלוחה יעד:<br><input name="dst_path"><br><br>
      
          <button type="submit">התחל העתקה</button>
          </form>
          </body></html>
          """
      
      if __name__ == "__main__":
          app.run(host="0.0.0.0", port=5000)
      
      
      I תגובה 1 תגובה אחרונה תגובה ציטוט 2
      • I מנותק
        isi @טנטפון
        נערך לאחרונה על ידי

        @טנטפון איך משתמשים בקוד, היכן מפעילים אותו, והיכן מקבלים את כל הגיבוי?

        ט תגובה 1 תגובה אחרונה תגובה ציטוט 0
        • ט מנותק
          טנטפון @isi
          נערך לאחרונה על ידי

          @isi שתשים את הקוד בשרת תיכנס בדפדפן לאר הזה ובאתר יבקש מספר מערכת סיסמה מאפו להעתיק למספר מערכת סיסמה לאן להעתק

          תגובה 1 תגובה אחרונה תגובה ציטוט 2

          שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.

          נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.

          בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗

          הרשמה התחברות
          • פוסט ראשון
            פוסט אחרון