function getNodes($parentId) { global $mysql; $arrTemp = array(); $res = $mysql->query("select id,name,parentid from coursecategory where parentid=" . $parentId . " order by id"); $num = $mysql->num_rows($res); while ($arr = $mysql->fetch_array($res)) { $arr["open"] = true; $arrTemp["children"][] = $arr; $res2 = $mysql->query("select id,name,parentid from coursecategory where parentid=" . $arr["id"] . " order by id"); $num2 = $mysql->num_rows($res2); echo $num2 . "aa "; if ($num2 > 0) { getNodes($arr["id"]); } } return $arrTemp; }
\t\t</form> \t</div> FORM; if (empty($answer)) { //Get the user level from database //from the user's current level $userLevel = getUserCurrentLevel(); //get the question for the userlevel $questionArray = getQuestion($userLevel); //$CONTENT = $questionArray['question']; header("Location: ./{$questionArray['header']}"); } else { //Check if the user has access to the particular level //$level = $request $userCurrentLevel = getUserCurrentLevel(); $requestLevelArray = getNodes($answer); //might be correct answer / trying to access a different level / the same level if ($userCurrentLevel == $requestLevelArray['from']) { //then user entered a correct answer $questionArray = getQuestion($requestLevelArray['to']); $CONTENT = $questionArray['question']; //update the database with the current level updateUserLevel($userCurrentLevel, $requestLevelArray['to']); } else { if ($userCurrentLevel == $requestLevelArray['to']) { //then user is trying to access the same level //$CONTENT = "You are still here"; //from the user's current level $userLevel = getUserCurrentLevel(); //get the question for the userlevel $questionArray = getQuestion($userLevel);
<?php include 'pass.php'; define("DB_host", $host); define("DB_name", $dbname); define("DB_username", $username); define("DB_pass", $pass); define("DB_port", $port); if (isset($_POST['func'])) { if ($_POST['func'] == 'getNodes') { getNodes(); } else { if ($_POST['func'] == 'getEdges') { getEdges(); } } } function connect() { return pg_connect("host=" . DB_host . " dbname=" . DB_name . " user="******" password="******" port=" . DB_port) or die('Could not connect: ' . pg_last_error()); } function close($result, $dbconn) { pg_free_result($result); pg_close(); } function getNodes() { $conn = connect(); $query = 'SELECT * FROM node'; $result = pg_query($query) or die('Query failed: ' . pg_last_error());
function printnav($PID, $LID) { $nodes = getNodes($LID, $PID); $numN = count($nodes) / 3; echo "<div id='Nav'>"; echo "<div>"; for ($x = 0; $x < $numN; $x = $x + 3) { $NID = $nodes[$x + 2]; $activities = getActivities($NID, $PID); $numA = count($activities) / 3; echo "<p title='" . $nodes[$x + 1] . "' class='ActionP'><b>{$nodes[$x]}</b></p>"; for ($y = 0; $y < $numA; $y = $y + 3) { $AID = $activities[$y + 2]; $desc = $activities[$y + 1]; $name = $activities[$y]; echo "<p title='{$desc}' class='InvP'><form action='action.php#invtab' method='post'>\n\t\t\t\t\t<input type='text' value='ACTION' name='mode' hidden>\n\t\t\t\t\t<input type='text' value='{$AID}' name='activity' hidden>\n\t\t\t\t\t<input type='submit' value='{$name}' title=''> </form></p>"; } } echo "</div>"; echo "<div>"; echo "<p><b>Travel</b></p>"; $paths = getRoutes($LID); $pathsN = count($paths); for ($x = 0; $x < $pathsN; $x = $x + 4) { $desc = $paths[$x + 2]; $name = $paths[$x + 1]; $idkey = $paths[$x]; echo "<p title='{$desc}' class='InvP'><form action='action.php#invtab' method='post'>\n\t\t\t<input type='text' value='MOVE' name='mode' hidden>\n\t\t\t<input type='text' value='{$idkey}' name='route' hidden>\n\t\t\t<input type='submit' value='{$name}'>\n\t\t\t</form></p>"; } echo "</div>"; echo "</div>"; }
} /* * Controller */ var Controller = function(){ return this; }; Controller.prototype.loadView = function(chart,iter_nodes,iter_links){ //Get data from database data_nodes = <?php getNodes($db, $nodes_array, $iteration, $file_id); ?> ; data_links = <?php getLinks($db, $links_array, $iteration); ?> ; file_id = <?php echo $file_id; ?> ; var model = new ModelData(data_nodes,data_links); view = new ViewData(model);
require_once 'Helper/PHPExcel/IOFactory.php'; $relations = array(); $definitions = array(); $additionalData = array(); $file = __DIR__ . '/data/US Data v1.1.xlsx'; if (!file_exists($file)) { exit("File ' . {$file} . ' first not found.\n"); } $objPHPExcel = PHPExcel_IOFactory::load($file); $relations = getSheetData($objPHPExcel, 0); $definitions = getSheetData($objPHPExcel, 1); $additionalData = getSheetData($objPHPExcel, 2); $returns = array(); if (count($relations) > 0 && count($definitions) > 0 && count($additionalData)) { $groups = getGroups($relations); $nodes = getNodes($relations, $definitions, $groups); /*echo '<pre>'; var_dump($nodes); echo '</pre>'; die;*/ $links = getLinks($relations, $nodes); $additionalNodesData = getAdditionalNodesData($additionalData, $nodes); $returns = array('nodes' => $nodes, 'links' => $links, 'groups' => $groups, 'additionalNodesData' => $additionalNodesData); echo json_encode($returns); } // helper functions function getSheetData($objPHPExcel, $number = 0) { $result = array(); $objPHPExcel->setActiveSheetIndex($number); $data = $objPHPExcel->getActiveSheet()->toArray();
<?php include "connection_openDB.php"; include "connection_closeDB.php"; include "getData.php"; $iterval = $_POST['itervalue']; $file_id = $_POST['file_id']; $db = connectDB(); createTransaction_file($db, $file_id); getNodes($db, $nodes_array, $iterval, $file_id); closeDB($db);
function getNodes($node, $depth, &$children, $parentid) { global $xml; foreach ($node as $n) { //workaround if ($n['name'] == "EnvironmentAmbientLight") { continue; } // Objekte auslesen $child = new stdClass(); $child->name = (string) $n['name']; $child->id = (string) $n['id']; $child->layer = (string) $n['layer']; $child->unit = (string) $xml->asset->unit['name']; $child->upAxis = (string) $xml->asset->up_axis; $child->parentid = $parentid; $child->children = []; // Matrix $m = preg_split('/\\s+/', $n->matrix); $child->matrix = [+$m[0], +$m[1], +$m[2], +$m[3], +$m[4], +$m[5], +$m[6], +$m[7], +$m[8], +$m[9], +$m[10], +$m[11], +$m[12], +$m[13], +$m[14], +$m[15]]; if (isset($n->node[0]) && !isset($n->node[0]['id'])) { $m = preg_split('/\\s+/', $n->node[0]->matrix); $pivotMatrix = [+$m[0], +$m[1], +$m[2], +$m[3], +$m[4], +$m[5], +$m[6], +$m[7], +$m[8], +$m[9], +$m[10], +$m[11], +$m[12], +$m[13], +$m[14], +$m[15]]; $child->matrix = multiplyMatrices($pivotMatrix, $child->matrix); append_simplexml($n, $n->node[0]); unset($n->node[0]); // if($child->name == "dach_fluegel_001") { // var_dump($pivotMatrix); // var_dump($child->matrix); // } } // Geometry $child->geometryUrl = ''; $child->material = null; if (isset($n->instance_geometry)) { $child->geometryUrl = substr((string) $n->instance_geometry['url'], 1); $child->type = 'object'; // material if (isset($n->instance_geometry->bind_material->technique_common->instance_material)) { $child->material = new stdClass(); $child->material->id = substr((string) $n->instance_geometry->bind_material->technique_common->instance_material['target'], 1); $mat = $xml->library_materials->xpath('./material[@id="' . $child->material->id . '"]')[0]; $child->material->name = (string) $mat['name']; $effect = $xml->library_effects->xpath('./effect[@id="' . substr((string) $mat->instance_effect['url'], 1) . '"]')[0]; if (isset($effect->profile_COMMON->technique->phong)) { $color = $effect->profile_COMMON->technique->phong->diffuse->color; } elseif (isset($effect->profile_COMMON->technique->lambert)) { $color = $effect->profile_COMMON->technique->lambert->diffuse->color; } elseif (isset($effect->profile_COMMON->technique->blinn)) { $color = $effect->profile_COMMON->technique->blinn->diffuse->color; } $color = preg_split('/\\s+/', $color); $child->material->color = [+$color[0], +$color[1], +$color[2], +$color[3]]; } } elseif (isset($n->instance_camera)) { $child->type = 'camera'; continue; } elseif (isset($n->instance_light)) { $child->type = 'light'; continue; } else { $child->type = 'group'; } if (!empty($child->geometryUrl)) { convertGeometry($child->geometryUrl); } getNodes($n->node, $depth + 1, $child->children, $child->id); array_push($children, $child); } }
function showSubAlbum($root = 1) { global $db, $prefix, $moduleName, $iConfig, $pag, $ofsppg, $ofsbgn; $root = intval($root); $showDetails = intval($iConfig['show_details']); $showColumns = intval($iConfig['show_columns']); $thumbsPath = $iConfig['thumbs_path']; $thumbsRealPath = iPath($thumbsPath); $thumbsFormat = strtolower($iConfig['thumbs_format']); $albumCounter = 0; //echo '<table class="show-child" cellspacing="5" cellpadding="5"><tr>' . PHP_EOL; echo '<ul class="thumbnails">' . PHP_EOL; $column = 1; $srow = 1; $node = getNodes($root); $sql = 'SELECT node.*, (COUNT(parent.album_id) - (sub_tree.depth + 1)) AS depth FROM ' . $prefix . '_igallery_albums AS node, ' . $prefix . '_igallery_albums AS parent, ' . $prefix . '_igallery_albums AS sub_parent, ( SELECT node.*, (COUNT(parent.album_id) - 1) AS depth FROM ' . $prefix . '_igallery_albums AS node, ' . $prefix . '_igallery_albums AS parent WHERE node.album_left BETWEEN parent.album_left AND parent.album_right AND node.album_id = \'' . $node['id'] . '\' GROUP BY node.album_id ORDER BY node.album_left ) AS sub_tree WHERE node.album_left BETWEEN parent.album_left AND parent.album_right AND node.album_left BETWEEN sub_parent.album_left AND sub_parent.album_right AND sub_parent.album_id = sub_tree.album_id GROUP BY node.album_id HAVING depth = 1 ORDER BY node.album_left;'; $result = $db->sql_query($sql); while ($album = $db->sql_fetchrow($result)) { $albumCounter++; $catId = $album['album_id']; $folderName = $album['album_folder']; $cover = $album['album_cover']; $title = $album['album_title']; $description = $album['album_desc']; $albumParent = $album['album_id']; $what = getAlbumInfo($catId); $latestDate = $what[0]; $totalPics = $what[1]; if (!empty($cover)) { $info = pathinfo($cover); $rawCover = str_replace($info['extension'], '', $cover); } if (!empty($rawCover)) { $pictureId = $db->sql_fetchrow($db->sql_query('SELECT picture_id FROM ' . $prefix . '_igallery_pictures WHERE picture_file=\'' . $cover . '\' AND album_id=\'' . $albumId . '\' LIMIT 0,1')); $coverSrc = 'modules.php?name=' . $moduleName . '&op=getThumb&pictureid=' . $pictureId['picture_id']; } else { $catListIds = getSubAlbumIds($catId); if (!empty($catListIds) && $catListIds !== ',') { $catListIds = $catId . ', ' . $catListIds; $sql = 'album_id IN (' . $catListIds . ')'; } else { $sql = 'album_id=' . $catId . ''; } $data = $db->sql_fetchrow($db->sql_query('SELECT picture_id FROM ' . $prefix . '_igallery_pictures WHERE ' . $sql . ' LIMIT 0,1')); $pictureId = $data['picture_id']; $coverSrc = 'modules.php?name=' . $moduleName . '&op=getThumb&pictureid=' . $pictureId; } //echo '<td class="sub-album">' . PHP_EOL; //echo '<div class="thumb-target">' . PHP_EOL; echo '<li class="span3">' . PHP_EOL; echo '<div class="thumbnail">' . PHP_EOL; echo ' <a href="modules.php?name=' . $moduleName . '&op=showAlbum&albumid=' . $catId . '"><img class="sub-album" src="' . $coverSrc . '" alt="' . $title . '" /></a>' . PHP_EOL; //echo ' <div class="tooltip_description">' . PHP_EOL; //echo ' <p>' . PHP_EOL; //echo ' <span class="title">'.$title .'</span>'; echo ' <div class="caption">' . PHP_EOL; echo ' <h4>' . $title . '</h4>'; //echo showNewEmblem($latestDate); //echo '<br />' . PHP_EOL; if ($description) { echo ' <p>' . $description . '</p>' . PHP_EOL; } echo ' <span class="label label-info">' . $totalPics . ' ' . _IG_TOTALPICS . '</span>' . PHP_EOL; echo ' </div>'; echo '</div>'; echo '</li>' . PHP_EOL; /*if (($column%$showColumns)==0) { //echo '<div style="clear:left;"></div>' . PHP_EOL; echo '</tr><tr>' . PHP_EOL; $srow++; }*/ $column++; } //echo '<div style="clear:left;"></div></div>'; //echo '<td></td></tr></table>' . PHP_EOL; echo '</ul>' . PHP_EOL; //$totalItems = $db->sql_numrows($db->sql_query('SELECT album_id FROM '.$prefix .'_igallery_albums WHERE album_parent=0 AND album_active=1 ;')); //paginationSystem($ofsbgn, $ofsppg, $totalItems); //if ($srow!==1 || $column!==1) echo '<hr />'; }