Exemple #1
0
function printArray($array, $title = null)
{
    if ($title != null) {
        echo "<h1>" . $title . "</h1>";
    }
    //fill table header
    if (empty($array)) {
        echo "No contents";
    } else {
        echo "<table border=1><tr>";
        foreach ($array[0] as $key => $value) {
            echo "<th>" . $key . "</th>";
        }
        echo "</tr>";
        foreach ($array as $item) {
            echo "<tr>";
            foreach ($item as $key => $value) {
                echo "<td>";
                if (is_array($value)) {
                    printArray($value);
                } elseif ($key == "Data") {
                    echo date('d/m/Y', strtotime($value));
                } else {
                    echo $value;
                }
                echo "</td>";
            }
            echo "</tr>";
        }
        echo "</table>";
    }
}
Exemple #2
0
 /**
  * Get path of this route
  * @since Version 3.9
  * @return array
  */
 public function getPath()
 {
     $params = array("mode" => 0, "line" => $this->route_id);
     $stops = $this->fetch("stops-for-line", $params);
     printArray($this->url);
     printArray($stops);
 }
Exemple #3
0
 /**
  * @param null $host - $host of socket server
  * @param null $port - port of socket server
  * @param string $action - action to execute in sockt server
  * @param null $data - message to socket server
  * @param string $address - addres of socket.io on socket server
  * @param string $transport - transport type
  * @return bool
  */
 public function send($action = "message", $data = null, $address = "socket.io/?EIO=2", $transport = 'websocket')
 {
     $fd = fsockopen($this->hostname, $this->port, $errno, $errstr);
     if (!$fd) {
         throw new Exception("Could not establish connection to " . $this->hostname . ":" . $this->port);
     }
     $key = $this->generateKey();
     $out = "GET {$address}&transport={$transport} HTTP/1.1\r\n";
     $out .= "Host: http://{$host}:{$port}\r\n";
     $out .= "Upgrade: WebSocket\r\n";
     $out .= "Connection: Upgrade\r\n";
     $out .= "Sec-WebSocket-Key: {$key}\r\n";
     $out .= "Sec-WebSocket-Version: 13\r\n";
     $out .= "Origin: *\r\n\r\n";
     fwrite($fd, $out);
     // 101 switching protocols, see if echoes key
     $result = fread($fd, 10000);
     preg_match('#Sec-WebSocket-Accept:\\s(.*)$#mU', $result, $matches);
     printArray($result);
     $keyAccept = trim($matches[1]);
     $expectedResonse = base64_encode(pack('H*', sha1($key . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11')));
     $handshaked = $keyAccept === $expectedResonse ? true : false;
     if ($handshaked) {
         fwrite($fd, $this->hybi10Encode('42["' . $action . '", "' . addslashes($data) . '"]'));
         fread($fd, 1000000);
         return true;
     } else {
         return false;
     }
 }
 function getContent()
 {
     $s = "<div>";
     $s .= printArray($this);
     $s .= "</div>";
     return $s;
 }
Exemple #5
0
function printAny($text)
{
    if (is_array($text)) {
        printArray($text);
    } else {
        printText($text);
    }
}
Exemple #6
0
 /**
  * Constructor
  * @since Version 3.2
  * @var object $db
  * @var object $User
  */
 public function __construct($User = false)
 {
     parent::__construct();
     if (!$User || !$User->id || $User->id == NULL || empty($User->id)) {
         throw new \Exception("Cannot instantiate " . __CLASS__ . " - user object is empty or not loaded" . printArray(debug_backtrace()));
     }
     $this->User = $User;
 }
Exemple #7
0
function sortArrarTest()
{
    $number = array(10, 2, 10, 88, 7, 7, 3);
    sort($number);
    printArray($number);
    rsort($number);
    printArray($number);
}
function printArray($array)
{
    foreach ($array as $key => $value) {
        echo "{$key} => {$value}";
        if (is_array($value)) {
            //If $value is an array, print it as well!
            printArray($value);
        }
    }
}
Exemple #9
0
/**
 * Определить рекурсивную функцию - аналог функции print_r
 */
function printArray(array &$arr)
{
    if (key($arr) === null) {
        reset($arr);
        return 0;
    } else {
        echo '[' . key($arr) . ']' . ' => ' . current($arr) . '</br>';
        next($arr);
        printArray($arr);
    }
    reset($arr);
    return 0;
}
Exemple #10
0
function init()
{
    if (isset($_SESSION["user"])) {
        return;
    }
    $tk = C('tk');
    echo $tk;
    if (empty($tk)) {
        return false;
    }
    printArray($_SESSION["user"]);
    $user = new Users();
    $auth = $user->AuthAuto($tk);
}
Exemple #11
0
function printArray($array, $spaces = "")
{
    $retValue = "";
    if (is_array($array)) {
        $spaces = $spaces . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        $retValue = $retValue . "<br/>";
        foreach (array_keys($array) as $key) {
            $retValue = $retValue . $spaces . "<strong>" . $key . "</strong>" . printArray($array[$key], $spaces);
        }
        $spaces = substr($spaces, 0, -30);
    } else {
        $retValue = $retValue . " - " . $array . "<br/>";
    }
    return $retValue;
}
Exemple #12
0
 function show()
 {
     header('Content-Type: text/html; charset=utf-8');
     if ($this->context->state->zakaz->debug) {
         //if (TRUE) {
         //echo $this->getContent();
         echo '<style> .active {font-weight: bold;} </style>';
         $this->include_();
         echo "<hr/>" . printArray($this);
     } else {
         include TEMPL . '/header.html';
         $this->include_();
         include TEMPL . '/footer.html';
     }
 }
Exemple #13
0
/**
 * Echo the list of videos in the specified feed.
 *
 * @param Zend_Gdata_Books_BookFeed $feed The video feed
 * @return void
 */
function echoBookList($feed)
{
    print <<<HTML
    <table><tr><td id="resultcell">
    <div id="searchResults">
        <table class="volumeList"><tbody width="100%">
HTML;
    $flipflop = false;
    foreach ($feed as $entry) {
        $title = printArray($entry->getTitles());
        $volumeId = $entry->getVolumeId();
        if ($thumbnailLink = $entry->getThumbnailLink()) {
            $thumbnail = $thumbnailLink->href;
        } else {
            $thumbnail = null;
        }
        $preview = $entry->getPreviewLink()->href;
        $embeddability = $entry->getEmbeddability()->getValue();
        $creators = printArray($entry->getCreators());
        if (!empty($creators)) {
            $creators = "by " . $creators;
        }
        if ($embeddability == "http://schemas.google.com/books/2008#embeddable") {
            $preview_link = '<a href="javascript:load_viewport(\'' . $preview . '\',\'viewport\');">' . '<img class="previewbutton" src="http://code.google.com/' . 'apis/books/images/gbs_preview_button1.png" />' . '</a><br>';
        } else {
            $preview_link = '';
        }
        $thumbnail_img = !$thumbnail ? '' : '<a href="' . $preview . '"><img src="' . $thumbnail . '"/></a>';
        print <<<HTML
        <tr>
        <td><div class="thumbnail">
            {$thumbnail_img}
        </div></td>
        <td width="100%">
            <a href="{$preview}">{$title}</a><br>
            {$creators}<br>
            {$preview_link}
        </td></tr>
HTML;
    }
    print <<<HTML
    </table></div></td>
        <td width=50% id="previewcell"><div id="viewport"></div>&nbsp;
    </td></tr></table><br></body></html>
HTML;
}
Exemple #14
0
 /**
  * Suggest events to tag
  * @since Version 3.10.0
  * @param \Railpage\Images\Image $imageObject
  * @return array
  */
 public static function SuggestEvents(Image $imageObject)
 {
     if (!$imageObject->DateCaptured instanceof DateTime) {
         return;
     }
     $Database = (new AppCore())->getDatabaseConnection();
     $query = "SELECT COUNT(*) AS num FROM image_link WHERE namespace = ? AND image_id = ?";
     $params = [(new Event())->namespace, $imageObject->id];
     if ($Database->fetchOne($query, $params) > 0) {
         return;
     }
     $Events = new Events();
     $list = $Events->getEventsForDate($imageObject->DateCaptured);
     foreach ($list as $k => $row) {
         $Event = new Event($row['event_id']);
         printArray($Event->namespace);
         die;
         $list[$k]['url'] = sprintf("/services?method=railpage.image.tag&image_id=%d&object=%s&object_id=%d", $imageObject->id, "\\Railpage\\Events\\Event", $row['event_id']);
     }
     return $list;
 }
Exemple #15
0
function printArray($arr)
{
    if (!is_object($arr) and !is_array($arr)) {
        return $arr;
    } else {
        if (is_object($arr)) {
            $s = "Object: " . get_class($arr) . "<ul>";
            foreach (get_object_vars($arr) as $key => $value) {
                $s .= "<li>" . $key . " = " . printArray($value) . "</li>";
            }
            $s .= "</ul>";
            return $s;
        } else {
            $s = "Array: <ul>";
            foreach ($arr as $key => $value) {
                $s .= "<li>" . $key . " = " . printArray($value) . "</li>";
            }
            $s .= "</ul>";
            return $s;
        }
    }
}
Exemple #16
0
            echo printArray($listItem);
        }
        echo '<BR>End of list.<BR><BR>';
    }
    i5_jobLog_list_close($list);
}
if ($doAdoptAuthority) {
    echo h2('Adopt authority');
    // Note: only works if you've defined $user and $testPw, and created the user profile.
    echo "About to adopt authority to user {$user}<BR>";
    $start = microtime(true);
    $success = i5_adopt_authority($user, $testPw);
    $end = microtime(true);
    $elapsed = $end - $start;
    if (!$success) {
        echo "Error adopting authority: " . printArray(i5_error()) . "<BR>";
    } else {
        echo "Success adopting authority in {$elapsed} seconds<BR>";
        echo "About to check current user and other variables after adopting authority.<BR>";
        $cmdString = 'RTVJOBA';
        $input = array();
        $output = array('ccsid' => array('ccsid', 'dec(5 0)'), 'dftccsid' => array('defaultCcsid', 'dec(5 0)'), 'curuser' => 'currentUser', 'nbr' => 'jobNumber', 'job' => 'jobName', 'user' => 'jobUser', 'usrlibl' => 'userLibl');
        $commandSuccessful = i5_command($cmdString, $input, $output, $conn);
        if (function_exists('i5_output')) {
            extract(i5_output());
        }
        // i5_output() required if called in a function
        echo "Ran command {$cmdString}. Return: " . OkBad($commandSuccessful) . " with original job user '{$jobUser}', current user '{$currentUser}', CCSID '{$ccsid}', default CCSID '{$defaultCcsid}', job name '{$jobName}', job number '{$jobNumber}', with user liblist '{$userLibl}'.<BR><BR>";
    }
}
$ret = i5_close($conn);
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
require_once "_lib/php/auth.php";
printArray($_POST);
filterQryPost("id");
$id = hex2str($id);
filterQryPost("rid");
filterQryPost("val");
filterQryPost("edit");
filterQryPost("pri");
switch ($edit) {
    case 0:
        $gdbo->sql = "insert into _srv_descr (srv_descr_privateBit,id_srv,srv_descr,id_sys_user,srv_descr_du) values ({$pri},{$id},'{$val}',{$id_sys_user},current_timestamp)";
        $gdbo->dbTable = "_srv_descr";
        $gdbo->execQuery();
        break;
    case 1:
        $gdbo->sql = "update _srv_descr set srv_descr_privateBit={$pri},srv_descr_du=current_timestamp,id_srv={$id},srv_descr='{$val}',id_sys_user={$id_sys_user} where id_srv_descr={$rid}";
        $gdbo->dbTable = "_srv_descr";
Exemple #18
0
function toStr($bin)
{
    $simplifiedBin = array();
    $binIndex = 0;
    $msglen = sizeof($bin) / 7;
    for ($i = 0; $i < $msglen; $i++) {
        $temp = "";
        for ($j = 0; $j < 7; $j++) {
            $temp[] .= $bin[$binIndex];
            $binIndex++;
        }
        $temp = implode("", $temp);
        $simplifiedBin[] = $temp;
    }
    printArray($simplifiedBin);
    $char = array();
    for ($i = 0; $i < sizeof($simplifiedBin); $i++) {
        $char[$i] = chr(bindec($simplifiedBin[$i]));
    }
    printArray($char);
}
Exemple #19
0
function printobject($object)
{
    if (!is_object($object)) {
        print 'Not an object';
        return;
    }
    $class = get_class($object);
    print "Class: {$class}<br/>";
    $vars = get_object_vars($object);
    print 'Vars:';
    printArray($vars);
}
                </h4>
                <hr />
                <?php 
// Sorting was already completed within the 7.2 question.
foreach ($combinedArray as $element) {
    $element = strtoupper($element);
}
printArray($combinedArray);
echo "\n";
?>
            </div>
            <div>
                <h4>
                    7.4 Using functions (built-in and/or your own), generate a new 
                    array of dorms that are good, but not big.
                </h4>
                <hr />
                <?php 
//Getting the values within the $goodDorms but not in $bigDorms.
$goodNotBigDorms = array_diff($goodDorms, $bigDorms);
printArray($goodNotBigDorms);
echo "\n";
?>
            </div>
        </div>
        
        <script src="js/jquery-2.1.3.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
    </body>
</html>
Exemple #21
0
/**
 * Dump the contents of a PHP array and apply some pretty-printing
 */
function printArray($array, $indent, $nameIndent)
{
    foreach ($array as $name => $value) {
        echo $indent . $name . substr($nameIndent, 0, -strlen($name)) . " = ";
        if (is_array($value)) {
            echo "\n";
            $_maxValueLength = 0;
            foreach ($value as $string => $_ignoredValue) {
                if (strlen($string) > $_maxValueLength) {
                    $_maxValueLength = strlen($string);
                }
            }
            printArray($value, $indent . "  ", str_repeat(" ", $_maxValueLength));
        } else {
            if (is_int($value)) {
                echo $value;
            } else {
                if (is_string($value)) {
                    $_valueLength = strlen($value);
                    global $STRING_LIMIT;
                    // $STRING_LIMIT is a string due to configuration file interoperability concerns
                    if (!ctype_print($value) || intval($STRING_LIMIT) > 0 && $_valueLength > intval($STRING_LIMIT)) {
                        echo "String[{$_valueLength}]";
                    } else {
                        echo $value;
                    }
                } else {
                    echo gettype($value);
                }
            }
        }
        echo "\n";
    }
}
Exemple #22
0
<?php

//////////MUST INCLUDE TO WORK/////////
/*************************************/
//include config file
require_once "config/config.inc.php";
//include the dom class
require_once "classes/dom.class.php";
//include twitter api class
require_once "classes/twit.class.php";
//include the scrapper class
require_once 'functions/scrape.php';
//include the sentiment analysis class
require_once 'functions/sentiment.php';
/*************************************/
/********** MAIN PROGRAM *************/
$sentence = ' I enjoy@ going to~ ]\' the mall with:';
$tok = tokenizeSentence($sentence);
echo "Original Sentence: {$sentence}<br />";
printArray($tok);
Exemple #23
0
function RESTresourceDetail()
{
    $type = validatetype(processRESTarg(1, ARG_STRING));
    $deleted = processInputVar('deleted', ARG_NUMERIC, 0);
    if ($deleted != 0 && $deleted != 1) {
        $deleted = 0;
    }
    $name = processInputVar('name', ARG_STRING, '*');
    $tmp = processInputVar('prettyname', ARG_STRING, '*');
    if ($name == '*' && $tmp != '*') {
        $name = $tmp;
    }
    if (is_null($type)) {
        RESTresponse(404, "invalid resource type");
        return;
    }
    $subid = processRESTarg(2, ARG_NUMERIC, 0);
    if ($type == 'image') {
        $resources = getUserResources(array("imageAdmin", "imageCheckOut"), array('available'), 0, $deleted);
    } elseif ($type == 'computer') {
        $resources = getUserResources(array("computerAdmin"), array("administer"), 0, $deleted);
    } elseif ($type == 'config') {
        $resources = getUserResources(array("configAdmin"), array('available'), 0, $deleted);
    }
    # TODO
    #elseif ...
    if ($subid && !array_key_exists($subid, $resources[$type])) {
        RESTresponse(404, "specified resource does not exist");
        printArray($resources[$type]);
        return;
    }
    if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
        if (RESTdeleteResource($type, $subid)) {
            RESTresponse(204);
        } else {
            RESTresponse(404, "specified resource does not exist 2");
        }
        return;
    }
    if ($type == 'image') {
        $items = getImages($deleted, $subid);
        $data = array();
        foreach (array_keys($resources[$type]) as $id) {
            if ($name != '*' && !preg_match("/^{$name}\$/i", $items[$id]['prettyname'])) {
                continue;
            }
            if (array_key_exists($id, $items)) {
                $data[$id] = $items[$id];
            }
        }
    } elseif ($type == 'computer') {
        $data = getComputers(1, 0, $subid);
    } elseif ($type == 'config') {
        $cluster = processInputVar('cluster', ARG_NUMERIC, -1);
        $cfg = new Config();
        $items = $cfg->getData($cfg->defaultGetDataArgs);
        $data = array();
        foreach (array_keys($resources[$type]) as $id) {
            if ($name != '*' && !preg_match("/^{$name}\$/i", $items[$id]['name'])) {
                continue;
            }
            if (array_key_exists($id, $items)) {
                if ($cluster == -1 || $cluster == 0 && $items[$id]['configtype'] != 'Cluster' || $cluster == 1 && $items[$id]['configtype'] == 'Cluster') {
                    $data[$id] = $items[$id];
                }
            }
        }
    }
    #elseif ...
    if ($subid == 0) {
        sendREST(dataToJSON($data));
        return;
    }
    sendREST(dataToJSON($data[$subid], 1));
}
Exemple #24
0
$color = array(4 => 'white', 6 => 'green', 11 => 'red');
echo getFirstElement($color);
echo "<br/>7---------------------------------------------<br/>";
//test of 7
$x = array(1, 2, 3, 4, 5);
print_r(insert("\$", $x, 2));
echo "<br/>8---------------------------------------------<br/>";
//test of 8
$f = array("Sophia" => "31", "Jacob" => "41", "William" => "39", "Ramesh" => "40");
printArray(sortValueAscending($f));
echo "<br/>";
printArray(sortValueDescending($f));
echo "<br/>";
printArray(sortKeyDescending($f));
echo "<br/>";
printArray(sortKeyAscending($f));
echo "<br/>";
echo "<br/>9---------------------------------------------<br/>";
//test of 9
$temp = array(78, 60, 62, 68, 71, 68, 73, 85, 66, 64, 76, 63, 75, 76, 73, 68, 62, 73, 72, 65, 74, 62, 62, 65, 64, 68, 73, 75, 79, 73);
//average
echo "average of the temp= " . getAverage($temp);
//sevenLowest
print_r(getSevenLowest($temp));
//sevenHighest
print_r(getSevenHighest($temp));
echo "<br/>10---------------------------------------------<br/>";
//test of 10
$d = array(5, 2, 3, 4, 1, 0);
convertArrayToBead($d);
echo "<br/>11---------------------------------------------<br/>";
Exemple #25
0
 /** 
  * Send this message
  * @since Version 3.3
  * @version 3.3
  * @return boolean
  */
 public function send()
 {
     $this->validate();
     $data = array("privmsgs_type" => PRIVMSGS_UNREAD_MAIL, "privmsgs_subject" => $this->subject, "privmsgs_from_userid" => $this->from_user_id, "privmsgs_to_userid" => $this->to_user_id, "privmsgs_date" => time(), "privmsgs_ip" => encode_ip($_SERVER['REMOTE_ADDR']), "privmsgs_enable_bbcode" => $this->enable_bbcode, "privmsgs_enable_html" => $this->enable_html, "privmsgs_enable_smilies" => $this->enable_smilies, "privmsgs_attach_sig" => $this->enable_signature, "object_id" => $this->object_id);
     if ($this->db->insert("nuke_bbprivmsgs", $data)) {
         $pm_id = $this->db->lastInsertId();
         $data = array("privmsgs_text_id" => $pm_id, "privmsgs_bbcode_uid" => $this->bbcode_uid, "privmsgs_text" => prepare_submit($this->body));
         $rs = $this->db->insert("nuke_bbprivmsgs_text", $data);
     }
     if ($rs) {
         // Send an email to the recipient if their settings say so
         try {
             $ThisUser = new User($this->to_user_id);
             if ($ThisUser->notify_privmsg == 1) {
                 try {
                     // Send the confirmation email
                     //require_once('vendor/pear-pear.swiftmailer.org/Swift/lib/swift_init.php');
                     global $smarty, $User;
                     $smarty->assign("server_addr", "www.railpage.com.au");
                     $smarty->assign("message_id", $pm_id);
                     $smarty->assign("pm_from_username", $User->username);
                     $smarty->assign("userdata_username", $ThisUser->username);
                     $html = $smarty->fetch(dirname(dirname(dirname(dirname(__DIR__)))) . DS . "content" . DS . "email_pm.tpl");
                     $crlf = "\n";
                     $message = Swift_Message::newInstance()->setSubject("New private message on Railpage")->setFrom(array("*****@*****.**" => "Railpage"))->setTo(array($ThisUser->contact_email => $ThisUser->username))->setBody($html, 'text/html');
                     // Mail transport
                     $transport = Swift_SmtpTransport::newInstance($this->Config->SMTP->host, $this->Config->SMTP->port, $this->Config->SMTP->TLS = true ? "tls" : NULL)->setUsername($this->Config->SMTP->username)->setPassword($this->Config->SMTP->password);
                     $mailer = Swift_Mailer::newInstance($transport);
                     $result = $mailer->send($message);
                 } catch (Exception $e) {
                     printArray($e->getMessage());
                     die;
                 }
             }
         } catch (Exception $e) {
             echo $e->getMessage();
         }
         return true;
     } else {
         throw new Exception($this->db->error);
         return false;
     }
 }
