public function __call($name, $args)
 {
     decho("{$name}  in: " . print_r($args, true) . "\n");
     $result = call_user_func_array(array($this->provider, $name), $args);
     decho("{$name} out: " . print_r($result, true) . "\n");
     return $result;
 }
Exemplo n.º 2
0
 public function Platoon($unit_id, $platoon_id)
 {
     $query = sprintf("SELECT leader_id, name, logo, creed, bio  \n\t\tFROM rudi_platoons \n\t\tWHERE unit_id = %d AND platoon_id = %d", (int) $unit_id, (int) $platoon_id);
     $result = $this->db->Query($query);
     $platoon = $this->db->FetchObject($result, 'UnitInfo', true);
     decho($platoon);
     return $platoon;
 }
Exemplo n.º 3
0
function getCombatSoldiers($war_id)
{
    global $db;
    $query = "SELECT m.member_id, \n\t\t\t\t\t\t\t\t\t m.first_name, \n\t\t\t\t\t\t\t\t\t m.last_name, \n\t\t\t\t\t\t\t\t\t r.shortname, \n\t\t\t\t\t\t\t\t\t r.longname, \n\t\t\t\t\t\t\t\t\t w.record_id,\n\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t  \n\t\t\t\t\t\t\t  FROM rudi_combat_record AS w \n\t\t\t\t\t\t\t  JOIN rudi_unit_members AS m \n\t\t\t\t\t\t\t  ON m.member_id = w.member_id \n\t\t\t\t\t\t\t  JOIN rudi_ranks AS r \n\t\t\t\t\t\t\t  ON m.rank_id = r.rank_id \n\t\t\t\t\t\t\t  WHERE m.status_id < 4, w.war_id = {$war_id} OR w.war_id IS NULL \n\t\t\t\t\t\t\t  ORDER BY r.weight DESC , m.date_promotion ASC , m.date_enlisted ASC";
    decho($query);
    $result = $db->Query($query);
    $data = $db->Fetch($result);
    return $data;
}
Exemplo n.º 4
0
function post_parse()
{
    global $appmsg, $apperr, $action, $dmon_msg;
    if (empty($_POST)) {
        decho("call function post_parse without post", 1);
        return -1;
    }
    foreach ($_POST as $ind => $val) {
        switch ($ind) {
            case "action":
                $action = $val;
                // switch val
                break;
            case "message":
                $dmon_msg = $val;
                break;
        }
        // switch $ind
    }
    // for
}
Exemplo n.º 5
0
 public function Translate($Code, $Default = FALSE)
 {
     $Result = parent::Translate($Code, $Default);
     if (!$Code || substr($Code, 0, 1) == '@') {
         return $Result;
     }
     $Prefix = self::GuessPrefix();
     if (!$Prefix) {
         return $Result;
     }
     if ($Prefix == 'unknown') {
         decho($Code);
         decho(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
         die;
     }
     if (Gdn_Theme::InSection('Dashboard')) {
         $Prefix = 'dash_' . $Prefix;
     } else {
         $Prefix = 'site_' . $Prefix;
     }
     $this->_CapturedDefinitions[$Prefix][$Code] = $Result;
     return $Result;
 }
Exemplo n.º 6
0
 /**
  * @return array   an array of two values:
  *                 1. Whether all descendants of this item were spidered
  *                 2. Whether this item has or may have valid descendants
  *                    - used to delete things that have no valid descendants
  */
 public function spider($recursionDepth = 0)
 {
     // don't spider a Term in batch mode if it's an old term
     if ($this instanceof Term && php_sapi_name() == 'cli' && $this->getStatus() == -1) {
         return array(true, true);
     }
     $shallowSpidering = $this instanceof School && $recursionDepth == 2 || $this instanceof Campus && $recursionDepth == 1 || $this instanceof Term && $recursionDepth == 0;
     if (!$shallowSpidering && !$this->needsSpidering()) {
         return array(true, true);
     }
     if ($shallowSpidering && !$this->needsSpidering($this->getShallowSpideredAt())) {
         return array(false, true);
     }
     if ($this instanceof Section) {
         return $this->getBookstore()->spiderSections(array($this));
     }
     decho("Spidering {$this->class} " . call_user_func(array($this, "get{$this->debug}")) . "\n");
     // mark all children in the database as untouched
     $this->getChildQuery()->update(array('Touched' => false));
     try {
         $children = $this->getChildren();
     } catch (BookstoreError $e) {
         // retry once
         $children = $this->getChildren();
     }
     // update the database with the spidered data
     list($allChildren, $skipped) = $this->updateDb($children);
     $recursionDepth -= (int) $skipped;
     // if we were in the middle of spidering, pick up where we left off
     $children = array_filter($allChildren, function ($c) {
         return $c->needsSpidering();
     });
     $partial = count($children) < count($allChildren);
     $complete = false;
     if ($recursionDepth > 0) {
         if ($this instanceof Course) {
             // spider multiple sections at once
             list($complete, $foo) = $this->getBookstore()->spiderSections($children);
             $partial = $partial || $foo;
         } else {
             $complete = true;
             foreach ($children as $child) {
                 $result = $child->spider($recursionDepth - 1);
                 $complete = $complete && $result[0];
                 $partial = $partial || $result[1];
             }
         }
     } else {
         $complete = $this instanceof Course;
         $partial = true;
     }
     if ($complete) {
         $this->setSpidered()->save();
     }
     if ($partial && $shallowSpidering) {
         $this->setShallowSpideredAt(time())->save();
     }
     if (!$partial) {
         $this->disable("No children!");
         return array(true, true);
     }
     return array($complete, $partial);
 }
Exemplo n.º 7
0
<?php

defined('APPLICATION') or exit;
?>


<h1><?php 
echo $this->Data('Title');
?>
</h1>
<div class="Info"><?php 
echo $this->Data('Info');
?>
</div>
<?php 
echo $this->Form->Open();
echo $this->Form->Errors();
echo $this->Form->Label($this->Data('CategoriesLabel'), 'CheckBoxList');
echo $this->Form->CheckBoxList('Plugins.EventCalendar.CategoryIDs', $this->CategoryData, $this->EventCategory, array('ValueField' => 'CategoryID', 'TextField' => 'Name'));
echo $this->Form->Button('Save');
echo $this->Form->Close();
decho($this);
Exemplo n.º 8
0
<?php

defined('APPLICATION') or exit;
?>
<h1><?php 
echo $this->Title();
?>
</h1>

<?php 
decho($this->Data('TEST')->Result());
Exemplo n.º 9
0
$statuses = GetStatuses();
foreach ($statuses as $status) {
    echo "<option value=\"{$status['status_id']}\">{$status['name']}</option>";
}
?>
		</select>
		</td></tr>
		<tr><td class="right">Primary MOS:</td><td class="left"><input type="text" name="primmos" value="" /></td></tr>
		<tr>
			<td class="right">Role:</td>
			<td class="left">
			<select name="role">
				<option value="0">---SELECT-POSITION---</option>
<?php 
$groups = GetRoles();
decho($groups);
foreach ($groups as $group) {
    echo "<optgroup label=\"{$group['name']}\">";
    foreach ($group['roles'] as $role) {
        echo "<option value=\"{$role['role_id']}\">{$role['name']}</option>";
    }
    echo "</optgroup>";
}
?>
				</select>
			</td>
		</tr>
		<tr>
			<td class="right" style="font-weight:bold;">Unit:</td>
			<td class="left">
			<select name="unit">
Exemplo n.º 10
0
 public static function addSchools()
 {
     $class = get_called_class();
     decho("Adding schools for {$class}");
     foreach (static::getSchools() as $data) {
         print_r($data);
         $school = SchoolQuery::create()->filterByBookstoreType($class)->filterBySubdomain($data['Subdomain'])->findOne();
         if (!$school) {
             $school = new School();
             $school->setBookstoreType($class)->setSubdomain($data['Subdomain']);
         }
         $school->setSlug($data['Slug'])->setName($school->getName() ?: $data['Name'])->setShortName($school->getShortName(true) ?: (isset($data['ShortName']) ? $data['ShortName'] : School::guessShortName($data['Name'], $data['Slug'])))->setTouched(1)->save();
     }
 }
Exemplo n.º 11
0
<?php

$class_id = $_GET['cid'];
$form = new BayonetForm("", "POST");
if ($form->verifySubmit('processed')) {
    global $db;
    $name = $form->request['name'];
    $text = $form->request['text'];
    decho("INSERT INTO `rudi_awards` SET `class_id` = '{$class_id}', `name` = '{$name}', `description` = '{$text}'");
    $db->Query("INSERT INTO `rudi_awards` SET `class_id` = '{$class_id}', `name` = '{$name}', `image` = '', `description` = '{$text}'");
    PageRedirect(1, "?op=rudi&show=awards&cid=" . $class_id);
    return;
}
echo LinkInternal("Cancel", "?op=rudi&show=awards&cid=" . $class_id);
OpenTable();
?>

<tr><th>Name:</th><td><?php 
$form->textField('name', "", false, "50");
?>
</td><tr>
<tr><th>Image:</th><td><?php 
?>
</td></tr>
<tr><th>Text:</th><td><?php 
$form->textArea('text', 10, 30);
?>
</td></tr>
<tr><td><?php 
$form->submitButton('processed', 'Add');
?>
Exemplo n.º 12
0
<HTML>
<BODY>
<?php 
$password = $_POST['pswd'];
$username = $_POST['name'];
echo "<BR>Checking authentication of user {$username} ... <P>";
if ($username == "" || $password == "") {
    echo "<H3>Sorry, you must supply both username and password.</H3>\n";
    die("<A HREF=\"./index.php\"><BUTTON TYPE=button> Try again or create new account? </BUTTON></A>\n");
}
my_connect();
$sessionid = session_id();
decho("You have authenticated as user '{$username}'. Your sessionid is '{$sessionid}'.<BR>");
my_disconnect();
$sessionid = session_id();
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$_SESSION['debug'] = $debug;
?>

<P>
<H3>You have logged in successfully.</H3>

<A HREF="./mainpage.php"><BUTTON TYPE=button> Proceed to the main page </BUTTON></A><P>
<A HREF="./logout.php"><BUTTON TYPE=button> Logout </BUTTON></A>

</BODY>
</HTML>
Exemplo n.º 13
0
 /**
  * Rewrite the request based on rewrite rules (currently called routes in Vanilla).
  *
  * This method modifies the passed {@link $request} object. It can also cause a redirect if a rule matches that
  * specifies a redirect.
  *
  * @param Gdn_Request $request The request to rewrite.
  */
 private function rewriteRequest($request)
 {
     $pathAndQuery = $request->PathAndQuery();
     $matchRoute = Gdn::router()->matchRoute($pathAndQuery);
     // We have a route. Take action.
     if (!empty($matchRoute)) {
         $dest = $matchRoute['FinalDestination'];
         if (strpos($dest, '?') === false) {
             // The rewrite rule doesn't include a query string so keep the current one intact.
             $request->path($dest);
         } else {
             // The rewrite rule has a query string so rewrite that too.
             $request->pathAndQuery($dest);
         }
         switch ($matchRoute['Type']) {
             case 'Internal':
                 // Do nothing. The request has been rewritten.
                 break;
             case 'Temporary':
                 safeHeader("HTTP/1.1 302 Moved Temporarily");
                 safeHeader("Location: " . url($matchRoute['FinalDestination']));
                 exit;
                 break;
             case 'Permanent':
                 safeHeader("HTTP/1.1 301 Moved Permanently");
                 safeHeader("Location: " . url($matchRoute['FinalDestination']));
                 exit;
                 break;
             case 'NotAuthorized':
                 safeHeader("HTTP/1.1 401 Not Authorized");
                 break;
             case 'NotFound':
                 safeHeader("HTTP/1.1 404 Not Found");
                 break;
             case 'Drop':
                 die;
             case 'Test':
                 decho($matchRoute, 'Route');
                 decho(array('Path' => $request->path(), 'Get' => $request->get()), 'Request');
                 die;
         }
     } elseif (in_array($request->path(), ['', '/'])) {
         $this->isHomepage = true;
         $defaultController = Gdn::router()->getRoute('DefaultController');
         $request->pathAndQuery($defaultController['Destination']);
     }
     return $request;
 }
Exemplo n.º 14
0
<?php

// File: edit-client-result.php
// Copyright (C) 2012 WoodDuck Computer Consulting
include "./header.php";
get_globals();
my_connect();
echo "<H3>Edit Client</H3>\n";
// Fetch client ID from the FORM POST data
$ID = $_POST['ID'];
decho("Editing client ID '{$ID}' ... <BR>");
// Do a SELECT query to get the old client data
$query = "SELECT ID,FName,MName,LName from clients WHERE ID = '{$ID}'";
$result = try_query($query);
// Display it as an editable form, including the INPUT boxes
echo "<FORM ACTION=\"./save-client.php\" METHOD=post>\n";
if (show_client_edit_form($result)) {
    // Display the form buttons only if the return value was TRUE
    echo "<P>" . "<INPUT TYPE=submit VALUE=\"  SAVE edited client data  \"><P>\n" . "<INPUT TYPE=reset VALUE=\"  Reset to original client data  \"><P>\n";
} else {
    echo "<P>Sorry, no results match Client ID '{$ID}'.<P>\n";
}
echo "</FORM>\n";
my_disconnect();
?>

<P>
<A HREF="./edit-client.php"><BUTTON TYPE=button> Edit another client </BUTTON></A><P>
<A HREF="./main.php"><BUTTON TYPE=button> Return to main page </BUTTON></A><P>
<A HREF="./logout.php"><BUTTON TYPE=button> Logout </BUTTON></A>
Exemplo n.º 15
0
function get_parse()
{
    global $appmsg;
    global $apperr;
    global $action;
    global $icsmsg;
    global $config_dir;
    global $log_dir;
    foreach ($_GET as $ind => $val) {
        decho("get_parse:: index: {$ind} and val: {$val}<br>", 1);
        switch ($ind) {
            case "action":
                $action = $val;
                break;
            case "message":
                $icsmsg = json_decode($val);
                $apperr .= "\n ics: " . $icsmsg;
                break;
                // ******* URL COMMANDLINE OPTIONS BELOW ***
                // Initial or repair load of th edatabase for LamPI
                // Need to specify this option on the URL: http://<my-lampi-url>/frontend_set.php?load
                //
            // ******* URL COMMANDLINE OPTIONS BELOW ***
            // Initial or repair load of th edatabase for LamPI
            // Need to specify this option on the URL: http://<my-lampi-url>/frontend_set.php?load
            //
            case "load":
                echo "load:: config file: " . $config_dir . "database.cfg\n";
                $cfg = read_database($config_dir . "database.cfg");
                // Load $cfg Object from File
                echo " cfg read; ";
                print_database($cfg);
                echo " now filling mysql; ";
                $ret = fill_database($cfg);
                // Fill the MySQL Database with $cfg object
                echo " Making backup; ";
                $ret = file_database($config_dir . "newdbms.cfg", $cfg);
                // Make backup to other file
                echo " Backup newdbms.cfg made";
                if ($val < 1) {
                    decho("file_database:: value must be >0");
                }
                exit(0);
                break;
            case "print":
                $cfg = load_database();
                print_database($cfg);
                exit(0);
                break;
            case "store":
                $cfg = load_database();
                // Fill $cfg from MySQL
                $ret = file_database($config_dir . "newdbms.cfg", $cfg);
                // Make backup to other file
                if ($val < 1) {
                    decho("store:: value must be >0");
                }
                echo "Backup is complete";
                exit(0);
                break;
        }
        //   Switch ind
    }
    //  Foreach
    return 0;
}
Exemplo n.º 16
0
 public function InsertID()
 {
     decho("Fetching insert id for auto increment");
     return mysqli_insert_id($GLOBALS['___mysqli_ston']);
 }
Exemplo n.º 17
0
 function purgeThumbnailsFromCDNetworks($files)
 {
     $locations = array();
     foreach ($files as $file) {
         $thumbnails = $file->getThumbnails();
         $dir = array_shift($thumbnails);
         foreach ($thumbnails as $thumbnail) {
             $dirPath = str_replace("mwstore://local-backend/local-thumb/", "", $dir);
             $locations[] = "/images/thumb/" . $dirPath . "/" . $thumbnail;
         }
     }
     $user = $this->getOption('cdnuser');
     $pass = $this->getOption('cdnpass');
     if ($user && $pass) {
         $params = array('user' => $user, 'password' => $pass);
         decho("will call to cdnet with", $locations, false);
         //TODO if this list is longer than 1000 split into separate calls
         // or maybe just write this all to a file
         $html = CDNetworksSupport::doCDnetworksApiCall($params, $locations);
         decho("response from CDN", $html, false);
     } else {
         decho("must provide user and password to do cdn flush");
     }
 }
Exemplo n.º 18
0
 public function updateSections($catalog, $sections = null)
 {
     decho("Updating sections... ");
     if (!$sections) {
         $sections = $catalog->getAllSections();
     }
     // if metadata provider doesn't do mass section lookup
     if (!$sections) {
         $query = $this->filterByCatalog(new DeptQuery(), $catalog);
         $sections = array();
         foreach ($query->find() as $dept) {
             if ($data = $catalog->getSectionsByDept($dept->getAbbr())) {
                 $foo = array();
                 foreach ($data as $section) {
                     $section['DeptAbbr'] = $dept->getAbbr();
                     $foo[] = $section;
                 }
                 $sections = array_merge($sections, $foo);
             }
         }
     }
     // if metadata provider doesn't do per-department section lookup either
     if (!$sections) {
         $query = CourseQuery::create()->join('Course.Dept')->withColumn('Dept.Abbr', 'DeptAbbr')->useDeptQuery();
         $query = $this->filterByCatalog($query, $catalog)->endUse();
         $sections = array();
         foreach ($query->find() as $c) {
             if ($data = $catalog->getSectionsByCourse($c->getDeptAbbr(), $c->getNum())) {
                 $foo = array();
                 foreach ($data as $section) {
                     $section['DeptAbbr'] = $c->getDeptAbbr();
                     $section['CourseNum'] = $c->getNum();
                     $foo[] = $section;
                 }
                 $sections = array_merge($sections, $foo);
             }
         }
     }
     // if metadata provider doesn't do per-course section lookup either
     if (!$sections) {
         $query = SectionQuery::create()->join('Section.Course')->join('Course.Dept')->withColumn('Course.Num', 'CourseNum')->withColumn('Dept.Abbr', 'DeptAbbr')->useCourseQuery()->useDeptQuery();
         $query = $this->filterByCatalog($query, $catalog)->endUse()->endUse();
         $sections = array();
         foreach ($query->find() as $s) {
             if ($data = $catalog->getSection($s->getDeptAbbr(), $s->getCourseNum(), $s->getNum())) {
                 $data['DeptAbbr'] = $s->getDeptAbbr();
                 $data['CourseNum'] = $s->getCourseNum();
                 $sections[] = $data;
             }
         }
     }
     // if metadata provider doesn't do single section lookup either
     if (!$sections) {
         decho("fail\n");
     } else {
         $depts = array();
         $courses = array();
         foreach ($sections as $section) {
             $s = SectionQuery::create()->filterByNum($section['Num'])->useCourseQuery()->filterByNum($section['CourseNum'])->useDeptQuery()->filterByAbbr($section['DeptAbbr']);
             $s = $this->filterByCatalog($s, $catalog)->endUse()->endUse()->findOne();
             if (!$s) {
                 decho("Unknown section: {$section['DeptAbbr']}:" . "{$section['CourseNum']}: {$section['Num']}\n");
             } else {
                 $s->setProfessor($section['Professor'])->save();
             }
             if (isset($section['DeptName']) && $section['DeptName']) {
                 $depts[] = array('Abbr' => $section['DeptAbbr'], 'Name' => $section['DeptName']);
             }
             if (isset($section['CourseName']) && $section['CourseName']) {
                 $courses[] = array('DeptAbbr' => $section['DeptAbbr'], 'Num' => $section['CourseNum'], 'Name' => $section['CourseName']);
             }
         }
         decho("success\n");
         if ($depts) {
             $this->updateDepts($catalog, $depts);
         }
         if ($courses) {
             $this->updateCourses($catalog, $courses);
         }
     }
 }
Exemplo n.º 19
0
				<a href="?load=news&page=<?php 
            echo $page_num + 2;
            ?>
">Older News</a>&nbsp;
			</div>
			<div class="clear"></div>	
<?php 
        }
        CloseContent();
        echo "<br />";
        displayNews($news);
        OpenContent();
        if ($page_num > 0) {
            echo "&nbsp;<a href=\"?load=news&page={$page_num}\">More Recent News</a>";
        }
        decho("count: " . count($news));
        if (count($news) == $limit) {
            ?>
		<div style="float:right;">
			<a href="?load=news&page=<?php 
            echo $page_num + 2;
            ?>
">Older News</a>&nbsp;
		</div>
<?php 
        }
    }
    echo "<div class=\"clear\"></div>";
    CloseContent();
    return;
}
Exemplo n.º 20
0
 public function __construct($id)
 {
     if (is_null($id)) {
         decho("No ID");
         return;
     } else {
         decho(get_class($this) . "received: {$id}");
     }
     $this->id = $id;
     $this->db = new RUDI_SQL();
     $this->link = $this->db->Connect('localhost', 'hunkeler', 'proball');
     $this->db->Select_db('rudi');
     $result = $this->db->Query("SELECT last_name, first_name FROM rudi_unit_members WHERE member_id = '{$id}'");
     $name = $this->db->FetchArray($result);
     echo "Current soldier selected: '{$name['last_name']}, {$name['first_name']}'";
 }
