$SVal) { $Log.=PHP_EOL.$SKey.'='.$SVal; } if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/'.__LINE__,$Log); } require_once(AL_PATH.'include/i_database.php'); require_once(AL_PATH.'/user/i_function.php'); $ExecUrl=parse_url($_SERVER['REQUEST_URI']); preg_match("/^\/([A-z0-9\.\-\_]+)/",$ExecUrl['path'],$Match); $Arg=$Match[1]; if (2==1 && $_SESSION['UserId']==2) { // debug('
'.var_export($Match,1).CRLF.CRLF.'$Arg='.$Arg.CRLF.CRLF.print_r($_SERVER,1).'
'); exit(); } if (!empty($Arg)) { // ----- Is an invitation ? $ValueHex=substr($Arg,1); // debug('$ValueHex='.$ValueHex); if (($Arg[0]=='i' || $Arg[0]=='m') && preg_match('/^[a-f0-9]{1,}$/is',$ValueHex) /*ctype_xdigit($ValueHex)*/) { $ValueDec=hexdec($ValueHex)/substr(UNIQUE_KEY,11,5); // debug('$ValueDec='.$ValueDec); if (is_int($ValueDec)) { $_SESSION['INVITED_BY']=$ValueDec; setCookie('InvitedUrlId',$ValueDec,$_SERVER['REQUEST_TIME']+(3600*24*90),'/','.'.SITE_DOMAIN,1,1); require_once(AL_PATH.'include/i_member.php'); $Data=array( 'DB_CONN' => $db_pf, 'USER_ID' => $ValueDec, 'TYPE_ID' => ($Arg[0]=='i' ? USER_INVITATION_URL_COUNT_SITE:USER_INVITATION_URL_COUNT_MEMBER), 'INCREMENT' => 1, ); member_parameters_increment($Data); // ---- then finally if ($Arg[0]=='i') { require(AL_PATH.'/index.php'); exit(0); } // ---- Continue to member $Arg=intval($ValueDec); } } // ---- Is a user ? /* $MemberId=1; $SQL='SELECT SQL_SMALL_RESULT Id FROM members WHERE Active=1 AND '.(is_numeric($Arg)==TRUE ?'Id='.intval($Arg):'NickName=\''.db_prepare_str($db_pf,$Arg).'\'').' LIMIT 1'; // debug($SQL); $Result=db_query(__FILE__,__LINE__,$SQL,$db_pf); $Row=db_fetch_assoc($Result); if ($Row!==FALSE) { // header('HTTP/1.1 200 OK',TRUE,200); $MemberId=intval($Row['Id']); db_close($db_pf); if (!$ValueDec) $UniquePath=str_replace($Arg,'',$ExecUrl['path']); $FinalPath=str_replace('//','/',AL_PATH.'/user/public/'.$UniquePath.'/index.php'); if (file_exists($FinalPath)) { require_once($FinalPath); exit(); } } */ $User=detect_user_from_id_or_nickname($db_pf,$Arg); $MemberId=intval($User['Id']); if ($MemberId>0) { if (!$ValueDec) $UniquePath=str_replace($Arg,'',$ExecUrl['path']); /* removed with PHP 8, creat too much problems :/ if ($UniquePath=='/') { switch ($User['Account']) { case ACCOUNT_VISITOR: $UniquePath='biography'; break; // case ACCOUNT_BOOK: // case ACCOUNT_ARTIST: // case ACCOUNT_PRO: // if (!$User['ImageCount']>0) $UniquePath='biography'; // break; } } */ $FinalPath=str_replace('//','/',AL_PATH.'/user/public/'.$UniquePath.'/index.php'); if (file_exists($FinalPath)) { require_once($FinalPath); exit(); } } } /* -------------------------------------------------------------------------------------------------------------------- -- ART CATEGORIES -------------------------------------------------------------------------------------------------- -- FORMAT: MEDIUM / PROCESS / CHROMINANCE / SUBJECT 1 / SUBJECT 2 / SUBJECT 3 -------------------------------------------------------------------------------------------------------------------- truncate category_artworks; INSERT INTO category_artworks (TypeId,Id,Name,Culture) (SELECT 1,Id,Name_EN,44 FROM category_technique); INSERT INTO category_artworks (TypeId,Id,Name,Culture) (SELECT 1,Id,Name_FR,33 FROM category_technique); INSERT INTO category_artworks (TypeId,Id,Name,Culture) (SELECT 2,Id,Name_EN,44 FROM category_process); INSERT INTO category_artworks (TypeId,Id,Name,Culture) (SELECT 2,Id,Name_FR,33 FROM category_process); INSERT INTO category_artworks (TypeId,Id,Name,Culture) (SELECT 3,Id,Name_EN,44 FROM category_chrominance); INSERT INTO category_artworks (TypeId,Id,Name,Culture) (SELECT 3,Id,Name_FR,33 FROM category_chrominance); INSERT INTO category_artworks (TypeId,Id,C1,C2,C3,Name,Culture) (SELECT 4,Id,C1,C2,C3,Name_EN,44 FROM category_subject); INSERT INTO category_artworks (TypeId,Id,C1,C2,C3,Name,Culture) (SELECT 4,Id,C1,C2,C3,Name_FR,33 FROM category_subject); */ /* foreach ($_SERVER as $key => $Val) { $Log.=CRLF.$Key.': '.$Val; } */ $Parameters=explode('/',trim(strtolower($_SERVER['REDIRECT_URL']),'/')); $Parameters=array_unique($Parameters); if ($CatDebug) $Log.=CRLF.var_export($Parameters,1).CRLF.CRLF.implode(',',$Parameters); if ($Parameters/* && $_SESSION['UserId']==2*/) { foreach ($Parameters as $Key => $Val) { if (!preg_match('/^[a-z0-9-]*$/',$Val)) { $ParametersError=1; break; } } if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/'.__LINE__,$Log.CRLF.CRLF.var_export($Parameters,1).CRLF.CRLF.'ParametersError='.$ParametersError); if (!$ParametersError) { $UrlTitle=array(); $ParameterCount=count($Parameters); $SQL='SELECT GUID,Id,TypeId,Name,C1,C2,C3,Slug,Description,Culture FROM category_artworks WHERE Slug IN (\''.implode('\',\'',$Parameters).'\') ORDER BY TypeId,C1,C2,C3'; $Result=db_query(__FILE__,__LINE__,$SQL,$db_pf); if ($CatDebug) $Log.=CRLF.CRLF.$SQL.CRLF.CRLF.'Recordset count: '.db_num_rows($Result); if (db_num_rows($Result)>0 && db_num_rows($Result)>=count($Parameters)) { $Categories=db_fetch_all($Result); if ($CatDebug) $Log.=CRLF.CRLF.'$Categories='.var_export($Categories,1); // if ($CatDebug) mail(SITE_EMAIL,'Step 3',$Log); // ---- select the main culture propability foreach ($Categories as $Row) { $SearchCultures[$Row['Culture']]++; } if ($CatDebug) $Log.=CRLF.CRLF.'Counting $SearchCultures='.var_export($SearchCultures,1); // ---- select the main culture to be used arsort($SearchCultures); if ($CatDebug) $Log.=CRLF.CRLF.'Sorting $SearchCultures='.var_export($SearchCultures,1); reset($SearchCultures); $SearchCulture=key($SearchCultures); if ($CatDebug) $Log.=CRLF.CRLF.'$SearchCulture='.$SearchCulture; // ---- parse the categories values foreach ($Categories as $Row) { if ($CatDebug) $Log.=CRLF.'Working on row: '.implode(',',$Row).', $Category["'.$Row['Name'].'"]='.$Category[$Row['Name']]; $UrlTitle[]=$Row['Name']; if ($Row['Culture']==$SearchCulture && $Category[$Row['Name']]==0) { switch ($Row['TypeId']) { case ART_CATEGORY_MEDIUM: if ($_LOCAL['ct']) break; $_LOCAL['ct']=$Row['Id']; $CategoryPath[0]=$Row['Slug']; $Category[$Row['Name']]=1; $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; $DesignParam['CATEGORY_CONTEXT']=$Row['Slug']; break; case ART_CATEGORY_MEDIUM_PROCESS: if ($_LOCAL['ct']>0) { if ($Row['C1']==$_LOCAL['ct']) { $_LOCAL['cp']=$Row['Id']; $CategoryPath[1]=$Row['Slug']; $Category[$Row['Name']]=1; $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; } } else { $_LOCAL['cp']=$Row['Id']; $CategoryPath[1]=$Row['Slug']; $Category[$Row['Name']]=1; $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; } break; case ART_CATEGORY_CHROMINANCE: $_LOCAL['to']=$Row['Id']; $CategoryPath[2]=$Row['Slug']; $Category[$Row['Name']]=1; $Category['Culture'][$Row['Culture']]++; break; case ART_CATEGORY_SUBJECT: if ($Row['C1']>0 && $Row['C2']==0 && $Row['C3']==0) { $_LOCAL['c1']=$Row['C1']; $CategoryPath[3]=$Row['Slug']; $Category[$Row['Name']]=1; $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; } if ($Row['C1']>0 && $Row['C2']>0 && $Row['C3']==0) { $_LOCAL['c1']=$Row['C1']; $_LOCAL['c2']=$Row['C2']; $CategoryPath[4]=$Row['Slug']; $Category[$Row['Name']]=1; $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; } if ($Row['C1']>0 && $Row['C2']>0 && $Row['C3']>0) { $_LOCAL['c1']=$Row['C1']; $_LOCAL['c2']=$Row['C2']; $_LOCAL['c3']=$Row['C3']; $CategoryPath[5]=$Row['Slug']; $Category[$Row['Name']]=1; $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; } break; case ART_CATEGORY_FILTER: // ---- buy $Category[$Row['Name']]=1; switch ($Row['Id']) { case 1: // for sale $_LOCAL['bupmin']=1; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; break; case 2: // black and white $_LOCAL['to']=2; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; break; case 3: // instant film $_LOCAL['cp']=13; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; $DesignParam['CATEGORY_CONTEXT']='photography'; break; case 4: // photography $_LOCAL['ct']=2; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; $DesignParam['CATEGORY_CONTEXT']='photography'; break; case 5: // best rate $_LOCAL['o']=1; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; break; case 6: // sell print(s) $_LOCAL['s']=1; $_LOCAL['bupmin']=1; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; break; case 7: // nature $_LOCAL['c1']=3; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; break; case 8: // featured $_LOCAL['o']=3; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; break; case 9: // fashion $_LOCAL['cg']=26; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; break; case 10: // painting $_LOCAL['ct']=4; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; $DesignParam['CATEGORY_CONTEXT']='painting'; break; case 11: // drawing $_LOCAL['ct']=3; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; $DesignParam['CATEGORY_CONTEXT']='drawing'; break; case 12: // keywords $_LOCAL['kw']=$Row['Slug']; $CategoryPath['6'.$Row['GUID']]=$Row['Slug']; break; } $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; break; case ART_CATEGORY_KEYWORD: $CategoryPath['7'.$Row['GUID']]=$Row['Slug']; $Category[$Row['Name']]=1; $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; break; case ART_CATEGORY_PROJECT: $CategoryPath['8'.$Row['GUID']]=$Row['Slug']; $_LOCAL['prj']=$Row['Id']; $Category[$Row['Name']]=1; $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; break; case ART_CATEGORY_MEDIUM_PROCESS_MAPPING: $CategoryPath['9'.$Row['GUID']]=$Row['Slug']; $_LOCAL['cp']=$Row['Id']; $Category[$Row['Name']]=1; $Category['Description'].=($Row['Description'] ? CRLF.CRLF.$Row['Description']:''); $Category['Culture'][$Row['Culture']]++; } } } if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/'.__LINE__,$Log.CRLF.CRLF.var_export($_LOCAL,1).CRLF.CRLF.var_export($Category,1)); // ---- force the good culture depending on categories if ($_SESSION['UserCulture']!=$SearchCulture) { $_SESSION['UserLang']=$LangSpec[$SearchCulture]['LANG_STRING_SHORT']; require(PATH_COMMON.'include/i_common_culture.php'); if ($CatDebug) $Log.=PHP_EOL.'Switching culture to '.$_SESSION['UserLang'].' ('.$_SESSION['UserCulture'].')'; } // ---- initiate local state $_LOCAL['State']=1; if ($CatDebug) { $Log.=CRLF.CRLF.'$Category='.var_export($Category,1); $Log.=CRLF.CRLF.'$CategoryPath='.var_export($CategoryPath,1); } $CategoryPath=array_unique($CategoryPath); ksort($CategoryPath); $_LOCAL['url_path']=implode('/',$CategoryPath); $UrlTitle=array_unique($UrlTitle); $UrlTitle=implode(' ',$UrlTitle); $_LOCAL['title']=trim(ucfirst(strtolower($UrlTitle))); $Scope=($_SESSION['UserId']>0 ? 'Auth':'Public'); $ScopeSource=($_SESSION['UserBot'] ? 'BotCount':'UserCount'); if ($CatDebug) { $Log.=CRLF.CRLF.'$_LOCAL='.var_export($_LOCAL,1); $Log.=CRLF.CRLF.'"'.$_SERVER['REDIRECT_URL'].'" versus "/'.$_LOCAL['url_path'].'"'; } if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/'.__LINE__,$Log.CRLF.CRLF.var_export($_LOCAL,1).CRLF.CRLF.var_export($_SERVER,1)); // ---- if "elements" not in the good order than redirect to the good one if ($_SERVER['REDIRECT_URL']!='/'.$_LOCAL['url_path']) { // mail(SITE_EMAIL,'/'.$_LOCAL['url_path'],var_export($_SERVER,1)); header('HTTP/1.0 301 Moved Permanently'); header('location: '.HTTP_WWW.SITE_DOMAIN.'/'.$_LOCAL['url_path'],1,301); exit(); } if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/'.__LINE__,$Log.CRLF.CRLF.var_export($_LOCAL,1).CRLF.CRLF.var_export($_SERVER,1)); if ($CategoryPath/* && !$_SERVER['QUERY_STRING']*/) { $SQL_Exist='SELECT GUID,ArtworkId'.$Scope.' AS FastId,UNIX_TIMESTAMP(Update'.$Scope.') AS Updated,Count'.$Scope.' AS ItemCount,Title,Description,NoIndex,Selector,TbCategories FROM category_artworks_boost WHERE Categories=\''.db_prepare_str($db_pf,$_LOCAL['url_path']).'\' LIMIT 1'; if ($CatDebug) $Log.=CRLF.CRLF.__LINE__.': $SQL_Exist='.$SQL_Exist; $Result=db_query(__FILE__,__LINE__,$SQL_Exist,$db_pf); if (db_num_rows($Result)>0) { $ThisScope=db_fetch_assoc($Result); if ($CatDebug) $Log.=CRLF.CRLF.__LINE__.': Found id #'.$ThisScope['GUID']; $_LOCAL['FastId']=$ThisScope['FastId']; // ---- lower case is normal if ($ThisScope['Title']) $_LOCAL['title']=$ThisScope['Title']; $_LOCAL['description']=$ThisScope['Description']; $_LOCAL['history']=trim($Category['Description']); $_LOCAL['NoIndex']=$ThisScope['NoIndex']; $_LOCAL['Selector']=$ThisScope['Selector']; $_LOCAL['TbCategories']=$ThisScope['TbCategories']; } } if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/'.__LINE__,$Log.CRLF.CRLF.var_export($_LOCAL,1).CRLF.CRLF.var_export($ThisScope,1)); require_once(AL_PATH.'/selections/new/index.php'); if ($CatDebug) $Log.=CRLF.': '.$CategoryPath. CRLF.'$Thumb[Count]: '.$Thumb['Count']. CRLF.'$ThisScope[ItemCount]: '.$ThisScope['ItemCount']. CRLF.'$_LOCAL[FastId]: '.$_LOCAL['FastId']. CRLF.'$ThisScope[Updated]: '.$ThisScope['Updated']. CRLF.'$_SERVER[QUERY_STRING]: '.$_SERVER['QUERY_STRING']; if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/line:'.__LINE__,$Log.CRLF.CRLF.var_export($_LOCAL,1).CRLF.CRLF.var_export($ThisScope,1)); if ($CategoryPath && strlen($_LOCAL['url_path'])<=128 && $Thumb['Count']>=$ThisScope['ItemCount'] && (!$_LOCAL['FastId'] || $ThisScope['Updated']1024 ? $Thumb['LastId']-1024:0); if (isset($_LOCAL['FastId'])) { $SQL_Save='UPDATE LOW_PRIORITY category_artworks_boost SET ArtworkId'.$Scope.'='.$ScopeId.',Update'.$Scope.'=\''.DATE_NOW_HH.'\',Count'.$Scope.'='.$Thumb['Count'].' WHERE GUID='.$ThisScope['GUID'].' LIMIT 1'; db_query(__FILE__,__LINE__,$SQL_Save,$db_pf); } else { $SQL_Save='INSERT LOW_PRIORITY IGNORE INTO category_artworks_boost (ArtworkId'.$Scope.',Update'.$Scope.',Count'.$Scope.',Categories,'.$ScopeSource.','.$ScopeSource.'All,Selector,Title) VALUES ('.$ScopeId.',\''.DATE_NOW_HH.'\','.intval($Thumb['Count']).',\''.db_prepare_str($db_pf,$_LOCAL['url_path']).'\',1,1,ROUND(RAND()*17),\''.strtolower(db_prepare_str($db_pf,$_LOCAL['title'])).'\')'; db_query(__FILE__,__LINE__,$SQL_Save,$db_pf); $ThisScope['GUID']=db_insert_id($db_pf); } if ($CatDebug) $Log.=CRLF.'db prepare='.db_prepare_str($db_pf,$_LOCAL['url_path']); } if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/Line:'.__LINE__,$Log.CRLF.CRLF.var_export($_LOCAL,1).CRLF.CRLF.var_export($ThisScope,1)); if ($ThisScope['GUID'] && !$_SESSION['Admin'] && strlen($_LOCAL['url_path'])<=128 && $_SESSION['UserId']==0 && $_SESSION['UserBot']==0) { // ---- update counters $SQL='UPDATE LOW_PRIORITY category_artworks_boost SET '.$ScopeSource.'='.$ScopeSource.'+'.($_SESSION['Admin'] ? 0:1).','.$ScopeSource.'All='.$ScopeSource.'All+'.($_SESSION['Admin'] ? 0:1).' WHERE GUID='.$ThisScope['GUID'].' LIMIT 1'; db_query(__FILE__,__LINE__,$SQL,$db_pf); // ---- Store statistics $SQL_Report='INSERT LOW_PRIORITY INTO category_artworks_report (Id,SetDate,Value) VALUES('.$ThisScope['GUID'].','.TIME_STAMP_BY_HOUR.',1) ON DUPLICATE KEY UPDATE Value=Value+1'; db_query(__FILE__,__LINE__,$SQL_Report,$db_pf); } if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/Line:'.__LINE__,$Log.CRLF.CRLF.var_export($_LOCAL,1).CRLF.CRLF.var_export($ThisScope,1)); exit(); } } } if ($CatDebug && $_SESSION['UserId']==2) mail(SITE_EMAIL,'Category '.$UniqueId.'/'.__LINE__, $Log. CRLF.CRLF.var_export($Parameters,1). CRLF.CRLF.$SQL. CRLF.CRLF.var_export($_LOCAL,1). CRLF.CRLF.'$ThisScope["FastId"]='.$ThisScope['FastId']. CRLF.CRLF.'$ThisScope["ItemCount"]='.$ThisScope['ItemCount']. CRLF.CRLF.'$Thumb["Count"]='.$Thumb['Count']. CRLF.CRLF.'$Thumb["LastId"]='.$Thumb['LastId']. CRLF.CRLF.'$ScopeId='.$ScopeId. CRLF.CRLF.$SQL_Save. CRLF.CRLF.var_export($_SESSION,1) ); require(AL_PATH.'/include/i_error_404.php'); ?>