コード例 #1
0
 /**
  * Perform the export.
  */
 function execute()
 {
     global $errors, $lang, $sid;
     $minus = 0;
     $pages = createDBCArray("sitepage", "SPID", "MENU_ID = " . $this->menuId);
     for ($i = 0; $i < count($pages); $i++) {
         $cluster = getDBCell("sitepage", "CLNID", "SPID=" . $pages[$i]);
         $articles = countRows("channel_articles", "ARTICLE_ID", "ARTICLE_ID=" . $cluster);
         if ($articles == 0) {
             importClusterToArticle($pages[$i], $this->channelId, $this->categoryId);
         } else {
             $minus++;
             $error = $lang->get("already_imported", "At least one page has not been imported, because it already exists in an channel.");
         }
     }
     if ($errors == "") {
         $this->add(new WZLabel($lang->get("ch_imp_success", "The data was successfully imported to the channel.")));
         if (strlen($error) > 0) {
             $this->add(new WZLabel($error));
         }
         $this->add(new WZLabel($lang->get("num_imp_pages", "Total number of imported pages:") . " " . (count($pages) - $minus)));
     } else {
         $this->add(new WZLabel($lang->get("ch_imp_failed", "There was an error while importing the data to the channel.")));
     }
     $this->parent->finished = true;
     $this->add(new WZLabel($lang->get("back_to_channels", "Back to Article Overview") . " >>", "modules/channels/overview.php?sid={$sid}"));
 }
コード例 #2
0
 /**
  * Checks, whether a user is in a group or not.
  * @param string ID of the group.
  * @returns boolean true|false
  */
 function isInGroup2($groupId)
 {
     if (countRows("user_permissions", "GROUP_ID", "GROUP_ID = {$groupId} AND USER_ID = " . $this->userId) > 0) {
         return true;
     } else {
         return false;
     }
 }
コード例 #3
0
function isValidSessionId($sessionId)
{
    return withStatement("SELECT * FROM SESSION WHERE SESSION_ID=? AND CREATED > NOW() - INTERVAL 1 DAY", function ($statement) use(&$sessionId) {
        $statement->bind_param("s", $sessionId);
        $valid = countRows($statement) > 0;
        debug("isValidUser: "******"true" : "false"));
        return $valid;
    });
}
コード例 #4
0
ファイル: lang.php プロジェクト: BackupTheBerlios/nxwcms-svn
		/**
		 * add a new label or description to the system.
		 * @param string Keyname of the label
		 * @param string Text for display of the label
		 * @param string Text for displaying a tooltip
		 */
		function add($title, $text, $tooltip="") {
			global $db;
		
			$title = strtoupper($title);

			if (countRows("internal_resources", "RESID", "RESID='$title' AND LANGID='" . $this->language . "'") == 0) {
				$sql = "INSERT INTO internal_resources (RESID, LANGID, VALUE, TOOLTIP) VALUES('$title', '" . $this->language . "', '$text', '$tooltip')";
			} else {
				$sql = "UPDATE internal_resources SET VALUE='$text' WHERE RESID='$title' AND LANGID='" . $this->language . "'";
			}

			$query = new query($db, $sql);
			$query->free();
		}
コード例 #5
0
	/**
	 * Deletes the key from the registry.
	 * @param $key string Key in format: folder1/folder11/keyname
	 */
	function reg_delete($key) {
		global $db, $auth;

		$pk = reg_getpk($key);

		if (countRows("registry", "REGID", "PARENTREGID=$pk") == 0) {
			$sql = "DELETE FROM registry WHERE REGID=$pk";

			$query = new query($db, $sql);
			return true;
		} else {
			return false;
		}
	}