Exemplo n.º 21
0
function close_session()
{
    decho("Closing session ...<BR>\n");
    session_unset();
    session_destroy();
}
Exemplo n.º 22
0
/**
 * getNumOfComments($id)
 * Function that gets the desired news from the database and returns it as an array
 * @param id - (optional) news_id cooresponding to `bayonet_news`
 */
function getNews($id = NULL, $limit = NULL, $index = 0)
{
    global $db;
    $query = "SELECT n.news_id, n.title, n.message, n.date, n.edited, n.category_id, u.username AS author, e.username AS eauthor, c.name AS catname, c.image AS catimage " . "FROM `bayonet_news` AS n " . "INNER JOIN `bayonet_news_categories` AS c ON c.category_id = n.category_id " . "LEFT OUTER JOIN `bayonet_users` AS u ON u.user_id = n.author_id " . "LEFT OUTER JOIN `bayonet_users` AS e ON e.user_id = n.edited_id ";
    if (isset($id)) {
        $query = $query . "WHERE n.news_id = '{$id}' ";
    } else {
        $query = $query . "ORDER BY date DESC";
        if ($index > 0) {
            $query = $query . " LIMIT {$index}, {$limit}";
        } else {
            if ($limit != NULL) {
                $query = $query . " LIMIT {$limit}";
            }
        }
    }
    decho($query);
    $result = $db->Query($query);
    $data = $db->Fetch($result);
    return $data;
}
Exemplo n.º 23
0
function ResetPassword($user_id)
{
    global $db;
    $result = $db->Query("SELECT `username`, `email` FROM `bayonet_users` WHERE `user_id` = '{$user_id}' LIMIT 1");
    $admin = $db->FetchRow($result);
    decho($admin);
    if (isset($_POST['proceed'])) {
        $password = GeneratePassword(8);
        $cryptpassword = crypt(md5($password), 'iamnotadirtywhorebitch');
        $status = EmailPassword($admin['username'], $password, $admin['email']);
        if ($status) {
            $db->Query("UPDATE `bayonet_users` SET `password` = '{$cryptpassword}' WHERE `user_id` = '{$user_id}' LIMIT 1");
            echo "Password has been reset and emailed to '{$admin['username']}'";
            PageRedirect(3, "?op=admins");
        } else {
            ReportError("An error has occured emailing the new password. It will not take effect.");
        }
        return;
    }
    if (isset($_POST['cancel'])) {
        echo "The password <b>WILL NOT</b> be reset for '{$admin['username']}'";
        PageRedirect(3, "?op=admins");
        return;
    }
    ?>
	<center>
	<form action="<?php 
    $_SERVER['PHP_SELF'];
    ?>
" method="post">
	<table>
	<th>Are you SURE you want to reset this user's password: '******'username'];
    ?>