Exemple #26
0
            }
        }
    }
    echo "limit before " . $limit_before;
    echo "<hr>";
    echo "limit after " . $limit_after;
    echo "<hr>";
    $query = $query_before . $query_union . $query_after;
}
echo $query;
echo "<hr>";
$stmtGet = $conn->prepare($query);
$stmtGet->bindParam(':id_content', $id_content);
$stmtGet->bindParam(':id_vendor', $id_vendor);
if ($countAll > $total_get && $countBefore > 0) {
    $stmtGet->bindParam(':limit_before', $limit_before, PDO::PARAM_INT);
}
if ($countAll > $total_get && $countAfter > 0) {
    $stmtGet->bindParam(':limit_after', $limit_after, PDO::PARAM_INT);
}
$stmtGet->execute();
$result = $stmtGet->fetchAll(PDO::FETCH_ASSOC);
//var_dump($result);
printArray($result);
function printArray($array)
{
    foreach ($array as $value) {
        var_dump($value);
        echo "<br>";
    }
}
Exemple #27
0
 function printSQLResult($result, $dataType = "json", $params = array(), $msg = "", $autoLing = true, $maxTextLength = 0)
 {
     if ($result == null || is_bool($result)) {
         $responce->MSG = $msg;
         header("Content-type: application/json");
         echo json_encode($responce);
         return;
     }
     if ($dataType == "json") {
         if (isset($params["page"])) {
             $responce->page = intval($params["page"]);
         }
         if (isset($params["total"])) {
             $responce->total = intval($params["total"]);
         }
         if (isset($params["records"])) {
             $responce->records = intval($params["records"]);
         }
         //if(isset($params["limit"])) $responce->limit =intval($params["limit"]);
         $i = 0;
         //while($row = mysql_fetch_array($result,MYSQL_NUM)) {//MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH mysql_fetch_array
         while ($row = _db()->fetchData($result, "array", MYSQL_NUM)) {
             //MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH
             $responce->rows[$i]['id'] = $row[0];
             $responce->rows[$i]['cell'] = array();
             $c = 0;
             foreach ($row as $a => $b) {
                 //if(is_numeric($a)) continue; if :: MYSQL_BOTH
                 $type = mysql_field_type($result, $c);
                 if (strlen($b) > 0) {
                     if ($type == "date") {
                         $df = str_replace("yy", "Y", getConfig("DATE_FORMAT"));
                         $b = _date($b, "Y/m/d", $df);
                         $bT = _date("0000-00-00", "Y/m/d", $df);
                         if ($b == $bT) {
                             $b = "";
                         }
                     } elseif ($type == "time") {
                         $dt = str_replace("m", "i", getConfig("TIME_FORMAT"));
                         $b = _time($b);
                         $bT = _time("00:00:00", "H:i:s", $dt);
                         if ($b == $bT) {
                             $b = "";
                         }
                     } elseif ($type == "datetime") {
                         $df = str_replace("yy", "Y", getConfig("DATE_FORMAT"));
                         $dt = str_replace("m", "i", getConfig("TIME_FORMAT"));
                         $ss = explode(" ", $b);
                         $s0 = _date($ss[0], "Y/m/d", $df);
                         if (isset($ss[1])) {
                             $s1 = _time($ss[1]);
                         } else {
                             $s1 = "";
                         }
                         $b = "{$s0} {$s1}";
                         $bT = _date("0000-00-00", "Y/m/d", $df);
                         $bT .= " " . _time("00:00:00", "H:i:s", $dt);
                         if ($b == $bT) {
                             $b = "";
                         }
                     } elseif ($type == "blob") {
                         if ($maxTextLength > 0 && strlen($b) > $maxTextLength) {
                             $b = substr($b, 0, 200) . "...";
                         } else {
                             $b = stripslashes($b);
                         }
                         $b = htmlentities($b);
                         //str_replace('"',"\\'",$b));
                     } else {
                         if ($autoLing) {
                             $b = _ling($b, true);
                         }
                     }
                 }
                 array_push($responce->rows[$i]['cell'], $b);
                 $c++;
             }
             $i++;
         }
         $responce->MSG = $msg;
         header("Content-type: application/json");
         echo json_encode($responce);
     } elseif ($dataType == "xml") {
         if (stristr($GLOBALS['LOGIKS']["_SERVER"]["HTTP_ACCEPT"], "application/xhtml+xml")) {
             header("Content-type: application/xhtml+xml;charset=utf-8");
         } else {
             header("Content-type: text/xml;charset=utf-8");
         }
         $et = ">";
         $s = "<?xml version='1.0' encoding='utf-8'?{$et}\n";
         $s .= "<rows>";
         $s .= "<page>" . $page . "</page>";
         $s .= "<total>" . $total_pages . "</total>";
         $s .= "<records>" . $count . "</records>";
         //while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
         while ($row = _db()->fetchData($result)) {
             $s .= "<row id='" . $row[id] . "'>";
             $i = 0;
             foreach ($row as $a => $b) {
                 $type = mysql_field_type($result, $i);
                 $length = mysql_field_len($result, $i);
                 if ($type == "date") {
                     if (strlen($b) > 0) {
                         $df = str_replace("yy", "Y", getConfig("DATE_FORMAT"));
                         $b = _date($b, "Y/m/d", $df);
                         $bT = _date("0000-00-00", "Y/m/d", $df);
                         if ($b == $bT) {
                             $b = "";
                         }
                     }
                     if (strlen($b) > 0) {
                         $s .= "<cell><![CDATA[" . $b . "]]></cell>";
                     }
                 } elseif ($type == "string" && $length > 5) {
                     if ($autoLing) {
                         $b = _ling($b);
                     }
                     if (strlen($b) > 0) {
                         $s .= "<cell><![CDATA[" . $b . "]]></cell>";
                     } else {
                         $s .= "<cell></cell>";
                     }
                 } else {
                     if ($autoLing) {
                         $b = _ling($b);
                     }
                     $s .= "<cell>" . $b . "</cell>";
                 }
                 $i++;
             }
             $s .= "</row>";
         }
         $s .= "</rows>";
         echo $s;
     } elseif ($dataType == "html") {
         if (isset($params["withheader"])) {
             $withheader = $params["withheader"];
         } else {
             $withheader = "false";
         }
         if (isset($params["multiselect"])) {
             $multiselect = $params["multiselect"];
         } else {
             $multiselect = "false";
         }
         if ($withheader == "true" || $withheader == 1) {
             $withheader = true;
         } else {
             $withheader = false;
         }
         if ($multiselect == "true" || $multiselect == 1) {
             $multiselect = true;
         } else {
             $multiselect = false;
         }
         $header = "";
         $body = "";
         if ($withheader) {
             $header .= "<thead>";
             $header .= "<tr class='tblheader'>";
             if ($multiselect) {
                 $header .= "<td width=40px> -- </td>";
             }
             while ($i < mysql_num_fields($result)) {
                 $meta = mysql_fetch_field($result, $i);
                 if ($meta) {
                     $t = str_replace("_", " ", $meta->name);
                     $t = ucwords($t);
                     $header .= "<td align=center>{$t}</td>";
                 } else {
                     $header .= "<td>&nbsp;</td>";
                 }
                 $i++;
             }
             $header .= "</tr>";
             $header .= "</thead>";
         }
         $body .= "<tbody>";
         //while($row = mysql_fetch_array($result,MYSQL_NUM)) {//MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH
         while ($row = _db()->fetchData($result, "array", MYSQL_NUM)) {
             //MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH
             $body .= "<tr id='ROW_" . $row[0] . "'>";
             if ($multiselect) {
                 $body .= "<td align=center><input type='checkbox' rel='" . $row[0] . "' row='ROW_" . $row[0] . "' /></td>";
             }
             $c = 0;
             foreach ($row as $a => $b) {
                 $meta = mysql_fetch_field($result, $c);
                 $type = $meta->type;
                 $name = $meta->name;
                 $tbl = $meta->table;
                 if ($type == "date") {
                     if (strlen($b) > 0) {
                         $df = str_replace("yy", "Y", getConfig("DATE_FORMAT"));
                         $b = _date($b, "Y/m/d", $df);
                         $bT = _date("0000-00-00", "Y/m/d", $df);
                         if ($b == $bT) {
                             $b = "";
                         }
                     }
                 } elseif ($autoLing) {
                     $b = _ling($b);
                 }
                 if ($meta->primary_key) {
                     $body .= "<td col='{$name}' class='serial_col'>{$b}</td>";
                 } else {
                     if ($type == "date") {
                         if ($b == "NA") {
                             $body .= "<td col='{$name}' class='calerroricon' >&nbsp;</td>";
                         } else {
                             $body .= "<td col='{$name}' align=center>{$b}</td>";
                         }
                     } elseif ($type == "int" || $type == "float" || $type == "double") {
                         $body .= "<td col='{$name}' align=right>{$b}</td>";
                     } elseif ($type == "bool" || $type == "boolean") {
                         $body .= "<td col='{$name}' align=center>{$b}</td>";
                     } elseif ($type == "blob") {
                         $body .= "<td col='{$name}' class='blobicon' onclick=\"viewBlobData('{$name}','{$tbl}')\">&nbsp;</td>";
                     } else {
                         $body .= "<td col='{$name}'>{$b}</td>";
                     }
                 }
                 $c++;
             }
             $body .= "</tr>";
         }
         $body .= "</tbody>";
         echo "<table width=100%>{$header} {$body}</table>";
     } else {
         printArray($data);
     }
 }