コード例 #6
0
	/**
	 * Determines the type of a GUID
	 * @param integer GUID of a resource
	 * @returns string CLUSTER, CLUSTERNODE, METATEMPLATE, CLUSTERTEMPLATE, PAGETEMPLATE
	 */
	 function getTypeByGUID($guid) {
	   $type == "";
	   if (countRows("cluster_variations", "CLNID", "CLNID = $guid") > 0) {
	   	$type = "CLUSTERNODE";
	   } else if (countRows("cluster_variations", "CLID", "CLID = $guid") > 0) {
	   	$type = "CLUSTER";
	   } else if (countRows("cluster_templates", "CLT_ID", "CLT_ID = $guid") >0) {
	   	$type = "CLUSTERTEMPLATE";  	
	   } else if (countRows("meta_templates", "MT_ID", "MT_ID = $guid") > 0) {
	   	$type = "METATEMPLATE";
	   } else if (countRows("sitepage_master", "SPM_ID", "SPM_ID = $guid") > 0) {
	     $type = "PAGETEMPLATE";	
	   }
	 	return $type;
	 }
コード例 #7
0
		/**
		 * Standard constructor
		 * @param integer GUID of the user or group that wants to access the object
		 */
		function Accessor($guid) {
			$this->guid = $guid;

			if (countRows("users", "USER_ID", "USER_ID = $guid") > 0) {
				$this->isUser = true;

				$this->isGroup = false;

				if (countRows("user_permissions", "USER_ID", "ROLE_ID= 1 AND GROUP_ID =1 AND USER_ID = $guid") > 0)
					$this->isAdmin = true;
			} else {
				$this->isUser = false;

				$this->isGroup = true;
				$this->isAdmin = false;
			}
		}
コード例 #8
0
ファイル: social.php プロジェクト: rickyalex/eshopper
    {
        return Xcrud::get_instance($name);
    }
}
require_once "userCake/models/config.php";
if (!securePage($_SERVER['PHP_SELF'])) {
    die;
} elseif (isUserLoggedIn()) {
    $table = 'social';
    $xcrud = Xcrud::get_instance();
    $xcrud->table($table);
    $xcrud->table_name('Your Social Media Links');
    $xcrud->columns('date_created', true);
    //$xcrud->column_tooltip('img','Recommended size is 720x252');
    //$xcrud->change_type('img','image');
    if (countRows($table) > 0) {
        $xcrud->unset_add();
    }
    $xcrud->pass_var('date_created', Date('Y-m-d h:i:s'), 'create');
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		
		<title>Administrator Page</title>
		<?php 
require_once '../inc/inc_header.php';
?>
		
コード例 #9
0
<?php

require_once "../../config.inc.php";
$auth = new auth("ANALYSE_RATINGS");
$page_action = "update";
$go = "update";
$page = new Page("Rating Results");
$form = new EditForm($lang->get("rateres", "Rate Results"));
$interval = array();
$count = countRows("pgn_rating", "RATINGID", "COMMENT <>''");
$steps = $count / 50;
for ($i = 0; $i < $steps; $i++) {
    $interval[$i][0] = $i * 50 . " - " . (($i + 1) * 50 - 1);
    $interval[$i][1] = $i;
}
$form->add(new Label("lbl", $lang->get("display", "Display"), "standard"));
$form->add(new Select("display", $interval, "standardlight", value("display"), 1));
$grid = new NXGrid("grid", 3);
$grid->setRatio(array(150, 350, 100));
$grid->addRow(array(new Label("lbl", "<b>" . $lang->get("page", "Page") . "</b>"), new Label("lbl", "<b>" . $lang->get("comment", "Comment") . "</b>"), new Label("lbl", "<b>" . $lang->get("date", "Date") . "</b>")));
$thisInterval = value("interval");
$sql = "SELECT SOURCEID, COMMENT, TIMESTAMP FROM pgn_rating WHERE COMMENT <> '' ORDER BY TIMESTAMP DESC";
$query = new query($db, $sql);
while ($query->getrow()) {
    $grid->addRow(array(new Label("lbl", resolvePageToLink($query->field("SOURCEID"))), new Label("lbl", str_replace('\\\\', '\\', $query->field("COMMENT"))), new Label("lbl", formatDBTimestamp($query->field('TIMESTAMP')))));
}
$query->free();
$form->add($grid);
$page->add($form);
$page->draw();
コード例 #10
0
		$page->add($form);
	} else {
		$form = new Form($lang->get("stats", "Statistics"));

		$page_action = "UPDATE";
		$langs = createDBCArray("internal_resources_languages", "LANGID", "1");

		for ($i = 0; $i < count($langs); $i++) {
			if ($vs != "0")
				syncronizeLanguage ($langs[$i]);

			$langname = getDBCell("internal_resources_languages", "NAME", "LANGID = '" . $langs[$i] . "'");
			$form->add(new Label("lbl", "Statistics for " . $langname, "standard", 2));
			$translated = countRows("internal_resources", "RESID", "LANGID='" . $langs[$i] . "' AND VALUE IS NOT NULL AND VALUE <>''");
			$nottranslated1 = countRows("internal_resources", "RESID", "LANGID='" . $langs[$i] . "' AND VALUE IS NULL");
			$nottranslated2 = countRows("internal_resources", "RESID", "LANGID='" . $langs[$i] . "' AND VALUE =''");
			$nottranslated = $nottranslated1 + $nottranslated2;
			$form->add(new Label("lbl", "Translated: " . $translated, "standardlight"));
			$form->add(new Label("lbl", "Not translated: " . $nottranslated, "standardlight"));
			$form->add(new Separator());
		}

		$page->add($form);
	}

	$page->addMenu($filtermenu);
	$page->draw();
	$db->close();

	/**
	 * Checks, if for a given language the translation flag exists
コード例 #11
0
		/**
		   * Syncs an ACLObject. Compare to sync, but does not write accessors.
		   */
		function syncEx() {
			if (countRows("acl_management", "GUID", "GUID = " . $this->guid) < 1) {
				$crs = new CreateSet("acl_management");

				$crs->add("GUID", $this->guid, "NUMBER");
				$crs->add("TYPE_ID", $this->typeId, "NUMBER");
				$crs->execute();
			}

			// now save the data...
			$this->saveEx();
		}