'?</th>
	<tr><th><button name="proceed">Yes</button>&nbsp;&nbsp;&nbsp;<button name="cancel">No</button></th></tr>
	</table>
	</form>
	</center>
	<?php 
}
Exemplo n.º 24
0
 /**
  * Parses the query string looking for supplied request parameters. Places
  * anything useful into this object's Controller properties.
  *
  * @param int $FolderDepth
  */
 protected function AnalyzeRequest(&$Request)
 {
     // Here is the basic format of a request:
     // [/application]/controller[/method[.json|.xml]]/argn|argn=valn
     // Here are some examples of what this method could/would receive:
     // /application/controller/method/argn
     // /controller/method/argn
     // /application/controller/argn
     // /controller/argn
     // /controller
     // Clear the slate
     $this->_ApplicationFolder = '';
     $this->ControllerFolder = '';
     $this->ControllerName = '';
     $this->ControllerMethod = 'index';
     $this->_ControllerMethodArgs = array();
     $this->Request = $Request->Path(FALSE);
     $PathAndQuery = $Request->PathAndQuery();
     $MatchRoute = Gdn::Router()->MatchRoute($PathAndQuery);
     // We have a route. Take action.
     if ($MatchRoute !== FALSE) {
         switch ($MatchRoute['Type']) {
             case 'Internal':
                 $Request->PathAndQuery($MatchRoute['FinalDestination']);
                 $this->Request = $Request->Path(FALSE);
                 break;
             case 'Temporary':
                 header("HTTP/1.1 302 Moved Temporarily");
                 header("Location: " . Url($MatchRoute['FinalDestination']));
                 exit;
                 break;
             case 'Permanent':
                 header("HTTP/1.1 301 Moved Permanently");
                 header("Location: " . Url($MatchRoute['FinalDestination']));
                 exit;
                 break;
             case 'NotAuthorized':
                 header("HTTP/1.1 401 Not Authorized");
                 $this->Request = $MatchRoute['FinalDestination'];
                 break;
             case 'NotFound':
                 header("HTTP/1.1 404 Not Found");
                 $this->Request = $MatchRoute['FinalDestination'];
                 break;
             case 'Test':
                 $Request->PathAndQuery($MatchRoute['FinalDestination']);
                 $this->Request = $Request->Path(FALSE);
                 decho($MatchRoute, 'Route');
                 decho(array('Path' => $Request->Path(), 'Get' => $Request->Get()), 'Request');
                 die;
         }
     }
     switch ($Request->OutputFormat()) {
         case 'rss':
             $this->_SyndicationMethod = SYNDICATION_RSS;
             break;
         case 'atom':
             $this->_SyndicationMethod = SYNDICATION_ATOM;
             break;
         case 'default':
         default:
             $this->_SyndicationMethod = SYNDICATION_NONE;
             break;
     }
     if ($this->Request == '') {
         $DefaultController = Gdn::Router()->GetRoute('DefaultController');
         $this->Request = $DefaultController['Destination'];
     }
     $Parts = explode('/', str_replace('\\', '/', $this->Request));
     /**
      * The application folder is either the first argument or is not provided. The controller is therefore
      * either the second argument or the first, depending on the result of the previous statement. Check that.
      */
     try {
         // if the 1st argument is a valid application, check if it has a controller matching the 2nd argument
         if (in_array($Parts[0], $this->EnabledApplicationFolders())) {
             $this->FindController(1, $Parts);
         }
         // if no match, see if the first argument is a controller
         $this->FindController(0, $Parts);
         // 3] See if there is a plugin trying to create a root method.
         list($MethodName, $DeliveryMethod) = $this->_SplitDeliveryMethod(GetValue(0, $Parts), TRUE);
         if ($MethodName && Gdn::PluginManager()->HasNewMethod('RootController', $MethodName, TRUE)) {
             $this->_DeliveryMethod = $DeliveryMethod;
             $Parts[0] = $MethodName;
             $Parts = array_merge(array('root'), $Parts);
             $this->FindController(0, $Parts);
         }
         throw new GdnDispatcherControllerNotFoundException();
     } catch (GdnDispatcherControllerFoundException $e) {
         switch ($this->_DeliveryMethod) {
             case DELIVERY_METHOD_JSON:
             case DELIVERY_METHOD_XML:
                 $this->_DeliveryType = DELIVERY_TYPE_DATA;
                 break;
             case DELIVERY_METHOD_TEXT:
                 $this->_DeliveryType = DELIVERY_TYPE_VIEW;
                 break;
             case DELIVERY_METHOD_XHTML:
                 break;
             default:
                 $this->_DeliveryMethod = DELIVERY_METHOD_XHTML;
                 break;
         }
         return TRUE;
     } catch (GdnDispatcherControllerNotFoundException $e) {
         $this->EventArguments['Handled'] = FALSE;
         $Handled =& $this->EventArguments['Handled'];
         $this->FireEvent('NotFound');
         if (!$Handled) {
             header("HTTP/1.1 404 Not Found");
             $Request->WithRoute('Default404');
             return $this->AnalyzeRequest($Request);
         }
     }
 }
