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

    קוד php ששולח פקודת API לא עובד טוב

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

      יש לי קוד PHP ששולח פקודות API של ימות.
      הקוד מיועד לסרוק את הקבצים בשלוחה.
      הבעיה היא שבכל השלוחות בקבצי השמע הוא מוצא רק את קובץ מספר 000 ולא את כל שאר הקבצים.
      בסריקת השלוחות הוא כן מוצא את כל השלוחות גם העמוקות יותר.
      אני מצרף את הקוד ואשמח אם יש מי שיוכל לעזור לי בפתרון הבעיה.

      הקוד

      <?php
      /**
       * Data Transfer Pro - STREAMING EDITION
       * העברה פיזית ומלאה - כולל וידוא קבלה ביעד
       */
      
      $fixed_src_token = "כאן_הטוקן_שלך";
      $fixed_src_path = "0/8"; 
      ?>
      <!DOCTYPE html>
      <html lang="he" dir="rtl">
      <head>
          <meta charset="UTF-8">
          <title>DATA-SYNC PRO | Transfer & Copy</title>
          <link href="https://fonts.googleapis.com/css2?family=Assistant:wght@300;400;600;700;800&display=swap" rel="stylesheet">
          <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
          <style>
              :root { --bg-page: #f0f9ff; --strong-blue: #0284c7; --light-blue-strip: #e0f2fe; --text-dark: #0c4a6e; --white: #ffffff; --success: #10b981; --admin-bg: #0f172a; }
              body { font-family: 'Assistant', sans-serif; background-color: var(--bg-page); color: var(--text-dark); margin: 0; padding: 0; direction: rtl; }
              header { background: var(--white); padding: 12px 60px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
              .logo { font-size: 22px; font-weight: 800; color: var(--strong-blue); }
              .container { max-width: 650px; margin: 50px auto; padding: 0 20px; }
              .card { background: var(--white); border-radius: 20px; box-shadow: 0 15px 35px rgba(12, 74, 110, 0.1); border: 1px solid var(--light-blue-strip); overflow: hidden; position: relative; }
              .card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 10px; background: var(--strong-blue); }
              .card-body { padding: 40px; }
              h2 { text-align: center; color: var(--strong-blue); margin-bottom: 30px; font-weight: 800; }
              .field { margin-bottom: 20px; position: relative; }
              .field label { display: block; margin-bottom: 8px; font-weight: 700; color: var(--strong-blue); }
              .field input { width: 100%; padding: 14px 45px 14px 15px; border: 2px solid var(--light-blue-strip); border-radius: 12px; font-size: 16px; box-sizing: border-box; outline: none; }
              .field i { position: absolute; right: 15px; top: 41px; color: #94a3b8; font-size: 18px; }
              .btn { width: 100%; padding: 18px; background: var(--strong-blue); color: white; border: none; border-radius: 12px; font-size: 19px; font-weight: 800; cursor: pointer; transition: 0.3s; }
              .btn:disabled { background: #94a3b8; }
              
              .progress-container { margin-top: 25px; display: none; }
              .progress-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-weight: 700; font-size: 13px; }
              .progress-bar-bg { width: 100%; height: 12px; background: #e2e8f0; border-radius: 10px; overflow: hidden; }
              .progress-bar-fill { width: 0%; height: 100%; background: var(--strong-blue); transition: width 0.1s linear; }
      
              #adminLog { display: block; margin-top: 20px; background: var(--admin-bg); color: #10b981; padding: 15px; border-radius: 12px; font-family: monospace; font-size: 12px; max-height: 250px; overflow-y: auto; border: 1px solid #334155; }
              .status-msg { text-align: center; font-weight: bold; margin-top: 15px; color: #e67e22; }
          </style>
      </head>
      <body>
      
      <header>
          <div class="logo"><i class="fas fa-bolt"></i> DATA-SYNC PRO</div>
          <div style="font-size: 12px; opacity: 0.7;">העתקה והעברה פיזית של כל הקבצים</div>
      </header>
      
      <div class="container">
          <div class="card">
              <div class="card-body">
                  <h2>העברה בשלבים</h2>
                  <div class="field">
                      <label>מספר מערכת יעד</label>
                      <i class="fas fa-phone"></i>
                      <input type="text" id="destSys" placeholder="הכנס מספר מערכת">
                  </div>
                  <div class="field">
                      <label>סיסמת ניהול</label>
                      <i class="fas fa-lock"></i>
                      <input type="password" id="destPass">
                  </div>
                  <div class="field">
                      <label>שלוחת יעד</label>
                      <i class="fas fa-folder"></i>
                      <input type="text" id="destPath" value="100">
                  </div>
                  
                  <button class="btn" id="execBtn" onclick="runTransfer()">התחל העתקה והעברה</button>
      
                  <div class="progress-container" id="progArea">
                      <div class="progress-label">
                          <span id="progText">מתחבר...</span>
                          <span id="progPercent">0%</span>
                      </div>
                      <div class="progress-bar-bg">
                          <div class="progress-bar-fill" id="progFill"></div>
                      </div>
                  </div>
      
                  <div id="statusMsg" class="status-msg">מוכן לפעולה</div>
              </div>
          </div>
          <div id="adminLog"><div id="logData">הלוג יתחיל לרוץ כאן...</div></div>
      </div>
      
      <script>
          const SRC_TOKEN = "<?php echo $fixed_src_token; ?>";
          const SRC_START = "<?php echo $fixed_src_path; ?>";
          let DEST_TOKEN = "";
      
          function log(msg, isHighlight = false) {
              const d = document.getElementById('logData');
              const color = isHighlight ? '#ffd700' : '#10b981';
              d.innerHTML += `<div style="color:${color}">[${new Date().toLocaleTimeString()}] ${msg}</div>`;
              document.getElementById('adminLog').scrollTop = d.scrollHeight;
          }
      
          function updateProgress(percent, text) {
              document.getElementById('progPercent').innerText = percent + "%";
              document.getElementById('progFill').style.width = percent + "%";
              if(text) document.getElementById('progText').innerText = text;
          }
      
          async function api(action, params) {
              const q = new URLSearchParams(params).toString();
              const r = await fetch(`https://www.call2all.co.il/ym/api/${action}?${q}`);
              return await r.json();
          }
      
          // פונקציית ההעברה הפיזית!
          async function transferPhysicalFile(srcPath, destPath, fileName) {
              try {
                  // שלב 1: מוריד מהמקור
                  const dl = await fetch(`https://www.call2all.co.il/ym/api/DownloadFile?token=${SRC_TOKEN}&path=ivr2:${srcPath}`);
                  if (!dl.ok || dl.status === 404) return false; // הקובץ לא קיים במקור
                  
                  const blob = await dl.blob();
                  if (blob.size < 100) return false; // זה לא באמת קובץ שמע (שגיאה של השרת)
      
                  // שלב 2: מעלה ליעד
                  const fd = new FormData();
                  fd.append('token', DEST_TOKEN);
                  fd.append('path', `ivr2:${destPath}`);
                  fd.append('qqfile', blob, fileName);
                  
                  const uploadReq = await fetch(`https://www.call2all.co.il/ym/api/UploadFile`, { method: 'POST', body: fd });
                  const uploadRes = await uploadReq.json();
      
                  // שלב 3: מוודא שהיעד באמת שמר את הקובץ
                  if(uploadRes.success || uploadRes.responseStatus === 'OK') {
                      return true; // הקובץ הועבר בהצלחה רבה
                  }
                  return false;
              } catch(e) { return false; }
          }
      
          async function processFolder(src, dest) {
              document.getElementById('progArea').style.display = 'block';
      
              log(`-- מתחיל לטפל בשלוחה: ${src} -> אל היעד: ${dest} --`, true);
      
              // 1. קבלת והעלאת ה-ext.ini - פעולה זו גם יוצרת את התיקייה הפיזית ביעד!
              const iniRes = await api('GetTextFile', { token: SRC_TOKEN, what: `ivr2:${src}/ext.ini` });
              if (iniRes.contents !== undefined) {
                  await api('UploadTextFile', { token: DEST_TOKEN, what: `ivr2:${dest}/ext.ini`, contents: iniRes.contents });
                  log(`העתקתי קובץ הגדרות (ext.ini) לשלוחה ${dest}`);
              } else {
                  // אם אין קובץ הגדרות, ניצור קובץ ריק רק כדי שהמערכת ביעד תיצור את התיקייה
                  await api('UploadTextFile', { token: DEST_TOKEN, what: `ivr2:${dest}/ext.ini`, contents: "" });
                  log(`יצרתי שלוחה חדשה ביעד: ${dest}`);
              }
      
              // 2. העתקה של כל קבצי השמע מ-000 עד 999
              log(`מחפש ומעתיק קבצי שמע בשלוחה ${src}...`);
              
              for (let i = 0; i <= 999; i++) {
                  const fileName = i.toString().padStart(3, '0') + ".wav";
                  
                  // עדכון תצוגה כל 10 מספרים
                  if (i % 10 === 0) {
                      updateProgress(Math.floor((i / 1000) * 100), `מחפש להעתיק את קובץ ${fileName}...`);
                  }
                  
                  // כאן מתבצעת ההעברה הפיזית
                  const isTransferred = await transferPhysicalFile(`${src}/${fileName}`, `${dest}/${fileName}`, fileName);
                  if (isTransferred) {
                      log(`✅ הועתק בהצלחה: קובץ ${fileName} מ-${src} אל היעד ${dest}!`);
                  }
              }
              updateProgress(100, `סיימתי להעתיק קבצים בשלוחה ${src}`);
      
              // 3. חיפוש ומעבר עמוק לתוך תתי-שלוחות (0 עד 99)
              log(`מחפש שלוחות פנימיות בתוך ${src} כדי להעתיק גם אותן...`);
              
              for (let i = 0; i <= 99; i++) {
                  const folderName1 = i.toString();
                  const folderName2 = i.toString().padStart(2, '0');
                  const possibleNames = folderName1 === folderName2 ? [folderName1] : [folderName1, folderName2];
      
                  for (const fName of possibleNames) {
                      // דופק בדלת כדי לבדוק אם השלוחה קיימת
                      const dirCheck = await api('GetIVR2Dir', { token: SRC_TOKEN, path: `ivr2:${src}/${fName}` });
                      
                      if (dirCheck && dirCheck.responseStatus === 'OK') {
                          log(`📁 מצאתי שלוחה נוספת: ${fName}! נכנס להעתיק את התוכן שלה...`, true);
                          // קריאה חוזרת - נכנס להעתיק את השלוחה החדשה שמצאנו!
                          await processFolder(`${src}/${fName}`, `${dest}/${fName}`);
                          break;
                      }
                  }
              }
          }
      
          async function runTransfer() {
              const sys = document.getElementById('destSys').value;
              const pass = document.getElementById('destPass').value;
              const dPath = document.getElementById('destPath').value;
      
              if (!sys || !pass) return alert("מלא פרטים");
              document.getElementById('execBtn').disabled = true;
              document.getElementById('logData').innerHTML = "";
      
              try {
                  const login = await api('Login', { username: sys, password: pass });
                  if (login.responseStatus !== 'OK') throw new Error("התחברות נכשלה, בדוק פרטים");
                  DEST_TOKEN = login.token;
      
                  // מתחילים את העתקה מהשלוחה הראשית!
                  await processFolder(SRC_START, dPath);
                  
                  log("--- כל השלוחות והקבצים הועתקו בהצלחה מלאה! ---", true);
                  document.getElementById('statusMsg').innerText = "✅ ההעברה הסתיימה!";
                  updateProgress(100, 'סיום מוצלח');
              } catch (e) { 
                  log("שגיאה: " + e.message, true);
                  document.getElementById('statusMsg').innerText = "❌ שגיאה התרחשה";
              } finally { 
                  document.getElementById('execBtn').disabled = false; 
              }
          }
      </script>
      </body>
      </html>
      

      R תגובה 1 תגובה אחרונה תגובה ציטוט 0
      • R מנותק
        R.E.T מערכות @אA
        נערך לאחרונה על ידי

        @אA
        תנסה את זה הקוד שאתה הבאת העלתי אותו לAI ומיד הוא זיהה תקלות מאוד מהותיות בקוד שלך

        <?php
        $fixed_src_token = "כאן_הטוקן_שלך";
        $fixed_src_path  = "0/8";
        ?>
        <!DOCTYPE html>
        <html lang="he" dir="rtl">
        <head>
            <meta charset="UTF-8">
            <title>DATA-SYNC PRO | Transfer & Copy</title>
            <link href="https://fonts.googleapis.com/css2?family=Assistant:wght@300;400;600;700;800&display=swap" rel="stylesheet">
            <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
            <style>
                :root {
                    --bg-page: #f0f9ff;
                    --strong-blue: #0284c7;
                    --light-blue-strip: #e0f2fe;
                    --text-dark: #0c4a6e;
                    --white: #ffffff;
                    --success: #10b981;
                    --admin-bg: #0f172a;
                    --warn: #f59e0b;
                    --danger: #ef4444;
                }
                body {
                    font-family: 'Assistant', sans-serif;
                    background-color: var(--bg-page);
                    color: var(--text-dark);
                    margin: 0;
                    padding: 0;
                    direction: rtl;
                }
                header {
                    background: var(--white);
                    padding: 12px 60px;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
                }
                .logo {
                    font-size: 22px;
                    font-weight: 800;
                    color: var(--strong-blue);
                }
                .container {
                    max-width: 650px;
                    margin: 50px auto;
                    padding: 0 20px;
                }
                .card {
                    background: var(--white);
                    border-radius: 20px;
                    box-shadow: 0 15px 35px rgba(12, 74, 110, 0.1);
                    border: 1px solid var(--light-blue-strip);
                    overflow: hidden;
                    position: relative;
                }
                .card::before {
                    content: "";
                    position: absolute;
                    top: 0; left: 0; right: 0;
                    height: 10px;
                    background: var(--strong-blue);
                }
                .card-body {
                    padding: 40px;
                }
                h2 {
                    text-align: center;
                    color: var(--strong-blue);
                    margin-bottom: 30px;
                    font-weight: 800;
                }
                .field {
                    margin-bottom: 20px;
                    position: relative;
                }
                .field label {
                    display: block;
                    margin-bottom: 8px;
                    font-weight: 700;
                    color: var(--strong-blue);
                }
                .field input {
                    width: 100%;
                    padding: 14px 45px 14px 15px;
                    border: 2px solid var(--light-blue-strip);
                    border-radius: 12px;
                    font-size: 16px;
                    box-sizing: border-box;
                    outline: none;
                }
                .field i {
                    position: absolute;
                    right: 15px;
                    top: 41px;
                    color: #94a3b8;
                    font-size: 18px;
                }
                .btn {
                    width: 100%;
                    padding: 18px;
                    background: var(--strong-blue);
                    color: white;
                    border: none;
                    border-radius: 12px;
                    font-size: 19px;
                    font-weight: 800;
                    cursor: pointer;
                    transition: 0.3s;
                }
                .btn:disabled {
                    background: #94a3b8;
                    cursor: not-allowed;
                }
        
                .progress-container {
                    margin-top: 25px;
                    display: none;
                }
                .progress-label {
                    display: flex;
                    justify-content: space-between;
                    margin-bottom: 8px;
                    font-weight: 700;
                    font-size: 13px;
                }
                .progress-bar-bg {
                    width: 100%;
                    height: 12px;
                    background: #e2e8f0;
                    border-radius: 10px;
                    overflow: hidden;
                }
                .progress-bar-fill {
                    width: 0%;
                    height: 100%;
                    background: var(--strong-blue);
                    transition: width 0.2s linear;
                }
        
                #adminLog {
                    display: block;
                    margin-top: 20px;
                    background: var(--admin-bg);
                    color: #10b981;
                    padding: 15px;
                    border-radius: 12px;
                    font-family: monospace;
                    font-size: 12px;
                    max-height: 320px;
                    overflow-y: auto;
                    border: 1px solid #334155;
                }
                .status-msg {
                    text-align: center;
                    font-weight: bold;
                    margin-top: 15px;
                    color: #e67e22;
                }
            </style>
        </head>
        <body>
        
        <header>
            <div class="logo"><i class="fas fa-bolt"></i> DATA-SYNC PRO</div>
            <div style="font-size: 12px; opacity: 0.7;">העתקה והעברה פיזית של כל הקבצים</div>
        </header>
        
        <div class="container">
            <div class="card">
                <div class="card-body">
                    <h2>העברה בשלבים</h2>
        
                    <div class="field">
                        <label>מספר מערכת יעד</label>
                        <i class="fas fa-phone"></i>
                        <input type="text" id="destSys" placeholder="הכנס מספר מערכת">
                    </div>
        
                    <div class="field">
                        <label>סיסמת ניהול</label>
                        <i class="fas fa-lock"></i>
                        <input type="password" id="destPass">
                    </div>
        
                    <div class="field">
                        <label>שלוחת יעד</label>
                        <i class="fas fa-folder"></i>
                        <input type="text" id="destPath" value="100">
                    </div>
        
                    <button class="btn" id="execBtn" onclick="runTransfer()">התחל העתקה והעברה</button>
        
                    <div class="progress-container" id="progArea">
                        <div class="progress-label">
                            <span id="progText">מתחבר...</span>
                            <span id="progPercent">0%</span>
                        </div>
                        <div class="progress-bar-bg">
                            <div class="progress-bar-fill" id="progFill"></div>
                        </div>
                    </div>
        
                    <div id="statusMsg" class="status-msg">מוכן לפעולה</div>
                </div>
            </div>
        
            <div id="adminLog">
                <div id="logData">הלוג יתחיל לרוץ כאן...</div>
            </div>
        </div>
        
        <script>
            const SRC_TOKEN = "<?php echo $fixed_src_token; ?>";
            const SRC_START = "<?php echo $fixed_src_path; ?>";
            let DEST_TOKEN = "";
        
            let totalFiles = 0;
            let copiedFiles = 0;
        
            function log(msg, type = "normal") {
                const d = document.getElementById('logData');
        
                let color = '#10b981';
                if (type === "highlight") color = '#ffd700';
                if (type === "warn") color = '#f59e0b';
                if (type === "error") color = '#ef4444';
        
                d.innerHTML += `<div style="color:${color}">[${new Date().toLocaleTimeString()}] ${msg}</div>`;
                document.getElementById('adminLog').scrollTop = d.scrollHeight;
            }
        
            function updateProgress(percent, text = "") {
                document.getElementById('progPercent').innerText = percent + "%";
                document.getElementById('progFill').style.width = percent + "%";
                if (text) {
                    document.getElementById('progText').innerText = text;
                }
            }
        
            async function api(action, params) {
                const q = new URLSearchParams(params).toString();
                const url = `https://www.call2all.co.il/ym/api/${action}?${q}`;
        
                const r = await fetch(url);
                const txt = await r.text();
        
                try {
                    return JSON.parse(txt);
                } catch (e) {
                    log(`תגובה לא תקינה מה־API בפעולה ${action}: ${txt}`, "error");
                    throw new Error(`תגובה לא תקינה מהשרת בפעולה ${action}`);
                }
            }
        
            function isAudioFile(fileName) {
                if (!fileName) return false;
                const lower = fileName.toLowerCase();
        
                return (
                    lower.endsWith('.wav') ||
                    lower.endsWith('.mp3') ||
                    lower.endsWith('.wma') ||
                    lower.endsWith('.ogg') ||
                    lower.endsWith('.m4a')
                );
            }
        
            async function ensureDestinationFolder(destPath, iniContents = "") {
                try {
                    await api('UploadTextFile', {
                        token: DEST_TOKEN,
                        what: `ivr2:${destPath}/ext.ini`,
                        contents: iniContents
                    });
                    return true;
                } catch (e) {
                    log(`שגיאה ביצירת/ext.ini בשלוחת יעד ${destPath}: ${e.message}`, "error");
                    return false;
                }
            }
        
            async function transferPhysicalFile(srcFilePath, destFolderPath, fileName) {
                try {
                    const downloadUrl =
                        `https://www.call2all.co.il/ym/api/DownloadFile?token=${encodeURIComponent(SRC_TOKEN)}&path=${encodeURIComponent('ivr2:' + srcFilePath)}`;
        
                    log(`מוריד: ivr2:${srcFilePath}`);
        
                    const dl = await fetch(downloadUrl);
        
                    if (!dl.ok) {
                        log(`כשל בהורדה: ${srcFilePath} | HTTP ${dl.status}`, "warn");
                        return false;
                    }
        
                    const blob = await dl.blob();
        
                    if (!blob || blob.size === 0) {
                        log(`הקובץ ריק או לא תקין: ${srcFilePath}`, "warn");
                        return false;
                    }
        
                    const fd = new FormData();
                    fd.append('token', DEST_TOKEN);
                    fd.append('path', `ivr2:${destFolderPath}`);
                    fd.append('qqfile', blob, fileName);
        
                    log(`מעלה ליעד: ivr2:${destFolderPath} | קובץ: ${fileName}`);
        
                    const uploadReq = await fetch(`https://www.call2all.co.il/ym/api/UploadFile`, {
                        method: 'POST',
                        body: fd
                    });
        
                    const uploadText = await uploadReq.text();
        
                    let uploadRes;
                    try {
                        uploadRes = JSON.parse(uploadText);
                    } catch (e) {
                        log(`תגובה לא תקינה מ־UploadFile: ${uploadText}`, "error");
                        return false;
                    }
        
                    if (uploadRes.success === true || uploadRes.responseStatus === 'OK') {
                        return true;
                    }
        
                    log(`העלאה נכשלה עבור ${fileName}: ${uploadText}`, "warn");
                    return false;
        
                } catch (e) {
                    log(`שגיאה בהעברת ${fileName}: ${e.message}`, "error");
                    return false;
                }
            }
        
            async function processFolder(src, dest) {
                document.getElementById('progArea').style.display = 'block';
        
                log(`-- מתחיל לטפל בשלוחה: ${src} -> ${dest} --`, "highlight");
        
                // קריאת ext.ini מהמקור
                let iniContents = "";
                try {
                    const iniRes = await api('GetTextFile', {
                        token: SRC_TOKEN,
                        what: `ivr2:${src}/ext.ini`
                    });
        
                    if (iniRes && iniRes.contents !== undefined) {
                        iniContents = iniRes.contents;
                        log(`נמצא ext.ini בשלוחה ${src}`);
                    } else {
                        log(`לא נמצא ext.ini בשלוחה ${src}, ייווצר קובץ ריק ביעד`, "warn");
                    }
                } catch (e) {
                    log(`לא הצלחתי לקרוא ext.ini מ-${src}: ${e.message}`, "warn");
                }
        
                // יצירת שלוחה ביעד
                const folderReady = await ensureDestinationFolder(dest, iniContents);
                if (!folderReady) {
                    log(`דילוג על השלוחה ${src} כי לא ניתן ליצור יעד ${dest}`, "error");
                    return;
                }
        
                // קריאת תוכן השלוחה
                let dirRes;
                try {
                    dirRes = await api('GetIVR2Dir', {
                        token: SRC_TOKEN,
                        path: `ivr2:${src}`
                    });
                } catch (e) {
                    log(`שגיאה ב-GetIVR2Dir עבור ${src}: ${e.message}`, "error");
                    return;
                }
        
                if (!dirRes || dirRes.responseStatus !== 'OK') {
                    log(`לא ניתן לקרוא את השלוחה ${src}`, "error");
                    return;
                }
        
                // ניסיון להבין איפה רשימת הקבצים ורשימת השלוחות
                const files = Array.isArray(dirRes.files) ? dirRes.files : [];
                const dirs  = Array.isArray(dirRes.dirs)  ? dirRes.dirs  : [];
        
                log(`בשלוחה ${src} נמצאו ${files.length} קבצים ו-${dirs.length} תתי־שלוחות`);
        
                // העתקת קבצי שמע
                for (const file of files) {
                    let fileName = "";
        
                    if (typeof file === "string") {
                        fileName = file;
                    } else if (file && typeof file === "object") {
                        fileName = file.name || file.fileName || "";
                    }
        
                    if (!fileName) continue;
        
                    if (!isAudioFile(fileName)) {
                        log(`מדלג על קובץ שאינו שמע: ${fileName}`, "warn");
                        continue;
                    }
        
                    totalFiles++;
                    const percent = totalFiles > 0 ? Math.floor((copiedFiles / totalFiles) * 100) : 0;
                    updateProgress(percent, `מעתיק את ${fileName} מתוך ${src}`);
        
                    const ok = await transferPhysicalFile(`${src}/${fileName}`, dest, fileName);
        
                    if (ok) {
                        copiedFiles++;
                        const p = totalFiles > 0 ? Math.floor((copiedFiles / totalFiles) * 100) : 0;
                        updateProgress(p, `הועתק ${fileName}`);
                        log(`✅ הועתק בהצלחה: ${src}/${fileName} -> ${dest}/${fileName}`);
                    } else {
                        log(`❌ נכשל בהעתקה: ${src}/${fileName}`, "error");
                    }
                }
        
                // מעבר רקורסיבי על תתי־שלוחות
                for (const dir of dirs) {
                    let subName = "";
        
                    if (typeof dir === "string") {
                        subName = dir;
                    } else if (dir && typeof dir === "object") {
                        subName = dir.name || dir.dirName || "";
                    }
        
                    if (!subName) continue;
        
                    log(`📁 נמצאה תת־שלוחה: ${src}/${subName}`, "highlight");
                    await processFolder(`${src}/${subName}`, `${dest}/${subName}`);
                }
        
                log(`-- סיימתי לטפל בשלוחה: ${src} --`, "highlight");
            }
        
            async function runTransfer() {
                const sys   = document.getElementById('destSys').value.trim();
                const pass  = document.getElementById('destPass').value.trim();
                const dPath = document.getElementById('destPath').value.trim();
        
                if (!sys || !pass) {
                    alert("מלא פרטים");
                    return;
                }
        
                document.getElementById('execBtn').disabled = true;
                document.getElementById('logData').innerHTML = "";
                document.getElementById('statusMsg').innerText = "מתחיל...";
                document.getElementById('progArea').style.display = 'block';
        
                totalFiles = 0;
                copiedFiles = 0;
                updateProgress(0, "מתחבר ליעד...");
        
                try {
                    const login = await api('Login', {
                        username: sys,
                        password: pass
                    });
        
                    if (!login || login.responseStatus !== 'OK' || !login.token) {
                        throw new Error("התחברות נכשלה, בדוק פרטים");
                    }
        
                    DEST_TOKEN = login.token;
                    log("התחברות למערכת היעד הצליחה", "highlight");
        
                    await processFolder(SRC_START, dPath);
        
                    updateProgress(100, "סיום מוצלח");
                    document.getElementById('statusMsg').innerText = "✅ ההעברה הסתיימה!";
                    log(`--- הסתיים. הועתקו ${copiedFiles} קבצי שמע ---`, "highlight");
        
                } catch (e) {
                    log("שגיאה כללית: " + e.message, "error");
                    document.getElementById('statusMsg').innerText = "❌ שגיאה התרחשה";
                } finally {
                    document.getElementById('execBtn').disabled = false;
                }
            }
        </script>
        
        </body>
        </html>
        
        א תגובה 1 תגובה אחרונה תגובה ציטוט 0
        • א מחובר
          אA @R.E.T מערכות
          נערך לאחרונה על ידי

          @R.E.T-מערכות
          עדיין מזהה רק את 000 ועכשיו גם נתקל בשגיאות.

          מעתיק את 000.wav מתוך 0/8/01/2
          0%
          מתחיל...
          [22:09:38] התחברות למערכת היעד הצליחה
          [22:09:38] -- מתחיל לטפל בשלוחה: 0/8 -> 2 --
          [22:09:38] נמצא ext.ini בשלוחה 0/8
          [22:09:38] בשלוחה 0/8 נמצאו 4 קבצים ו-50 תתי־שלוחות
          [22:09:38] מוריד: ivr2:0/8/M1101.wav
          [22:09:38] מעלה ליעד: ivr2:2 | קובץ: M1101.wav
          [22:09:38] העלאה נכשלה עבור M1101.wav: {"responseStatus":"ERROR","message":"path is invalid","messageCode":110,"yemotAPIVersion":7,"success":false}
          [22:09:38] ❌ נכשל בהעתקה: 0/8/M1101.wav
          [22:09:38] מוריד: ivr2:0/8/M1100.wav
          [22:09:38] מעלה ליעד: ivr2:2 | קובץ: M1100.wav
          [22:09:38] העלאה נכשלה עבור M1100.wav: {"responseStatus":"ERROR","message":"path is invalid","messageCode":110,"yemotAPIVersion":7,"success":false}
          [22:09:38] ❌ נכשל בהעתקה: 0/8/M1100.wav
          [22:09:38] מוריד: ivr2:0/8/M1000.wav
          [22:09:40] מעלה ליעד: ivr2:2 | קובץ: M1000.wav
          [22:09:47] העלאה נכשלה עבור M1000.wav: {"responseStatus":"ERROR","message":"path is invalid","messageCode":110,"yemotAPIVersion":7,"success":false}
          [22:09:47] ❌ נכשל בהעתקה: 0/8/M1000.wav
          [22:09:47] מוריד: ivr2:0/8/M1000-1.wav
          [22:09:47] מעלה ליעד: ivr2:2 | קובץ: M1000-1.wav
          [22:09:47] העלאה נכשלה עבור M1000-1.wav: {"responseStatus":"ERROR","message":"path is invalid","messageCode":110,"yemotAPIVersion":7,"success":false}
          [22:09:47] ❌ נכשל בהעתקה: 0/8/M1000-1.wav
          [22:09:47] 📁 נמצאה תת־שלוחה: 0/8/01
          [22:09:47] -- מתחיל לטפל בשלוחה: 0/8/01 -> 2/01 --
          [22:09:47] נמצא ext.ini בשלוחה 0/8/01
          [22:09:47] בשלוחה 0/8/01 נמצאו 1 קבצים ו-9 תתי־שלוחות
          [22:09:47] מוריד: ivr2:0/8/01/M1000.wav
          [22:09:48] מעלה ליעד: ivr2:2/01 | קובץ: M1000.wav
          [22:09:49] העלאה נכשלה עבור M1000.wav: {"responseStatus":"ERROR","message":"path is invalid","messageCode":110,"yemotAPIVersion":7,"success":false}
          [22:09:49] ❌ נכשל בהעתקה: 0/8/01/M1000.wav
          [22:09:49] 📁 נמצאה תת־שלוחה: 0/8/01/1
          [22:09:49] -- מתחיל לטפל בשלוחה: 0/8/01/1 -> 2/01/1 --
          [22:09:49] נמצא ext.ini בשלוחה 0/8/01/1
          [22:09:49] בשלוחה 0/8/01/1 נמצאו 1 קבצים ו-0 תתי־שלוחות
          [22:09:49] מוריד: ivr2:0/8/01/1/000.wav
          [22:09:50] מעלה ליעד: ivr2:2/01/1 | קובץ: 000.wav
          [22:09:59] העלאה נכשלה עבור 000.wav: {"responseStatus":"ERROR","message":"path is invalid","messageCode":110,"yemotAPIVersion":7,"success":false}
          [22:09:59] ❌ נכשל בהעתקה: 0/8/01/1/000.wav
          [22:09:59] -- סיימתי לטפל בשלוחה: 0/8/01/1 --
          [22:09:59] 📁 נמצאה תת־שלוחה: 0/8/01/2
          [22:09:59] -- מתחיל לטפל בשלוחה: 0/8/01/2 -> 2/01/2 --
          [22:09:59] נמצא ext.ini בשלוחה 0/8/01/2
          [22:10:00] בשלוחה 0/8/01/2 נמצאו 1 קבצים ו-0 תתי־שלוחות
          [22:10:00] מוריד: ivr2:0/8/01/2/000.wav
          [22:10:01] מעלה ליעד: ivr2:2/01/2 | קובץ: 000.wav
          

          R תגובה 1 תגובה אחרונה תגובה ציטוט 0
          • R מנותק
            R.E.T מערכות @אA
            נערך לאחרונה על ידי R.E.T מערכות

            @אA כתב בקוד php ששולח פקודת API לא עובד טוב:

            [22:09:38] בשלוחה 0/8 נמצאו 4 קבצים ו-50 תתי־שלוחות

            דבר ראשון אני רואה שהוא לא מזהה לך עכשיו רק את 000 אלא 4 קבצים הוא איתר שם נראה לי שעיקר הבעיה זה בהעלאה של הקבצים

            א תגובה 1 תגובה אחרונה תגובה ציטוט 0
            • א מחובר
              אA @R.E.T מערכות
              נערך לאחרונה על ידי

              @R.E.T-מערכות
              נכון
              גם בקוד שהבאתי הוא זיהה אותם וגם העביר וכן את כל שאר השלוחות אבל בנוגע לקבצי השמע הרגילים הוא מעביר בשלוחות רק את קובץ 000 ובלוג גם לא נרשם שהוא מזהה עוד.

              תגובה 1 תגובה אחרונה תגובה ציטוט 0
              • פוסט ראשון
                פוסט אחרון