コード例 #12
0
		$clt = getDBCell("sitepage_master", "CLT_ID", $cond);

		$clttype = getDBCell("sitepage_master", "SPMTYPE_ID", $cond);
		$clttypename = getDBCell("sitepage_types", "NAME", "SPMTYPE_ID = $clttype");
		$cltname = getDBCell("cluster_templates", "NAME", "CLT_ID = $clt");
		$form->add(new Label("lbl", $lang->get("spm_type"), "standard"));
		$form->add(new Label("lbl", $clttypename, "standard"));
		$form->add(new Label("lbl", $lang->get("spm_cluster"), "standard"));
		$form->add(new Label("lbl", $cltname, "standard"));
	}

	//$form->add(new SelectOneInput($lang->get("spm_meta"), "sitepage_master", "MT_ID", "meta_templates", "NAME", "MT_ID", "INTERNAL=0", $cond, "type:dropdown", "MANDATORY")); 
	$form->add(new SelectMultiple2Input($lang->get("spm_variations"), "sitepage_variations", "VARIATION_ID", $cond, "variations", "NAME", "VARIATION_ID", "DELETED=0"));

	// forbid deletion, until no more SPMs are used in sitemap.
	$amount = countRows("sitemap", "MENU_ID", "SPM_ID = $oid AND DELETED=0");

	if ($amount > 0)
		$form->forbidDelete(true);

	$form->registerActionHandler($deleteHandler);
	$form->registerActionHandler($insertHandler);
	$form->registerActionHandler($updateHandler);
	$form->add(new Hidden("action", ""));
	$page->addMenu($filtermenu);
	$page->add($form);
	$page->drawAndForward("modules/pagetemplate/sitepage_master.php?sid=$sid&go=update&oid=<oid>");
	$db->close();
	
	
	/**
コード例 #13
0
		$allowedVariations = createDBCArray("sitepage_variations", "VARIATION_ID", "SPM_ID = $spm");

		$commatext = implode(", ", $allowedVariations);
		$variations = createNameValueArray("variations", "NAME", "VARIATION_ID", "DELETED=0 AND VARIATION_ID IN ($commatext)");
	}

	$switchbar->setVariationSelector($variations, $variation);

	if ($mpProp) {
		$backup = $spid;

		$spid = $menuID;
	}

	// synchronize.... because new feature
	if (countRows("sitepage_names", "SPID", "SPID = $spid AND VARIATION_ID = $variation") < 1) {
		$sql = "INSERT INTO sitepage_names (SPID, VARIATION_ID) VALUES ($spid, $variation)";

		$query = new query($db, $sql);
		$query->free();
	}

	$menuPanel->add($switchbar);
	$menuPanel->add(new Cell('clc', '', 3, 600,10));
	$menuPanel->add(new SubTitle("st", $lang->get("sp_menuprops"), 3));
	$menuPanel->add(new Cell('clc', '', 3, 600,10));
	$menuPanel->add(new TextInput($lang->get("sp_menuname"), "sitepage_names", "NAME", "VARIATION_ID = $variation AND SPID = $spid", "type:text,size:128,width:300", ""));
	$menuPanel->add(new TextInput($lang->get("sp_menudescription", "Page Description (for sitemap...)"), "sitepage_names","HELP", "VARIATION_ID = $variation AND SPID = $spid", "type:textarea,size:5,width:400", ""));
	$menuPanel->add(new Label('lbl', $lang->get('url', 'URL'), 'standard',1));
	$uri = getPageURL($menuID, $variation);
	if (file_exists($c["livepath"].$uri)) {
コード例 #14
0
	$page->setJS('TREE');
	$action = value("action");

	$mid = value("mid", "NUMERIC");
	$spid = value("oid", "NUMERIC");	
	$isDeletable = (defined('ADMINMODE') || (getDBCell("sitepage", "DELETABLE", "SPID = $spid")=='1'));
	
	if ($mid == "0" && $spid != "0") 
		$mid = getDBCell("sitepage", "MENU_ID", "SPID = $spid");
	if ($mid == "") $mid = "0";

		if (value("jump") != "0") {
		  $oid = value("oid");
		  if (! is_numeric($oid)) $oid="-1";

		if (countRows("sitepage", "SPID", "SPID=$oid") > 0) {
			// check if is live id...
			$check = getDBCell("state_translation", "IN_ID", "OUT_ID=$oid");

			if ($check != "")
				$oid = $check;

			// start processing
			$spm = getDBCell("sitepage", "SPM_ID", "SPID=$oid");
			$sptype = getDBCell("sitepage_master", "SPMTYPE_ID", "SPM_ID = $spm");

			if ($sptype == 1) {
				$action = "editobject";

				$omid = getDBCell("sitepage", "MENU_ID", "SPID=$oid");
				$mid = getDBCell("sitemap", "PARENT_ID", "MENU_ID = $omid");
コード例 #15
0
ファイル: menu.php プロジェクト: BackupTheBerlios/nxwcms-svn
	 	/**
		 * Returns a menu-object with the menu corresponding to the pageId
		 * @param integer PageID, you want to set as menu start node.
		 */
		function getMenuById($pageId) {
			// check, if ID is a page.
			if (countRows("sitepage", "SPID", "SPID=$pageId") < 1) {
				return null;
			} else {
			  return $this->createInstance(null, $pageId, $this->variation, $this->level); 
			}  
		}