/**
 * @param $array
 */
function printArray($array, $otherLemmas, $n, &$string, &$totalToTranslate)
{
    foreach ($array as $key => $value) {
        $tab = $n * 1;
        if (is_array($value)) {
            $string = $string . str_repeat("\t", $tab) . "\"" . $key . "\" => array(\n";
            printArray($value, $otherLemmas[$key], $n + 1, $string, $totalToTranslate);
            $string = $string . str_repeat("\t", $tab) . "),\n";
        } else {
            if ($value == $otherLemmas[$key]) {
                $string = $string . str_repeat("\t", $tab) . "\"" . $key . "\" => \"" . $value . "\",\n";
            } else {
                $totalToTranslate = $totalToTranslate . " " . $otherLemmas[$key];
                $string = $string . str_repeat("\t", $tab) . "\"" . $key . "\" => \"" . $value . "\", //" . $otherLemmas[$key] . "\n";
            }
        }
    }
}
Exemple #29
0
 /**
  * Store jobs in the database
  * @since Version 3.8.7
  * @return $this
  */
 public function store()
 {
     foreach ($this->jobs as $job) {
         $Job = new Job();
         $Job->title = $job['title'];
         $Job->Organisation = $this->Organisation;
         $Job->desc = $job['description'];
         $Job->Open = $job['date']['open'];
         $Job->expiry = $job['date']['close'];
         $Job->salary = $job['salary'];
         $Job->duration = implode(", ", $job['type']);
         $Job->Location = new Location($job['location']['name']);
         $Job->Classification = new Classification(strval($job['category']));
         $Job->reference_id = $job['id'];
         $Job->url = new Url();
         $Job->url->apply = strval($job['url']['apply']);
         try {
             $Job->commit();
         } catch (Exception $e) {
             printArray($e->getMessage());
             die;
         }
     }
 }
function checkSuccess($set, $colRules, $rowCount, $columnCount)
{
    $output = array();
    $match = 0;
    for ($i = 0, $index = 0; $i < $columnCount; $i++) {
        $output[$index] = 0;
        for ($j = 0; $j < $rowCount; $j++) {
            if ($set[$j][$i] == "1") {
                $output[$index]++;
            } else {
                if ($output[$index] != 0) {
                    $index++;
                    $output[$index] = 0;
                }
            }
        }
        $valid = doesRulesMatch($output, $colRules[$i]);
        if (!$valid) {
            return false;
        } else {
            $match++;
            $output = array();
            $index = 0;
        }
        if ($match == $columnCount) {
            printArray($set, $rowCount, $columnCount);
            return true;
        }
    }
}