Exemplo n.º 25
0
 /**
  * Constructor will serve any JSON-RPC request received and terminate processing, or return
  * control to the page to continue.
  * @param Object $object The object whose methods will be made available for JSON RPC calls.
  * @param Array $methodMap An optional associative array that can be used to map RPC method
  *                         names to object methods, permitting renaming of methods. This is
  *                         useful for providing PHP reserved words as methods, such as 'echo',
  *                         and can be used for restricting access to methods. If this parameter
  *                         is provided, but a method is not listed in the array, access to the method
  *                         is denied.
  * @param Array $config Optional configuration array. Two associative values are supported:
  *   'jsonlib' The location of the JSON-PHP library file.
  *   'jsolaitlib' The directory off which jsolait has been installed.
  *
  * @return None If a valid JSON RPC Request has been received, JSONRpcServer will return a response and terminate
  *  the page. If no such request has been received, JSON RPC will pass control back to the web page, and
  *  a call to JSONRpcServer::javascript( proxyName ) will insert the appropriate JavaScript proxy code into your
  *  web page source.
  *
  */
 function JSONRpcServer($object, $methodMap = null, $config = null)
 {
     /*
      * NOTE: The request object ($request) is parsed into an object, but the response object
      * is an associative array. Writing this code, this distinction caused me headaches. Just a
      * warning :-)
      */
     $this->jsonlib = JSON_PHP_FILE;
     $this->jsolaitlib = JSOLAIT_ROOT;
     if ($config != null) {
         if (array_key_exists("jsonlib", $config)) {
             $this->jsonlib = $config["jsonlib"];
         }
         if (array_key_exists("jsolait", $config)) {
             $this->jsolaitlib = $config["jsolait"];
         }
     }
     $json = new PHPJsonWrapper($this->jsonlib);
     $additionalMethods = array();
     $input = file_get_contents("php://input");
     $request = $json->decode($input);
     /*
      * If we have no request object, we are processing our page, so prepare the js Wrappers
      */
     if ($request == null) {
         $this->object = $object;
         $this->methodMap = $methodMap;
         return;
     }
     $return = array("id" => $request->id, "result" => null, "error" => null);
     /* We've got the incoming JSON request object in request - we need to identify the method and the parameters */
     $method = $request->method;
     /* The methodMap parameter can convert a named method as follows:
      *     string => string - simply rename the method
      *     string => anything else - permit access to the method (the actual boolean value does not matter)
      */
     if ($methodMap != null) {
         if (array_key_exists($method, $methodMap)) {
             if (is_string($methodMap[$method])) {
                 $method = $methodMap[$method];
             }
         } else {
             $return['error'] = "No such method (" . $method . ") permitted on this server.";
             return $json->encode($return);
         }
     }
     if (is_object($object)) {
         if (!method_exists($object, $method)) {
             $return['error'] = "No such method (" . $method . ") exists on this server.";
         } else {
             /*
              * TODO: Try to catch an error in the call: use set_error_handler and restore_error_handler...?
              */
             $return['result'] = call_user_func_array(array(&$object, $method), $request->params);
         }
     } else {
         decho("/* object = {$object} */");
         if (!function_exists($method)) {
             $return['error'] = "No such function (" . $method . ") exists on this server.";
         } else {
             $return['result'] = call_user_func_array($method, $request->params);
         }
     }
     print $json->encode($return);
     exit(0);
 }
