Example #1
0
        break;
    case 'units':
        $Unit = new Product_Unit();
        foreach ($Unit->findList(array('Name <> -')) as $Unit) {
            $Unit->Name = rtrim($Unit->Name, 'м') . 'мм';
            $Unit->save();
        }
        break;
    case 'names':
        $Product = new Product();
        $Layout = new Product_Layout_Standard();
        $params = array();
        $params[] = 'CategoryId = ' . $Layout->getCategory()->Id;
        foreach ($Product->findList($params) as $Product) {
            if (strpos($Product->Name, 'поликарбонат') > 0) {
                continue;
            }
            $Product->Name .= ' поликарбонат "' . $Product->getBrand()->Name . '"';
            $Product->save();
        }
        break;
    case 'mail':
        Console::writeln(sprintf('%dMb', memory_get_peak_usage(true) / 1024 / 1024));
        if (mail($argv[2], 'Hello from ankor.com.ua', 'Here is the test email')) {
            Console::writeln('Email sent');
        } else {
            Console::writeln('Failed');
        }
        break;
}
echo "\n";
Example #2
0
    if ($i == 'a') {
        break;
    }
    Console::left(count(${$i}), 4);
    Console::left(File::getFilesize($stats['size'][$i], 'b,K,M,G'), 5);
    Console::left($stats['lines'][$i] . 'L', 8);
    Console::write('|  ');
}
Console::left(count($m) + count($c) + count($v), 4);
Console::left(File::getFilesize($stats['size']['a'], 'b,K,M,G'), 5);
Console::left($stats['lines']['a'] . 'L', 8);
Console::writeln('|');
Console::write('\\');
Console::write(str_repeat('=', 98));
Console::writeln('/');
Console::writeln();
if ($argv[1]) {
    $sign = '$';
    $time = $price = 0;
    $arr = explode('/', $argv[1]);
    if (count($arr) == 2) {
        $price = $stats['lines']['a'] / $arr[1];
        $sign = $arr[0] ? $arr[0] : $sign;
    } else {
        $price = $stats['lines']['a'] * $arr[1];
    }
    $time = round($stats['lines']['a'] / 1500);
    Console::writeln('Price: ' . Price::show($price) . $sign . ', Time: ' . $time . ' days.');
    Console::writeln();
}
//Console::writeln('DONE');
Example #3
0
                            $DB->execute($q);
                            if (in_array($DB->getError(), $codes)) {
                                Console::write($key . ' ');
                            } else {
                                Console::write($key . ' ');
                                $error[] = $q;
                            }
                        }
                        Console::writeln();
                    } else {
                    }
                } else {
                    Console::left($new['name'], 30);
                    // new table
                    $DB->execute($query);
                    if (in_array($DB->getError(), $codes)) {
                        Console::writeln('added');
                    } else {
                        Console::writeln('FAILED!');
                        //$error[] = $query;
                        $error[] = $DB->getError(true);
                    }
                }
            }
            continue;
        }
    }
}
Console::writeln($error);
Console::writeln('DONE');
Example #4
0
 $fd_name = array_search($fd, $fds);
 if ($fd_name == 'stdin') {
     /* let readline handle use input */
     readline_callback_read_char();
 } elseif ($fd_name == 'sck') {
     if (feof($fd)) {
         $ret = FALSE;
     } else {
         $ret = $console->debugger->getData();
     }
     if ($ret === FALSE) {
         /* EOF - close this fd */
         @fclose($fd);
         $sck = NULL;
         $console->debugger = NULL;
         $console->writeln("Debugger Disconnected");
     }
 } elseif ($fd_name == 'listen') {
     /* accept the incomming connection */
     $sck = stream_socket_accept($listen);
     /* don't let any more in */
     fclose($listen);
     $listen = NULL;
     $p = setting('accept');
     if (!empty($p)) {
         $ip = strtok(stream_socket_get_name($sck, TRUE), ':');
         if (!wildMatch($p, $ip)) {
             /* try to match against the hostname */
             $h = gethostbyaddr($ip);
             if (!wildMatch($p, $h)) {
                 $console->writeln("Rejected connection from {$h} [{$ip}]");