function getAPIListWhere($srcType, $authorCol = "creator,author") { $whr = ""; if (session_check(false)) { if (checkUserRoles($srcType, "Allow Moderation Of All " . toTitle($srcType)) || $_SESSION['SESS_PRIVILEGE_ID'] <= 3) { } else { $authorCol = explode(",", $authorCol); foreach ($authorCol as $a => $b) { $authorCol[$a] = "{$b} LIKE '%[{$_SESSION['SESS_USER_ID']}]'"; } $whr .= " AND (" . implode(" OR ", $authorCol) . " OR approved='true')"; } } else { $whr .= " AND approved='true'"; } return $whr; }
function printContent($refID, $category = "", $silent = false, $autoCreate = false) { $sql = "SELECT title,category,text,blocked FROM " . _dbtable("contents") . " WHERE (ID='{$refID}' OR reflink='{$refID}')"; if (strlen($category) > 0) { $sql .= " AND category='{$category}'"; } $sql .= " AND (site='*' OR site='" . SITENAME . "')"; $rs = _dbQuery($sql); $data = _dbData($rs); _dbFree($rs); $text = ""; if (count($data) > 0) { if ($data[0]['blocked'] == "false") { $text = $data[0]['text']; } else { if (!$silent) { echo "<div class=divError>"; dispErrMessage("Page Content Currently Not Available For <i class='text2'>{$refID}</i><br/><br/>Visit Us Again ...", "Not Available!", "400", "notfound/file.png"); echo "</div>"; } } if (strlen($text) > 0) { echo $text; return $data[0]['title']; } else { if (!$silent) { echo "<div class=divError>"; dispErrMessage("Page Content Not Found For <i class='text2'>{$refID}</i>", "Content Not Found OR Missing !", "404", "notfound/file.png"); echo "</div>"; } return false; } } elseif ($autoCreate) { $date = date("Y-m-d"); $cols = "id,reflink,title,category,text,blocked,site,userid,doc,doe"; $vals = "0,'{$refID}','" . toTitle($refID) . "','{$category}','','false','" . SITENAME . "','auto','{$date}','{$date}'"; $sql = "INSERT INTO " . _dbtable("contents") . " ({$cols}) VALUES ({$vals})"; _dbQuery($sql); return true; } return false; }
function getDefaultParams($userID = "", $pwd = "", $privilegeID = "", $accessID = "") { $params = array("guid" => "c21f969b5f03d33d43e04f8f136e7682", "userid" => $userID, "pwd" => getPWDHash($pwd), "privilegeid" => $privilegeID, "accessid" => $accessID, "name" => toTitle($userID), "dob" => "", "gender" => "male", "email" => "", "mobile" => "", "address" => "", "region" => "", "country" => "", "zipcode" => "", "geolocation" => "", "geoip" => "", "blocked" => "false", "expires" => "", "remarks" => "", "vcode" => "", "mauth" => "", "refid" => "", "privacy" => "protected", "avatar_type" => "photoid", "avatar" => ""); return $params; }
function arrayToHTML($arr = array(), $format = "table", $classes = "") { $out = ""; //printArray($arr); switch ($format) { case 'list': $out = "<ul class='{$classes}'>"; foreach ($arr as $a => $v) { $a = toTitle($a); if (is_array($v)) { $out .= "<li>{$a} : </li>"; $out .= arrayToHTML($v, $format); } else { $out .= "<li>{$a} : {$v}</li>"; } } $out .= "</ul>"; break; case 'table': default: $out = "<table class='{$classes}' width=100%>"; foreach ($arr as $a => $v) { $a = toTitle($a); if (is_array($v)) { $out .= '<tr><td colspan=10>' . arrayToHTML($v) . '</td></tr>'; } else { $out .= "<tr><td>{$a}</td><td>{$v}</td></tr>"; } } $out .= '</table>'; break; } return $out; }
} if (count($pageArr) > 1) { $title = end($pageArr); $title = explode("-", $title); $title = implode(" ", $title); //$titleArr=explode("-",$title); //$category=end($titleArr); $apiCategoryList = getlist($title); } ?> <div class="apiContent container-fluid"> <div class="row"> <div class="col-lg-12"> <h1 class="page-header"> <small><?php echo toTitle($category); ?> APIs</small> </h1> <div class="navigation"> <ul class="list-group linkList"> <?php if (count($apiCategoryList) > 0) { foreach ($apiCategoryList as $api) { $apiLink = _link("api/") . $api['category'] . "/" . urlencode($api['subcategory'] . "." . $api['title']) . "-" . $api['id']; ?> <li class='list-group-item'> <a href="<?php echo $apiLink; ?> "> <?php echo $api['title'];
setCookie("PAGEPATH", $_REQUEST['page'], time() + 86400 * 30, "/"); } if (count($pages) > 0 && $pages[0] != 'home') { foreach ($pages as $n => $p) { if (strlen($p) <= 0) { continue; } $pth .= "/{$p}"; $t = toTitle(_ling("MENU-" . $p)); if (strtoupper($t) == strtoupper("MENU-" . $p)) { $t = explode("-", $p); if (is_numeric($t[count($t) - 1])) { $t = array_splice($t, 0, count($t) - 1); $t = toTitle(implode("_", $t)); } else { $t = toTitle($p); } } if ($p == $pages[$max]) { echo "<a class='active'>{$t}</a>"; } else { echo "<a href='{$pth}'>{$t}</a>"; } } } ?> </ol> <ol class='footlink' style='float:right;margin-right:10px;'> <a href='<?php echo _link("about/license"); ?>
function createForm($data, $layoutType = "table", $printTopLevels = true, $middleSeparator = "::", $withHelp = false, $params = array("border" => "0", "cellspacing" => "0", "cellpadding" => "0", "width" => "100%", "height" => "100%", "style" => "", "class" => "formTable")) { $s = ""; if ($layoutType != "table" && $layoutType != "list") { $layoutType = "table"; } if ($layoutType == "table") { if ($printTopLevels) { $s .= "<table " . parseTagParams($params) . ">"; } if (is_array($data)) { $i = 0; foreach ($data as $nm => $d) { if ($i % 2 == 0) { $tr_class = "rowEven"; } else { $tr_class = "rowOdd"; } if (is_array($d)) { $fs = "<tr class='{$tr_class}'><th width=150px align=left class='columnName'>%s</th><td width=20px align=center class='columnEqual'>{$middleSeparator}</td><td class='columnInput'>%s</td><td class='columnHelp' width=40px align=left>%s</td></tr>"; if (!$withHelp) { $fs = "<tr class='{$tr_class}'><th width=150px align=left class='columnName'>%s</th><td width=20px align=center class='columnEqual'>{$middleSeparator}</td><td class='columnInput'>%s</td></tr>"; } $title = ""; $help = ""; $fld = parseFieldParams($d); if (isset($d['title'])) { $title = $d['title']; } else { $title = toTitle($nm); } if (isset($d['help'])) { $help = parseFieldHelp($d['help']); } if ($withHelp) { $s .= sprintf($fs, $title, $fld, $help); } else { $s .= sprintf($fs, $title, $fld); } } else { if ($d == "" || $d == null) { $s .= "<tr class='{$tr_class} blankrow'><th align=left colspan=10></th></tr>"; } elseif ($d == "hbar") { $s .= "<tr class='{$tr_class} hbar'><th align=left colspan=10><hr/></th></tr>"; } else { $s .= "<tr class='subheader'><th align=left colspan=10>{$d}</th></tr>"; } } $i++; } } if ($printTopLevels) { $s .= "</table>"; } } elseif ($layoutType == "list") { if ($printTopLevels) { $s .= "<ul " . parseTagParams($params) . ">"; } if (is_array($data)) { foreach ($data as $nm => $d) { if (is_array($d)) { $fs = "<li for='{$nm}' class='nameLI'>%s</li><li for='{$nm}' class='inputLI'>%s</li><li for='{$nm}' class='helpLI'>%s</li>"; if (!$withHelp) { $fs = "<li for='{$nm}' class='nameLI'>%s</li><li for='{$nm}' class='inputLI'>%s</li>"; } $title = ""; $help = ""; $fld = parseFieldParams($d); if (isset($d['title'])) { $title = $d['title']; } else { $title = toTitle($nm); } if (isset($d['help'])) { $help = parseFieldHelp($d['help']); } if ($withHelp) { $s .= sprintf($fs, $title, $fld, $help); } else { $s .= sprintf($fs, $title, $fld); } } else { if ($d == "" || $d == null) { $s .= "<li> </li>"; } elseif ($d == "hbar") { $s .= "<hr/>"; } else { $s .= "<li class='subheader'>{$d}</li>"; } } } } if ($printTopLevels) { $s .= "</ul>"; } } else { $s = "Form Layout Not Supported"; } return $s; }
function getDefaultParams($userID = "", $pwd = "", $privilegeID = "", $accessID = "") { $hashSalt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.'); $pwdAns = getPWDHash($pwd, $hashSalt); if (is_array($pwdAns)) { $pwdAns = $pwdAns['hash']; } $params = array("guid" => "c21f969b5f03d33d43e04f8f136e7682", "userid" => $userID, "pwd" => $pwdAns, "pwd_salt" => $hashSalt, "privilegeid" => $privilegeID, "accessid" => $accessID, "groupid" => 1, "name" => toTitle($userID), "dob" => "", "gender" => "male", "email" => "", "mobile" => "", "address" => "", "region" => "", "country" => "", "zipcode" => "", "geolocation" => "", "geoip" => "", "blocked" => "false", "expires" => "", "remarks" => "", "vcode" => "", "mauth" => "", "refid" => "", "registerd_site" => SITENAME, "privacy" => "protected", "avatar_type" => "photoid", "avatar" => "", "created_on" => date("Y-m-d H:i:s"), "edited_on" => date("Y-m-d H:i:s")); return $params; }
function printFormattedArray($arr, $autoTitle = true, $format = null) { if ($format == null) { if (isset($_REQUEST["format"])) { $format = $_REQUEST["format"]; } else { $format = "select"; } } $format = strtolower($format); //HTML Format if ($format == "select") { if (!array_is_associative($arr)) { foreach ($arr as $a => $b) { if ($autoTitle) { echo "<option title='{$b}' value='{$b}'>" . toTitle(_ling($b)) . "</option>\n"; } else { echo "<option title='{$b}' value='{$b}'>" . _ling($b) . "</option>\n"; } } } else { foreach ($arr as $a => $b) { $xs = ""; if (is_array($b)) { $xx = array(); foreach ($b as $x => $y) { $xx[] = "{$x}='{$y}'"; } $xs = implode(" ", $xx); if (isset($b['value'])) { $b = $b['value']; } else { $b = $a; } } if ($autoTitle) { echo "<option title='{$a}' value='{$b}' {$xs}>" . toTitle(_ling($a)) . "</option>\n"; } else { echo "<option title='{$a}' value='{$b}' {$xs}>" . _ling($a) . "</option>\n"; } } } } elseif ($format == "table") { foreach ($arr as $a => $b) { $s = "<tr rel='{$a}'>"; if (is_array($b)) { foreach ($b as $x => $y) { if (is_numeric($y)) { $s .= "<td name='{$x}' rel='{$y}' align=center>" . toTitle(_ling($y)) . "</td>"; } elseif (is_array($y)) { $xs = ""; foreach ($y as $u => $v) { $xx[] = "{$u}='{$v}'"; } $xs = implode(" ", $xx); if (isset($y['value'])) { $y = $y['value']; } else { $y = $x; } $s .= "<td name='{$x}' rel='{$y}' {$xs}>" . toTitle(_ling($y)) . "</td>"; } elseif (is_bool($y) || $y == "true" || $y == "false") { if ($y == "true" || $y == 1) { $s .= "<td name='{$x}' rel='{$y}' align=center><input name={$x} type=checkbox checked /></td>"; } else { $s .= "<td name='{$x}' rel='{$y}' align=center><input name={$x} type=checkbox /></td>"; } } else { if (strpos("#" . $y, "<") == 1) { $s .= "<td name='{$x}' rel='{$x}'>{$y}</td>"; } elseif (strpos($y, "@") === 0) { $y = substr($y, 1); $s .= "<td name='{$x}' rel='{$x}'>{$y}</td>"; } else { $s .= "<td name='{$x}' rel='{$y}'>" . toTitle(_ling($y)) . "</td>"; } } } } else { $s .= "<td name='{$a}' rel='{$b}'>" . toTitle(_ling($b)) . "</td>"; } $s .= "</tr>\n"; echo $s; } } elseif ($format == "list") { if (!array_is_associative($arr)) { foreach ($arr as $a => $b) { if (is_array($b)) { echo "<ul>\n"; printFormattedArray($b, $autoTitle, $format); echo "</ul>\n"; } else { if ($autoTitle) { echo "<li title='{$b}' value='{$b}'>" . toTitle(_ling($b)) . "</li>\n"; } else { echo "<li title='{$b}' value='{$b}'>" . _ling($b) . "</li>\n"; } } } } else { foreach ($arr as $a => $b) { if (is_array($b)) { $xs = ""; if (is_array($b)) { $xx = array(); foreach ($b as $x => $y) { $xx[] = "{$x}='{$y}'"; } $xs = implode(" ", $xx); } if ($autoTitle) { echo "<li title='{$a}' {$xs}>" . toTitle(_ling($a)) . "</li>\n"; } else { echo "<li title='{$a}' {$xs}>" . _ling($a) . "</li>\n"; } // echo "<ul>\n"; // printFormattedArray($b,$autoTitle,$format); // echo "</ul>\n"; } else { if ($autoTitle) { echo "<li title='{$a}' value='{$b}'>" . toTitle(_ling($a)) . "</li>\n"; } else { echo "<li title='{$a}' value='{$b}'>" . _ling($a) . "</li>\n"; } } } } } elseif ($format == "text") { foreach ($arr as $a => $b) { if (is_array($b)) { printFormattedArray($b, $autoTitle, $format); } else { $sx = strip_tags("{$a}={$b}"); echo "{$sx}\n"; } } } elseif ($format == "json") { echo json_encode($arr); } elseif ($format == "xml") { $arr = array_flip($arr); $xml = new SimpleXMLElement('<service/>'); //arrayToXML($arrData,$xml); array_walk_recursive($arr, array($xml, 'addChild')); echo $xml->asXML(); } else { printArray($arr); } }
function createDataSelectorFromSQL($dbLink, $sql, $nameCol, $valCol, $classCol = null, $dataCol = null, $groupCol = null, $concatName = false, $allowNone = true, $format = "select", $params = array()) { if ($valCol == null || strlen($valCol) <= 0) { $valCol = $nameCol; } if ($groupCol != null && strlen($groupCol) > 0) { $groupSelector = true; } else { $groupSelector = false; } //echo $sql; if (isset($params['name'])) { $nameX = $params['name']; } else { $nameX = ""; } $result = $dbLink->executeQuery($sql); if ($allowNone) { if ($format == "select") { $outArr[] = "<option value='' rel=''>" . _ling("None") . "</option>"; } elseif ($format == "checkbox") { $outArr[] = "<input type=checkbox name='{$nameX}' rel='' value='' /> <label for=''>None</label>"; } elseif ($format == "radio") { $outArr[] = "<input type=radio name='{$nameX}' rel='' value='' /> <label for=''>None</label>"; } } else { $outArr = array(); } $lastGroup = ""; $tmpl = ""; if ($format == "select") { $tmpl = "<option class='%s' rel='%s' value='%s' >%s</option>"; } elseif ($format == "checkbox") { $tmpl = "<input type=checkbox name='{$nameX}' class='%s' rel='%s' value='%s' /> <label for=''>%s</label>"; } elseif ($format == "radio") { $tmpl = "<input type=radio name='{$nameX}' class='%s' rel='%s' value='%s' /> <label for=''>%s</label>"; } if ($result) { if ($dbLink->recordCount($result) > 0) { while ($record = $dbLink->fetchData($result)) { if ($record[$valCol] == null) { $record[$valCol] = $record[$nameCol]; } $name = $record[$nameCol]; $name = str_replace('_', ' ', $name); $name = ucwords($name); $name = _ling($name); if ($concatName) { $name = $name . " [" . $record[$valCol] . "]"; } if ($classCol != null && strlen($classCol) > 0 && isset($record[$classCol])) { $c = $record[$classCol]; } else { $c = ""; } if ($dataCol != null && strlen($dataCol) > 0 && isset($record[$dataCol])) { $d = $record[$dataCol]; } else { $d = ""; } if (isset($params['class'])) { $c = $params['class']; } if (isset($params['rel'])) { $d = $params['rel']; } $str = sprintf($tmpl, $c, $d, $record[$valCol], _ling($name)); if ($groupSelector) { if (isset($record[$groupCol]) && strlen($record[$groupCol]) > 0) { if (!isset($outArr[$record[$groupCol]])) { $outArr[$record[$groupCol]] = array(); } array_push($outArr[$record[$groupCol]], $str); } else { $outArr[] = $str; } } else { $outArr[] = $str; } } } } $str = ""; foreach ($outArr as $a => $b) { if (is_array($b)) { if ($format == "select") { $str .= "<optgroup label='" . toTitle($a) . "' value='{$a}'>"; foreach ($b as $x) { $str .= $x; } $str .= "</optgroup>"; } else { $str .= "<span label='" . toTitle($a) . "' value='{$a}'>"; foreach ($b as $x) { $str .= $x; } $str .= "</span>"; } } else { $str .= $b; } } $dbLink->freeResult($result); return $str; }
function getNavigationList() { $arr = array(); $sql = "SELECT menuid,count(*) as cnt FROM lgks_admin_links WHERE (SITE='" . SITENAME . "' OR SITE='*') GROUP BY menuid"; $result = _dbQuery($sql, true); if ($result) { $data = _dbData($result); foreach ($data as $a) { if (strlen($a['menuid']) > 0) { $arr[toTitle($a['menuid']) . " [{$a['cnt']}]"] = $a['menuid']; } } } return $arr; }
<h1 class="page-header"> <small><?php echo toTitle($title); ?> Guides</small> </h1> <div class="navigation linkList"> <ul class="list-group"> <?php if (count($guideCategoryList) > 0) { foreach ($guideCategoryList as $guide) { $subcategory = str_replace(" ", "-", $guide['subcategory']); $title = str_replace(" ", "-", $guide['title']); $guideLink = _link("guides/") . $guide['category'] . "/" . urlencode($subcategory . "." . $title) . "-" . $guide['id']; ?> <li class='list-group-item'><a href="<?php echo $guideLink; ?> "><?php echo toTitle($guide['title']); ?> </a></li> <?php } } ?> <ul> </div> </div> </div> </div>