コード例 #16
0
ファイル: meta.php プロジェクト: BackupTheBerlios/nxwcms-svn
	$filter->icon = "li_meta.gif";
	$filter->type_name = "Meta Templates";

	$filtermenu = new Filtermenu($lang->get("metatemplates"), $filter);
	
	$deleteHandler = new ActionHandler("DELETE");
	// add update action for referenced meta-templates!!!
	$deleteHandler->addDbAction("DELETE FROM meta_templates where MT_ID=$oid and MT_ID > 999");
	$deleteHandler->addDbAction("DELETE FROM meta_template_items where MT_ID=$oid and MT_ID>999");

	$form = new stdEDForm($lang->get("mt_properties"), "i_meta.gif");
	$cond = $form->setPK("meta_templates", "MT_ID");
	$form->add(new TextInput($lang->get("name"), "meta_templates", "NAME", $cond, "type:text,width:200,size:32", "MANDATORY&UNIQUE"));
	$form->add(new TextInput($lang->get("description"), "meta_templates", "DESCRIPTION", $cond, "type:textarea,width:300,size:4", ""));
	$form->registerActionHandler($deleteHandler);
	//check, if deletion is alowed or not.
	$amount = countRows("cluster_templates", "MT_ID", "MT_ID = $oid");
	$amount += countRows("content", "MT_ID", "MT_ID = $oid");

	if ($amount > 0)
		$form->forbidDelete(true);

	if ($page_action == 'UPDATE' || $page_action == "DELETE" || ($page_action=="INSERT" && $page_state == 'processing' && $errors == "")) {
		$form->headerlink = crHeaderLink($lang->get('mt_scheme', 'Edit Scheme'), 'modules/meta/metascheme.php?sid='.$sid.'&oid=<oid>&go=update');
	}

	$page->addMenu($filtermenu);
	$page->add($form);
	$page->draw();
	$db->close();
