コード例 #1
0
function listitems()
{
    global $APPNAME, $ebayusername, $SiteId;
    $active_user = 8;
    $f_endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1';
    // Finding
    $responseEncoding = 'XML';
    // Format of the response
    $s_version = '667';
    // Shopping API version number
    $f_version = '1.4.0';
    // Finding API version number
    $appID = $APPNAME;
    //replace this with your AppID
    $debug = true;
    $sitearray = array(0 => 'EBAY-US', 2 => 'EBAY-ENCA', 3 => 'EBAY-GB', 15 => 'EBAY-AU', 77 => 'EBAY-DE');
    $globalID = $sitearray[$SiteId];
    $sellerID = $ebayusername;
    // cleanse input
    $apicall = "{$f_endpoint}?OPERATION-NAME=findItemsAdvanced" . "&version={$f_version}" . "&GLOBAL-ID={$globalID}" . "&SECURITY-APPNAME={$appID}" . "&RESPONSE-DATA-FORMAT={$responseEncoding}" . "&itemFilter(0).name=Seller" . "&itemFilter(0).value={$sellerID}" . "&paginationInput.entriesPerPage=100" . "&affliate.networkId=9" . "&affliate.trackingId=123456789" . "&affliate.customId=456";
    $resp = simplexml_load_file($apicall);
    if ($resp->ack == "Success") {
        $nbpages = ceil($resp->paginationOutput->totalEntries / 100);
    } else {
        $nbpages = 1;
    }
    //$sql="DELETE FROM user_products where ItemID>0 and UserID = $active_user";
    // mysql_query($sql);
    //echo $nbpages;die;
    /*touch($cron_file); 
        chmod($cron_file, 0777); 
    	*/
    for ($page = 1; $page <= $nbpages; $page++) {
        $my_sellings_activelist = get_my_ebay_selling_ActiveList($page);
        $xml = simplexml_load_string($my_sellings_activelist);
        $active_data = $xml->ActiveList->ItemArray->Item;
        $count_array = count($active_data);
        $minute = 0;
        $hour = 0;
        foreach ($active_data as $item) {
            $item_id = $item->ItemID;
            $item_url = $item->ListingDetails->ViewItemURL;
            $ebay_price = $item->BuyItNowPrice;
            $quantity = $item->QuantityAvailable;
            $title = $item->Title;
            $sku = $item->SKU;
            $sku = str_replace(' ', '', $sku);
            $image_url = $item->PictureDetails->GalleryURL;
            $pattern = '/^AMZ/';
            $posamaz = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^WM/';
            $poswm = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^OS/';
            $posos = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^AL/';
            $posal = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^HN/';
            $poshe = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^WF/';
            $poswa = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            if ($posamaz > 0) {
                $asin = str_replace('AMZ', '', $sku);
            } elseif ($poswm > 0) {
                $asin = str_replace('WM', '', $sku);
            } elseif ($posos > 0) {
                $asin = str_replace('OS', '', $sku);
            } elseif ($posal > 0) {
                $asin = str_replace('AL', '', $sku);
            } elseif ($poshe > 0) {
                $asin = str_replace('HN', '', $sku);
            } elseif ($poswa > 0) {
                $asin = str_replace('WF', '', $sku);
            } else {
                $asin = $sku;
            }
            if (!empty($asin)) {
                $sql = "SELECT * FROM ebay_asin WHERE asins='{$asin}'";
                $rs = mysql_query($sql);
                if (!mysql_num_rows($rs)) {
                    $insert = "INSERT INTO ebay_asin SET UserID={$active_user},asins='{$asin}',item_id={$item_id},ebay_title='{$title}',ebay_price= {$ebay_price},quantity={$quantity},max_quantity={$quantity},in_ebay=1,in_amazon=1";
                    mysql_query($insert);
                }
                $sql = "SELECT * FROM user_products WHERE SKU='{$sku}'";
                $rs = mysql_query($sql);
                if (!mysql_num_rows($rs)) {
                    $insert = "INSERT INTO user_products SET UserID={$active_user},ItemID={$item_id},Qty={$quantity},Price={$ebay_price},Title='{$title}',SKU='{$sku}',Image='{$image_url}',ItemUrl='{$item_url}',MaxQty={$quantity}";
                    mysql_query($insert);
                    $hour1 = $hour;
                    if ($hour1 > 23) {
                        $hour1 = $hour1 - 24;
                    }
                    $hour2 = $hour1 + 4;
                    if ($hour2 > 23) {
                        $hour2 = $hour2 - 24;
                    }
                    $hour3 = $hour2 + 4;
                    if ($hour3 > 23) {
                        $hour3 = $hour3 - 24;
                    }
                    $hour4 = $hour3 + 4;
                    if ($hour4 > 23) {
                        $hour4 = $hour4 - 24;
                    }
                    $hour5 = $hour4 + 4;
                    if ($hour5 > 23) {
                        $hour5 = $hour5 - 24;
                    }
                    $hour6 = $hour5 + 4;
                    if ($hour6 > 23) {
                        $hour6 = $hour6 - 24;
                    }
                    $command = $minute . ' ' . $hour1 . ',' . $hour2 . ',' . $hour3 . ',' . $hour4 . ',' . $hour5 . ',' . $hour6 . ' * * * wget http://dropshippingpower.com/ezonsync/cron_price_qty.php?itemid=' . $item_id;
                    append_cronjob($command);
                    $minute += 10;
                    if ($minute > 60) {
                        $minute = 0;
                    }
                    $hour += 1;
                    if ($hour > 23) {
                        $hour = 0;
                    }
                }
            }
        }
    }
}
コード例 #2
0
function startInstall()
{
    $dbhost = trim($_REQUEST['dbhost']);
    $dbuser = trim($_REQUEST['dbuser']);
    $dbpass = trim($_REQUEST['dbpass']);
    $dbname = isset($_REQUEST['dbname']) ? trim($_REQUEST['dbname']) : '';
    $dbport = trim($_REQUEST['dbport']);
    $url = trim($_REQUEST['url']);
    $path = trim($_REQUEST['path']);
    $username = trim($_REQUEST['username']);
    $email = trim($_REQUEST['email']);
    $password = trim($_REQUEST['password']);
    $secretKey = String::randAlpha(20);
    // echo $path;
    // die();
    // define("ENCRYPT_SECRET_KEY", $secretKey);
    if (!preg_match('/^http/i', $url)) {
        $url = 'http://' . $url;
    }
    if (!preg_match('/^http.*?\\/$/i', $url)) {
        $url = $url . '/';
    }
    $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname, $dbport);
    if (isset($conn->connect_error[5])) {
        echo json_encode(array('error' => 'yes'));
        die;
    }
    if (!isset($dbname[1])) {
        $dbname = 'noblessecms_db' . String::randText(5);
        $conn->query("CREATE DATABASE {$dbname} CHARACTER SET utf8 COLLATE utf8_general_ci;");
        $conn->query("GRANT ALL ON {$dbname}.* TO '{$dbuser}'@localhost IDENTIFIED BY '{$dbpass}';");
        $conn->query("FLUSH PRIVILEGES;");
        if (isset($conn->connect_error[5])) {
            echo json_encode(array('error' => 'yes', 'message' => 'Can not connect to database'));
            die;
        }
        $conn->select_db($dbname);
    }
    $rootPath = dirname(dirname(__FILE__)) . '/';
    if (!file_exists($rootPath . '.htaccess')) {
        copy($rootPath . 'install/htaccess.txt', $rootPath . '.htaccess');
    }
    // Check & create htaccess
    $requestUri = $_SERVER['REQUEST_URI'];
    $pathSelf = $_SERVER['PHP_SELF'];
    if (isset($requestUri[12])) {
        // $requestUri=dirname($requestUri).'/';
        $pathSelf = dirname(dirname($pathSelf)) . '/';
        $getData = file_get_contents($rootPath . '.htaccess');
        $getData = preg_replace('/RewriteBase.*/i', 'RewriteBase ' . $pathSelf, $getData);
        $fp = fopen($rootPath . '.htaccess', 'w');
        fwrite($fp, $getData);
        fclose($fp);
    }
    $getData = file_get_contents($rootPath . '.htaccess');
    $getData = str_replace('RewriteBase \\/', 'RewriteBase /', $getData);
    $fp = fopen($rootPath . '.htaccess', 'w');
    fwrite($fp, $getData);
    fclose($fp);
    $loadData = file_get_contents($rootPath . 'config.php');
    $tmpPath = str_replace('\\', '/', $path);
    $replace = array('/"dbhost" \\=\\> ".*?"/i' => '"dbhost" => "' . $dbhost . '"', '/"dbuser" \\=\\> ".*?"/i' => '"dbuser" => "' . $dbuser . '"', '/"dbpassword" \\=\\> ""/i' => '"dbpassword" => "' . $dbpass . '"', '/"dbname" \\=\\> ".*?"/i' => '"dbname" => "' . $dbname . '"', '/"dbport" \\=\\> ".*?"/i' => '"dbport" => "' . $dbport . '"', '/root_path = \'.*?\';/i' => 'root_path = \'' . $tmpPath . '\';', '/root_url = \'.*?\';/i' => 'root_url = \'' . $url . '\';', '/"ENCRYPT_SECRET_KEY", ".*?"/i' => '"ENCRYPT_SECRET_KEY", "' . $secretKey . '"');
    $loadData = preg_replace(array_keys($replace), array_values($replace), $loadData);
    $fp = fopen($rootPath . 'config.php', 'w');
    fwrite($fp, $loadData);
    fclose($fp);
    $importStatus = '';
    try {
        import($conn, 'db.sql');
    } catch (Exception $e) {
        $importStatus = $e->getMessage();
    }
    if (isset($importStatus[2])) {
        echo json_encode(array('error' => 'yes', 'message' => $importStatus));
        die;
    }
    $ip = $_SERVER['REMOTE_ADDR'];
    $date_added = date('Y-m-d H:i:s');
    $md5Pass = String::encrypt($password, $secretKey);
    $query = $conn->query("insert into users(groupid,firstname,lastname,username,email,password,ip,date_added) values('1','Admin','System','{$username}','{$email}','{$md5Pass}','{$ip}','{$date_added}')");
    if (isset($conn->error[5])) {
        echo json_encode(array('error' => 'yes', 'message' => $conn->error));
        die;
    }
    $query = $conn->query("select * from users");
    $rowData = $query->fetch_assoc();
    $id = $rowData['userid'];
    $query = $conn->query("insert into address(userid,firstname,lastname) values('{$id}','Admin','System')");
    if (isset($conn->error[5])) {
        echo json_encode(array('error' => 'yes', 'message' => $conn->error));
        die;
    }
    rename('../install', '../installBackup');
    exec('crontab -r', $crontab);
    append_cronjob('* * * * * curl -s ' . $url . 'api/cronjob/run.php');
    $result['username'] = Request::get('username');
    $result['password'] = Request::get('password');
    $result['siteurl'] = Request::get('url') . 'admincp/';
    $result['Urlfontend'] = Request::get('url');
    $result['error'] = 'no';
    echo json_encode($result);
    die;
}
コード例 #3
0
 case 'new':
     function append_cronjob($command)
     {
         if (is_string($command) && !empty($command)) {
             exec('echo -e "`crontab -l`\\n' . $command . '" | crontab -', $output);
         }
         return $output;
     }
     $min = is_numeric($_POST['min']) && $_POST['min'] < 60 && $_POST['min'] >= 0 ? $_POST['min'] : die('min vide');
     $hour = is_numeric($_POST['hour']) && $_POST['hour'] < 24 && $_POST['hour'] >= 0 ? $_POST['hour'] : die('hour vide');
     $day = is_numeric($_POST['day']) && $_POST['day'] < 32 && $_POST['day'] > 0 ? $_POST['day'] : die('day vide');
     $month = is_numeric($_POST['month']) && $_POST['month'] < 13 && $_POST['month'] > 0 ? $_POST['month'] : die('month vide');
     $id = $cnx->query('SELECT id FROM ' . $row_config_globale['table_archives'] . ' ORDER BY id DESC')->fetch(PDO::FETCH_ASSOC);
     $msg_id = $id['id'] + 1;
     $new_task = "{$min} {$hour} {$day} {$month} * " . exec("command -v php") . " " . __DIR__ . "/task.php {$cronID} >/dev/null # JOB : {$cronID} list_id : {$list_id} msg_id : {$msg_id} date : " . date("Y-m-d H:i:s") . "###";
     append_cronjob($new_task . PHP_EOL);
     $cnx->query('INSERT INTO ' . $row_config_globale['table_crontab'] . ' VALUES
                     ("","' . $cronID . '","' . $list_id . '","' . $msg_id . '","' . $min . '","' . $hour . '",
                      "' . $day . '","' . $month . '","scheduled","' . addslashes($new_task) . '",
                      (SELECT textarea FROM ' . $row_config_globale['table_sauvegarde'] . ' WHERE list_id = "' . $list_id . '"),
                      (SELECT subject FROM ' . $row_config_globale['table_sauvegarde'] . ' WHERE list_id = "' . $list_id . '"),"html",CURTIME())');
     $cnx->query('DELETE FROM ' . $row_config_globale['table_sauvegarde'] . ' WHERE list_id = "' . $list_id . '"');
     $cnx->query('UPDATE ' . $row_config_globale['table_upload'] . ' SET msg_id=' . $msg_id . ' WHERE list_id=' . $list_id . ' AND msg_id=0');
     $continue_transaction = true;
     break;
 case 'update':
     $continue_transaction = false;
     break;
 case 'delete':
     $min = isset($_POST['deltask']) && $_POST['deltask'] != '' ? $_POST['deltask'] : die;
     $detail_crontab = $cnx->query('SELECT job_id,list_id,msg_id,mail_subject,min,hour,day,month,etat