Exemplo n.º 26
0
function getDocData($row, $noImages)
{
    $page_id = $row->page_id;
    $page_counter = $row->page_counter;
    $title = Title::newFromDBkey($row->page_title);
    if (!$title || !$title->exists()) {
        decho("unknown title for id", $page_id, false);
        return "";
    }
    $title_text = "<![CDATA[" . wfMsg('howto', $title->getText()) . "]]>";
    if (!$noImages) {
        $image = Wikitext::getTitleImage($title, true) ?: AppDataFormatter::getCategoryImageFile($title);
    }
    if ($image) {
        $heightPreference = $image->getWidth() > $image->getHeight();
        $thumb = WatermarkSupport::getUnwatermarkedThumbnail($image, AppDataFormatter::SEARCH_THUMB_WIDTH, AppDataFormatter::SEARCH_THUMB_HEIGHT, true, true, $heightPreference);
    }
    if ($thumb && !$thumb instanceof MediaTransformError) {
        $thumbUrl = AppDataFormatter::uriencode(wfGetPad($thumb->url));
    }
    $update = "";
    if ($noImages) {
        $update = 'update="set"';
    }
    $postData = '<doc>' . '<field name="id">' . $page_id . '</field>' . '<field name="title" ' . $update . '>' . $title_text . '</field>' . '<field name="page_counter" ' . $update . '>' . $page_counter . '</field>';
    if ($thumbUrl) {
        $postData .= '<field name="image_58x58">' . $thumbUrl . '</field>';
    }
    $postData .= '</doc>';
    return $postData;
}
Exemplo n.º 27
0
 </td>