?>
コード例 #17
0
    }
    if ($aclf->checkAccessToFunction("B_LAUNCH_TREE")) {
        $clustereditbar->addAction($lang->get('launch_tree', "Launch Tree"));
    }
    if ($aclf->checkAccessToFunction("B_RELAUNCH_TREE")) {
        $clustereditbar->addAction($lang->get("sp_rltree", "Refresh Tree"));
    }
    if ($aclf->checkAccessToFunction("B_EXPIRE_TREE")) {
        $clustereditbar->addAction($lang->get('exp_tree', 'Expire Tree'));
    }
    if ($aclf->checkAccessToFunction("B_DESTROY_TREE") && $isDeletable) {
        $clustereditbar->addAction('separator');
        $clustereditbar->addAction($lang->get('del_tree', 'Delete Tree'));
    }
}
if (!$c["disableTranslationHelp"] && $editState && countRows("variations", "VARIATION_ID", "1") > 1) {
    $toolbar = new Buttonbar("Toolbar");
    $toolbar->selectBoxDescr = true;
    $toolbar->setTranslationSelector(createNameValueArrayEx("variations", "NAME", "VARIATION_ID", "VARIATION_ID <>" . variation()), translation());
    if (!$isArticle) {
        $toolbar->setVariationSelector(populateVariations($clnid, variation()), variation());
    }
    $clusterPanel->add($toolbar);
}
// PANELS
// Edit-Content Panel.
// include needed sources
includePGNISources();
//Plugin Sources.
$clid = getClusterFromNode($clnid, $variation);
if ($view == $pos_clusterPanel) {
コード例 #18
0
	function destroyTree() {
		global $destroyexecuted, $form, $db;

		$variations = createDBCArray("variations", "VARIATION_ID", "1");

		if (!$destroyexecuted) {
			$destroyexecuted = true;

			$delstart = value("del", "NUMERIC");
			$parentId = getDBCell("sitemap", "PARENT_ID", "MENU_ID = $delstart");
			$destroyArray = getPageTree($delstart);

			if (value("destroypages") == "0") {
				// geht nicht
				$meldung = "Please select also the check Destroy Tree. Only then the system will delete the tree.";

				$form->addToTopText($meldung);
			} else {
				if (value("destroycluster") == "0") {
					// nur pages löschen
					for ($i = 0; $i < count($destroyArray); $i++) {
						for ($j = 0; $j < count($variations); $j++) {
							expireSitepage($destroyArray[$i], 10, $variations[$j]);
						}

						$sql1 = "DELETE FROM sitepage WHERE SPID = $destroyArray[$i]";
						$menuid = getDBCell("sitepage", "MENU_ID", "SPID = " . $destroyArray[$i]);
						$deletequery = new query($db, $sql1);

						if ($menuid != "0" and $menuid != 0 and $menuid != "") {
							$sql2 = "DELETE FROM sitemap WHERE MENU_ID = $menuid";

							$sql3 = "DELETE FROM sitepage_names WHERE SPID = " . $destroyArray[$i];
							$sql4 = "DELETE FROM sitepage_owner WHERE SPID = " . $destroyArray[$i];

							$deletequery = new query($db, $sql3);
							$deletequery = new query($db, $sql4);
							$deletequery = new query($db, $sql2);
						}

						$deletequery->free();
					}
				} else {
					// pages und cluster
					for ($i = 0; $i < count($destroyArray); $i++) {
						for ($j = 0; $j < count($variations); $j++) {
							expireSitepage($destroyArray[$i], 10, $variations[$j]);
						}

						$clnid = getDBCell("sitepage", "CLNID", "SPID = $destroyArray[$i]");
						// only delete cluster if it is not used as channel article.
						if (!getDBCell("channel_articles", "CHID", "ARTICLE_ID = ".$clnid)) {
							$usage = 0;
							$usage += countRows("sitepage", "CLNID", "CLNID = $clnid AND DELETED=0");
							$usage += countRows("cluster_content", "FKID", "FKID = $clnid");
							$usage += countRows("cluster_template_items", "FDIK", "FKID = $clnid");
	
							if ($usage < 2) {
								$sql = "UPDATE cluster_node SET DELETED = 1 WHERE CLNID = $clnid";
	
								$query = new query($db, $sql);
							}
						}

						$sql1 = "DELETE FROM sitepage WHERE SPID = $destroyArray[$i]";
						$menuid = getDBCell("sitepage", "MENU_ID", "SPID = " . $destroyArray[$i]);
						$deletequery = new query($db, $sql1);

						if ($menuid != "0" and $menuid != 0 and $menuid != "") {
							$sql2 = "DELETE FROM sitemap WHERE MENU_ID = $menuid";

							$sql3 = "DELETE FROM sitepage_names WHERE SPID = " . $destroyArray[$i];
							$sql4 = "DELETE FROM sitepage_owner WHERE SPID = " . $destroyArray[$i];

							$deletequery = new query($db, $sql3);
							$deletequery = new query($db, $sql4);
							$deletequery = new query($db, $sql2);
						}

						$deletequery->free();
					
					}
				}
			}
			sortTableRows("sitemap", "MENU_ID", "POSITION", "PARENT_ID = $parentId");
		}
		
	}
コード例 #19
0
ファイル: register.php プロジェクト: holybom/ubcair
        	
        // Create sequence
        executePlainSQL("create sequence cid_sequence 
        				start with 0 
        				increment by 1 
        				minvalue 0
        				maxvalue 100000");
        
        				
        OCICommit($db_conn);
        */
    } else {
        if (array_key_exists('insertsubmit', $_POST)) {
            // check if email is taken
            $q = "select * from Customer where email = '" . $_POST['email'] . "'";
            $numrows = countRows($db_conn, $q);
            if ($numrows == 1) {
                $success = 0;
                ?>
				<script type="text/javascript"> 
					alert("Error: Email address already registered. Please try a different email address"); 
				</script>
				<?php 
            } else {
                $success = 1;
                //Getting the values from user and insert data into the table
                $tuple = array(":bind1" => $_POST['cid'], ":bind2" => $_POST['email'], ":bind3" => $_POST['password'], ":bind4" => $_POST['cname'], ":bind5" => $_POST['passport_country'], ":bind6" => $_POST['passport_num'], ":bind7" => $_POST['phone#'], ":bind8" => $_POST['address'], ":bind9" => 0);
                $alltuples = array($tuple);
                executeBoundSQL("insert into Customer values (\r\n\t\t\t\t\t\t\t\tcid_sequence.nextval, \t\r\n\t\t\t\t\t\t\t\t:bind2,\r\n\t\t\t\t\t\t\t\t:bind3,\r\n\t\t\t\t\t\t\t\t:bind4,\r\n\t\t\t\t\t\t\t\t:bind5,\r\n\t\t\t\t\t\t\t\t:bind6,\r\n\t\t\t\t\t\t\t\t:bind7,\r\n\t\t\t\t\t\t\t\t:bind8,\r\n\t\t\t\t\t\t\t\t:bind9\r\n\t\t\t\t\t\t\t\t)", $alltuples);
                OCICommit($db_conn);
            }
コード例 #20
0
ファイル: login.php プロジェクト: holybom/ubcair
	<div class="banner">
    <h1 class="banner-head">
        Welcome to UBC Air
    </h1>
</div>

<?php 
session_start();
include 'oci_functions.php';
// connect to database
if ($db_conn) {
    if (!empty($_POST['email']) && !empty($_POST['password']) && !array_key_exists('login', $_COOKIE)) {
        $email = $_POST['email'];
        $password = $_POST['password'];
        $loginquery = "SELECT * FROM Customer WHERE email = '" . $email . "' AND password = '******'";
        $numrows = countRows($db_conn, $loginquery);
        if ($numrows == 1) {
            $stmt = oci_parse($db_conn, $loginquery);
            $r = oci_execute($stmt, OCI_DEFAULT);
            $row = oci_fetch_array($stmt, OCI_BOTH);
            setcookie('loggedin', 1);
            setcookie('cid', $row['CID']);
            setcookie('cname', $row['CNAME']);
            // Go to customer only page
            header('Location: support.php');
        } else {
            ?>
			<script type="text/javascript"> 
				alert("Unable to sign in. Please check your username and password combination.");
				location = "login.php";
			</script>
コード例 #21
0
    return $_FILES['file']['type'];
}
function getName()
{
    return $_FILES['file']['name'];
}
$performPost = function () {
    validateUser();
    $id = getParameter(PARAMETER_ID, PARAMETER_REQUIRED);
    $dataType = getParameter(PARAMETER_DATA_TYPE, PARAMETER_REQUIRED);
    $contentType = getContentType();
    $data = getData();
    $name = getName();
    $insert = withStatement("SELECT id FROM DATA WHERE id=?", function ($statement) use($id) {
        $statement->bind_param("s", $id);
        return countRows($statement) == 0;
    });
    if ($insert) {
        withStatement("INSERT INTO DATA(id,dataType,contentType,data, name) VALUES(?,?,?,?,?)", function ($statement) use($id, $dataType, $contentType, $data, $name) {
            $statement->bind_param("sssss", $id, $dataType, $contentType, $data, $name);
            executeStatement($statement);
        });
    } else {
        withStatement("UPDATE DATA SET data=?,dataType=?,contentType=?,name=? WHERE id=?", function ($statement) use($id, $dataType, $contentType, $data, $name) {
            $statement->bind_param("sssss", $data, $dataType, $contentType, $name, $id);
            executeStatement($statement);
        });
    }
};
validateUser();
handleRequest(array("POST" => $performPost));
コード例 #22
0
ファイル: pdo_017.php プロジェクト: lsqtongxin/hhvm
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
    $suf = ' ENGINE=' . MySQLPDOTest::detect_transactional_mysql_engine($db);
} else {
    $suf = '';
}
$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10))' . $suf);
$db->exec("INSERT INTO test VALUES(1, 'A')");
$db->exec("INSERT INTO test VALUES(2, 'B')");
$db->exec("INSERT INTO test VALUES(3, 'C')");
$delete = $db->prepare('DELETE FROM test');
function countRows($action)
{
    global $db;
    $select = $db->prepare('SELECT COUNT(*) FROM test');
    $select->execute();
    $res = $select->fetchColumn();
    return "Counted {$res} rows after {$action}.\n";
}
echo countRows('insert');
$db->beginTransaction();
$delete->execute();
echo countRows('delete');
$db->rollBack();
echo countRows('rollback');
$db->beginTransaction();
$delete->execute();
echo countRows('delete');
$db->commit();
echo countRows('commit');
コード例 #23
0
ファイル: auth.php プロジェクト: BackupTheBerlios/nxwcms-svn
 /**
  * Checks, whether a user is in a group or not.
  * @param string Name of the group.
  * @returns boolean true|false
  */
 function isInGroup($groupName)
 {
     $groupName = strtoupper($groupName);
     $groupId = getDBCell("groups", "GROUP_ID", "UPPER(GROUP_NAME) = '{$groupName}'");
     if ($groupId != "") {
         if (countRows("user_permissions", "GROUP_ID", "GROUP_ID = {$groupId} AND USER_ID = " . $this->userId) > 0) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #24
0
	/**
	 * delete all expired contents form the database (at least try it :-))
	 */
	function purgeExpired() {
		global $db;

		$delHandler = new ActionHandler("del");
		$expired = createDBCArray("state_translation", "OUT_ID", "EXPIRED=1");

		for ($i = 0; $i < count($expired); $i++) {
			$id = $expired[$i];

			// the ID can be wether a sitemap-entry or a sitepage-entry.
			$sitepage = countRows("sitepage", "SPID", "SPID = $id");
			$sitemap = countRows("sitemap", "MENU_ID", "MENU_ID = $id");

			if ($sitemap > 0)
				$delHandler->addDBAction("UPDATE sitemap SET DELETED=1 WHERE MENU_ID = $id");

			if ($sitepage > 0) {
				$delHandler->addDBAction("UPDATE sitepage SET DELETED=1 WHERE SPID = $id");
			}
		}

		// step ready, so process.
		$delHandler->process("del");
		$delHandler = new ActionHandler("del");

		// check, whether all sitepage_masters are require_onced in live-instance.
		$spms = createDBCArray("sitepage_master", "SPM_ID", "DELETED=0 AND VERSION=10");

		for ($i = 0; $i < count($spms); $i++) {
			$id = $spms[$i];

			$check = countRows("sitepage", "SPID", "SPM_ID = $id AND DELETED = 0 AND VERSION = 10");

			if ($check == 0)
				$delHandler->addDBAction("UPDATE sitepage_master SET DELETED=1 WHERE SPM_ID = $id");
		}

		// step ready, so process.
		$delHandler->process("del");
		$delHandler = new ActionHandler("del");

		// check, whether all cluster-templates are still require_onced.
		$clts = createDBCArray("cluster_templates", "CLT_ID", "DELETED=0 AND VERSION=10");

		for ($i = 0; $i < count($clts); $i++) {
			$id = $clts[$i];

			$check = countRows("sitepage_master", "CLT_ID", "CLT_ID = $id AND DELETED = 0 AND VERSION = 10");
			$clnids = createDBCArray("cluster_node", "CLNID", "CLT_ID = $id AND VERSION=10");

			for ($j = 0; $j < count($clnids); $j++) {
				$check += countRows("cluster_template_items", "CLTI_ID", "FKID = " . $clnids[$j]);
			}

			if ($check == 0)
				$delHandler->addDBAction("UPDATE cluster_templates SET DELETED=1 WHERE CLT_ID = $id");
		}

		// step ready, so process.
		$delHandler->process("del");
		$delHandler = new ActionHandler("del");

		// check, whether all meta-templates are still require_onced.
		$meta = createDBCArray("meta_templates", "MT_ID", "DELETED=0 AND VERSION=10");

		for ($i = 0; $i < count($meta); $i++) {
			$id = $meta[$i];

			$check = countRows("cluster_templates", "MT_ID", "MT_ID = $id AND DELETED = 0 AND VERSION = 10");
			$backtrans = getDBCell("state_translation", "IN_ID", "OUT_ID = $id AND LEVEL = 10");
			$check += countRows("modules", "MT_ID", "MT_ID = $backtrans");

			if ($backtrans < 1000)
				$check += 1;

			$check += countRows("content", "MT_ID", "MT_ID = $id AND DELETED=0 AND VERSION = 10");

			if ($check == 0) {
				$delHandler->addDBAction("DELETE FROM meta_templates WHERE MT_ID = $id");

				$delHandler->addDBAction("DELETE FROM meta_template_items WHERE MT_ID = $id");
			}
		}

		// step ready, so process.
		$delHandler->process("del");
		$delHandler = new ActionHandler("del");
		
		// check, whether all clusters are still required.
		// note: checks for variations are not done here, as there may be dependencies between 
		// standard and other variations.
		$clids = createDBCArray("cluster_node", "CLNID", "DELETED=0 AND VERSION=10");

		for ($i = 0; $i < count($clids); $i++) {
			$id = $clids[$i];

			$check = countRows("sitepage", "CLNID", "CLNID = $id AND DELETED = 0 AND VERSION = 10");
			$check += countRows("cluster_template_items", "FKID", "FKID = $id AND DELETED = 0 AND VERSION = 10");
			$check += countRows("cluster_content", "FKID", "FKID = $id AND DELETED = 0");

			if ($check == 0)
				$delHandler->addDBAction("UPDATE cluster_node SET DELETED=1 WHERE CLNID = $id");
		}

		// step ready, so process.
		$delHandler->process("del");
		$delHandler = new ActionHandler("del");
	}