code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
$doRegist = (strpos($cmd, '*') !== false);
if (! $doRegist) {
$_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);');
$doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd))));
}
if ($doRegist) {
if (! is_array($handlers) || is_object($handlers[0])) {
$handlers = array($handlers);
}
foreach($handlers as $handler) {
if ($handler) {
if (is_string($handler) && strpos($handler, '.')) {
list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, '');
if (strcasecmp($_domain, 'plugin') === 0) {
if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array())
and method_exists($plugin, $_method)) {
$this->bind($cmd, array($plugin, $_method));
}
}
} else {
$this->bind($cmd, $handler);
}
}
}
}
}
} | Base | 1 |
$controller = new $ctlname();
if (method_exists($controller,'isSearchable') && $controller->isSearchable()) {
// $mods[$controller->name()] = $controller->addContentToSearch();
$mods[$controller->searchName()] = $controller->addContentToSearch();
}
}
uksort($mods,'strnatcasecmp');
assign_to_template(array(
'mods'=>$mods
));
} | Class | 2 |
function db_case($array)
{
global $DatabaseType;
$counter = 0;
if ($DatabaseType == 'mysqli') {
$array_count = count($array);
$string = " CASE WHEN $array[0] =";
$counter++;
$arr_count = count($array);
for ($i = 1; $i < $arr_count; $i++) {
$value = $array[$i];
if ($value == "''" && substr($string, -1) == '=') {
$value = ' IS NULL';
$string = substr($string, 0, -1);
}
$string .= "$value";
if ($counter == ($array_count - 2) && $array_count % 2 == 0)
$string .= " ELSE ";
elseif ($counter == ($array_count - 1))
$string .= " END ";
elseif ($counter % 2 == 0)
$string .= " WHEN $array[0]=";
elseif ($counter % 2 == 1)
$string .= " THEN ";
$counter++;
}
}
return $string;
} | Base | 1 |
public function __construct(
AuthManager $auth,
Encrypter $encrypter,
Google2FA $google2FA,
Repository $config,
CacheRepository $cache,
RecoveryTokenRepository $recoveryTokenRepository,
UserRepositoryInterface $repository
) {
parent::__construct($auth, $config);
$this->google2FA = $google2FA;
$this->cache = $cache;
$this->repository = $repository;
$this->encrypter = $encrypter;
$this->recoveryTokenRepository = $recoveryTokenRepository;
} | Class | 2 |
public function approve_toggle() {
if (empty($this->params['id'])) return;
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];
// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];
// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];
// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];
$comment = new expComment($this->params['id']);
$comment->approved = $comment->approved == 1 ? 0 : 1;
if ($comment->approved) {
$this->sendApprovalNotification($comment,$this->params);
}
$comment->save();
expHistory::back();
} | Base | 1 |
public function testOpen()
{
$this->mock->expects($this->once())
->method('open')
->will($this->returnValue(true));
$this->assertFalse($this->proxy->isActive());
$this->proxy->open('name', 'id');
if (PHP_VERSION_ID < 50400) {
$this->assertTrue($this->proxy->isActive());
} else {
$this->assertFalse($this->proxy->isActive());
}
} | Base | 1 |
function update_vendor() {
$vendor = new vendor();
$vendor->update($this->params['vendor']);
expHistory::back();
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
$this->response->html($this->template->render('project_tag/remove', array(
'tag' => $tag,
'project' => $project,
)));
} | Base | 1 |
public function enable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->enable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public static function isAnimationGif($path) {
list($width, $height, $type, $attr) = getimagesize($path);
switch ($type) {
case IMAGETYPE_GIF:
break;
default:
return false;
}
$imgcnt = 0;
$fp = fopen($path, 'rb');
@fread($fp, 4);
$c = @fread($fp,1);
if (ord($c) != 0x39) { // GIF89a
return false;
}
while (!feof($fp)) {
do {
$c = fread($fp, 1);
} while(ord($c) != 0x21 && !feof($fp));
if (feof($fp)) {
break;
}
$c2 = fread($fp,2);
if (bin2hex($c2) == "f904") {
$imgcnt++;
}
if (feof($fp)) {
break;
}
}
if ($imgcnt > 1) {
return true;
} else {
return false;
}
} | Base | 1 |
function reset_stats() {
// global $db;
// reset the counters
// $db->sql ('UPDATE '.$db->prefix.'banner SET impressions=0 WHERE 1');
banner::resetImpressions();
// $db->sql ('UPDATE '.$db->prefix.'banner SET clicks=0 WHERE 1');
banner::resetClicks();
// let the user know we did stuff.
flash('message', gt("Banner statistics reset."));
expHistory::back();
} | Base | 1 |
function searchByModelForm() {
// get the search terms
$terms = $this->params['search_string'];
$sql = "model like '%" . $terms . "%'";
$limit = !empty($this->config['limit']) ? $this->config['limit'] : 10;
$page = new expPaginator(array(
'model' => 'product',
'where' => $sql,
'limit' => !empty($this->config['pagination_default']) ? $this->config['pagination_default'] : $limit,
'order' => 'title',
'dir' => 'DESC',
'page' => (isset($this->params['page']) ? $this->params['page'] : 1),
'controller' => $this->params['controller'],
'action' => $this->params['action'],
'columns' => array(
gt('Model #') => 'model',
gt('Product Name') => 'title',
gt('Price') => 'base_price'
),
));
assign_to_template(array(
'page' => $page,
'terms' => $terms
));
} | Class | 2 |
function show_vendor () {
$vendor = new vendor();
if(isset($this->params['id'])) {
$vendor = $vendor->find('first', 'id =' .$this->params['id']);
$vendor_title = $vendor->title;
$state = new geoRegion($vendor->state);
$vendor->state = $state->name;
//Removed unnecessary fields
unset(
$vendor->title,
$vendor->table,
$vendor->tablename,
$vendor->classname,
$vendor->identifier
);
assign_to_template(array(
'vendor_title' => $vendor_title,
'vendor'=>$vendor
));
}
} | Base | 1 |
public function remind()
{
/*if (!check_captcha())
{
$this->templatemanager->notify_next(__("You have entered wrong security code."), "error", __("Error!"));
redirect("administration/auth/forgot");
die;
}//*/
$email = trim($this->input->post("email", true));
$u = User::factory()->get_by_email($email);
if (!$u->exists())
{
$this->templatemanager->notify_next(__("User with that e-mail does not exists!"), "error", __("Error"));
redirect("administration/auth/forgot");
}
$u->key = random_string('unique');
$u->save();
Log::write('requested password change', LogSeverity::Notice, $u->id);
//set variables for template
$vars = array(
'name'=>$u->name
,'email'=>$u->email
,'website_title'=>Setting::value('website_title', CS_PRODUCT_NAME)
,'reset_link'=>site_url('administration/auth/resetpass/'.$u->id.'/'.$u->key)
,'site_url'=>site_url()
);
//get email template
$template = file_get_contents(APPPATH . "templates/forgot_password.html");
$template = __($template, null, 'email');
$template .= "<br />\n<br />\n<br />\n" . __(file_get_contents(APPPATH . "templates/signature.html"), null, 'email');
$template = parse_template($template, $vars);
//send email
$this->email->to("$email");
$this->email->subject(__("%s password reset", Setting::value('website_title', CS_PRODUCT_NAME), 'email'));
$this->email->message($template);
$this->email->set_alt_message(strip_tags($template));
$from = Setting::value("default_email", false);
if (empty($from))
$from = "noreply@".get_domain_name(true);
$this->email->from($from);
$sent = $this->email->send();
if ($sent)
$this->templatemanager->notify_next(__("Please check your e-mail for further information."), "notice", __("Notice"));
else
$this->templatemanager->notify_next(__("Activation e-mail could not be sent!"), "error", __("Error"));
redirect("administration/auth/login");
} | Base | 1 |
public function getQueryOrderby()
{
return '`' . $this->name . '`';
} | Base | 1 |
public function showUnpublished() {
expHistory::set('viewable', $this->params);
// setup the where clause for looking up records.
$where = parent::aggregateWhereClause();
$where = "((unpublish != 0 AND unpublish < ".time().") OR (publish > ".time().")) AND ".$where;
if (isset($this->config['only_featured'])) $where .= ' AND is_featured=1';
$page = new expPaginator(array(
'model'=>'news',
'where'=>$where,
'limit'=>25,
'order'=>'unpublish',
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->baseclassname,
'action'=>$this->params['action'],
'src'=>$this->loc->src,
'columns'=>array(
gt('Title')=>'title',
gt('Published On')=>'publish',
gt('Status')=>'unpublish'
),
));
assign_to_template(array(
'page'=>$page
));
} | Class | 2 |
public function search() {
// global $db, $user;
global $db;
$sql = "select DISTINCT(a.id) as id, a.firstname as firstname, a.middlename as middlename, a.lastname as lastname, a.organization as organization, a.email as email ";
$sql .= "from " . $db->prefix . "addresses as a "; //R JOIN " .
//$db->prefix . "billingmethods as bm ON bm.addresses_id=a.id ";
$sql .= " WHERE match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] .
"*' IN BOOLEAN MODE) ";
$sql .= "order by match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) ASC LIMIT 12";
$res = $db->selectObjectsBySql($sql);
foreach ($res as $key=>$record) {
$res[$key]->title = $record->firstname . ' ' . $record->lastname;
}
//eDebug($sql);
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
} | Class | 2 |
$loc = expCore::makeLocation('navigation', '', $standalone->id);
if (expPermissions::check('manage', $loc)) return true;
}
return false;
}
| Base | 1 |
foreach ($flatArray as $key => $value) {
$pattern = '/' . $key . '([^.]|$)/';
if (preg_match($pattern, $expression, $matches)) {
switch (gettype($flatArray[$key])) {
case 'boolean':
$expression = str_replace($key, $flatArray[$key] ? 'true' : 'false', $expression);
break;
case 'NULL':
$expression = str_replace($key, 'false', $expression);
break;
case 'string':
$expression = str_replace($key, '"' . $flatArray[$key] . '"', $expression);
break;
case 'object':
$expression = self::executeClosure($expression, $key, $flatArray[$key], $flatArray);
break;
default:
$expression = str_replace($key, $flatArray[$key], $expression);
break;
}
$bool = eval("return $expression;");
}
} | Variant | 0 |
$percent = round($percent, 0);
} else {
$percent = round($percent, 2); // school default
}
if ($ret == '%')
return $percent;
if (!$_openSIS['_makeLetterGrade']['grades'][$grade_scale_id])
$_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] = DBGet(DBQuery('SELECT TITLE,ID,BREAK_OFF FROM report_card_grades WHERE SYEAR=\'' . $cp[1]['SYEAR'] . '\' AND SCHOOL_ID=\'' . $cp[1]['SCHOOL_ID'] . '\' AND GRADE_SCALE_ID=\'' . $grade_scale_id . '\' ORDER BY BREAK_OFF IS NOT NULL DESC,BREAK_OFF DESC,SORT_ORDER'));
foreach ($_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] as $grade) {
if ($does_breakoff == 'Y' ? $percent >= $programconfig[$staff_id][$course_period_id . '-' . $grade['ID']] && is_numeric($programconfig[$staff_id][$course_period_id . '-' . $grade['ID']]) : $percent >= $grade['BREAK_OFF'])
return $ret == 'ID' ? $grade['ID'] : $grade['TITLE'];
}
} | Base | 1 |
public function manage_sitemap() {
global $db, $user, $sectionObj, $sections;
expHistory::set('viewable', $this->params);
$id = $sectionObj->id;
$current = null;
// all we need to do is determine the current section
$navsections = $sections;
if ($sectionObj->parent == -1) {
$current = $sectionObj;
} else {
foreach ($navsections as $section) {
if ($section->id == $id) {
$current = $section;
break;
}
}
}
assign_to_template(array(
'sasections' => $db->selectObjects('section', 'parent=-1'),
'sections' => $navsections,
'current' => $current,
'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),
));
}
| Base | 1 |
static function validUTF($string) {
if(!mb_check_encoding($string, 'UTF-8') OR !($string === mb_convert_encoding(mb_convert_encoding($string, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {
return false;
}
return true;
} | Base | 1 |
public function fixsessions() {
global $db;
// $test = $db->sql('CHECK TABLE '.$db->prefix.'sessionticket');
$fix = $db->sql('REPAIR TABLE '.$db->prefix.'sessionticket');
flash('message', gt('Sessions Table was Repaired'));
expHistory::back();
} | Base | 1 |
public function update_discount() {
$id = empty($this->params['id']) ? null : $this->params['id'];
$discount = new discounts($id);
// find required shipping method if needed
if ($this->params['required_shipping_calculator_id'] > 0) {
$this->params['required_shipping_method'] = $this->params['required_shipping_methods'][$this->params['required_shipping_calculator_id']];
} else {
$this->params['required_shipping_calculator_id'] = 0;
}
$discount->update($this->params);
expHistory::back();
} | Base | 1 |
public function getQuerySelect()
{
$R1 = 'R1_' . $this->field->id;
$R2 = 'R2_' . $this->field->id;
return "$R2.id AS `" . $this->field->name . "`";
} | Base | 1 |
unset($return[$key]);
}
}
break;
}
return @array_change_key_case($return, CASE_UPPER);
} | Base | 1 |
public function actionDeleteDropdown() {
$dropdowns = Dropdowns::model()->findAll();
if (isset($_POST['dropdown'])) {
if ($_POST['dropdown'] != Actions::COLORS_DROPDOWN_ID) {
$model = Dropdowns::model()->findByPk($_POST['dropdown']);
$model->delete();
$this->redirect('manageDropDowns');
}
}
$this->render('deleteDropdowns', array(
'dropdowns' => $dropdowns,
));
} | Base | 1 |
public static function showModal($params) {
if (!isset($params['argument']) || empty($params['argument'])) {
return array(
'processed' => true,
'process_status' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chatcommand', 'Please provide modal URL!')
);
}
$paramsURL = explode(' ',$params['argument']);
$URL = array_shift($paramsURL);
if (is_numeric($URL)) {
$URL = (erLhcoreClassSystem::$httpsMode == true ? 'https:' : 'http:') . '//' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '') . erLhcoreClassDesign::baseurldirect('form/formwidget') . '/' . $URL;
} | Class | 2 |
function storeSerializedSession($serialized_session_data, $session_id)
{
$doSession = OA_Dal::staticGetDO('session', $session_id);
if ($doSession) {
$doSession->sessiondata = $serialized_session_data;
$doSession->update();
}
else {
$doSession = OA_Dal::factoryDO('session');
$doSession->sessionid = $session_id;
$doSession->sessiondata = $serialized_session_data;
$doSession->insert();
}
} | Compound | 4 |
public static function recent($vars, $type = 'post') {
$sql = "SELECT * FROM `posts` WHERE `type` = '{$type}' ORDER BY `date` DESC LIMIT {$vars}";
$posts = Db::result($sql);
if(isset($posts['error'])){
$posts['error'] = "No Posts found.";
}else{
$posts = $posts;
}
return $posts;
} | Base | 1 |
public function __construct($site)
{
// If the REST API Proxy Plugin isn't active, always use the current site.
if(! PMB_REST_PROXY_EXISTS){
$site = '';
}
$this->setSite($site);
$this->getSiteInfo();
} | Base | 1 |
public function testEncrypt($string, $key, $expected) {
$this->string(\Toolbox::encrypt($string, $key))->isIdenticalTo($expected);
} | Class | 2 |
$contents = ['form' => tep_draw_form('testimonials', 'testimonials.php', 'page=' . $_GET['page'] . '&tID=' . $tInfo->testimonials_id . '&action=deleteconfirm')]; | Base | 1 |
function delete() {
global $db;
if (empty($this->params['id'])) return false;
$product_type = $db->selectValue('product', 'product_type', 'id=' . $this->params['id']);
$product = new $product_type($this->params['id'], true, false);
//eDebug($product_type);
//eDebug($product, true);
//if (!empty($product->product_type_id)) {
//$db->delete($product_type, 'id='.$product->product_id);
//}
$db->delete('option', 'product_id=' . $product->id . " AND optiongroup_id IN (SELECT id from " . $db->prefix . "optiongroup WHERE product_id=" . $product->id . ")");
$db->delete('optiongroup', 'product_id=' . $product->id);
//die();
$db->delete('product_storeCategories', 'product_id=' . $product->id . ' AND product_type="' . $product_type . '"');
if ($product->product_type == "product") {
if ($product->hasChildren()) {
$this->deleteChildren();
}
}
$product->delete();
flash('message', gt('Product deleted successfully.'));
expHistory::back();
} | Base | 1 |
foreach ($evs as $key=>$event) {
if ($condense) {
$eventid = $event->id;
$multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;'));
if (!empty($multiday_event)) {
unset($evs[$key]);
continue;
}
}
$evs[$key]->eventstart += $edate->date;
$evs[$key]->eventend += $edate->date;
$evs[$key]->date_id = $edate->id;
if (!empty($event->expCat)) {
$catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color);
// if (substr($catcolor,0,1)=='#') $catcolor = '" style="color:'.$catcolor.';';
$evs[$key]->color = $catcolor;
}
}
| Base | 1 |
public function testAddsSlashForRelativeUriStringWithHost()
{
$uri = (new Uri)->withPath('foo')->withHost('bar.com');
$this->assertEquals('foo', $uri->getPath());
$this->assertEquals('bar.com/foo', (string) $uri);
} | Base | 1 |
public function setPageTextMatch( array $pageTextMatch = [] ) {
$this->pageTextMatch = (array)$pageTextMatch;
} | Class | 2 |
function XMLRPCaddImageGroupToComputerGroup($imageGroup, $computerGroup){
$imageid = getResourceGroupID("image/$imageGroup");
$compid = getResourceGroupID("computer/$computerGroup");
if($imageid && $compid){
$tmp = getUserResources(array("imageAdmin"),
array("manageMapping"), 1);
$imagegroups = $tmp['image'];
$tmp = getUserResources(array("computerAdmin"),
array("manageMapping"), 1);
$computergroups = $tmp['computer'];
if(array_key_exists($compid, $computergroups) &&
array_key_exists($imageid, $imagegroups)){
$mapping = getResourceMapping("image", "computer",
$imageid,
$compid);
if(!array_key_exists($imageid, $mapping) ||
!array_key_exists($compid, $mapping[$imageid])){
$query = "INSERT INTO resourcemap "
. "(resourcegroupid1, "
. "resourcetypeid1, "
. "resourcegroupid2, "
. "resourcetypeid2) "
. "VALUES ($imageid, "
. "13, "
. "$compid, "
. "12)";
doQuery($query, 101);
}
return array('status' => 'success');
} else {
return array('status' => 'error',
'errorcode' => 84,
'errormsg' => 'cannot access computer and/or image group');
}
} else {
return array('status' => 'error',
'errorcode' => 83,
'errormsg' => 'invalid resource group name');
}
} | Class | 2 |
function gce_ajax_list() {
$nonce = $_POST['gce_nonce'];
// check to see if the submitted nonce matches with the
// generated nonce we created earlier
if ( ! wp_verify_nonce( $nonce, 'gce_ajax_nonce' ) ) {
die ( 'Request has failed.');
}
$grouped = $_POST['gce_grouped'];
$start = $_POST['gce_start'];
$ids = $_POST['gce_feed_ids'];
$title_text = $_POST['gce_title_text'];
$sort = $_POST['gce_sort'];
$paging = $_POST['gce_paging'];
$paging_interval = $_POST['gce_paging_interval'];
$paging_direction = $_POST['gce_paging_direction'];
$start_offset = $_POST['gce_start_offset'];
$paging_type = $_POST['gce_paging_type'];
if( $paging_direction == 'back' ) {
if( $paging_type == 'month' ) {
$this_month = mktime( 0, 0, 0, date( 'm', $start ) - 1, 1, date( 'Y', $start ) );
$prev_month = mktime( 0, 0, 0, date( 'm', $start ) - 2, 1, date( 'Y', $start ) );
$prev_interval_days = date( 't', $prev_month );
$month_days = date( 't', $this_month );
$int = $month_days + $prev_interval_days;
$int = $int * 86400;
$start = $start - ( $int );
$changed_month_days = date( 't', $start );
$paging_interval = $changed_month_days * 86400;
} else {
$start = $start - ( $paging_interval * 2 );
}
} else {
if( $paging_type == 'month' ) {
$days_in_month = date( 't', $start );
$paging_interval = 86400 * $days_in_month;
}
}
$d = new GCE_Display( explode( '-', $ids ), $title_text, $sort );
echo $d->get_list( $grouped, $start, $paging, $paging_interval, $start_offset );
die();
} | Base | 1 |
public function delete() {
global $db;
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];
// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];
// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];
// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('Missing id for the comment you would like to delete'));
expHistory::back();
}
// delete the comment
$comment = new expComment($this->params['id']);
$comment->delete();
// delete the association too
$db->delete($comment->attachable_table, 'expcomments_id='.$this->params['id']);
// send the user back where they came from.
expHistory::back();
} | Base | 1 |
public function testDolEval()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$result=dol_eval('1==1', 1, 0);
print "result = ".$result."\n";
$this->assertTrue($result);
$result=dol_eval('1==2', 1, 0);
print "result = ".$result."\n";
$this->assertFalse($result);
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$result=dol_eval('(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref: "Parent project not found"', 1, 1);
print "result = ".$result."\n";
$this->assertEquals('Parent project not found', $result);
$result=dol_eval('$a=function() { }; $a;', 1, 1);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result=dol_eval('$a=exec("ls");', 1, 1);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result=dol_eval('$a=exec ("ls")', 1, 1);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result=dol_eval('$a="test"; $$a;', 1, 0);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result=dol_eval('`ls`', 1, 0);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
} | Base | 1 |
$emails[$u->email] = trim(user::getUserAttribution($u->id));
}
| Base | 1 |
$text = preg_replace($exp, '', $text);
}
// Primary expression to filter out tags
$exp = '/(?:^|\s|\.)(#\w+[-\w]+\w+|#\w+)(?:$|[^\'"])/u';
$matches = array();
preg_match_all($exp, $text, $matches);
return $matches;
} | Base | 1 |
public function addFile($filename, $conditional_ie = false)
{
$hash = md5($filename);
if (!empty($this->_files[$hash])) {
return;
}
$has_onload = $this->_eventBlacklist($filename);
$this->_files[$hash] = array(
'has_onload' => $has_onload,
'filename' => $filename,
'conditional_ie' => $conditional_ie
);
} | Base | 1 |
private function getCategory()
{
$category = $this->categoryModel->getById($this->request->getIntegerParam('category_id'));
if (empty($category)) {
throw new PageNotFoundException();
}
return $category;
} | Base | 1 |
public function crossOriginRedirectProvider()
{
return [
['http://example.com?a=b', 'http://test.com/', false],
['https://example.com?a=b', 'https://test.com/', false],
['http://example.com?a=b', 'https://test.com/', false],
['https://example.com?a=b', 'http://test.com/', false],
['http://example.com?a=b', 'http://example.com/', true],
['https://example.com?a=b', 'https://example.com/', true],
['http://example.com?a=b', 'https://example.com/', true],
['https://example.com?a=b', 'http://example.com/', false],
];
} | Class | 2 |
static function author() {
return "Dave Leffler";
}
| Base | 1 |
$db->updateObject($value, 'section');
}
$db->updateObject($moveSec, 'section');
//handle re-ranking of previous parent
$oldSiblings = $db->selectObjects("section", "parent=" . $oldParent . " AND rank>" . $oldRank . " ORDER BY rank");
$rerank = 1;
foreach ($oldSiblings as $value) {
if ($value->id != $moveSec->id) {
$value->rank = $rerank;
$db->updateObject($value, 'section');
$rerank++;
}
}
if ($oldParent != $moveSec->parent) {
//we need to re-rank the children of the parent that the moving section has just left
$childOfLastMove = $db->selectObjects("section", "parent=" . $oldParent . " ORDER BY rank");
for ($i = 0, $iMax = count($childOfLastMove); $i < $iMax; $i++) {
$childOfLastMove[$i]->rank = $i;
$db->updateObject($childOfLastMove[$i], 'section');
}
}
}
}
self::checkForSectionalAdmins($move);
expSession::clearAllUsersSessionCache('navigation');
}
| Base | 1 |
public static function getKey ($var) {
return self::$hooks[$var];
}
| Base | 1 |
form_end_row();
$i++;
}
html_end_box(false);
/*
print "<pre>";
if (isset($check) && is_array($check)) {
print_r($check);
}
print "</pre>";
*/
} | Base | 1 |
static function displayname() {
return gt("e-Commerce Category Manager");
} | Base | 1 |
public function updatePreferences(Codendi_Request $request)
{
$request->valid(new Valid_String('cancel'));
if (!$request->exist('cancel')) {
$job_id = $request->get($this->widget_id . '_job_id');
$sql = "UPDATE plugin_hudson_widget SET job_id=" . $job_id . " WHERE owner_id = " . $this->owner_id . " AND owner_type = '" . $this->owner_type . "' AND id = " . (int) $request->get('content_id');
$res = db_query($sql);
} | Base | 1 |
public static function getList () {
$handle = dir(GX_PATH.'/inc/lang/');
while (false !== ($entry = $handle->read())) {
if ($entry != "." && $entry != ".." ) {
$file = GX_PATH.'/inc/lang/'.$entry;
$ext = pathinfo($file, PATHINFO_EXTENSION);
if(is_file($file) == true && $ext == 'php'){
$lang[] = $entry;
}
}
}
$handle->close();
return $lang;
}
| Base | 1 |
public static function _date2timestamp( $datetime, $wtz=null ) {
if( !isset( $datetime['hour'] )) $datetime['hour'] = 0;
if( !isset( $datetime['min'] )) $datetime['min'] = 0;
if( !isset( $datetime['sec'] )) $datetime['sec'] = 0;
if( empty( $wtz ) && ( !isset( $datetime['tz'] ) || empty( $datetime['tz'] )))
return mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );
$output = $offset = 0;
if( empty( $wtz )) {
if( iCalUtilityFunctions::_isOffset( $datetime['tz'] )) {
$offset = iCalUtilityFunctions::_tz2offset( $datetime['tz'] ) * -1;
$wtz = 'UTC';
}
else
$wtz = $datetime['tz'];
}
if(( 'Z' == $wtz ) || ( 'GMT' == strtoupper( $wtz )))
$wtz = 'UTC';
try {
$strdate = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['min'], $datetime['sec'] );
$d = new DateTime( $strdate, new DateTimeZone( $wtz ));
if( 0 != $offset ) // adjust for offset
$d->modify( $offset.' seconds' );
$output = $d->format( 'U' );
unset( $d );
}
catch( Exception $e ) {
$output = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );
}
return $output;
}
| Base | 1 |
$opt .= "<option value=\"{$key}\" title=\"".htmlspecialchars($value)."\" {$sel}>".htmlspecialchars($value)."</option>";
}
return $opt;
}
| Base | 1 |
public function confirm()
{
$task = $this->getTask();
$link = $this->getTaskLink();
$this->response->html($this->template->render('task_internal_link/remove', array(
'link' => $link,
'task' => $task,
)));
} | Base | 1 |
$value = str_replace($originalName, $cleanedName, $value);
}
unset($value);
}
$result = hash_equals(GeneralUtility::hmac(serialize($fieldChangeFunctions)), $this->parameters['fieldChangeFuncHash']);
}
return $result;
} | Class | 2 |
public static function desc($vars){
if(!empty($vars)){
$desc = substr(strip_tags(htmlspecialchars_decode($vars).". ".self::$desc),0,150);
}else{
$desc = substr(self::$desc,0,150);
}
$desc = Hooks::filter('site_desc_filter', $desc);
return $desc;
}
| Base | 1 |
public function approve() {
expHistory::set('editable', $this->params);
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
// $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];
// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];
// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];
// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for comment to approve'));
expHistory::back();
}
$comment = new expComment($this->params['id']);
assign_to_template(array(
'comment'=>$comment
));
} | Base | 1 |
function db_properties($table)
{
global $DatabaseType, $DatabaseUsername;
switch ($DatabaseType) {
case 'mysqli':
$result = DBQuery("SHOW COLUMNS FROM $table");
while ($row = db_fetch_row($result)) {
$properties[strtoupper($row['FIELD'])]['TYPE'] = strtoupper($row['TYPE'], strpos($row['TYPE'], '('));
if (!$pos = strpos($row['TYPE'], ','))
$pos = strpos($row['TYPE'], ')');
else
$properties[strtoupper($row['FIELD'])]['SCALE'] = substr($row['TYPE'], $pos + 1);
$properties[strtoupper($row['FIELD'])]['SIZE'] = substr($row['TYPE'], strpos($row['TYPE'], '(') + 1, $pos);
if ($row['NULL'] != '')
$properties[strtoupper($row['FIELD'])]['NULL'] = "Y";
else
$properties[strtoupper($row['FIELD'])]['NULL'] = "N";
}
break;
}
return $properties;
} | Base | 1 |
public function renderAttribute ($name) {
switch ($name) {
case 'name':
echo $this->relatedModel->getLink (/*array (
'class' => 'quick-read-link',
'data-id' => $this->relatedModel->id,
'data-class' => get_class ($this->relatedModel),
'data-name' => CHtml::encode ($this->relatedModel->name),
)*/);
break;
case 'relatedModelName':
echo $this->getRelatedModelName ();
break;
case 'assignedTo':
echo $this->relatedModel->renderAttribute ('assignedTo');
break;
case 'label':
echo $this->getLabel ();
break;
case 'createDate':
echo X2Html::dynamicDate ($this->relatedModel->createDate);
break;
}
} | Class | 2 |
function send_feedback() {
$success = false;
if (isset($this->params['id'])) {
$ed = new eventdate($this->params['id']);
// $email_addrs = array();
if ($ed->event->feedback_email != '') {
$msgtemplate = expTemplate::get_template_for_action($this, 'email/_' . $this->params['formname'], $this->loc);
$msgtemplate->assign('params', $this->params);
$msgtemplate->assign('event', $ed);
$email_addrs = explode(',', $ed->event->feedback_email);
//This is an easy way to remove duplicates
$email_addrs = array_flip(array_flip($email_addrs));
$email_addrs = array_map('trim', $email_addrs);
$mail = new expMail();
$success += $mail->quickSend(array(
"text_message" => $msgtemplate->render(),
'to' => $email_addrs,
'from' => !empty($this->params['email']) ? $this->params['email'] : trim(SMTP_FROMADDRESS),
'subject' => $this->params['subject'],
));
}
}
if ($success) {
flashAndFlow('message', gt('Your feedback was successfully sent.'));
} else {
flashAndFlow('error', gt('We could not send your feedback. Please contact your administrator.'));
}
}
| Base | 1 |
function selectArraysBySql($sql) {
$res = @mysqli_query($this->connection, $this->injectProof($sql));
if ($res == null)
return array();
$arrays = array();
for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++)
$arrays[] = mysqli_fetch_assoc($res);
return $arrays;
} | Base | 1 |
public function getRequestFormat($default = 'html')
{
if (null === $this->format) {
$this->format = $this->get('_format', $default);
}
return $this->format;
} | Base | 1 |
static public function getCategoryName($_id = 0) {
if ($_id != 0) {
$stmt = Database::prepare("
SELECT `name` FROM `" . TABLE_PANEL_TICKET_CATS . "` WHERE `id` = :id"
);
$category = Database::pexecute_first($stmt, array('id' => $_id));
return $category['name'];
}
return null;
} | Class | 2 |
public function confirm()
{
$project = $this->getProject();
$this->response->html($this->helper->layout->project('column/remove', array(
'column' => $this->columnModel->getById($this->request->getIntegerParam('column_id')),
'project' => $project,
)));
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
$this->response->html($this->template->render('project_tag/remove', array(
'tag' => $tag,
'project' => $project,
)));
} | Base | 1 |
protected function itemLocked($hash)
{
if (!elFinder::$commonTempPath) {
return false;
}
$lock = elFinder::$commonTempPath . DIRECTORY_SEPARATOR . $hash . '.lock';
if (file_exists($lock)) {
if (filemtime($lock) + $this->itemLockExpire < time()) {
unlink($lock);
return false;
}
return true;
}
return false;
} | Base | 1 |
function edit_optiongroup_master() {
expHistory::set('editable', $this->params);
$id = isset($this->params['id']) ? $this->params['id'] : null;
$record = new optiongroup_master($id);
assign_to_template(array(
'record'=>$record
));
} | Base | 1 |
function format_install_param( $value )
{
$value = str_replace( array( "'", "\$" ), array( "\'", "\\$" ), $value );
return preg_replace( "#([\\\\]*)(\\\\\\\')#", "\\\\\\\\\\\\\\\\\'", $value );
} | Class | 2 |
public function checkRedirect(RequestInterface $request, array $options, ResponseInterface $response)
{
if (\strpos((string) $response->getStatusCode(), '3') !== 0
|| !$response->hasHeader('Location')
) {
return $response;
}
$this->guardMax($request, $response, $options);
$nextRequest = $this->modifyRequest($request, $options, $response);
// If authorization is handled by curl, unset it if host is different.
if ($request->getUri()->getHost() !== $nextRequest->getUri()->getHost()
&& defined('\CURLOPT_HTTPAUTH')
) {
unset(
$options['curl'][\CURLOPT_HTTPAUTH],
$options['curl'][\CURLOPT_USERPWD]
);
}
if (isset($options['allow_redirects']['on_redirect'])) {
($options['allow_redirects']['on_redirect'])(
$request,
$response,
$nextRequest->getUri()
);
}
$promise = $this($nextRequest, $options);
// Add headers to be able to track history of redirects.
if (!empty($options['allow_redirects']['track_redirects'])) {
return $this->withTracking(
$promise,
(string) $nextRequest->getUri(),
$response->getStatusCode()
);
}
return $promise;
} | Class | 2 |
public static function add($tags) {
$tag = explode(",", $tags);
foreach ($tag as $t) {
if (self::exist($t)) {
return false;
}else{
$slug = Typo::slugify(Typo::cleanX($t));
$cat = Typo::cleanX($t);
$tag = Db::insert(
sprintf("INSERT INTO `cat` VALUES (null, '%s', '%s', '%d', '', 'tag' )",
$cat, $slug, 0
)
);
return true;
}
}
}
| Base | 1 |
private function drain(StreamInterface $source, StreamInterface $sink)
{
Psr7\copy_to_stream($source, $sink);
$sink->seek(0);
$source->close();
return $sink;
} | Base | 1 |
static function validUTF($string) {
if(!mb_check_encoding($string, 'UTF-8') OR !($string === mb_convert_encoding(mb_convert_encoding($string, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {
return false;
}
return true;
} | Base | 1 |
$newret = recyclebin::restoreFromRecycleBin($iLoc, $page_id);
if (!empty($newret)) $ret .= $newret . '<br>';
if ($iLoc->mod == 'container') {
$ret .= scan_container($container->internal, $page_id);
}
}
return $ret;
}
| Base | 1 |
public function breadcrumb() {
global $sectionObj;
expHistory::set('viewable', $this->params);
$id = $sectionObj->id;
$current = null;
// Show not only the location of a page in the hierarchy but also the location of a standalone page
$current = new section($id);
if ($current->parent == -1) { // standalone page
$navsections = section::levelTemplate(-1, 0);
foreach ($navsections as $section) {
if ($section->id == $id) {
$current = $section;
break;
}
}
} else {
$navsections = section::levelTemplate(0, 0);
foreach ($navsections as $section) {
if ($section->id == $id) {
$current = $section;
break;
}
}
}
assign_to_template(array(
'sections' => $navsections,
'current' => $current,
));
}
| Base | 1 |
public function setContainer($container)
{
$this->container = $container;
$container->setType('ctArticles');
} | Base | 1 |
function nvweb_website_comments_list($offset=0, $limit=2147483647, $permission=NULL, $order='oldest')
{
global $DB;
global $website;
global $current;
if($order=='newest')
$orderby = "nvc.date_created DESC";
else
$orderby = "nvc.date_created ASC";
$DB->query('SELECT SQL_CALC_FOUND_ROWS nvc.*, nvwu.username, nvwu.avatar, nvwd.text as item_title
FROM nv_comments nvc
LEFT OUTER JOIN nv_webusers nvwu
ON nvwu.id = nvc.user
LEFT OUTER JOIN nv_webdictionary nvwd
ON nvwd.node_id = nvc.object_id AND
nvwd.website = nvc.website AND
nvwd.node_type = nvc.object_type AND
nvwd.subtype = "title" AND
nvwd.lang = '.protect($current['lang']).'
WHERE nvc.website = '.protect($website->id).'
AND status = 0
ORDER BY '.$orderby.'
LIMIT '.$limit.'
OFFSET '.$offset);
$rs = $DB->result();
$total = $DB->foundRows();
return array($rs, $total);
}
| Base | 1 |
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
app('view')->share('title', (string) trans('firefly.currencies'));
app('view')->share('mainTitleIcon', 'fa-usd');
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
return $next($request);
}
);
} | Compound | 4 |
public function testGetRoutes($uri, $expectedVersion, $expectedController, $expectedAction, $expectedId)
{
$request = new Enlight_Controller_Request_RequestTestCase();
$request->setMethod('GET');
$response = new Enlight_Controller_Response_ResponseTestCase();
$request->setPathInfo($uri);
$this->router->assembleRoute($request, $response);
static::assertEquals($expectedController, $request->getControllerName());
static::assertEquals($expectedAction, $request->getActionName());
static::assertEquals($expectedVersion, $request->getParam('version'));
static::assertEquals($expectedId, $request->getParam('id'));
static::assertEquals(200, $response->getHttpResponseCode());
} | Base | 1 |
public function savePassword()
{
$user = $this->getUser();
$values = $this->request->getValues();
list($valid, $errors) = $this->userValidator->validatePasswordModification($values);
if (! $this->userSession->isAdmin()) {
$values['id'] = $this->userSession->getId();
}
if ($valid) {
if ($this->userModel->update($values)) {
$this->flash->success(t('Password modified successfully.'));
$this->userLockingModel->resetFailedLogin($user['username']);
$this->response->redirect($this->helper->url->to('UserViewController', 'show', array('user_id' => $user['id'])), true);
return;
} else {
$this->flash->failure(t('Unable to change the password.'));
}
}
$this->changePassword($values, $errors);
} | Base | 1 |
static function searchUser(AuthLDAP $authldap) {
if (self::connectToServer($authldap->getField('host'), $authldap->getField('port'),
$authldap->getField('rootdn'),
Toolbox::decrypt($authldap->getField('rootdn_passwd'), GLPIKEY),
$authldap->getField('use_tls'),
$authldap->getField('deref_option'))) {
self::showLdapUsers();
} else {
echo "<div class='center b firstbloc'>".__('Unable to connect to the LDAP directory');
}
} | Class | 2 |
if ($current_realm_id == -1 || is_realm_allowed($current_realm_id) || !isset($user_auth_realm_filenames{basename($item_url)})) {
/* draw normal (non sub-item) menu item */
$item_url = $config['url_path'] . $item_url;
if (is_menu_pick_active($item_url)) {
print "<li><a role='menuitem' class='pic selected' href='" . htmlspecialchars($item_url) . "'>$item_title</a></li>\n";
} else {
print "<li><a role='menuitem' class='pic' href='" . htmlspecialchars($item_url) . "'>$item_title</a></li>\n";
}
}
}
} | Base | 1 |
public function load_by_hash($hash)
{
global $DB;
global $session;
global $events;
$ok = $DB->query('SELECT * FROM nv_webusers WHERE cookie_hash = '.protect($hash));
if($ok)
$data = $DB->result();
if(!empty($data))
{
$this->load_from_resultset($data);
// check if the user is still allowed to sign in
$blocked = 1;
if( $this->access == 0 ||
( $this->access == 2 &&
($this->access_begin==0 || $this->access_begin < time()) &&
($this->access_end==0 || $this->access_end > time())
)
)
{
$blocked = 0;
}
if($blocked==1)
return false;
$session['webuser'] = $this->id;
// maybe this function is called without initializing $events
if(method_exists($events, 'trigger'))
{
$events->trigger(
'webuser',
'sign_in',
array(
'webuser' => $this,
'by' => 'cookie'
)
);
}
}
}
| Base | 1 |
public static function startup()
{
//Override the default expire time of token
\CsrfMagic\Csrf::$expires = 259200;
\CsrfMagic\Csrf::$callback = function ($tokens) {
throw new \App\Exceptions\AppException('Invalid request - Response For Illegal Access', 403);
};
$js = 'vendor/yetiforce/csrf-magic/src/Csrf.min.js';
if (!IS_PUBLIC_DIR) {
$js = 'public_html/' . $js;
}
\CsrfMagic\Csrf::$dirSecret = __DIR__;
\CsrfMagic\Csrf::$rewriteJs = $js;
\CsrfMagic\Csrf::$cspToken = \App\Session::get('CSP_TOKEN');
\CsrfMagic\Csrf::$frameBreaker = \Config\Security::$csrfFrameBreaker;
\CsrfMagic\Csrf::$windowVerification = \Config\Security::$csrfFrameBreakerWindow;
/*
* if an ajax request initiated, then if php serves content with <html> tags
* as a response, then unnecessarily we are injecting csrf magic javascipt
* in the response html at <head> and <body> using csrf_ob_handler().
* So, to overwride above rewriting we need following config.
*/
if (static::isAjax()) {
\CsrfMagic\Csrf::$frameBreaker = false;
\CsrfMagic\Csrf::$rewriteJs = null;
}
} | Compound | 4 |
function productFeed() {
// global $db;
//check query password to avoid DDOS
/*
* condition = new
* description
* id - SKU
* link
* price
* title
* brand - manufacturer
* image link - fullsized image, up to 10, comma seperated
* product type - category - "Electronics > Audio > Audio Accessories MP3 Player Accessories","Health & Beauty > Healthcare > Biometric Monitors > Pedometers"
*/
$out = '"id","condition","description","like","price","title","brand","image link","product type"' . chr(13) . chr(10);
$p = new product();
$prods = $p->find('all', 'parent_id=0 AND ');
//$prods = $db->selectObjects('product','parent_id=0 AND');
} | Class | 2 |
$json_response = ['status' => 'error', 'message' => $e->getMessage()]; | Base | 1 |
function extract_plural_forms_header_from_po_header($header) {
if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs))
$expr = $regs[2];
else
$expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
return $expr;
} | Base | 1 |
static function isSearchable() { return true; }
| Base | 1 |
$product = X2Model::model('Products')->findByAttributes(array('name'=>$lineItem->name));
if (isset($product))
$lineItem->productId = $product->id;
if(empty($lineItem->currency))
$lineItem->currency = $defaultCurrency;
if($lineItem->isPercentAdjustment) {
$lineItem->adjustment = Fields::strToNumeric(
$lineItem->adjustment,'percentage');
} else {
$lineItem->adjustment = Fields::strToNumeric(
$lineItem->adjustment,'currency',$curSym);
}
$lineItem->price = Fields::strToNumeric($lineItem->price,'currency',$curSym);
$lineItem->total = Fields::strToNumeric($lineItem->total,'currency',$curSym);
} | Class | 2 |
private function getNewPrinter() {
$printer = getItemByTypeName('Printer', '_test_printer_all');
$pfields = $printer->fields;
unset($pfields['id']);
unset($pfields['date_creation']);
unset($pfields['date_mod']);
$pfields['name'] = $this->getUniqueString();
$this->integer((int)$printer->add($pfields))->isGreaterThan(0);
return $printer;
} | Base | 1 |
function ac_checkme($id, $name) {
global $cms_db;
$ret = true;
$cquery = sprintf("select count(*) from %s where sid='%s' and name='%s'",
$cms_db['sessions'],
$id,
$name);
$squery = sprintf("select sid from %s where sid = '%s' and name = '%s'",
$cms_db['sessions'],
$id,
addslashes($name));
$this->db->query($squery);
if ( $this->db->affected_rows() == 0
&& $this->db->query($cquery)
&& $this->db->next_record() && $this->db->f(0) == 0 ) {
// nothing found here
$ret = false;
}
return $ret;
} | Base | 1 |
$comments->records[$key]->avatar = $db->selectObject('user_avatar',"user_id='".$record->poster."'");
}
if (empty($this->params['config']['disable_nested_comments'])) $comments->records = self::arrangecomments($comments->records);
// eDebug($sql, true);
// count the unapproved comments
if ($require_approval == 1 && $user->isAdmin()) {
$sql = 'SELECT count(com.id) as c FROM '.$db->prefix.'expComments com ';
$sql .= 'JOIN '.$db->prefix.'content_expComments cnt ON com.id=cnt.expcomments_id ';
$sql .= 'WHERE cnt.content_id='.$this->params['content_id']." AND cnt.content_type='".$this->params['content_type']."' ";
$sql .= 'AND com.approved=0';
$unapproved = $db->countObjectsBySql($sql);
} else {
$unapproved = 0;
}
$this->config = $this->params['config'];
$type = !empty($this->params['type']) ? $this->params['type'] : gt('Comment');
$ratings = !empty($this->params['ratings']) ? true : false;
assign_to_template(array(
'comments'=>$comments,
'config'=>$this->params['config'],
'unapproved'=>$unapproved,
'content_id'=>$this->params['content_id'],
'content_type'=>$this->params['content_type'],
'user'=>$user,
'hideform'=>$this->params['hideform'],
'hidecomments'=>$this->params['hidecomments'],
'title'=>$this->params['title'],
'formtitle'=>$this->params['formtitle'],
'type'=>$type,
'ratings'=>$ratings,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
));
} | Base | 1 |
protected function generateCookieHash($class, $username, $expires, $password)
{
return hash_hmac('sha256', $class.$username.$expires.$password, $this->getSecret());
} | Class | 2 |
function select_string($n) {
if (!is_int($n)) {
throw new InvalidArgumentException(
"Select_string only accepts integers: " . $n);
}
$string = $this->get_plural_forms();
$string = str_replace('nplurals',"\$total",$string);
$string = str_replace("n",$n,$string);
$string = str_replace('plural',"\$plural",$string);
$total = 0;
$plural = 0;
eval("$string");
if ($plural >= $total) $plural = $total - 1;
return $plural;
} | Base | 1 |
public function disable($id) {
$this->active($id, FALSE);
} | Compound | 4 |
public function delete(){
$page_id = I("page_id/d")? I("page_id/d") : 0;
$page = D("Page")->where(" page_id = '$page_id' ")->find();
$login_user = $this->checkLogin();
if (!$this->checkItemManage($login_user['uid'] , $page['item_id']) && $login_user['uid'] != $page['author_uid']) {
$this->sendError(10303);
return ;
}
if ($page) {
$ret = D("Page")->softDeletePage($page_id);
//更新项目时间
D("Item")->where(" item_id = '$page[item_id]' ")->save(array("last_update_time"=>time()));
}
if ($ret) {
$this->sendResult(array());
}else{
$this->sendError(10101);
}
} | Compound | 4 |
function build_daterange_sql($timestamp, $endtimestamp=null, $field='date', $multiday=false) {
if (empty($endtimestamp)) {
$date_sql = "((".$field." >= " . expDateTime::startOfDayTimestamp($timestamp) . " AND ".$field." <= " . expDateTime::endOfDayTimestamp($timestamp) . ")";
} else {
$date_sql = "((".$field." >= " . expDateTime::startOfDayTimestamp($timestamp) . " AND ".$field." <= " . expDateTime::endOfDayTimestamp($endtimestamp) . ")";
}
if ($multiday)
$date_sql .= " OR (" . expDateTime::startOfDayTimestamp($timestamp) . " BETWEEN ".$field." AND dateFinished)";
$date_sql .= ")";
return $date_sql;
}
| Base | 1 |
public function getQuerySelect()
{
return "R_{$this->id}.rank AS `$this->name`";
} | Base | 1 |
public function testUserCredentials($email, $password, $server, $port, $security) {
require_once(realpath(Yii::app()->basePath.'/components/phpMailer/class.phpmailer.php'));
require_once(realpath(Yii::app()->basePath.'/components/phpMailer/class.smtp.php'));
$phpMail = new PHPMailer(true);
$phpMail->isSMTP();
$phpMail->SMTPAuth = true;
$phpMail->Username = $email;
$phpMail->Password = $password;
$phpMail->Host = $server;
$phpMail->Port = $port;
$phpMail->SMTPSecure = $security;
try {
$validCredentials = $phpMail->SmtpConnect();
} catch(phpmailerException $error) {
$validCredentials = false;
}
return $validCredentials;
} | Class | 2 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.