</tr>
<?php 
}
?>
</table>

</div>
<?php 
CloseContent();
OpenContent();
if (isset($_GET['stats']) && $_GET['stats'] == 'true') {
    ?>
<div class="contentHeading">Statistics</div>
<div class="content">
<?php 
    //decho($drills->getMemberAttendanceFull());
    require_once 'view.drills.statistics.php';
    ?>
</div>
</div>

<?php 
}
?>

<?php 
CloseContent();
decho('DATA FOR NO ID QUERY');
decho($drills->manifest);
Exemplo n.º 28
0
<tr><th>Last Name</th><td><input type="text" name="last" value="<?php 
echo $edit->last_name;
?>
" /></td></tr>
<tr><th>First Name</th><td><input type="text" value="<?php 
echo $edit->first_name;
?>
" /></td></tr>
<tr><th>Rank</th><td><select name="rank">
<?php 
foreach ($common->getRanks() as $ranks) {
    ?>
  <option value="<?php 
    echo $ranks->rank_id;
    ?>
"><?php 
    echo $ranks;
    ?>
</option>
<?php 
}
?>
</select></td></tr>
<tr><th colspan="2"><input type="submit" value="submit"/></th></tr>
</table>
</form>

<?php 
decho($_POST);
decho($common->data[$id]);
//decho($common->getRanks())
Exemplo n.º 29
0
" alt="<?php 
echo $data->logo;
?>
"/></td>
	</tr>
	<tr>
		<th width="25%">Platoon</th>
		<td><?php 
echo $data->name;
?>
</td>
	</tr>
	<tr>
		<th>Creed</th>
		<td><?php 
echo $data->creed;
?>
</td>
	</tr>
	<tr>
		<th valign="top">Biography</th>
		<td><?php 
echo $data->bio;
?>
</td>
	</tr>
</table>

<?php 
decho($data);
Exemplo n.º 30
0
function getDocData($row, $dbr, $printIntro = false)
{
    $page_id = $row->page_id;
    $page_counter = $row->page_counter;
    $title = Title::newFromDBkey($row->page_title);
    if (!$title || !$title->exists()) {
        decho("unknown title for id", $page_id, false);
        return "";
    }
    $wikitext = Wikitext::getWikitext($dbr, $title);
    $intro = Wikitext::getIntro($wikitext);
    //$intro = str_replace("{{toc}}", "", $intro);
    $intro = preg_replace('#\\{\\{.*?\\}\\}#s', '', $intro);
    $intro = trim(preg_replace('#\\[\\[.*?\\]\\]#s', '', $intro));
    $intro = preg_replace('/\\s+/', ' ', trim($intro));
    $intro = str_replace('<br>', '', $intro);
    //if (contains($intro, "Here's how:")) {
    if (stripos($intro, "here's how") !== FALSE || ":" == substr($intro, -1)) {
        //check the number of monthly page views...
        $data = getTitusData($row->page_id);
        if ($data->titus) {
            $ti30 = $data->titus->ti_30day_views;
        }
        if ($ti30 >= 5000 && $ti30 <= 6000) {
            echo $ti30 . " http://www.wikihow.com/" . $row->page_title . " ";
            if ($printIntro) {
                echo $intro;
            }
            echo "\n";
        }
    }
    //echo $page_counter ." http://www.wikihow.com/".$row->page_title." ,> ".$intro."\n";
    //echo "http://www.wikihow.com/".$row->page_title." ,> ".$intro."\n";
    return $intro;
}